akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 99999999999999999;




long long int N,L[100],sum=0;


int main()
{
    cout << fixed << setprecision(18);
    cin>>N;
    for (long long int i = 0; i < N; i++)
    {
        cin>>L[i];
        sum+=L[i];
    }
    sort(L,L+N);
    IFYes(sum-L[N-1]>L[N-1]);

    
}


Measured memory_bytes: 256
from sys import stdin, stdout
def readLine_str_list():return list(map(str, stdin.readline().split()))
def main():
    s = readLine_str_list()
    vow = ['a', 'i', 'u', 'e', 'o']
    if s[0] in vow:
        print('vowel')
    else:
        print('consonant')

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);

class UnionFind{
	vector<int> par,siz;
	//0-indexed
	void init(int n){
		component = n;
		par.resize(n);
		for(int i=0;i<n;++i)par[i]=i;
		siz.resize(n,1);
		msiz = 1;
	}
public:
	int msiz,component;
	UnionFind(int n_){init(n_);}
	int root(int x){
		if(par[x]==x)return x;
		return par[x] = root(par[x]);
	}
	void unite(int x,int y){
		x = root(x);
		y = root(y);
		if(x==y)return;
		siz[y] += siz[x];
		siz[x] = 0;
		par[x] = y;
		msiz = max(msiz,siz[y]);
		component--;
	}
	int size(int x){
		return siz[root(x)];
	}
	bool same(int x,int y){
		return root(x)==root(y);
	}
};

int main(){
	ll N,M,K;
	cin >> N >> M >> K;
	vector<ll> F[N+1],B[N+1];
	UnionFind uf(N+1);
	FOR(i,0,M){
		ll a,b;
		cin >> a >> b;
		uf.unite(a,b);
		F[a].push_back(b);
		F[b].push_back(a);
	}
	FOR(i,0,K){
		ll a,b;
		cin >> a >> b;
		B[a].push_back(b);
		B[b].push_back(a);
	}

	FOR(i,1,N+1){
		ll ans = 0;
		ans = uf.size(i) - F[i].size();
		for(auto x:B[i]){
			if(uf.same(i,x))ans--;
		}
		if(i!=1)cout << " ";
		cout << ans-1;
	}
	cout << endl;

}



Measured memory_bytes: 14068
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)

int main(){
 
ll N,A,B;
cin>>N>>A>>B;

 ll dt = B-A;
 if(dt==0){
   cout<<0<<endl;
   return 0;
 }

 if(dt%2==0){
   cout<<((dt-1)/2LL)+1<<endl;
   return 0;
 }
 ll rr = min(B-1,(N-A));



 //yasumi
 //migi
  dt = N - (A+(N-B)+1);
 rr = min(rr,((dt-1)/2LL)+1+(N-B+1));
 dt = B-(A-1+1)-1;
 rr = min(rr,((dt-1)/2LL)+1+(A-1+1));








cout<<rr<<endl;
return 0;


}


Measured memory_bytes: 256
N,X,Y=map(int,input().split())
cost=[[] for _ in range(N)]

for i in range(N-1):
  cost[i].append(i+1)
for j in range(1,N):
  cost[j].append(j-1)

cost[X-1].append(Y-1)
cost[Y-1].append(X-1)
#print(cost)

def bfs(v):
    d=[-1]*N
    d[v]=0
    q=[v]
    c=1
    while q:
        q1=[]
        for i in q:
            for j in cost[i]:
                if d[j]==-1:
                    d[j]=c
                    q1.append(j)
        q=q1
        c+=1
        #print(d,q)
    return d

d=dict()
for m in range(N):
  tmp=bfs(m)
  #print(tmp)
  for num in tmp:
    if num not in d:
      d[num]=1
    else:
      d[num] += 1
#print(d)

for z in range(1,N):
  if z in d:
    print(d[z]//2)
  else:
    print(0)

Measured memory_bytes: 53596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}
void YES_NO(bool f) {
  if (f)
    printf("YES\n");
  else
    printf("NO\n");
}

template <typename T>
void deb1(T x) {
  cout << x << "\n";
}

template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void) {
  string s;
  cin >> s;
  set<char> st;
  rep(i, 26) st.insert('a' + i);
  rep(i, size(s)) st.erase(s[i]);
  if (size(st) != 0)
    out(*st.begin());
  else
    out("None");
}
int main(void) { solve(); }

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int count=0;
	while(n>0){
		double x,y;
		cin>>x>>y;
		double ans=sqrt(x*x+y*y);
//		cout<<ans<<endl;
		if(ans<=m){
			count++;
		}
		n--;
	}
	cout<<count<<endl;
}

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

int main() {
    int h=0, w=0, n=0;
    cin >> h >> w >> n;

    vector<int> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }

    vector<int> c(h*w);

    int i=0, ind=0;

    while (i < n) {
        for (int j=0; j<a.at(i); j++) {
            c.at(ind) = i+1;
            ind++;
        }
        i++;
    }

    int t=0;

    while (t < h) {
        if (t%2 == 0) {
            for (int j=0; j<w; j++) {
                cout << c.at(j+t*w) << ' ';
            }
        } else {
            for (int j=w-1; j>=0; j--) {
                cout << c.at(j+t*w) << ' ';
            }
        }
        cout << endl;
        t++;
    }

}

Measured memory_bytes: 764
_ = gets
rate = Hash.new(0)
gets.split.map!{|x| x.to_i / 400}.each {|c| rate[c] += 1}

ans = count = 0
rate.each do |key,value|
    if key <= 7
        ans += 1
    else
        count += value
    end
end

min = ans == 0 ? 1 : ans
max = ans + count
puts "#{min} #{max}"

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

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

  if (n % 2 == 1 || n < 10) {
    cout << 0 << endl;
    return 0;
  }

  ll cnt2 = 0, cnt5 = 0;

  cnt2 += n / 2;

  n /= 2;

  while (n) {
    n /= 5;
    cnt5 += n;
  }

  cout << cnt5 << endl;
  return 0;
}

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

int main()
{
	unsigned int n,m;
	long int x[100000],y[100000];
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>x[i];
	}
	if(n>=m){cout<<0;return 0;}
	sort(x,x+m);
	for(int i=0;i<m-1;i++){
		y[i]=x[i+1]-x[i];
	}
	sort(y,y+m-1);
	long long int s=0;
	for(int i=0;i<m-n;i++){
		s+=y[i];
	}
	cout<<s;
}


Measured memory_bytes: 1792
import collections
n = int(input())
a = [int(i) for i in input().split()]
x,y,z = collections.Counter(a),[0],[0,0]
for i in x.keys():
	if x[i]>=4:
		y.append(i)
	if x[i]>=2:
		z.append(i)
y,z = sorted(y),sorted(z)
print(max(y[-1]**2,z[-1]*z[-2]))

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(500005);

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

  mint ans = 0;
  for(int i=0;i<=n;i++){
    mint sum = comb(n, i);
    sum *= comb(m-i, n-i)*comb.fact[n-i];
    if(i%2 == 1) sum = -sum;
    ans += sum;
  }

  ans *= comb(m, n)*comb.fact[n];

  cout << ans << endl;

}


Measured memory_bytes: 10948
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}



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

   int a=0;
   rep(i,n.size()){
      a+=n[i]-'0';
   }

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


   


return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
#define int long long int
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll m = 998244353;
int power(int x,int y, int m) 
{ 
    if (y == 0) 
        return 1;
    int p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
  
    return (y%2 == 0)? p : (x * p) % m; 
} 
int modInverse(int a, int m) 
{     
        return power(a, m-2, m); 
}
int mod(int x)
{
	if(x<0)return -x;
	else return x;
 } 
signed main()
{
readb(n,wt);
int w[n+1]={0},v[n+1]={0};
FOR(i,1,n)
{
	cin>>w[i]>>v[i];
}
int dp[n+1][wt+1];
FOR(i,0,n)
FOR(j,0,wt)
dp[i][j]=0;
FOR(i,1,n)
{
	FOR(j,1,wt)
	{
	     if(j>=w[i])
		dp[i][j]=max((dp[i-1][j-w[i]]+v[i]),dp[i-1][j]);
		else if(j<w[i])
		dp[i][j]=dp[i-1][j];
		//cout<<dp[i][j]<<" ";
	}
	//cout<<endl;
}
cout<<dp[n][wt]<<endl;
}

Measured memory_bytes: 79104
#pragma once
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;


int w,h,n;
int x[100],y[100],a[100];
int result;
int maxA[5];



int main(){

	scanf("%d",&w);
	scanf("%d",&h);
	scanf("%d",&n);

	maxA[1] =0;
	maxA[2] =w;
	maxA[3] =0;
	maxA[4] =h;


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

	for(int i=0;i<n;i++){
		switch(a[i]){
		case 1:
			if(x[i]>maxA[1]){
				maxA[1] = x[i];
			}

		break;
		case 2:

			if(x[i]<maxA[2]){
				maxA[2] = x[i];
			}

		break;
		case 3:

			if(y[i]>maxA[3]){
				maxA[3] = y[i];
			}

		break;
		case 4:

			if(y[i]<maxA[4]){
				maxA[4] = y[i];
			}


		break;
		
		}
		
	}

	if(maxA[1]>maxA[2] || maxA[3]>maxA[4]){
		result=0;
	}
	else{
		result =(maxA[2]-maxA[1])*(maxA[4]-maxA[3]);
	}



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


return 0;
}



Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
	   int i = 0;
	   int j;
        Scanner sc = new Scanner(System.in);
		String b = sc.next();			
	   String[] enki;
	   enki = new String[4];
	   enki[0] = "A";
	   enki[1] = "C";
	   enki[2] = "G";
	   enki[3] = "T";
	   for(i = 0;!(b.equals(enki[i])); i++){
	   }
		j = 3-i;	
	   System.out.println(enki[j]);
    }
}

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

using namespace std;

const int N = 100007;
const int INF = 1000000007;

int h[N], dp[N];

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

  for(int i = 0; i < n; ++i) cin >> h[i];

  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  for(int i = 2; i < n; ++i) {
    dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
  }

  cout << dp[n - 1] << "\n";
  return 0;
}


Measured memory_bytes: 1024
n, m = map(int, input().split())
name = []
city = []
prefecture = [1] * n
for i in range(m):
    a = list(map(int, input().split())) + [i+1]
    city.append(a)
    name.append("{}{}".format("0" * (6 - len(str(a[0]))), a[0]))
city_1 = sorted(city, key=lambda x: x[0])
city_sorted = sorted(city, key=lambda x: x[1])

x = 1
for i in range(m):
    p, y, num = city_sorted[i]
    x = prefecture[p-1]
    name[num-1] += "{}{}".format("0" * (6 - len(str(x))), x)
    prefecture[p-1] += 1
for i in name:
    print(i)


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

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

Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;
using Edge = pair<int, int>;
using Graph = vector<vector<int>>;

int main() {
    int N; cin >> N;
    
    Graph G(N);
    map<Edge, int> ma;
    map<int, Edge> order;
    for(int i = 0; i < N-1; ++i) {
        int a, b; cin >> a >> b;
        --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
        order[i] = Edge(a, b);
    }
    
    vector<int> dist(N, -1);
    queue<int> que;
    
    dist[0] = 0;
    que.push(0);
    
    int K = 0;
    vector<int> pre(N, -1);
    while(!que.empty()) {
        int v = que.front(); que.pop();
        int color = 1;
        for(auto nv : G[v]) {
            if(dist[nv] != -1) continue;
            
            pre[nv] = v;
            if(ma[Edge(pre[v], v)] == color) ++color;
            ma[Edge(v, nv)] = color;
            
            dist[nv] = dist[v] + 1;
            que.push(nv);
            K = max(K, color);
            
            ++color;
        }
    }
    
    cout << K << endl;
    for(auto e : order) cout << ma[e.second] << endl;
}


Measured memory_bytes: 19328
#include<bits/stdc++.h>
#define ll 	 long long
#define pb push_back
#define mp make_pair
using namespace std;


int main()
{

int n,k; cin>>n>>k;

int a[n+9];

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

vector<int> dp(n+9, INT_MAX);

dp[0]=0;

if(n==1)
{
	cout<<dp[0]<<endl;
	return 0;
}
dp[1]= abs(a[0]-a[1]);

if(n==2)
{
		cout<<dp[1]<<endl;
	return 0;
}

   for(int i=2;i<n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if(i-j>=0) dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
        }
 
    }

cout<<dp[n-1]<<endl;

     return 0;
 }

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
#define ri register int
int main(){
	ri k,n,i,j;
	scanf("%d",&k);
	if(k==1){
		puts("1");
		puts("1"); 
		return 0;
	}
	n=(k+3)/4*2;
	printf("%d\n",n);
	for(i=0;i<n;++i){
		for(j=0;j<n;++j)
			if(i&1)
				printf("%d ",((i+j)%n+n<k?(i+j)%n+n:(i+j)%n)+1);
			else
				printf("%d ",(i+j)%n+1);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

struct Graph {
    struct Vertex { int n, d[2]; };
    struct Edge { int i, n; };
    Graph(int n, int m) : v(n, { -1, 0, 0 }), e(m), n(n), m(0) {}
    void add_edge(int i, int j) {
        e[m] = { j, v[i].n };
        v[i].n = m;
        m++;
    }
    void dfs(int i, int p, int d, int t) {
        v[i].d[t] = d;
        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge &o = e[j];
            if (o.i == p) continue;
            dfs(o.i, i, d + 1, t);
        }
    }
    void solve() {
        int r = 0;
        for (int i = 0; i < n; i++) {
            if (v[i].d[0] < v[i].d[1]) {
                r = max(r, v[i].d[1] - 1);
            }
        }
        cout << r << endl;
    }
    vector<Vertex> v;
    vector<Edge> e;
    int n, m;
};

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

    int n, u, v;
    cin >> n >> u >> v;
    u--; v--;

    Graph g(n, (n - 1) * 2);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;

        g.add_edge(a, b);
        g.add_edge(b, a);
    }

    g.dfs(u, -1, 0, 0);
    g.dfs(v, -1, 0, 1);
    g.solve();

    return 0;
}

Measured memory_bytes: 4864
#include<stdio.h>

int shift(int* array, int n){
    for(int i = 0; i < n; i++){
        if(array[i] & 1 == 1 || array[i] == 0) return 0;
        else array[i] >>= 1;
    }
    return 1;
}

int main(){
    int cnt;
    int N;
    int A[200];
    scanf("%d", &N);

    for(int i = 0; i < N; i++){
        scanf("%d", &A[i]);
    }

    cnt = 0;
    while(shift(A, N)){
        cnt++;
    }
    printf("%d", cnt);
    return 0;
}

Measured memory_bytes: 128
def main():
    N, K = map(int, input().split())
    d = []
    A = []
    for _ in range(K):
        d.append(int(input()))
        A.extend(list(map(int, input().split())))
    A = list(set(A))
    #print(A)
    result = [i+1 for i in range(N) if i+1 not in A]
    print(len(result))
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9228
#include <iostream>
#include <vector>
#include <queue>
#include <utility>

using namespace std;
typedef pair<int, int> P;
const int INF = 2100000000;

struct edge {int to, cost;};

int V, E, r;
int d[100010];
vector<edge> G[100010];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, s));
    fill(d, d + V, INF);
    d[s] = 0;
    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (auto e: G[v]) {
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main(void) {
    cin >> V >> E >> r;
    for (int i = 0; i < E; i++) {
        int s, t, d;
        cin >> s >> t >> d;
        G[s].push_back(edge {t, d});
    }

    dijkstra(r);

    for (int i = 0; i < V; i++) {
        if (d[i] < INF) cout << d[i] << endl;
        else cout << "INF" << endl;
    }

    return 0;
}

Measured memory_bytes: 11296
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n,a,b,Ans;
  cin>>n>>a>>b;
  Ans=0;
  Ans=n/(a+b)*a;
  if(a<n%(a+b)){
    Ans+=a;
  }else{
    Ans+=n%(a+b);
  }
  cout<<Ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  if(a > 9 || b > 9){
    cout << "-1\n";
    return 0;
  }
  cout << a * b << "\n";
}

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

signed main() {
  int N, A, B;
  cin >> N >> A >> B;
  
  int ans = 0;
  int total = 0;
  int kazu = 0;
  for( int i = 1; i <= N; i++ ){
    kazu = i;
    total = 0;
    while( kazu != 0 ){
      total += kazu%10;
      kazu /= 10;
    }
    if( A <= total && total <= B ){
      ans += i;
    }
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	int N;
	cin >> N;

	vector<int> p( N );
	for( auto& v: p ) {
		cin >> v;
		v -= 1;
	}

	int ans = 0;
	for( int i = 0; i < N; ++i ) {
		if( p[i] == i ) {
			swap( p[i], p[i + (i < N-1 ? 1 : -1)] );
			ans += 1;
		}
	}

	cout << ans << endl;

	return 0;
}


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

int N, M, A[100000];
pair<int, int> BC[100000];

int main(){
    cin >> N >> M;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    sort(A, A + N);
    for(int j = 0; j < M; j++){
        int b, c;
        cin >> b >> c;
        BC[j] = make_pair(-c, b);
    }
    sort(BC, BC + M);

    int next_change_idx = 0;
    for(int i = 0; i < M; i++){
        for(int j = 0; j < BC[i].second; j++){
            if(next_change_idx >= N || A[next_change_idx] >= -BC[i].first){
                break;
            }else{
                A[next_change_idx] = -BC[i].first;
                next_change_idx++;
            }
        }
    }

    long long ans = 0;
    for(int i = 0; i < N; i++){
        ans += A[i];
    }
    cout << ans << endl;
}



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

using namespace std;

int main(){
	vector<bool> isprime(1000000,true);
	isprime[0] = isprime[1] = false;
	for(int i = 2; i < 1000000; i++){
		if(isprime[i]){
			for(int j = 2; i*j < 1000000; j++){
				isprime[i*j] = false;
			}
		}
	}
	vector<int> p;
	for(int i = 0; i < 1000000; i++){
		if(isprime[i])p.push_back(i);
	}
	while(true){
		int a,d,n; cin >> a >> d >> n;
		if(a == 0)break;
		int cnt = 0;
		for(int i = a; i < 1000000; i+= d){
			if(*lower_bound(p.begin(),p.end(),i) == i){
				cnt++;
				if(cnt == n){
					cout << i << endl;
					break;
				}
			}
		}
	}



	return 0;
}




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

int main(){
    while (1){
	int n;
	vector<int> s;
	
	cin >> n;
	if (n == 0) break;
	int t;
	for (int i = 0; i < n; i++){
	    cin >> t;
	    s.push_back(t);
	}
	sort(s.begin(), s.end());

	int score = 0;
	for (int i = 1; i < s.size() - 1; i++){
	    score += s[i];
	}
	score /= s.size() - 2;

	cout << score << endl;
    }
}

Measured memory_bytes: 0
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int n,k,x;
    int ans=0;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        ans+=min(2*abs(x-0),2*abs(k-x));
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(pos,mp) for(ll pos=mp.begin();pos!=mp.end();pos -++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

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

    // reward[i] : i+1日後にもらえる報酬のベクトル
    vector<vector<ll>> reward(100010);
    rep(i, n){
        ll a, b;
        cin >> a >> b;
        reward[a-1].push_back(b);
    }

    // 未来から逆算，Mまでにもらえる最大報酬のバイトをする
    priority_queue<ll> que;
    ll ans = 0;
    rep(i, m){
        for(ll r_i : reward[i])que.push(r_i);

        if(!que.empty()){
            ans += que.top();
            que.pop();
        }
    }

    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;

#define TT template<typename T>
#define TTF template<typename T, typename F>
#define ET(T) typename T::value_type
TT inline T sq(T x){return x*x;}
TT inline T In(){T x;cin>>x;return x;}
TT inline void Out(T&x){cout<<x;}
TT inline void sort(T&v){sort(begin(v),end(v));}
TT inline void revs(T&v){reverse(begin(v),end(v));}
TT inline void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT inline int ubnd(T&v,ET(T)&x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT inline int lbnd(T&v,ET(T)&x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF inline void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF inline void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
#undef TT
#undef TTF
#undef ET

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}

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

int main()
{
  int h, w;
  cin >> h >> w;
  int dp[64][64] = {};
  for (int i = 0; i < 64; i++){
    for (int j = 0; j < 64; j++){
      dp[i][j] = INT_MAX;
    }
  }
  dp[0][0] = 0;
  vector<string> vs;
  inpt(vs, h, In<string>);
  for (int i = 0; i < h; i++){
    for (int j = 0; j < w; j++){
      if (i < h - 1) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + vs[i + 1][j] - '0');
      if (j < w - 1) dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + vs[i][j + 1] - '0');
    }
  }
  printf("%d\n", dp[h - 1][w - 1]);
  return (0);
}

// priority_queue queue deque front stringstream max_element min_element insert count make_tuple

Measured memory_bytes: 1224
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.println(a / b);
        System.out.println(a % b);

        double ad = (double) a;
        double bd = (double) b;
        double ans = ad / bd;
        System.out.printf("%.5f", ans);
    }
}



Measured memory_bytes: 26504
import numpy as np

W,H,N=map(int,input().split())

X=Y=0
for i in range(N):
    x,y,a=map(int,input().split())

    if a==1:
        X=max(X,x)
    elif a==2:
        W=min(W,x)
    elif a==3:
        Y=max(Y,y)
    else:
        H=min(H,y)

S=max((W-X),0)*max((H-Y),0)

print(S)

Measured memory_bytes: 27076
from collections import Counter

N = int(input())

if N == 1:
    print(0)
else:
    factors = []

    tmp = N
    for i in range(2, int((N+1)**(1/2))+1):
        while tmp % i == 0:
            factors.append(i)
            tmp //= i
    if tmp != 1:
        factors.append(tmp)
    # print(factors)

    counter = Counter(factors)
    # print(counter)

    remains = []
    ans = 0
    for i, item in enumerate(counter.items()):
        # print(item)
        key = item[0]
        val = item[1]
        for j in range(1, val+1):
            if val-j >= 0:
                val -= j
                ans += 1
            else:
                break
            # print("val: {}".format(val))
        if val > 0:
            remains.append([key, val])

    # print(remains)

    print(ans)


Measured memory_bytes: 9696
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin() (a).end()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

template<class T = int>
T in() { T x; cin >> x; return x; }

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  ll n; cin >> n;
  ll mn = INFL, idx = -1;
  for (int i = 0; i < 5; i++) {
    ll tmp; cin >> tmp;
    if (tmp < mn) {
      mn = tmp;
      idx = i;
    }
  }
  ll ans = (n+mn-1)/mn + 4;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 5;
int a[N];

int main() {
	int n;
	ll ans = 0;
	cin >> n;
	n *= 3;
	for(int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n);
    for(int i = n - 2; i >= n /3; i-= 2)
        ans += a[i];
    cout << ans;
}


Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <utility>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    ll n;
    cin >> n;
    map<ll, ll> v1, v2;
    repi(i, n, 0)
    {
        ll v;
        cin >> v;
        if (i % 2)
        {
            v1[v]++;
        }
        else
        {
            v2[v]++;
        }
    }
    ll m1 = 0, m2 = 0, val1, val2, prev1 = 0, prev2 = 0;
    for (auto itr = v1.begin(); itr != v1.end(); itr++)
    {
        if (m1 < itr->second)
        {
            prev1 = m1;
            val1 = itr->first;
            m1 = itr->second;
        }
        else
        {
            prev1 = max(prev1, itr->second);
        }
    }
    for (auto itr = v2.begin(); itr != v2.end(); itr++)
    {
        if (m2 < itr->second)
        {
            prev2 = m2;
            val2 = itr->first;
            m2 = itr->second;
        }
        else
        {
            prev2 = max(prev2, itr->second);
        }
    }
    if (val1 != val2)
    {
        cout << n - m1 - m2 << endl;
    }
    else
    {
        cout << (prev1 + m2 > prev2 + m1 ? n - prev1 - m2 : n - prev2 - m1) << endl;
    }
    return 0;
}

Measured memory_bytes: 6528
#include <cstdio>
int main()
{
	int N, i, x, sum = 0, sqr = 0, ans;
	scanf("%d", &N);
	for(i=0; i<N; ++i)
	{
		scanf("%d", &x);
		sum += x;
		sqr += x * x;
	}
	x = int(1.0 * sum / N);
	ans = sqr + x * (x*N - sum - sum);
	++x;
	sqr = sqr + x * (x*N - sum - sum);
	if(sqr < ans) ans = sqr;
	printf("%d\n", ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

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

int v, e;
vector<int> g[10010], rg[10010], vs, st;
vector<bool> vis;

void dfs(int x) {
    vis[x] = true;
    for (int i = 0; i < g[x].size(); i++) {
        if (!vis[g[x][i]]) dfs(g[x][i]);
    }
    vs.pb(x);
}

void rdfs(int x, int k) {
    vis[x] = true;
    st[x] = k;
    for (int i = 0; i < rg[x].size(); i++) {
        if (!vis[rg[x][i]]) rdfs(rg[x][i], k);
    }
}

bool isSame(int u, int v) {
    return (st[u] == st[v]);
}

int main() {
    cin >> v >> e;
    for (int i = 0; i < e; i++) {
        int a, b;
        cin >> a >> b;
        g[a].pb(b);
        rg[b].pb(a);
    }
    st.resize(v);

    vis.resize(v, false);
    for (int i = 0; i < v; i++) {
        if (!vis[i]) dfs(i);
    }
    int k = 0;
    fill(vis.begin(), vis.end(), false);
    for (int i = vs.size() - 1; i >= 0; i--) {
        if (!vis[vs[i]]) rdfs(vs[i], k++);
    }

    int q;
    cin >> q;
    int u, v;
    for (int i = 0; i < q; i++) {
        cin >> u >> v;
        cout << isSame(u, v) << endl;
    }

    return 0;
}

Measured memory_bytes: 4836
#include <stdio.h>

int main(){
int n;
int ctr=0;
scanf("%d",&n);
for(int i=0;i<n;i++){
	int a,b;
	scanf("%d %d",&a,&b);
	if (a == b){
		ctr++;
	}
	else{
		ctr = 0;
	}
	if(ctr==3){
		printf("Yes\n");
		return 0;
	}
}
printf("No");
return 0;
}


Measured memory_bytes: 1728
#include<stdio.h>
int main(){
  int n,k,i,tmp,ans=0;
  int x;
  scanf("%d%d",&n,&k);
  for(i=0;i<n;i++){
    scanf("%d",&x);
    tmp = x<k-x?x:k-x;
    ans+=2*tmp;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
const ll mod = 1e9 + 7;
const ll inf = 1e18;

// i番目まで見て
// 価値j
// を達成する最小の重さ
const int V_MAX = 100010;
ll dp[100][V_MAX];

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

    // input
    ll N, C;
    cin >> N >> C;

    VI V(N);
    VI W(N);
    rep(i, N){
        cin >> W[i] >> V[i];
    }

    // 初期化
    rep(i, 100){
      rep(j, V_MAX){
        if(j==0){
          dp[i][j] = 0;
        }else{
          dp[i][j] = inf;
        }
      }
    }

    // 1つめの荷物
    ll v = V[0];
    ll w = W[0];
    dp[0][v] = w;
    dp[0][0] = 0;

    // 2つめ以降の荷物
    FOR(i, 1, N){
      ll w = W[i]; // 今回の重さ
      ll v = V[i]; // 今回の価値
      rep(j, V_MAX){
        // 選ばない
        dp[i][j] = dp[i-1][j];

        if(j-v>=0){
          chmin(dp[i][j], dp[i-1][j-v] + w);
        }
      }
    }
    
    ll ans = 0;
    rep(j, V_MAX){
      ll w = dp[N-1][j];
      if(w<=C){
        chmax(ans, j);
      }
    }
    p(ans);

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int N;
    cin >> N;
    ll ans = 1;
    while(ans * (ans + 1) / 2 < N){
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007LL;

ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}


// verified
//   https://onlinejudge.u-aizu.ac.jp/courses/library/6/NTL/1/NTL_1_B
void AOJ_NTL_1_B() {
    ll m, n;
    cin >> m >> n;
    cout << pow_mod(m, n, MOD) << "\n";
}


// verified
//   https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/all/DPL_5_A
void AOJ_DPL_5_A() {
    int n, k;
    cin >> n >> k;
    cout << pow_mod(k, n, MOD) << "\n";
}

int main() {
    // AOJ_NTL_1_B();
    AOJ_DPL_5_A();
    return 0;
}


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

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

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;
}

long long fac[MAX_N], finv[MAX_N], inv[MAX_N];
// テーブルを作る前処理 from: https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX_N; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// factorial
long long fact(int n) {
    if (n == 1) return fac[n] = 1;
    if (fac[n]) return fac[n];
    return fac[n] = (fact(n - 1) * n) % MOD;
}

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

    int n;
    string s;
    cin >> n >> s;

    char lp = '(';
    char rp = ')';
    int cnt = 0;

    revrep(i, n) {
        if (s[i] == rp) cnt++;
        if (s[i] == lp and cnt > 0) cnt--;
    }
    n += cnt;
    while (cnt > 0) {
        s = lp + s;
        cnt--;
    }

    rep(i, n) {
        if (s[i] == lp)
            cnt++;
        else
            cnt--;
    }
    while (cnt > 0) {
        s += rp;
        cnt--;
    }

    out(s);
}


Measured memory_bytes: 256
# xの階乗 mod 10**9 + 7 について、1~nまでの結果を辞書にして返す
def factorial_table(n):
    result = {0:1}

    curr = 1
    acc = 1
    modmax = (10**9) + 7
    while curr <= n:
        acc *= curr
        acc %= modmax
        result[curr] = acc
        curr += 1

    return result

# xの逆元 mod 10**9 + 7を求める
def reverse_mod(x, rev_table):
    if x in rev_table.keys():
        return rev_table[x]

    rev_table[x] = power_n(x, 10**9 + 5)
    return rev_table[x]


# xのn乗 mod 10**9 + 7を求める
def power_n(x, n):
    r = 1
    curr_a = x
    modmax = (10 ** 9) + 7
    while n:
        if 1 & n:
            r *= curr_a
            r %= modmax

        n = n >> 1
        curr_a *= curr_a
        curr_a %= modmax

    return r


def factorial(n, fact_table):
    return fact_table[n]


def combination(n, k, fact_table, combi_table, rev_table):
    if (n, k) in combi_table.keys():
        return combi_table[(n, k)]

    combi_table[(n, k)] = factorial(n, fact_table) * \
        reverse_mod(factorial(k, fact_table), rev_table) * \
        reverse_mod(factorial(n - k, fact_table), rev_table) % (10**9 + 7)
    return combi_table[(n, k)]


def read_input():
    n, k = map(int, input().split())
    return n, k


def submit():
    n, k = read_input()

    md = 10 ** 9 + 7

    # 階乗を求めておく
    fact_table = factorial_table(n)

    # 逆元を求めておく
    rev_table = {}
    for i in range(n + 1):
        reverse_mod(i, rev_table)

    r = n - k
    combi_table = {}

    print(r + 1)

    for i in range(2, k + 1):
        inner_sum = 0
        for s in range(i - 1, r + 1):
            red_divided = combination(s - 1, i - 2, fact_table, combi_table, rev_table)
            inner_sum += (r - s + 1) * red_divided
            inner_sum %= md

        blue_divided = combination(k - 1, i - 1, fact_table, combi_table, rev_table)
        ans = blue_divided * inner_sum % md
        print(ans)

    return


if __name__ == '__main__':
    submit()


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

using namespace std;

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

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

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

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


signed main(void) {
    int n;
    cin >> n;
    int a = n/2;
    int b = n/2 + n%2;
    cout << a*b << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
flag = False

for i in range(1,max(A)):
  a = 2 ** i
  for n in range(N):
    if A[n] % a != 0:
      flag = True
      break
  if flag:
    break
    
print(i-1)

Measured memory_bytes: 9180
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    string s; cin >> s;

    vector<string> vs;
    int n = s.size();

    string prev = s.substr(0, 1);
    for(int i=1; i<n; i++){
        // cout << "i: " << i << endl;
        if(prev == s.substr(i, 1)){
            if(i != n-1){
                vs.push_back(prev);
                prev = s.substr(i, 2);
                i++;
                if(i >= n-1){
                    vs.push_back(prev);
                }
            }
            else{
                vs.push_back(s.substr(i-1, 2));
                i++;
            }
        }
        else{
            if(i != n-1){
                vs.push_back(prev);
                prev = s.substr(i, 1);
            }
            else{
                vs.push_back(prev);
                vs.push_back(s.substr(i, 1));
            }
        }
    }

    // for(int i=0; i<vs.size(); i++){
    //     cout << vs[i] << endl;
    // }

    int ans = vs.size();

    

    cout << ans;




    return 0;
}
 

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n; cin >> n;
    vector<int> ans(n + 10, 0);
    queue<int> q;
//    set<int> S;
    vector<bool> vis(n + 10, false);
    vector<vector<pair<int, int>>> adj(n + 10);
    for (int i = 1; i < n; i++) {
        int u, v, w; cin >> u >> v >> w;
        adj[u].emplace_back(v, w);
        adj[v].emplace_back(u, w);
//        if (w % 2 == 0) {
//            ans[u] = ans[v] = 1;
//            vis[u] = vis[v] = true;
//            S.insert(u);
//            S.insert(v);
//        }
    }
//    for (auto it : S) {
//        q.push(it);
//    }
    q.push(1); vis[1] = true;
    while (!q.empty()) {
        int v = q.front(); q.pop();
        for (auto &edge : adj[v]) {
            int u = edge.first, w = edge.second;
            if (vis[u]) {
                continue;
            }
            if (w % 2 == 0) {
                ans[u] = ans[v];
            } else {
                ans[u] = !ans[v];
            }
            q.push(u);
            vis[u] = true;
        }
    }
    for (int i = 1; i <= n; i++) {
        cout << ans[i] << "\n";
    }
}


Measured memory_bytes: 6912
n = list(map(int,input()))

if n[0] + n[1] + n[2] + n[3] == 7:
    print("{}+{}+{}+{}=7".format(n[0],n[1],n[2],n[3]))
elif n[0] + n[1] + n[2] - n[3] == 7:
    print("{}+{}+{}-{}=7".format(n[0],n[1],n[2],n[3]))
elif n[0] + n[1] - n[2] + n[3] == 7:
    print("{}+{}-{}+{}=7".format(n[0],n[1],n[2],n[3]))
elif n[0] + n[1] - n[2] - n[3] == 7:
    print("{}+{}-{}-{}=7".format(n[0],n[1],n[2],n[3]))
elif n[0] - n[1] + n[2] + n[3] == 7:
    print("{}-{}+{}+{}=7".format(n[0],n[1],n[2],n[3]))
elif n[0] - n[1] + n[2] - n[3] == 7:
    print("{}-{}+{}-{}=7".format(n[0],n[1],n[2],n[3]))
elif n[0] - n[1] - n[2] + n[3] == 7:
    print("{}-{}-{}+{}=7".format(n[0],n[1],n[2],n[3]))
elif n[0] - n[1] - n[2] - n[3] == 7:
    print("{}-{}-{}-{}=7".format(n[0],n[1],n[2],n[3]))
else:
    print("error")

Measured memory_bytes: 3188