akhauriyash/Code-Regression huggingface dataset:
class Daise:
    def __init__(self, info_list):
        self.T = info_list[0]
        self.S = info_list[1]
        self.E = info_list[2]
        self.W = info_list[3]
        self.N = info_list[4]
        self.B = info_list[5]
    
    def change(self, axis):
        if axis == 'S':
            self.T, self.B, self.S, self.N = self.N, self.S, self.T, self.B
        
        elif axis == 'E':
            self.T, self.B, self.E, self.W = self.W, self.E, self.T, self.B
        
        elif axis == 'W':
            self.T, self.B, self.W, self.E = self.E, self.W, self.T, self.B
        
        elif axis == 'N':
            self.T, self.B, self.N, self.S = self.S, self.N, self.T, self.B


if __name__ == '__main__':
    info = list(map(str, input().split()))
    axis = str(input())
    obj = Daise(info)

    for i in axis:
        obj.change(i)
    print(obj.T)


Measured memory_bytes: 5568
n = io.read("*n")
lim = math.ceil(math.sqrt(n))
for i = lim, 1, -1 do
  if i * i <= n and n % i == 0 then
    z = n // i
    r = 0
    while 0 < z do
      r, z = r + 1, z // 10
    end
    print(r)
    break
  end
end


Measured memory_bytes: 760
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=2002,mo=1e9+7;
int fac[maxn*maxn],n,k,m,inv[maxn*maxn],f[maxn][maxn];
int qpow(int a,int b)
{
	int ans=1;
	for(;b;b>>=1,a=a*a%mo)
		if(b&1)ans=ans*a%mo;
	return ans;
}
int calc(int x,int y)
{
	if(!y)return 1;
//	cout<<x<<" "<<inv[y]<<" "<<inv[x-y]<<endl;
	return fac[x]*inv[y]%mo*inv[x-y]%mo;
}
signed main()
{
	cin>>n>>k;
	if(k==1){puts("1");return 0;}
	fac[0]=1;
	for(int i=1;i<=2000*2000;i++)fac[i]=i*fac[i-1]%mo,inv[i]=qpow(fac[i],mo-2);
	inv[2000*2000]=qpow(fac[2000*2000],mo-2); 
	for(int i=2000*2000-1;i>=0;i--)inv[i]=(inv[i+1]*(i+1))%mo;
	f[0][0]=1;
	for(int i=1;i<=n;i++)
	for(int j=0;j<=i;j++)
	{
		f[i][j]=f[i-1][j];
		if(j)f[i][j]+=f[i][j-1]*calc(n*k-i-(j-1)*(k-1)-1,k-2)%mo*(n-j+1)%mo,f[i][j]%=mo;
	//	cout<<i<<" "<<j<<" "<<f[i][j]<<endl;
	}
	cout<<f[n][n];
}


Measured memory_bytes: 88752
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t  ll;
typedef uint64_t ull;

#define rep(i,n)   for (int i = 0; i < (n); i++)
#define rrep(i,n)  for (int i = (n)-1; i >= 0; i--)
#define rep1(i,n)  for (int i = 1; i <= (n); i++)
#define rrep1(i,n) for (int i = (n); i > 0; i--)

int main(void) {
    int n, k, ans=0;
    cin >> n >> k;
    rep(i,n) {
        int h;        
        cin >> h;
        if (h >= k) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a) for(int i=0;i<a;i++)
#define pb push_back
#define F first
#define S second
#define pii pair<int,int>
#define tests int t1234;cin>>t1234;for(int i1234=1;i1234<=t1234;i1234++)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
const int N=1000010;

int32_t main() {
    fastio;
    int x,y,z;cin>>x>>y>>z;
    if(x+y+z>=22)cout<<"bust"<<endl;
    else cout<<"win"<<endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{

    int A, B;   cin >> A >> B;

    if (A == B){
        cout << "Draw" << endl;
    }

    else {
        if (A == 1){
            cout << "Alice" << endl;
        }

        else if (B == 1){
            cout << "Bob" << endl;
        }

        else if (A > B && B != 1){
            cout << "Alice" << endl;
        }

        else{
            cout << "Bob" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
int main(void){
	int n,b,f,r,v,i,bj,fj,rj=0;
	int ka[4][3][10]={{{0}}};
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		ka[b-1][f-1][r-1]=ka[b-1][f-1][r-1]+v;
	}
	for(bj=0;bj<4;bj++){
		for(fj=0;fj<3;fj++){
			for(rj=0;rj<10;rj++){
				printf(" %d",ka[bj][fj][rj]);
			}
			printf("\n");
		}
		if(bj!=3)printf("####################\n");
	}
	return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll mod=1e9+7;
ll n;
ll dp[1000001][2][2];
ll func(ll ind,ll x,ll y)
{
	if(ind==n)
	{
		if(x==1 and y==1)
		return 1;
		else return 0;
	}
	if(dp[ind][x][y]!=-1) return dp[ind][x][y];
	ll ret=0;
	for(int i=0;i<=9;i++)
	{
		if(i==0)
		ret+=func(ind+1,1,y);
		else if(i==9)
		ret+=func(ind+1,x,1);
		else
		ret+=func(ind+1,x,y);
		ret%=mod;
	}
	return dp[ind][x][y]=ret;
}
int main()
{
	ll i,j,k,m,t;
	cin>>n;
	for(i=0;i<=n;i++)
	{
		for(j=0;j<2;j++)
		{
			dp[i][j][0]=dp[i][j][1]=-1;
		}
	}
	cout<<func(0,0,0);
}

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

#define ALL(container) (container).begin(), (container).end()
#define INF 1000000007
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll GCD (ll a, ll b) { return b ? GCD(b, a % b) : a; }

using namespace std;

int main()
{
    int X;
    cin >> X;
    string s = (X == 3 || X == 5 || X == 7) ? "YES" : "NO";
    cout << s;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <random>

#include <fstream>
#include <vector>
#include <algorithm>

#define ll long long int

using namespace std;

int main(void)
{
    
    char a;
    
    cin >> a;
    
    if('A' <= a && a <= 'Z')
    {
        cout << "A";
    }
    else
    {
        cout << "a";
    }
    
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	int k;
	scanf("%d",&k);
//	printf("%d %d\n",nb,nc);
	int cnt=0;
	while(b<=a) cnt++,b*=2;
	while(c<=b) cnt++,c*=2;
//	printf("%d",cnt);
	if(cnt<=k) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3752
#include<iostream>
#define N 100
using namespace std;

int main(){
  int n,a[N],mini,cnt=0;
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++){
    mini=i;
    for(int j=i;j<n;j++)
      if(a[j]<a[mini])mini=j;
    if(i!=mini){
      cnt++;
      int t=a[i];
      a[i]=a[mini];
      a[mini]=t;
    }
  }
  for(int i=0;i<n;i++){
    if(i)cout<<' ';
    cout<<a[i];
  }
  cout<<endl<<cnt<<endl;
  return 0;
}



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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

ll dp[111111];
ll inv[222];

//ａをbで割る
long long mod_div(long long a,long long b){
	long long tmp = MOD - 2,c = b,ret = 1;
	while(tmp > 0){
		if(tmp & 1){
			ret *= c;ret %= MOD;
		}
		c *= c;c %= MOD;tmp >>= 1;
	}
	return a*ret%MOD;
}

void mod_add(ll &a, ll b){
	a +=b; a%= MOD;
}

int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
	REP(i, 222)inv[i] = mod_div(1, i);

	ll n, x;cin >> n >> x;
	vector<ll> v(n);
	REP(i, n)cin >> v[i];
	sort(ALL(v));

	dp[x] = 1;
	REV(i, 100001){
		if(dp[i] == 0)continue;
		int cou = 0;
		while(cou < n && v[cou] <= i)cou++;
		if(cou == 0)continue;
		ll rate = inv[cou];
		REP(j, cou){
			mod_add(dp[i % v[j]], dp[i] * rate);
		}
		dp[i] = 0;
	}

	ll ans = 0;
	REP(i, 111111){
		mod_add(ans, dp[i] * i % MOD);
	}
	REP(i, n)ans = (ans * (i + 1)) % MOD;
	cout << ans << endl;

	return 0;
}


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

int main(){
  int n;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++){
    cin>>arr[i];
  }
  int c = 0;
  for(int i = 0;i<n;i++){
  	if(arr[i]!=i+1)
      	c++;
  }
  if(c==2 || c==0)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
D1 = [0]*N
D2 = [0]*N
for i in range(N):
    D1[i], D2[i] = map(int, input().split())

table = [False]*N
key = False

for i in range(N):
    if D1[i]==D2[i]:
        table[i] = True
    if (i>=2 and key == False):
        if (table[i]==True and table[i-1]==True and table[i-2]==True):
            key = True

if key==True:
    ans = "Yes"
else:
    ans = "No"
    
print(ans)

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;
struct edge {int from,to,cost;};

signed main() {
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)cin>>a[i];
int amax=0;for(int i=0;i<n;i++)amax=max(amax,a[i]);
int b=0;
for(int i=0;i<n;i++){
    if(a[i]==amax){
        b++;
        continue;
    }
    if(a[i]!=amax-1){
        cout<<"No";
    return 0;
    }
    
}
if(b==1){
    cout<<"No";
    return 0;
}

if(amax>(n-b)+b/2||amax<(n-b)+1){
    if(n!=b||b!=amax+1){
        cout<<"No";
        return 0;
    }
}
cout<<"Yes";
return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

class D
{
	static void Main()
	{
		var n = long.Parse(Console.ReadLine());
		Console.WriteLine(Factorize(n).Distinct().Aggregate(n, (t, p) => t / p * (p - 1)));
	}

	static long[] Factorize(long n)
	{
		var r = new List<long>();
		for (long x = 2; x * x <= n && n > 1; ++x) while (n % x == 0) { r.Add(x); n /= x; }
		if (n > 1) r.Add(n);
		return r.ToArray();
	}
}



Measured memory_bytes: 18196
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    int k;
    cin>>k>>s;
    vector<string> t(k);
 
    int n=s.size();
    
    if(n>k){
        for(int i=0;i<k;i++){
            t.at(i)=s.at(i);

        }
        t.push_back("...");
        for(int i=0;i<k+1;i++){
            cout<<t.at(i);
        }cout<<endl;
        
        
    }else{
        cout<<s;
    }
}

Measured memory_bytes: 3632
import java.io.IOException;
import java.util.Scanner;
public class Main {
    public static void main (String args[]) throws IOException {
        Scanner sc = new Scanner(System.in);
        StringBuffer sb = new StringBuffer();
        int a = Integer.parseInt(sc.nextLine());
        String x =sc.nextLine();
        String[] i =x.split(" ");
        String str = i[a-1];
        int b = a-2;
        for (int c=1;c<a;c++){
        	str=str+" "+i[b] ;
        	b = b-1;
        }
        System.out.println(str);
        }


    }

Measured memory_bytes: 26200
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N; vector<int> K;

	while (true)
	{
		scanf("%d", &N);

		if (N == 0) { break; }

		K = vector<int>(N);

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

		if (*max_element(K.begin(), K.end()) < 2)
		{
			printf("NA\n");
		}
		else
		{
			int sum = 0;

			for (int i = 0; i < N; i++)
			{
				sum += min(K[i], 1);
			}

			printf("%d\n", sum + 1);
		}
	}

	return 0;
}

Measured memory_bytes: 2788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int n,x,a,ans;
  cin>>n>>x;
  a=10000;
  ans=n;
  int p[n];
  rep(i,n){
    cin>>p[i];
    x-=p[i];
    a=min(a,p[i]);
  }
  ans+=x/a;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#!python3.8
# -*- coding: utf-8 -*-
# abc166/abc166_c
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, M = i2nn()
    H = i2nn()
    good = [1] * N
    for _ in range(M):
        A, B = map(lambda n:n-1, i2nn())
        if H[A] > H[B]:
            good[B] = 0
        elif H[A] < H[B]:
            good[A] = 0
        else:
            good[A] = good[B] = 0
    print(sum(good))
    return

main()


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

int main(){
 int w,h;
 while(1){
  cin >> h >> w;
  if(h==0&&w==0)break;
  for(int i=0;i<h;i++){
   for(int j=0;j<w;j++){
    cout << "#" ;
   }
   cout << endl;
  }
 cout << endl;
 }
 return 0;
}

Measured memory_bytes: 3072
#include<iostream>
#include<iomanip>
#define _USE_MATH_DEFINES
#include<cmath>
int main()
{
	double a, b, C;
	std::cin >> a >> b >> C;
	const double S = a * b * sin(C / 180 * M_PI) / 2;
	const double L = a + b + sqrt(a * a + b * b - 2 * a * b * cos(C / 180 * M_PI));
	const double h = 2 * S / a;
	std::cout << std::fixed << std::setprecision(10);
	std::cout << S << std::endl;
	std::cout << L << std::endl;
	std::cout << h << std::endl;
	return 0;
}


Measured memory_bytes: 3480
// https://atcoder.jp/contests/abc083/tasks/abc083_a
#include <bits/stdc++.h>
using namespace std;

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

  int Plan1 = A * N;
  int low_price;
  if (Plan1 > B)
    low_price = B;
  else
    low_price = Plan1;

  cout << low_price << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int len;
	cin>>len;
	vector<ll> vl(len+1);
	ll asdf;
	cin>>asdf;
	vl[0] = asdf;
	ll mi = 1e17;
	for(int i=1;i<len;i++)
	{
		ll a;
		cin>>a;vl[i] = a;
	}
	for(int i=0;i<len;i++)
	{
		ll ns=0,ls=0;
		for(int j=0;j<=i;j++)
			ns+=vl[j];
		for(int j=len-1;j>i;j--)
			ls+=vl[j];
		mi = min(abs(ns-ls),mi);
	}
	cout<<mi<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pp = pair<ll,ll>;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)

int main(){
	int a,b;
	while(true){
		cin >> a >> b;
		if(a == 0 && b == 0)break;
		int count = 0;
		for(int i = 1; i <= a - 2; i++){
			for(int j = i + 1; j <= a - 1; j++){
				for(int k = j + 1; k <= a; k++){
					if(i + j + k == b && i != j && j != k && i != k)count++;
				}
			}
		}
		cout << count << endl;
	}
	return 0;
} 


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

#define TIF(c,a,b) (c ? a : b)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define READ(v) std::cin >> v;
#define WRITE(v) std::cout << v;
#define USORT(a,n) sort(a, a + n);
#define LSORT(a,n) sort(a, a + n, greater<int>());

#define cin std::cin
#define cout std::cout
using ll = long long;
using ull = unsigned long long;

int main()
{
	int n, k, q;
	cin >> n >> k >> q;
	int* p = new int[n];
	FOR(i, 0, n) p[i] = k;
	int a;
	FOR(i, 0, q)
	{
		cin >> a;
		p[a-1]++;
	}
	FOR(j, 0, n) p[j] -= q;
	FOR(i, 0, n)
	{
		cout << TIF(p[i] > 0, "Yes", "No") << endl;;
	}
	return 0;
}

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

int main(){
    int k;
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2] >> k;
    sort(ALL(a));
    int ans = a[0] + a[1] + pow(2, k) * a[2];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M0D 1000000007
int main(){

    int m1,m2;
    int d1,d2;
    cin >> m1 >> d1;
    cin >> m2 >> d2;
    if(d2==1 && m2%12==(m1+1)%12) cout << "1" << endl;
    else cout << "0" <<  endl;

  return 0;
}


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

int main(){
    string S,T;
    cin>>S>>T;
    int c=0;
    for(int i=0;i<S.size();i++){
        if(S.at(i)==T.at(i)) c++;
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
/* package whatever; // don't place package name! */

import java.util.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		if(n==1){
			System.out.println("Hello World");
			
		}	
		else{
			int A=in.nextInt();
			int B=in.nextInt();
			System.out.println(A+B);
			
		}	
		
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  int k;
  cin>>k>>s;
  if(s.length()<=k){
    cout<<s;
    return 0;
  }
  else{
    cout<<s.substr(0,k)+"...";
    return 0;
  }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<(n);i++)
#define init(a,i) for(int k=0;k<(i);k++)(a)[k]=0
#define in(a,i) for(int k=0;k<(i);k++)cin>>(a)[k]
#define all(a)  (a).begin(),(a).end()
#define el(a) (a).end()-(a).begin()
#define mod 1000000007
int main(){
	ll n,k,sum=0;
	cin>>n>>k;
	for(ll i=k;i<=n+1;i++){
		sum=((sum+(i*((n-i+1)%mod))+1)%mod)%mod;
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 1000000005
#define MOD 1000000007
#define N 100005
#define M 27000
#define LOG 1000000
#define KOK 650
#define EPS 0.000000001
using namespace std;

int n,m,x,y;
int ans[N],dp[N];
vector<int> v[N];

void dfs2(int node,int ata,int up) {

	ans[node]=1ll*dp[node]*(up+1)%m;

	vector<ii> pre,suf;

	for(int i:v[node]) {

		if(i==ata) continue ;

		pre.pb({dp[i]+1,i});
		suf.pb({dp[i]+1,i});

	}

	for(int i=1;i<sz(pre);i++) {

		pre[i].st=1ll*pre[i-1].st*pre[i].st%m;

	}

	for(int i=sz(suf)-2;i>=0;i--) {

		suf[i].st=1ll*suf[i+1].st*suf[i].st%m;

	}

	for(int i=0;i<sz(pre);i++) {

		int l=(i-1>=0?pre[i-1].st:1);
		int r=(i+1<sz(suf)?suf[i+1].st:1);

		dfs2(pre[i].nd,node,(1ll*l*r%m*(up+1)%m)%m);

	}

}

void dfs(int node,int ata) {

	dp[node]=1;

	for(int i:v[node]) {

		if(i==ata) continue ;

		dfs(i,node);

		dp[node]=1ll*dp[node]*(dp[i]+1)%m;

	}

}

int main() {

	//freopen("input.txt","r",stdin);	
	
	scanf("%d %d",&n,&m);

	for(int i=1;i<n;i++) {

		scanf("%d %d",&x,&y);

		v[x].pb(y);
		v[y].pb(x);

	}

	dfs(1,0);

	dfs2(1,0,0);

	for(int i=1;i<=n;i++) printf("%d\n",ans[i]);

}


Measured memory_bytes: 23296
N = int(input())
K = [0 for i in range(N+1)]
A = list(map(int,input().rstrip().split(" ")))
ans = 1
for i in A:
    K[i] += 1
for i in range(N):
    if i != 0 and K[i] != 0 and K[i] != 2:
        ans = 0
        break
    if K[i] == 2:
        ans *= 2
        ans %= 10 ** 9 + 7
print(ans)

Measured memory_bytes: 21292
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int S = scan.nextInt();
    int h = S / 3600;
    S -= h * 3600;
    int m = S/60;
    int s = S-m*60;
    System.out.println(h + ":" + m + ":" + s);
  }
}


Measured memory_bytes: 26244
n,m = map(int,input().split())
a = []
for i in range(n):
    a0 = list(map(int,input().split()))
    a.append(a0)
l = [0 for i in range(m)]
d = []
kl = [0 for i in range(n)]
for i in range(n):
    l[a[i][0] - 1] += 1
for i in range(m):
    d.append([l[i],i])
d.sort(reverse=True)
ans = d[0][0]
for i in range(m-1):
    l[d[0][1]] = -1
    for i in range(n):
        #print(kl,l)
        if a[i][kl[i]]-1 == d[0][1]:
            while l[a[i][kl[i]]-1] < 0:
                kl[i] += 1
            l[a[i][kl[i]]-1] += 1
        #print(kl,l)
    d = []
    for i in range(m):
        if l[i] >= 0:
            d.append([l[i],i])
    d.sort(reverse=True)
    ans = min(ans,d[0][0])
print(ans)

Measured memory_bytes: 44124
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n);i++)
#define rep1(i,n) for(int i=1; i<(n); i++)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
const int INF = 1e9;
const LL LLINF = 1e16;
const int mod = 1e9+7;


int main(){
    LL n;
    cin >> n;
    vector<LL> a(5);
    rep(i,5) cin >> a[i];
    LL ans = 5;
    ans += (n-1) / *min_element(all(a));
    cout << ans << endl;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n" 

int main() {
    IOS;
    long int n;
    cin>>n;
    
    vector<long double> v(n);
    for(long int i = 0; i  <n; i++)
        cin>>v[i];
    
    double ans = 0;

    for(long int i = 0; i < n; i++)
        ans += 1/v[i];
    
    cout<<fixed<<setprecision(10)<<1/ans;

    return 0;
}


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

using namespace std;

int main()
{


        int n;
        int k;
        cin >> n >> k;
        int p[n];
        double kitaichi[n];
        for (int i = 0; i < n; ++i) {
                kitaichi[i] = 0;

                cin >> p[i];
                for (int j = 0; j < p[i]; ++j) {
                        kitaichi[i] += j+1;
                }
                kitaichi[i] /= p[i];
        }
        double sum = 0;
        double sum_max = 0;
        double pre_sum = 0;

        for (int i = 0; i < n-k+1; ++i) {

                if (i == 0) {
                        for (int j = 0; j < k; ++j) {
                                sum += kitaichi[i+j];
                        }
                }
                else {
                        sum = pre_sum - kitaichi[i-1];
                        sum += kitaichi[i+k-1];
                }
                pre_sum = sum;
                if (sum_max == 0) {
                        sum_max = sum;
                }
                else if (sum_max < sum) {
                        sum_max = sum;
                }


        }

        cout << std::setprecision(10) << fixed << sum_max << endl;



}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#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 mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> 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<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-9;
const int inf=1e8;
int main(){
	int n;
	while(cin>>n,n){
		vvi in(5,vi(n));
		rep(i,n)rep(j,5)cin>>in[j][n-1-i];
		int out=0;
		while(1){
			bool h=false;
			rep(i,in[2].size()){
				int l=2,r=2;
				while(l>=0&&in[l].size()>=i&&in[l][i]==in[2][i])l--;
				while(r< 5&&in[r].size()>=i&&in[r][i]==in[2][i])r++;
				if(r-l-1<3)continue;
				out+=(r-l-1)*in[2][i];
				h=true;
				loop(j,l+1,r)in[j][i]=inf;
			}
			rep(i,5)rep(j,in[i].size())if(in[i][j]==inf){
				in[i].erase(in[i].begin()+j);
				j--;
			}
//		rep(i,5){rep(j,in[i].size())cout<<" "<<in[i][j];cout<<endl;}
			if(!h)break;
		}
		cout<<out<<endl;
	}
}

Measured memory_bytes: 3084
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	try {
    		final int N = sc.nextInt();
    		int [] d = new int[N];
    		for (int i =0; i<N; i++) {
    			d[i] = sc.nextInt();
    		}
    		int sum = 0;

    		for (int i=0; i<N-1; i++) {
    			for (int j=i+1; j<N; j++) {
    				sum += d[i] * d[j];
    			}
    		}

    		System.out.println(sum);

    	} finally {
    		sc.close();
    	}
    }
}



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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  ll N, C; scanf("%lld %lld", &N, &C);
  vector<ll> X(N), V(N);
  for (int i = 0; i < N; ++i) {
    scanf("%lld %lld", &X[i], &V[i]);
  }
  vector<ll> C1(N, 0LL), C2(N, 0LL);
  vector<ll> bestC1(N, 0LL), bestC2(N, 0LL);
  C1[0] = V[0] - X[0];
  bestC1[0] = max(0LL, C1[0]);
  for (int i = 1; i < N; ++i) {
    C1[i] = C1[i - 1] - (X[i] - X[i - 1]) + V[i];
    bestC1[i] = max(bestC1[i - 1], C1[i]);
  }

  C2[N - 1] = V[N - 1] - (C - X[N - 1]);
  bestC2[N - 1] = max(0LL, C2[N - 1]);
  for (int i = N - 2; i >= 0; --i) {
    C2[i] = C2[i + 1] - (X[i + 1] - X[i]) + V[i];
    bestC2[i] = max(bestC2[i + 1], C2[i]);
  }
  // fprintf(stderr, "DEBUG: C1=");
  // copy(C1.begin(), C1.end(), ostream_iterator<int>(cerr, ", "));
  // fprintf(stderr, "\n");
  // fprintf(stderr, "DEBUG: bestC1=");
  // copy(bestC1.begin(), bestC1.end(), ostream_iterator<int>(cerr, ", "));
  // fprintf(stderr, "\n");
  ll ans = max(bestC1[N - 1], bestC2[0]);
  // clockwise => counter clockwise
  for (int i = 0; i < N - 1; ++i) {
    ll val = C1[i] - X[i] + bestC2[i + 1];
    ans = max(ans, val);
  }
  // counter clockwise => clockwise
  for (int i = N - 1; i > 0; --i) {
    ll val = C2[i] - (C - X[i]) + bestC1[i - 1];
    ans = max(ans, val);
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 4992
import string

def resolve():
    N = int(input())
    tmp = N
    name = ""
    # 10^15 < 26^13
    for i in range(13):
        div, mod = divmod(tmp - 1, 26)
        name = string.ascii_lowercase[mod] + name
        if div == 0:
            print(name)
            return
        tmp = div

resolve()

Measured memory_bytes: 9992
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
int n;
int x[400000],y[400000];
signed main(){
    cin>>n;
    rep(i,n){
        cin>>x[i];
        y[i]=x[i];
    }
    sort(x,x+n);
    int b=x[n/2];
    rep(i,n){
        if(y[i]>=b)cout<<x[n/2-1]<<endl;
        else cout<<b<<endl;
    }
    return 0;
}



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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

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

  string s;
  cin >> s;
  ll wa = 0;
  for (auto c : s) {
    wa += c - '0';
    wa %= 9;
  }

  cout << ((wa == 0) ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3784
def is_prime(x):
    if x < 2:
        return False
    i = 2
    while i * i <= x:
        if x % i == 0:
            return False
        i += 1
    return True


upper = 55555
count = {i: [] for i in range(5)}

for i in range(2, upper + 1):
    if is_prime(i):
        count[i % 5].append(i)

N = int(input())

ans = count[1][:N]
print(' '.join([str(a) for a in ans]))

Measured memory_bytes: 40684
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
using namespace std;
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int rb[2] = {0,0};//R,L
    for(int i = 0;i<n;i++){
        if(s[i] == 'R'){
            rb[0]++;
        }
        else{
            rb[1]++;
        }
    }
    if(rb[0] > rb[1]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

int main(){
    int n; cin >> n;
    string s; cin >> s;
    ll r = 0, g = 0, b = 0;

    rep(i, n) {
        char c = s[i];
        if(c == 'R') r++;
        else if(c == 'G') g++;
        else if(c == 'B') b++;
    }

    ll ex = 0;
    roop(i, 1, n-1){
        roop(j, 1, i+1){
            char a = s[i - j];
            char b = s[i];
            char c = s[i + j];
            if(a == 'R' && b == 'G' && c == 'B') ex++;
            else if(a == 'R' && b == 'B' && c == 'G') ex++;
            else if(a == 'B' && b == 'R' && c == 'G') ex++;
            else if(a == 'B' && b == 'G' && c == 'R') ex++;
            else if(a == 'G' && b == 'R' && c == 'B') ex++;
            else if(a == 'G' && b == 'B' && c == 'R') ex++;
        }
    }

    ll ans = r*g*b - ex;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    int a, b;
    cin >> a >> b;
    cout << (a+b+1)/2;
}


Measured memory_bytes: 256
import java.util.*; 
import java.lang.*; 

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		int K = scan.nextInt();
                int A = scan.nextInt();
                int B = scan.nextInt();
                
                for(int i=A; i<=B; i++){
                    if(i%K==0){
                         System.out.println("OK");
                         System.exit(0);
                    }
                    else{
                        continue;
                    }
                }
                System.out.println("NG"); 
	}
}

Measured memory_bytes: 35916
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
#define VMAX 100000
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INFTY (1<<30)

vector< pair<int, int> > adj[VMAX];
int n;
int color[VMAX], d[VMAX];

void bfs(int num) {
    queue<int> Q;

    for (int i=0; i<n; i++) {
        color[i] = WHITE;
        d[i] = 0;
    }

    int v, u = num;
    Q.push(u);
    
    while(!Q.empty()) {
        u = Q.front();
        Q.pop();
        color[u] = BLACK;

        for (int i=0; i<adj[u].size(); i++) {
            v = adj[u][i].first;
            if (color[v]==WHITE) {
                color[v] = GRAY;
                Q.push(v);
                d[v] = max(d[v], d[u] + adj[u][i].second);
            }
        }
        color[u] = BLACK;
    }
}

void tree_diameter() {
    int maxd, index;

    maxd = 0;
    bfs(0);

    for (int i=0; i<n; i++) {
        if (maxd < d[i]) {
            maxd = d[i];
            index = i;
        }
    }

    maxd = 0;
    bfs(index);

    for (int i=0; i<n; i++) {
        if (maxd < d[i]) {
            maxd = d[i];
            index = i;
        }
    }

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

}

int main() {
    int s, t, w;

    scanf("%d", &n);

    for (int i=0; i<n-1; i++) {
        scanf("%d %d %d", &s, &t, &w);
        adj[s].push_back(make_pair(t, w));
        adj[t].push_back(make_pair(s, w));
    }

    tree_diameter();

    return 0;
}


Measured memory_bytes: 9816
#include<bits/stdc++.h>
using namespace std;
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vec             vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define inf             1e18
#define no_of_test(x)        int x; cin>>x; while(x--)
const int mod = 1e9 + 7;
int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//	no_of_test(x)
	{
		int n;
		cin>>n;
		int a[n];
		for(int i=0;i<n;i++)
		{
			cin>>a[i];
		}	
		int pre[n+1];
		pre[n]=0;
		for(int i=n-1;i>=0;i--)
		{
			pre[i]=((pre[i+1]+a[i])%mod);
		}
		int sum=0;
		for(int i=0;i<n;i++)
		{
			sum=sum%mod+(((a[i]%mod)*(pre[i+1] %mod))%mod);
		}
		cout<<sum<<'\n';
	}
	return 0;
}

Measured memory_bytes: 6756
s = input()
q = int(input())

f1 = 1
f2 = 2

st = ""
se = ""

for _ in range(q):
    q = input().split()
    if int(q[0]) == 1:
        f1,f2 = f2,f1
    elif int(q[0]) == 2:
            if int(q[1]) == f1:
                st = q[2] + st
            elif int(q[1]) == f2:
                se += q[2]

ans = st + s + se
if f1 == 1:
    print(ans)
else:
    ans = list(ans)
    ans.reverse()
    ans = "".join(ans)
    print(ans)

Measured memory_bytes: 11840
import java.util.Scanner;


public class Main {
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		
		String sign;
		if(a < b)
			sign = "<";
		else if(a > b)
			sign = ">";
		else {
			sign = "==";
		}
		
		System.out.println("a "+sign+" b");
	}
}

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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int li, ri;
    cin >> li >> ri;
    int x = ri - li + 1;
    sum += x;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
//#define int long long

using namespace std;

signed main() {
  IOS;
  int N,i=0;
  cin >> N;
  int ans=N;
  string S;
  cin >> S;

  int wh[N], bl[N];
  wh[0] = S[0] == '#' ? 1 : 0;
  for (i = 1; i < N; i++) {
    if (S[i] == '#') {
      wh[i] = wh[i-1] + 1;
    } else {
      wh[i] = wh[i-1];
    }
  }

  ans = wh[N-1];
  bl[N-1] = S[N-1] == '.' ? 1 : 0;
  ans = min(ans, wh[N-2]+bl[N-1]);
  for (i = N-2; i >= 0; i--) {
    if (S[i] == '.')
      bl[i] = bl[i+1] + 1;
    else
      bl[i] = bl[i+1];
    if (i > 0)
      ans = min(ans, wh[i-1]+bl[i]);
  }
  ans = min(ans, bl[0]);

//  for (int k: wh) {
//    cout << setw(2) << k << " ";
//  }
//  cout <<endl;
//  for (int k: bl) {
//    cout << setw(2) << k << " ";
//  }
//  cout <<endl;

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2196
#include <stdio.h>
#include <algorithm>

using namespace std;

int x[100005], n;
long long ans = 0, a, b;

int main() {
    scanf("%d %lld %lld", &n, &a, &b);
    for(int i=0; i<n; i++) {
        scanf("%d", &x[i]);
    }
    for(int i=1; i<n; i++) {
        long long s = x[i-1], e = x[i];
        ans += min((e-s) * a, b);
    }
    printf("%lld\n", ans);
//    system("pause");
    return 0; 
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <queue>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
struct point {
	int h, w,s;
	point(int _h, int _w,int _s) {
		h = _h, w = _w,s = _s;
	}
};
void  GridRepainting() {

	int H, W;
	cin >> H >> W;
	char t[51][51];
	int b = 0;
	for (size_t i = 0; i < H; i++)
	{
		for (size_t j= 0; j < W; j++) 
		{
			cin >> t[i][j];
			if (t[i][j] == '#') b++;
		}
	}

	queue<point> q;
	q.push(point(0, 0, 1));
	const int INF = 100000;
	int dp[51][51];
	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; j++) dp[i][j] = INF;
	int nx[4] = { 0,1,0,-1 };
	int ny[4] = { 1,0,-1,0 };

	while (!q.empty())
	{
		point p = q.front(); q.pop();
		if (dp[p.h][p.w] <= p.s) continue;
		dp[p.h][p.w] = p.s;
		for (size_t i = 0; i < 4; i++)
		{
			int nex = p.h + nx[i];
			int ney = p.w + ny[i];
			if (nex < 0 || nex >= H || ney < 0 || ney >= W) continue;
			if (t[nex][ney] == '#') continue;
			q.push(point(nex, ney, p.s + 1));
		}
 	}
	if (dp[H - 1][W - 1] == INF) {
		cout << -1 << endl;
	}
	else {
		cout << (H * W - dp[H - 1][W - 1] - b) << endl;
	}
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// const long long MAX = 510000;

// long long fac[MAX], finv[MAX], inv[MAX];

// // テーブルを作る前処理
// void COMinit() {
//     fac[0] = fac[1] = 1;
//     finv[0] = finv[1] = 1;
//     inv[1] = 1;
//     for (int i = 2; i < MAX; 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(ll 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;
// }

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


int main () {

    ll n;
    int a,b;
    cin>>n>>a>>b;

    // COMinit();

    ll c=1,d=1,e=1,f=1;
    rep(i,a) {
        c=c*(n-i)%MOD;
        d=d*(i+1)%MOD;
    }
    rep(i,b) {
        e=e*(n-i)%MOD;
        f=f*(i+1)%MOD;
    }
    // c=(c/d)%MOD;

    ll aa = (c*modinv(d,MOD)%MOD);
    
    ll ans = modpow(2,n,1000000007)-1-(c*modinv(d,MOD)%MOD)-(e*modinv(f,MOD)%MOD);
    while (ans<0) {
        ans+=MOD;
    }
    cout<<ans<<endl;
    // cout<<modpow(2,n,1000000007)<<endl;
    // cout<<c*modinv(d,MOD)%MOD<<endl;
    // cout<<(modpow(2,n,1000000007)-1-COM(n,a)-COM(n,b))%MOD<<endl;

}

Measured memory_bytes: 256
// AOJ 2960 Four Tea
// 2019.8.8 bal4u

#include <stdio.h>
#include <string.h>

#define MAX 505
#define INF 10000000
int p[5], t[5];
int dp[MAX];

int main()
{
	int i, j, k, N, a, ma, ans;
	
	scanf("%d", &N);
	for (i = 1; i <= 4; i++) scanf("%d", p+i);
	for (i = 1; i <= 4; i++) scanf("%d", t+i);
	for (i = 1; i < MAX; i++) dp[i] = INF;
	dp[0] = 0, ma = 0;
	for (i = 1; i <= 4; i++) {
		for (j = N-1; j >= 0; j--) if (dp[j] < INF) {
			k = 1; while (1) {
				if (dp[j+k*t[i]] > dp[j]+k*p[i]) dp[j+k*t[i]] = dp[j]+k*p[i];
				if ((a = j+ k++ *t[i]) >= N) {
					if (a > ma) ma = a;
					break;
				}
			}
		}
	}
	ans = INF;
	for (i = N; i <= ma; i++) if (dp[i] < ans) ans = dp[i];
	printf("%d\n", ans);
	return 0;
}


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

int main(){
  
 int N, count = 1;
 cin >> N;
  vector<int>H(N);

 for(int i = 0; i < N; i++){
  cin >> H.at(i); 
 }

 for(int i = 1; i < N; i++){
 
   for(int x = 0; x < i ; x++){
    
     if(H.at(x) > H.at(i)){
     break;
    }else if(x + 1 == i){
     count++;
     }
   
   }
	
 
 }
 
  cout << count << endl;
  
 }

Measured memory_bytes: 256
S = input()
T = input()
t = len(T)
min = 10**3+1
for i in range(len(S)-t+1) :
    count = 0
    Si = S[i:t+i]
    for j in range(t) :
        if Si[j] != T[j] :
            count += 1
    if count < min :
        min = count


print(min)

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

using namespace std;

long long n, k, p[5004], c[5004], ans;
long long score[5004], score1[5004];

void cycle(int start){
    int cur = p[start], len = 1;
    score[1] = c[cur];
    score1[1] = max(-1ll*1000000000000, score[1]);
    while(cur != start){
        cur = p[cur], len++;
        score[len] = score[len-1] + c[cur];
        score1[len] = max(score[len], score1[len-1]);
    }
 
    long long s = 0;
    if(k > len){
        long long d = k/len;
        ans = max(d * score[len] + score1[k%len], ans);
        if (d > 1) ans = max(ans, (d-1)*score[len] + score1[len]);
        ans = max(ans, score1[len]);
    }
    else{
        ans = max(ans, score1[k]);
    }
}

void solve(){
    cin>>n>>k;
    ans = -1000000000000;
    for(int i = 1; i <= n; i++) cin>>p[i];
    for(int i = 1; i <= n; i++) cin>>c[i];
    for(int i = 1; i <= n; i++) cycle(i);
    cout<<ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TC;
    //cin>>TC;
    TC=1;
    while(TC--){
        solve();
    }
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
int a[MAXN], b[MAXN];
vector<int> cifre;
bool ok(int x, int pos){
    bool ret = true;
    for(int i = 29; i >= 0; i--){
        int kbit = cifre[i];
        int xbit = (x >> i) & 1;
        if(i > pos){
            if(xbit > kbit) ret = false;
        } else if(i == pos){
            if(xbit >= kbit) ret = false;
        }
    }
    return ret;
}
int main(){
    int n, k;
    scanf("%d %d", &n, &k);
    for(int i = 1; i <= n; i++){
        scanf("%d %d", &a[i], &b[i]);
    }
    int K = k;
    while(K){
        cifre.push_back(K % 2);
        K /= 2;
    }
    while(cifre.size() < 30) cifre.push_back(0);

    long long best = 0ll;
    for(int pos = -1; pos < 30; pos++){
        long long cur = 0ll;
        for(int i = 1; i <= n; i++){
            if(ok(a[i], pos)) cur += b[i];
        }
        best = max(best, cur);
    }
    printf("%lld\n", best);
    return 0;
}


Measured memory_bytes: 1024
import math
a, b, x = map(int, input().split())

v = a * b / 2
if v * a >= x:
  h = x / v
  theta = math.degrees(math.atan2(h, b))
  ans = 90-theta
else:
  k = 2 * x / a / a - b
  theta = math.degrees(math.atan2(a, (b-k)))
  ans = 90 - theta
  
print(ans)

Measured memory_bytes: 38256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define mid (low+high)/2
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 300004
#define INF 1e9+7

using namespace std;

ll k,a,b;

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

    cin >> k >> a >> b;

    if(b-a+1 >= k)
    {
        cout << "OK\n";
    }
    else if(a%k > b%k || a%k == 0)
    {
        cout << "OK\n";
    }
    else
        cout << "NG\n";

    return 0;
}



Measured memory_bytes: 3636
#include <vector>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>


using namespace std;


int main(void){

  string S;
  int index;

  cin >> S ;

  vector<string> str= {"SUN","MON","TUE","WED","THU","FRI","SAT"};

  for(int i = 0; i < str.size() ; i++){
    if(str.at(i) == S){
      index = i;
      break;
    }
  }

  cout << 7-index << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

class Node():

	def __init__(self,id,k,children):
		
		self.id = id
		self.k = k
		self.children = children
		self.parent = -1
		self.depth = 0

def find_root(Nodes,node):

	if node.parent == -1:
		return node.id

	return find_root(Nodes,Nodes[node.parent])

def define_depth(Nodes,node):

	if node.k == 0: #leaf
		return True

	for child in node.children: #internal node
		Nodes[child].depth = node.depth + 1
		define_depth(Nodes,Nodes[child])

def sort(Nodes):

	for i in range(len(Nodes)-1):
		for j in range(i+1,len(Nodes)):

			if Nodes[i].id > Nodes[j].id:

				Nodes[i],Nodes[j] = Nodes[j],Nodes[i]

def test():

	n = int(sys.stdin.readline())
	child = []
	Nodes = [Node(0,0,child)] * n
	root = 0

	# Reading inputs
	for i in range(n):

		inputs = list(map(int,sys.stdin.readline().split()))
		id = inputs[0]
		k = inputs[1]
		child = []
		for j in range(k):
			child.append(inputs[2+j])

		tmp_node = Node(id,k,child)
		Nodes[id] = tmp_node

	#sort(Nodes)

	# Add "parent" attribute
	for node in Nodes:

		for i in range(node.k):
			
			Nodes[node.children[i]].parent = node.id
	
	# Find "root"
	root = find_root(Nodes,Nodes[0])

	#print(root)

	# Define depth from root
	define_depth(Nodes,Nodes[root])

	for i in range(n):

		print(f"node {Nodes[i].id}: parent = {Nodes[i].parent}, depth = {Nodes[i].depth}, ",end='')

		if Nodes[i].parent == -1:
			print(f"root, [",end='')
		elif Nodes[i].k == 0:
			print(f"leaf, [",end='')
		else:
			print(f"internal node, [",end='')

		for j in range(Nodes[i].k - 1):
			print(f"{Nodes[i].children[j]}, ",end='')
		if Nodes[i].k != 0:
			print(f"{Nodes[i].children[Nodes[i].k-1]}]")
		else:
			print("]")


if __name__ == "__main__":
	test()



Measured memory_bytes: 37148
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
//
#define int long long
#define ALL(x) (x).begin(), (x).end()
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))
// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((a) >> (b)) & 1
#define bitcount(a) __builtin_popcountll((a))
//
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;
//
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
//
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

struct edge {
  int cost, to;
};

int N;

vector<edge> G[101010];
int d[101010];
bool used[101010];

void rec(int n) {
  used[n] = true;
  for (int i = 0; i < G[n].size(); i++) {
    edge e = G[n][i];
    if (used[e.to]) {
      continue;
    }
    d[e.to] = d[n] + e.cost;
    rec(e.to);
  }
}

signed main() {
  int N;
  cin >> N;
  for (int i = 1; i < N; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    G[a].push_back(edge{c, b});
    G[b].push_back(edge{c, a});
  }

  int Q, K;
  cin >> Q >> K;
  K--;

  m0(d);
  m0(used);

  rec(K);

  for (int i = 0; i < Q; i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    cout << d[x] + d[y] << endl;
  }

  return 0;
}


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

int p(int i,vector<int>& P) {
  if(P[i] == i)return P[i];
  else return P[i] = p(P[i],P);
}

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> P(N);
  int i;
  for(i=0;i<N;i++)P[i] = i;
  int a,b;
  for(i=0;i<M;i++) {
    cin >> a >> b;
    P[a] = p(a,P);
    P[b] = p(b,P);
    P[P[b]] = P[a];
  }
  for(i=0;i<N;i++)P[i] = p(i,P);
  vector<int> cnt(N,0);
  for(i=0;i<N;i++)cnt[P[i]]++;
  int ans = 0;
  for(i=0;i<N;i++)ans = max(ans,cnt[i]);
  cout << ans << endl;
}

Measured memory_bytes: 5788
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){

    for(int R, N; cin >> R >> N, R;){
        map<int, int>H;
        for(int i = 0; i < N; i++){
            int l, r, h;
            cin >> l >> r >> h;
            for(int x = l; x < r; x++){
                H[x] = max(H[x], h);
            }
        }
        double ans = 1234567;
        for(int X = -R; X < R; X++){
            int x = X;
            if(X < 0)x++;
            double bottom = R - sqrt(R * R - x * x);
            ans = min(ans, H[X] + bottom);
        }
        printf("%.9f\n", ans);
    }

    return 0;
}


Measured memory_bytes: 3116