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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll n; cin >> n;
    vl a(n);
    map<int,int> mp; //数字, 回数
    ll res = 0;
    rep(i,n){
        cin>>a[i];
        mp[a[i]]++;
        res += a[i];
    }
    int q; cin >> q;
    rep(i,q){
        int b,c; cin >> b >> c;
        int pre_cnt = mp[b];
        if(pre_cnt == 0)out(res);
        else{
            mp[b] = 0;
            mp[c] += pre_cnt;
            res += (c-b)*pre_cnt;
            out(res); 
        }
    }
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    ll x;
    cin >> x;
    ll res = 100;
    int count = 0;
    while (res < x) {
        ++count;
        res = res * 1.01;
    } 
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3676
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int n,m,a[100111],ord[100111];
LL x[100111],y[100111],k;

bool used[100111];
int top,stk[100111];
int main()
{
	get1(n);
	for(int i=1;i<=n;i++)get1(x[i]);
	for(int i=n;i>=2;i--)x[i]-=x[i-1];
	get2(m,k);
	for(int i=2;i<=n;i++)ord[i]=i;
	for(int i=1;i<=m;i++)
	{
		get1(a[i]);
		swap(ord[a[i]],ord[a[i]+1]);
	}
	for(int i=2;i<=n;i++)
	{
		if(used[i])continue;
		top=0;int cur=i;
		while(!used[cur])
		{
			used[cur]=1;
			stk[top++]=cur;
			cur=ord[cur];
		}
		int shift=k%top;
		for(int j=0;j<top;j++)
			y[stk[j]]=x[stk[(j+shift)%top]];
	}
	y[1]=x[1];
	for(int i=2;i<=n;i++)y[i]+=y[i-1];
	for(int i=1;i<=n;i++)printendl(y[i]);
	return 0;
}

Measured memory_bytes: 4096
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		long num[]=new long[N];
		for(int i=0;i<N;i++) {
			num[i]=sc.nextLong();
		}
		sc.close();
		long border=1000000000000000000l;
		long result=1l;
		for(int i=0;i<N;i++) {
			if(num[i]==0) {
				System.out.println(0);
				System.exit(0);
			}
		}
		for(int i=0;i<N;i++) {
			if(result>border/num[i]) {
				System.out.println(-1);
				System.exit(0);
			}else {
				result*=num[i];
			}
		}
		System.out.println(result);
	}
}

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

int main(){
    int n;
    int a[4][14];
    char x;
    int y;
    


    for (int i = 0; i < 4; i++){
        for (int j = 0; j < 14; j++){
            a[i][j] = 0;
        }

    }

    cin >> n;
    
    for (int i = 0; i < n; i++) {
 
        cin >> x >> y;

        if (x == 'S')  a[0][y] = 1;
        if (x == 'H') a[1][y] = 1;
        if (x == 'C') a[2][y] = 1;
        if (x == 'D') a[3][y] = 1;
        
    }

    for (int i = 1; i <= 13 ; i++) {
        if (a[0][i] == 0) cout << "S" << " " << i << endl;
    }

    for (int i = 1; i <= 13 ; i++) {
        if (a[1][i] == 0) cout << "H" << " " << i << endl;
    }
    
    for (int i = 1; i <= 13 ; i++) {
        if (a[2][i] == 0) cout << "C" << " " << i << endl;
    }
    
    for (int i = 1; i <= 13; i++) {
        if (a[3][i] == 0) cout << "D" << " " << i << endl;
    }

}



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

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			list.add(x);
		}
		List<Integer> temp = new ArrayList<>(list);
		Collections.sort(temp);
		Integer min = temp.get(n / 2 - 1);
		Integer max = temp.get(n / 2);
		for (int i = 0; i < n; i++) {
			if (list.get(i) <= min) {
				System.out.println(max);
			} else {
				System.out.println(min);
			}
		}
	}
}


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

int main(){
  char ch;
  int d;
  while(1){
    scanf("%c",&ch);
    d = ch;
    if((d >= 65)&&(d <= 96)){
      d = d + 32;
    }else if((d > 96)&&(d <=122)){
      d = d - 32;
    }
    if(ch == '\n'){
      break;
    }else{
      printf("%c",d);
    }
  }
  printf("\n");
  return 0;
}



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

static class Program
{
    class Pair
    {
        public readonly int d;
        public readonly long c;
        public Pair(long[] args)
        {
            d = (int)args[0];
            c = args[1];
        }
    }

    static long Solve(int M, Pair[] pairs)
    {
        long length = 0;
        long sum = 0;
        foreach (var pair in pairs)
        {
            length += pair.c;
            sum += pair.d * pair.c;
        }
        return (sum + 8) / 9 + length - 2;
    }

    static void Main(string[] args)
    {
        int M = int.Parse(Console.ReadLine());
        var pairs = new Pair[M];
        for (int i = 0; i < M; ++i)
        {
            pairs[i] = new Pair(Array.ConvertAll(Console.ReadLine().Split(), long.Parse));
        }
        Console.WriteLine(Solve(M, pairs));
    }
}


Measured memory_bytes: 24504
#include <stdio.h>
#include <string.h>

typedef struct Eq{
  int location,eq;
}S;

int pop1();
S pop2();
void push1(int);
void push2(int,int);

int S1[20000];
S S2[20000];

int top1 = 0;
int top2 = 0;

int main(){
  int i,j,n,add,sum = 0;
  char C[20000];
  scanf("%s",C);
  n = strlen(C);
  for(i = 0; i < n; i++){
      if(C[i] == '\\'){
        push1(i);
      }
      else if( top1 > 0 && C[i] == '/'){
        j = pop1();
        add = i - j;
        sum += add;
        while( top2 > 0 && S2[top2-1].location > j){
          add += pop2().eq;
        }
        push2(j,add);
      }
  }

  printf("%d\n",sum);
  printf("%d",top2);
  for(i = 0; i < top2; i++){
    printf(" %d",S2[i].eq);
  }
  printf("\n");

  return 0;
}


void push1(int i){
  S1[top1] = i;
  top1++;
}

int pop1(){
  top1--;
  return S1[top1];
}

void push2(int j,int add){
  S2[top2].location = j;
  S2[top2].eq = add;
  top2++;
}

S pop2(){
  top2--;
  return S2[top2];
}

Measured memory_bytes: 644
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <cctype>
#include <set>
#include <fstream>
#include <cmath>
using namespace std;

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

char field[15][15];
bool visit[15][15];
int cnt[100];
int sz[100];
int id[15][15];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, -1, 0, 1};
int nextlimit;


void dfs(int r, int c, int k){
  id[r][c] = k;
  sz[k]++;
  rep(i, 4){
    int r2 = r + dy[i];
    int c2 = c + dx[i];
    if(id[r2][c2] == -1 && field[r2][c2] == 'X'){
      dfs(r2, c2, k);
    }
  }
}

bool iddfs(int r, int c, int gr, int gc, int dep, int limit){
  if(dep + abs(gr - r) + abs(gc - c) > limit){
    nextlimit = min(dep + abs(gr - r) + abs(gc - c), nextlimit);
    return false;
  }
  if(r == gr && c == gc) return true;
  visit[r][c] = true;
  
  rep(i, 4){

    int r2 = r + dy[i];
    int c2 = c + dx[i];
    
    if(field[r2][c2] == '#' || visit[r2][c2]) continue;
    if(field[r2][c2] == '.'){
      if(iddfs(r2, c2, gr, gc, dep + 1, limit)) return true;
    }
    if(field[r2][c2] == 'X'){
      if(cnt[id[r2][c2]] + 1 > sz[id[r2][c2]] / 2) continue;
      cnt[id[r2][c2]]++;
      if(iddfs(r2, c2, gr, gc, dep + 1, limit)) return true;
      cnt[id[r2][c2]]--;
    }
  }
  visit[r][c] = false;
  return false;
}



int main(){
  int x, y ,sr, sc, gr, gc, c;
  while(cin >> x >> y){
    c = 0;
    if(x == 0 && y == 0) continue;;
    fill(&field[0][0], &field[0][0] + 15 * 15, '#');
    
    memset(sz, 0, sizeof(sz));
    memset(cnt, 0, sizeof(cnt));
    memset(id, -1, sizeof(id));
    memset(visit, false, sizeof(visit));
    
    rep(i, y)rep(j, x){
      cin >> field[i+1][j+1];
      if(field[i+1][j+1] == 'S') sr = i + 1, sc = j + 1;
      if(field[i+1][j+1] == 'G') gr = i + 1, gc = j + 1, field[i+1][j+1] = '.';
    }
    
    rep(i, y)rep(j, x){
      if(id[i+1][j+1] == -1 && field[i+1][j+1] == 'X'){
	dfs(i + 1, j + 1, c++);
      }
      //cout << setw(3) << id[i+1][j+1];
      //      if(j == x - 1) cout << endl;
    }
    
    int len = 1;
    nextlimit = INF;
    while(!iddfs(sr,sc,gr,gc,0,len)){
      len = nextlimit;
      nextlimit = INF;      
    }
    cout << len << endl;
  }
  return 0;
}

Measured memory_bytes: 868
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pll;

const int maxN = 1e5 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b){return !b ? a : gcd(b, a % b);}
ll modP(ll a, ll b) {return (!b ? 1 : (modP(a, b / 2) * modP(a, b / 2) * (b % 2 ? a : 1)) % MOD);}

int n, l, r, m, lq, rq, mq;
string s;

int query(int k){
	cout << k << endl;
	cin >> s;
	return (s == "Vacant" ? 0 : (s == "Male" ? 1 : 2));
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	l = 0;
	r = n - 1;
	lq = query(0);
	if (!lq){
		return 0;
	}
	rq = query(n - 1);
	if (!rq){
		return 0;
	}
	while (r - l > 1){
		m = (l + r) / 2;
		mq = query(m);
		if (!mq){
			return 0;
		}
		if ((m + mq + l + lq) % 2 == 1){
			rq = mq;
			r = m;
		}
		else{
			lq = mq;
			l = m;
		}
	}
	return 0;
}



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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#define INFILE freopen("input.txt", "r", stdin)
#else
#define debug(x)
#define INFILE
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll INF = 1LL << 60;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr ll MOD = 1000000007;

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

ll memo[100010][2];  // memo[n][0] = white, memo[n][1] = black
vector<int> edges[100010];

void dfs(int cur, int par = -1) {
  memo[cur][0] = memo[cur][1] = 1;

  for (int e : edges[cur]) {
    if (e == par) continue;
    dfs(e, cur);

    memo[cur][0] *= (memo[e][0] + memo[e][1]) % MOD;
    memo[cur][0] %= MOD;
    memo[cur][1] *= memo[e][0];
    memo[cur][1] %= MOD;
  }
}

int main(int argc, char* argv[]) {
  int n;
  cin >> n;

  rep(i, 0, n - 1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    edges[a].pb(b);
    edges[b].pb(a);
  }

  dfs(0);
  cout << (memo[0][0] + memo[0][1]) % MOD << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[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;
}

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 14208
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define FORV(a, A) for (auto &a : A)

using namespace std;

using ll = long long;

void Main() {
  int a, b, x;
  cin >> a >> b >> x;
  if (a * a * b / 2 >= x) {
    double y = (double)x / a / b * 2.0;
    double theta = atan(b / y) / M_PI * 180;
    cout << theta << endl;
  } else {
    double y = (double)2.0 * b - (double)x / a / a * 2.0;
    double theta = atan(y / a) / M_PI * 180;
    cout << theta << endl;
  }
  cout << endl;
}

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


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	long a,b,c,d,e;
	while(scanf("%ld",&a)!=EOF){
	b=0;
	c=0;
	d=0;
	e=a;
	while(1){
		if(a>599){break;}
		b=e*a*a;
		c=c+b;
		a=a+e;
	}
	printf("%ld\n",c);}
	return 0;
}

Measured memory_bytes: 596
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#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 pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
//typedef ll 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-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	vi in(3);
	rep(i,3)cin>>in[i];
	int out=inf;
	loop(i,0,51){
		int co=0;
		rep(j,3){
			int a=in[j];
			if(i<=a)co+=a-i;
			else{
				if((i-a)%2==0)co+=(i-a)/2;
				else co+=(i-a)/2+2;
			}
		}
		out=min(out,co);
	}
	cout<<out<<endl;
}












Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n=scanner.nextInt();
		int x=scanner.nextInt();
		int a[]=new int[n];
		long sum=0;
		for(int i=0;i<n;i++) {
			a[i]=scanner.nextInt();
			sum+=a[i];
		}
		Arrays.sort(a);
		if(sum==x) {
			System.out.println(a.length);
		}else if(sum<x) {
			System.out.println(a.length-1);
		}else {
			int cnt=0;
			for(int i=0;i<n;i++) {
				int tar=a[i];
				if(tar<=x) {
					x-=tar;
					cnt++;
				}else break;
			}
			System.out.println(cnt);
		}
	}
}	

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

int main() {
  int n;
  cin >> n;
  //vector<vector<vector<int>>> a(4, vector<vector<int>>(3, vector<int>(10, 0)));
  int a[4][3][10] = { 0 };
  rep(i, n) {
    int b, f, r, v;
    cin >> b >> f >> r >> v;
    b--;
    f--;
    r--;
    //a.at(b).at(f).at(r) += v;
    a[b][f][r] += v;
  }
  rep(i, 4) {
    rep(j, 3) {
      rep(k, 10) {
        //cout << " " << a.at(i).at(j).at(k);
        cout << " " << a[i][j][k];
      }
      cout << endl;
    }
    if (i == 3) {
      break;
    }
    rep(j, 20) {
      cout << "#";
    }
    cout << endl;
  }
}



Measured memory_bytes: 3100
#include<stdio.h>

int main()
{
  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: 2016
#include <iostream>
using namespace std;
int main(void) {
  int a, b;
  cin >> a >> b;
  string s;
  cin >> s;
  bool f = true;
  for (int i = 0; i < s.size(); i++) {
    if (i == a) {
      if (s[i] != '-') f = false;
    } else {
      if (s[i] == '-') f = false;
    }
  }
  if (f) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n = gets.to_i
k = gets.to_i
x = gets.split(" ").map(&:to_i)
count = 0
n.times do |i|
    small = (x[i] - 0).abs
    big = (k - x[i]).abs
     saitan = [small,big].min
     count = count + saitan * 2
end
puts count

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

int main(){
  vector<int> n(3);
  for(int i=0;i<3;i++){
    cin >> n.at(i);
  }
  int cnt=0;
  for(int i=0;i<2;i++){
    for(int j=i+1;j<3;j++){
      if( n.at(i) == n.at(j) ){
        cnt++;
      }
    }
  }
  if( cnt == 1 ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    ll n,h;cin>>n>>h;
    vl a(n),b(n);
    vll c;
    vl sum(n+1);
    sum[0]=0;
    rep(i,n){
        cin>>a[i]>>b[i];
        c.PB(MP(b[i],a[i]));
    }
    sort(all(c));
    reverse(all(c));
    ll m=0;
    rep(i,n){
        m=max(m,a[i]);   
    }
    rep(i,n){
        sum[i+1]=sum[i]+max(m,c[i].F);
        if(sum[i+1]>=h){
            cout<<i+1;
            return 0;
        }
    }
    ll ans=n;
    ans+=(h-sum[n])/m;
    if((h-sum[n])%m!=0)ans++;
    cout<<ans;
}


Measured memory_bytes: 4724
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

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

    int ans = 0;
    for (int i = 1; i * i <= m; i ++)
    if (m % i == 0)
    {
        if (m / i >= n) 
            ans = max(ans, i);
        if (i >= n) 
            ans = max(ans, m / i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <unordered_map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

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

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	string s;
	cin >> s;

	auto check = [&](int len) {

		if (len == 0) return true;
		unordered_map<string, vector<int>> mp;
		for (int j = 0; j <= N - len; j++) mp[s.substr(j, len)].emplace_back(j);
		
		return any_of(mp.begin(), mp.end(), [](auto &p) { return p.second.size() >= 2 && (p.second.back() - p.second.front() >= p.first.size());});
	};

	vector<int> len(N);
	iota(len.begin(), len.end(), 0);
	cout << *partition_point(len.begin(), len.end(), check) - 1 << endl;

	return 0;
}


Measured memory_bytes: 6788
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int a[]={0,1,2,3,5,7,8,9},n;
  while(cin>>n&&n){
    for(i=0;pow(8,i)<=n;i++);
    for(i--;i>=0;i--){
      cout<<a[n/(int)pow(8,i)];
      n%=(int)pow(8,i);
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 884
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  char m1[55][55],m2[55][55];
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      cin>>m1[i][j];
  for(int i=0;i<m;i++)
    for(int j=0;j<m;j++)
      cin>>m2[i][j];
  int f=0;
  for(int i=0;i<=n-m;i++)
    for(int j=0;j<=n-m;j++){
      int tmp=1;
      for(int x=0;x<m;x++)
	for(int y=0;y<m;y++)
	  if(m1[x+i][y+j]!=m2[x][y])tmp=0;
      f+=tmp;
    }
  cout<<(f?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
p=gets.split.map(&:to_i)
n=gets.to_i*4
s=[1,2,4,8]
sr=s.reverse
d=p.map.with_index{|v,i|[v*sr[i],i]}.sort{|a,b|a[0]<=>b[0]}.map{|x|x[1]}
a=0
0.upto(3){|i|a+=n/s[d[i]]*p[d[i]];break if n%s[d[i]]==0;n%=s[d[i]]}
puts a

Measured memory_bytes: 1788
#include <stdio.h>

int main(void){
  int par,sol[20][20],pro,i,j,max,sum[20]={0};

  scanf("%d %d", &par, &pro);
  for(i=0;i<par;i++){
    for(j=0;j<pro;j++){
      scanf("%d", &sol[i][j]);
      if(sol[i][j]==1) sum[i]++;
    }
  }
  for(i=0;i<par;i++){
    if(sum[i]>max) max=sum[i];
  }
  printf("%d\n", max);

  return 0;
}


Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
int main(){int i,j,k,w,s,l,a,b,c,d,e,f,at=0,as=0;cin>>a>>b>>c>>d>>e>>f;for(i=0;i<=f;i+=100*a)for(j=0;;j+=100*b){w=i+j;if(w>f)break;for(k=0;w+k<=f;k+=c)for(l=0;;l+=d){s=k+l;if(w+s>f||s>w/100*e)break;if(as*(w+s)<=at*s)as=s,at=w+s;}}cout<<at<<" "<<as<<endl;return 0;}

Measured memory_bytes: 256
N = int(input())
m = 1000
k = 0
A = list(map(int,input().split()))
M = A[0]
for a in A:
  if M > a:
    if k > 0:
      m += k * M
      k = 0
  elif M < a:
    if k == 0:
      k,m = divmod(m,M)
  M = a
m += k * M
print(m)

Measured memory_bytes: 61964
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

int ans, n, m, s, t;
int d[100005];
vector<int> g[100005];

void bfs(int s) {
    queue<int> q1, q2, q3;
    rep(i, 0, n) d[i] = -1;

    q1.push(s);
    d[s] = 0;
    while (!q1.empty()) {
        int u = q1.front(); q1.pop();
        for (int v1 : g[u]) {
            q2.push(v1);
        }

        while (!q2.empty()) {
            int v1 = q2.front(); q2.pop();
            for (int v2 : g[v1]) {
                q3.push(v2);
            }
        }

        while (!q3.empty()) {
            int v2 = q3.front(); q3.pop();
            for (int v3 : g[v2]) {
                if (d[v3]==-1) {
                    d[v3] = d[u] + 1;
                    if (v3==t) return;
                    q1.push(v3);
                }
            }
        }

    }

}

int main(void) {

    cin >> n >> m;

    rep(i, 0, m) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        g[u].pb(v);
    }
    cin >> s >> t;
    s--; t--;

    bfs(s);

    cout << d[t] << "\n";
    return 0;
}



Measured memory_bytes: 9472
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (int i = 0; i < (n); ++i)	

int max(ll a, ll b) {
	ll max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(ll a, ll b) {
	ll min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main() {
	int n;
	double a[110];

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

	double ans = 0;
	double sum = 0;
	rep(i, n) {
		sum += 1 / a[i];
	}

	ans = 1 / sum;
	printf("%.8lf", ans);
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int main(void) {
    cout << std::fixed << std::setprecision(10);
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::string s;
    cin >> s;
    s[5]  = ' ';
    s[13] = ' ';
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 504
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const int MOD = 1e9 + 7;

template <ll mod> class ModInt {
    ll a;
public:
    constexpr ModInt(const ll a = 0) noexcept : a((a % mod + mod) % mod) {}
    constexpr ll &value() noexcept { return a; }
    constexpr ModInt operator + (const ModInt &rhs) const noexcept { return ModInt(*this) += rhs; }
    constexpr ModInt operator - (const ModInt &rhs) const noexcept { return ModInt(*this) -= rhs; }
    constexpr ModInt operator * (const ModInt &rhs) const noexcept { return ModInt(*this) *= rhs; }
    constexpr ModInt operator / (const ModInt &rhs) const noexcept { return ModInt(*this) /= rhs; }
    constexpr ModInt &operator += (const ModInt &rhs) noexcept {
        a += rhs.a;
        if (a >= mod) a -= mod;
        return *this;
    }
    constexpr ModInt &operator -= (const ModInt &rhs) noexcept {
        a -= rhs.a;
        if (a < mod) a += mod;
        return *this;
    }
    constexpr ModInt &operator *= (const ModInt &rhs) noexcept {
        a = a * rhs.a % mod;
        return *this;
    }
    constexpr ModInt pow(ll t) const noexcept {
        if (t == 0) return 1;
        auto ret = pow(t >> 1);
        ret *= ret;
        if (t & 1) ret *= *this;
        return ret;
    }
    constexpr ModInt inv() const noexcept { return pow(mod - 2); }
    constexpr ModInt operator /=(const ModInt &rhs) { return (*this) *= rhs.inv(); }
    constexpr bool operator == (const ModInt &rhs) const noexcept { return this->a == rhs.a; }
    constexpr bool operator != (const ModInt &rhs) const noexcept { return this->a != rhs.a; }
    friend constexpr ostream &operator << (ostream &os, const ModInt &rhs) noexcept { return os << rhs.a; }
    friend constexpr istream &operator >> (istream &is, ModInt &rhs) {
        ll t = 0;
        is >> t;
        rhs = ModInt<mod>(t);
        return is;
    }
};
using mint = ModInt<MOD>;

class Combination {
public:
    vector <mint> fac, inv, fiv;
    Combination(int N) : fac(N + 1), inv(N + 1), fiv(N + 1) {
        fac[0] = inv[0] = fiv[0] = fac[1] = inv[1] = fiv[1] = 1;
        for (ll i = 2; i <= N; i++) {
            fac[i] = fac[i - 1] * i; // n!
            inv[i] = inv[MOD % i] * (MOD - MOD / i); // n^-1
            fiv[i] = fiv[i - 1] * inv[i]; // (n!)^-1
        }
    }
    mint C(ll n, ll k) {
        if (k < 0 || n < k) return 0;
        return fac[n] * fiv[k] * fiv[n - k];
    }
};

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

    ll n, m, k;
    cin >> n >> m >> k;

    Combination com(200005);

    mint ans = 0;
    for (int i = 1; i < n; i++) ans += i * (n - i) * m * m;
    for (int i = 1; i < m; i++) ans += i * (m - i) * n * n;
    ans *= com.C(n * m - 2, k - 2);

    cout << ans << "\n";
    return 0;
}

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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef long long i64;

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

  int w, h, n;
  cin >> w >> h >> n;
  vi ymax(w, 0), xmax(h, 0);
  rep(i, 0, n) {
    int x, y;
    cin >> x >> y;
    ymax[x] = max(ymax[x], y);
    xmax[y] = max(xmax[y], x);
  }

  int ans = min(h, w) - 1;
  {
    int MAX = 0;
    for(int i = w - 2; i >= 0; --i) {
      MAX = max(MAX, ymax[i + 1]);
      ans = min(ans, i + MAX);
    }
  }
  {
    int MAX = 0;
    for(int i = h - 2; i >= 0; --i) {
      MAX = max(MAX, xmax[i + 1]);
      ans = min(ans, i + MAX);
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3636
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.Unboxed            as AU
import qualified Data.Array.ST                 as ST
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.Int
import qualified Data.IntMap                   as IM
import           Data.List
import qualified Data.Map                      as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
readInts n = replicateM n readInt
readString = map BS.unpack . BS.words <$> BS.getLine
readStrings n = replicateM n $ BS.unpack <$> BS.getLine
toPair [x, y] = (x, y)

main = do
  [n] <- readInt
  print $ solve n

solve n = minimum $ f n 1

f n x | n < x * x      = []
      | n `mod` x == 0 = (length $ show $ max x (n `div` x)) : f n (x + 1)
      | otherwise      = f n (x + 1)



Measured memory_bytes: 892
class Dice:
    def __init__(self,u,w,s,e,n,d):
        self.u=u
        self.w=w
        self.s=s
        self.e=e
        self.n=n
        self.d=d

    def rot(self,way):

        if way=="W":
            c=self.u
            self.u=self.e
            self.e=self.d
            self.d=self.w
            self.w=c
        elif way=="S":
            c=self.u
            self.u=self.n
            self.n=self.d
            self.d=self.s
            self.s=c
        elif way=="E":
            c=self.u
            self.u=self.w
            self.w=self.d
            self.d=self.e
            self.e=c
        else:
            c=self.u
            self.u=self.s
            self.s=self.d
            self.d=self.n
            self.n=c

u,s,e,w,n,d=map(int,input().split())
dice=Dice(u,w,s,e,n,d)
st=input()
for c in st:
    dice.rot(c)
print(dice.u)


Measured memory_bytes: 5608
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, ans; cin >> n;
    vector<int> a(n);
    rep(i, n) {
      cin >> a[i];
    }
    ans = a[0];
    rep(i, n) {
      ans = gcd(ans, a[i]);
    }

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


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

int main(){
	int N;
	cin>>N;
	vector<int> h(N);
	rep(i,N)cin>>h[i];
	int ans=0,counter,sum=0;
	rep(i,N)sum+=h[i];
	rep(i,sum){
		rep(j,N){
			if(h[j]==0){
				continue;
			}else{
				for(int k=j;k<N;k++){
					if(h[k]!=0 and k!=N-1){
						continue;
					}else if(h[k]==0){
						counter=k;
						break;
					}else if(k==N-1){
						counter=N;
						break;
					}
				}
				for(int l=j;l<counter;l++){
					h[l]-=1;
				}
				ans++;
				break;
			}
		}
		
	}
	cout<<ans<<endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), L(N), R(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  L.at(0) = A.at(0);
  for (int i = 1, gcd = L.at(0); i < N; i++) L.at(i) = (gcd = __gcd(gcd, A.at(i)));
  R.at(N - 1) = A.at(N - 1);
  for (int i = N - 2, gcd = R.at(N - 1); i >= 0; i--) R.at(i) = (gcd = __gcd(gcd, A.at(i)));

  int ans = max(L.at(N - 2), R.at(1));
  for (int i = 1; i + 1 < N; i++) ans = max(ans, __gcd(L.at(i - 1), R.at(i + 1)));
  cout << ans << "\n";
}

Measured memory_bytes: 1408
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            li = []
            while self.parents[x] >= 0:
                li.append(x)
                x = self.parents[x]
            for y in li:
                self.parents[y] = x
            return x

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

import sys
input = sys.stdin.buffer.readline
N,M = map(int,input().split())
uf = UnionFind(N)
for i in range(M):
    A,B = map(int,input().split())
    uf.union(A-1,B-1)
ans = 0
for i in uf.roots():
    ans = max(uf.size(i),ans)
print(ans)


Measured memory_bytes: 84564
#include <bits/stdc++.h>
using namespace std;
const int BASE = 1e9 + 7;

int n, k;
vector <int> a[100100];
long long fact[100100], invFact[100100];

long long power(int x, int y)
{
  if (!y)
    return 1;
  long long res = power(x, y / 2);
  res = res * res % BASE;
  if (y % 2)
    res = res * x % BASE;
  return res;
}

long long p(int n, int k)
{
  return n < k ? 0 : fact[n] * invFact[n - k] % BASE;
}

long long visit(int x, int par)
{
  int child = a[x].size() - (par > 0);
  long long res = p(k - 1 - (par > 0), child);
  for (int y : a[x])
    if (y != par)
      res = res * visit(y, x) % BASE;
  return res;
}

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

  int x, y;
  cin >> n >> k;
  for (int i = 1; i < n; i++)
  {
    cin >> x >> y;
    a[x].push_back(y);
    a[y].push_back(x);
  }

  for (int i = 0; i <= 100000; i++)
  {
    fact[i] = i ? fact[i - 1] * i % BASE : 1;
    invFact[i] = power(fact[i], BASE - 2);
  }

  cout << visit(1, 0) * k % BASE << endl;
}


Measured memory_bytes: 12032
#include <iostream>
#include <vector>

using namespace std;

int main()
{
  size_t n, m;
  cin >> n >> m;
  
  vector<size_t> holes(m);
  for(size_t i = m; i != 0; --i)
    cin >> holes[i-1];

  n += 1;
  vector<unsigned long long> steps(n);
  for(size_t i = 0; i < n; ++i)
  {
    if(m > 0 && holes[holes.size()-1] == i)
    {
      holes.pop_back();        
      steps[i] = 0;
      continue;
    }
    
    if(i < 2)
    {
    	steps[i] = 1;
      	continue;
    }
    
    steps[i] = (steps[i-1] + steps[i-2]) % (unsigned long long)1000000007;
  }
  cout << steps[steps.size()-1] << endl;
  
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6;
const int INF = 1e9;
 
int main()
{
	cin.sync_with_stdio(false);
    vector<int> dp(MAX, INF), res(MAX, INF), four, odd;
    for (int i = 1; i * (i + 1) * (i + 2) / 6 < MAX; i++) {
        four.push_back(i * (i + 1) * (i + 2) / 6);
        if (i * (i + 1) * (i + 2) / 6 % 2)
            odd.push_back(i * (i + 1) * (i + 2) / 6);
    }
    dp[0] = res[0] = 0;
    for (int j = 0; j < MAX; j++) {
        if (dp[j] != INF) {
            for (int k = 0; k < (int)four.size() && j + four[k] < MAX;k++) {
                dp[j + four[k]] = min(dp[j + four[k]], dp[j] + 1);
            }
        }
    }
    for (int j = 0; j < MAX; j++) {
        if (res[j] != INF) {
            for (int k = 0; k < (int)odd.size() && j + odd[k] < MAX; k++) {
                res[j + odd[k]] = min(res[j + odd[k]], res[j] + 1);
            }
        }
    }
    int n;
    while (cin >> n, n) {
        printf("%d %d\n", dp[n], res[n]);
    }
    return 0;
}

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

visited = []
tf_visited = [0] * n
pos = 0
count = 0

while tf_visited[pos] == 0:
	visited.append(pos)
	tf_visited[pos] = 1
	pos = a[pos]-1
	count += 1
	if count >= k:
		print(pos+1)
		exit()

loop_start = visited.index(pos)
loop_length = len(visited)-loop_start
pos_t = (k-loop_start) % loop_length + loop_start
print(visited[pos_t]+1)

Measured memory_bytes: 32368
#include<iostream>
using namespace std;
#define MAX 100005
int main(){
  int n,d,x;
  cin >> n >> d >> x;
  int p[20][20]={{}};
  int i,j,k;
  for(i=0;i<d;i++){
    for(j=0;j<n;j++){
      cin >> p[i][j];
    }
  }
  int o=x,pre=x;
  int inf = 1<<20;
  for(k=0;k<d-1;k++){
    int dp[20][MAX]={{}};
    fill(dp[0],dp[19],-inf);
    dp[0][0]=pre;
    for(i=0;i<n;i++){
      for(j=0;j<=pre;j++){
	if(dp[i][j]==-inf) continue;
	for(int l=0;j+l*p[k][i]<=pre;l++){
	  dp[i+1][j+l*p[k][i]]=max(dp[i+1][j+l*p[k][i]],
				   dp[i][j]+l*(p[k+1][i]-p[k][i]));
	}
      }  
    }
    pre=0;
    for(j=0;j<MAX;j++) pre=max(pre,dp[n][j]);
    //cout << pre << endl;
    o=max(o,pre);
  }

      
  cout << o << endl;
  return 0;
}

Measured memory_bytes: 8984
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC108B
int main(void) {
  int n, k, i, cou=0, tmp, x1, x2, y1, y2;
  scanf(" %d %d %d %d", &x1, &y1, &x2, &y2);
  printf("%d %d %d %d", x2-y2+y1, y2+x2-x1, x1-y2+y1, y1+x2-x1);
  return 0;
}


Measured memory_bytes: 128
//Finite Disappointment and Infinite Hope
#include <bits/stdc++.h>
using namespace std;
#define help ios_base:: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.first<<","<<v.second<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    for(auto &x:c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long ll;
const ll N=2e5+5,MOD=1e9+7;
int main(){
help
    ll a,b;cin>>a>>b;
    ll s=0,t=0;
    for(ll i=0;i<b;i++)s=s*10 + a;
    for(ll i=0;i<a;i++)t=t*10 + b;
    cout<<max(s,t);
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
MOD = 10**9 + 7
INF = float('INF')

def main():
    a, b, k = list(map(int,input().split()))

    a = a - k
    if a < 0:
        b = b + a
        a = 0
        b = max(0, b)
    print(a, b)

if __name__ == '__main__':
    main()

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

int main() {
    int k;
    string s;
    cin >> k >> s;
    if (s.size()<=k) {
        cout << s << endl;
    }
    else {
        for (int i=0;i<k;i++) {
            cout << s[i];
        }
        cout << "..." << endl;
    }

}


Measured memory_bytes: 3540
k=int(input())

que=list(range(1,9+1))

while True:
  if len(que)>=k:
    break
  k-=len(que)
  for q in que[:]:
    que.remove(q)
    lq=int(str(q)[-1])
    for r in (lq-1,lq,lq+1):
        if 0<=r<=9:
            que.append(int(str(q)+str(r)))
 
  if len(que)>=k:
    break
 
que.sort()
print(que[k-1])

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

int main(){

int n;
cin>>n;

vector<int> arr(1e5+1);
int k = 0;
int mx = 0;
for(int i = 0; i < n; i++){
	int t;cin>>t;
	arr[t]++;
	mx = max(mx,t);
}

for(int i = 1; i<=mx;i++){
	arr[i]+=arr[i-1];
	if(arr[i]*2 == n) k++;
}

cout<<k;

}

Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int d, n;
	cin >> d >> n;
	if (d==0) {
		if (n<100) {
			cout << n << endl;
		}
		else {
			cout << 101 << endl;
		}
	}
	else if (d==1) {
		if (n<100) {
			cout << n * 100 << endl;
		}
		else {
			cout << 10100 << endl;
		}
	}
	else {
		if (n<100) {
			cout << n * 10000 << endl;
		}
		else {
			cout << 1010000 << endl;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

int main(){
    int N,K;
    cin >> N >> K;
    LL ans=0;
    for(int i=K+1;i<=N;i++){
        ans+=N/i*(i-K);
        ans+=max(N-N/i*i-K+1,0);
    }
    if(K==0) ans-=N;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256