akhauriyash/Code-Regression huggingface dataset:
n, a, b = map(int ,input().split())
mod = 1000000007
def inv(k):
    return pow(k, mod - 2, mod)

def comb(n, k):
    bunshi = 1
    bunbo = 1
    for i in range(k):
        bunshi = bunshi * (n - i) % mod
        bunbo = bunbo * (i + 1) % mod
    return bunshi * inv(bunbo) % mod


all_num = pow(2, n, mod)

ans = all_num - 1 - comb(n, a) - comb(n, b)
print(ans % mod)

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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             1e9
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);

const int N = 200005;
int p1[N],p2[N],p3[N],seg[N];

int find(int r,int p[])
{
    if(p[r] == r)return r;
    else return p[r] = find(p[r],p);
}
int n , k, l;

int main()
{
    cin >> n >> k >> l;
    for(int i = 1;i <= n;i++)p1[i] = p2[i] = p3[i] = i,seg[i] = 1;

    vector<pair<int,int>>vec;
    for(int i = 1;i <= k;i++){
        int a,b;
        cin >> a >> b;
        vec.push_back(mk(a,b));
        int u = find(a,p1);
        int v = find(b,p1);
        if(u == v)continue;
        p1[v] = u;
    }

    for(int i = 1;i <= l;i++){
        int a,b;
        cin >> a >> b;
        vec.push_back(mk(a,b));
        int u = find(a,p2);
        int v = find(b,p2);
        if(u == v)continue;
        p2[v] = u;
    }
    map<pair<int,int>,int>mp;
    for(int i = 1;i <= n;i++)mp[mk(find(i,p1),find(i,p2))]++;
    for(int i = 1;i <= n;i++)cout << mp[mk(find(i,p1),find(i,p2))] << " ";

}


Measured memory_bytes: 16624
import sys
input = sys.stdin.readline

def main():
    N = int(input())

    mark_to_num = {"S":0, "H":1, "C":2, "D":3}
    num_to_mark = {0:"S", 1:"H", 2:"C", 3:"D"}

    check = [[False for i in range(13)] for j in range(4)]
    
    for i in range(N):
        mark, num = input().split()
        check[mark_to_num[mark]][int(num)-1] = True
    # print(check)
    for i in range(4):
        for j in range(13):
            if not check[i][j]:
                print(num_to_mark[i], j+1)




if __name__ == "__main__":
    main()


Measured memory_bytes: 5616
//       Author: Mostafa Mounir Shehab
 
#include <bits/stdc++.h>
using namespace std;
 
#define PI  acos(-1)
#define EPS (1e-10)
#define endl "\n"
#define SZ(v) (int)(v.size())
#define IO ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL), cerr.tie(NULL);
typedef long long ll;
typedef long double ld;
 

 
ll MOD=1e9 + 7;
ll OO=1e9 + 10;
const int N=1e4 + 5,M=1e2 + 5;

ll dp[N][M][2];



int n,m,k,cnt,SU,idx,len,MN,MX,T;
int l,r,mid;
int a,b,c;
string str;

ll Solve(int idx,int sum,bool flage){
	sum%=k;
	if(idx == SZ(str))
		return !sum;
	
	ll &ret = dp[idx][sum][flage];
	if(~ret)
		return ret;
	ret = 0;
	
	int en = flage ? str[idx]-'0' : 9;
	for(int i=0;i<=en;++i)
		ret+=Solve(idx+1,sum+i,flage&(i == str[idx]-'0'));
		
	
	return ret = ret%MOD;
}


int main(){
	
	IO
	memset(dp,-1,sizeof dp);
	
	cin>>str>>k;
	
	
	cout<<(Solve(0,0,true)-1+MOD)%MOD<<endl;

	
}


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

public class Main {

    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        int [] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = cin.nextInt();
        }
        Arrays.sort(a);
        final int ai = a[n - 1];
        final int aj = Arrays.stream(a, 0, n - 1)
                             .mapToObj(x -> new int[] {x, (int) Math.round(Math.abs(ai / 2.0 - x))})
                             .min((p1, p2) -> p1[1] - p2[1])
                             .map(p -> p[0])
                             .orElse(-1);


        System.out.printf("%d %d\n", ai, aj);
    }
}


Measured memory_bytes: 52252
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

int main(){
    double tmp[20][2];
    int cnt=0;
    int n;
    for (;;) {
        scanf("%d",&n);
        if (n==-1) break;
        double ans=1.0*n/2.0;
        while (abs(ans*ans*ans-n)>=0.00001*n) ans-=(ans*ans*ans-n)/(3*ans*ans);
        printf("%.8lf\n",ans);
    }
    return 0;
}

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

signed main() {
  string s;
  cin >> s;
  
  if( s == "Sunny" ) cout << "Cloudy" << endl;
  else if( s == "Cloudy" ) cout << "Rainy" << endl;
  else cout << "Sunny" << endl;
  
}

Measured memory_bytes: 256
function main(input){
  const i=input.split(' ');
  const a=parseInt(i[0],10);
  const b=parseInt(i[1],10);
  if((a*b)%2==0){
      console.log('Even');
  } else{
      console.log('Odd');
  }
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
  int N, K;
  cin >> N >> K;
  map<int, int> as;
  int a;
  for(int i = 0; i < N; ++i) {
    cin >> a;
    as[a]++;
  }
  vector<int> ass;
  for(auto a : as) {
    ass.push_back(a.second);
  }
  sort(ass.begin(), ass.end());
  int ans = 0;
  if(ass.size() > K) {
    for(int i = 0; i < ass.size() - K; ++i) {
      ans += ass[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 10748
import math
a, b, C = list(map(int, input().split(' ')))
c = math.sqrt(a**2 + b**2)
PI = math.acos(-1)
rad = C * PI / 180
h = b * math.sin(rad)
S = 1/2*a*h
L = a + b + math.sqrt(a**2 + b**2 - 2*a*b * math.cos(rad))
print("{0:.8f}".format(S))
print("{0:.8f}".format(L))
print("{0:.8f}".format(h))


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

int main()
{
	int n,m;
	int i,j;
	char bef[100],aft[100];
	char tar[100001];
	char out[100001];
	while(scanf("%d",&n)!=EOF)
	{
		if(n==0)break;
		for(i=0;i<n;i++)scanf(" %c %c",&bef[i],&aft[i]);
		scanf(" %d",&m);
		for(i=0;i<m;i++)
		{
			scanf(" %c",&tar[i]);
			for(j=0;j<n;j++)
			{
				if(tar[i]==bef[j])
				{
					tar[i]=aft[j];
					break;
				}
				
			}
		}
		for(i=0;i<m;i++)printf("%c",tar[i]);
		printf("\n");
	}
	return 0;
}

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

using namespace std;

int main(){

	int high[10];
	vector<int> higher;
	for(int i=0;i<10;i++){
		cin >> high[i];
	}

	for(int i=0;i<10;i++){
		higher.push_back(high[i]);
	}

	sort(higher.begin(),higher.end());

	for (int i=0;i<3;i++){
		cout << higher[9-i] << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(ll 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
#define inf 2147483647
#define range(x,a,b) (a)<=x&&x<=(b)
int main(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll M=max(a*c,b*d);
	if(M<0)M=max(a*d,b*c);
	cout<<M;
	return 0;
}

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

using namespace std;
  vector<long long int> DP;
  vector<int> h;
long long int DP_function(int i){
	if(DP[i] == -1)
		DP[i] = min(abs(h[i + 2] - h[i]) + DP_function(i + 2), abs(h[i + 1] - h[i]) + DP_function(i + 1));

	return DP[i];
}

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

	 h.resize(N);
	for(int index = 0; index < N; index++)
		cin >> h[index];

	 DP.resize(N, -1);
	DP[N - 1] = 0;
	DP[N - 2] = abs(h[N - 1] - h[N - 2]);
	cout << DP_function(0);

	return 0;
}


Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define foreach(i,a) for(auto &i:a)
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d!=0&&d>0?i<n:i>n;i+=d)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}

void solve(){
  ll Q; cin>>Q;
  ll cnt,a,B; cin>>cnt>>a>>B;
  multiset<ll> se;
  auto itl=se.insert(a);
  auto itr=itl;

  ll score=0;
  rep(_,Q-1){
    ll k; cin>>k;
    if(k==1){
      ll a,b; cin>>a>>b;
      se.insert(a);
      B+=b;
      if(cnt){
        if(a<*itl){
          score+=*itl-a;
          itl--;
        }else{
          score+=a-*itr;
          itr++;
        }
      }else{
        if(a<*itl){
          score+=*itl-a;
          itr--;
        }else if((*itl<=a)&&(a<*itr)){
          itl++; itr--;
        }else{
          score+=a-*itr;
          itl++;
        }
      }
      cnt^=1;
    }else{
      cout<<*itl<<' '<<score+B<<endl;
    }
  }
}

Measured memory_bytes: 9600
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

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

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N,M;
  cin>>N>>M;
  vector<ll> a(M),b(M),c(M,0);
  REP(i,M){
    cin>>a[i]>>b[i];
    REP(j,b[i]){
      int t;
      cin>>t;t--;
      c[i]+=(1<<t);
    }
  }
  vector<vector<ll>> dp(M+1, vector<ll>(1<<N, INFLL));
  dp[0][0]=0;

  REP(i,M){
    REP(j,1<<N){
      chmin(dp[i+1][j],dp[i][j]);
      int nj=j|c[i];
      chmin(dp[i+1][nj],dp[i][j]+a[i]);
    }
  }
  ll ans=dp[M][(1<<N)-1];
  if(ans==INFLL){
    cout<<-1<<endl;
  }else{
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 32384
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}


void solve() {
   int n;
   cin >> n;
   int ans = 0;
   bool flag  = true;
   for(int i = 1;i <= n;i++){
       if(i == 10)flag = false;
       if(i == 100) flag = true;
       if(i  == 1000) flag = false;
       if(i == 10000) flag = true;
       if(i == 100000) flag = false;
       if(flag) ans++;
   }
   cout << ans << endl;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int h, w;
    cin >> h >> w;
    int mp[55][55] = {};
    for(int i = 1; i <= h; ++i) {
        for(int j = 1; j <= w; ++j) {
            char c;
            cin >> c;
            if(c == '#') mp[i][j] = 1;
        }
    }

    for(int i = 1; i <= h; ++i) {
        for(int j = 1; j <= w; ++j) {
            if(mp[i][j] == 1) cout << '#';
            else {
                cout << mp[i - 1][j - 1] + mp[i - 1][j] + mp[i - 1][j + 1] + mp[i][j - 1] + mp[i][j + 1] + mp[i + 1][j - 1] + mp[i + 1][j] + mp[i + 1][j + 1];
            }
        }
        cout << endl;
    }
    return 0;
}



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

const int maxn=10000000+5;
long long arr[10005];
int n;
int main()
{
    //freopen("1137_1.in","r",stdin);//设置 cin scanf 这些输入流都从 test.in中读取
    //freopen("1137_1.out","w",stdout);
    // freopen("1137_5.in","w",stdout);
    cin>>n;
    for(int i=0;i<n;++i)
       cin>>arr[i];
    unsigned long long ans=0;
    for(int i=0;i<n;++i)
    {

        while(arr[i]%2==0)
        {
            //cout<<" fr"<<endl;
            arr[i]/=2;
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
typedef pair<int,int> pii;
typedef pair <long long,long long> pll;
typedef long long ll; 
typedef long double ld; 
const ll mod = 1e9+7;

ll dp[10001][101][2];
ll solve( string & k, int& D, int pos , int d , bool tight)
{	if(dp[pos][d][tight] != -1)
		return dp[pos][d][tight];
		
	int ub = (tight) ? (k[pos]-'0') : 9 ;
	if(pos == k.length() - 1){
		ll ans = 0;
		for(int x = 0; x <= ub ; x++)
			if(x%D == d)
				ans++;
		return ans;
	}
	else{
	ll ans = 0;
	for(int x = 0; x <= ub; x++)
		ans = (ans + solve( k , D, pos+1, (D + d - x%D)%D , tight&&(x == ub)))%mod;
	return dp[pos][d][tight] = ans;
	}
} 
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	int d;
	string k;
	cin >> k >> d;
	memset(dp, -1, sizeof(dp));
	cout << (mod+solve(k, d, 0, 0, 1)-1)%mod;
	return 0;
}


Measured memory_bytes: 20320
# -*- coding: utf-8 -*

# 整数の入力
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if w > v and a != b:
    print("NO")
    exit(0)

s = abs(a - b)
r_v = abs(v - w)

if r_v == 0:
    print("NO")
    exit(0)

if (s / r_v <= t):
    print("YES")
else:
    print("NO")

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

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 200005
#define MOD 1000
#define oo 1000000000000000007LL
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int n, a[maxN];

int main () {
    scanf("%d", &n);
    fto(i, 1, n) scanf("%d", &a[i]);

    ll ans = 0;
    fdto(i, n, 1) {
        if (a[i] >= i || (i < n && a[i] < a[i+1]-1)) {
            puts("-1");
            return 0;
        }

        if (i == n || a[i] != a[i+1]-1) ans += a[i];
    }

    cout << ans;

    return 0;
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    int ans;
    if (c - (a - b) < 0) {
        ans = 0;
    } else {
        ans = c - (a - b);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from sys import stdin, stdout
from collections import deque, defaultdict
import math as m

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	r = int(rl())
	print(2*m.pi*r)
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 65264
#include "bits/stdc++.h"
using namespace std;


int main()
{
    int A,B,C,D;
    //体力、攻撃
    cin >> A >> B >> C >> D;

    int countC = 0;
    while (C > 0){
        C = C - B;
        countC = countC + 1;
    }
    int countA = 0;
    while (A > 0) {
        A = A-D;
        countA = countA + 1;
    }
    if (countC<=countA) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

using namespace std;

int main() {
    int a, b;
    scanf("%d%d", &a, &b);
    if(a == 1 && b != 1) {
        printf("Alice\n");
    }
    else if(a != 1 && b == 1) {
        printf("Bob\n");
    }
    else if(a == b) {
        printf("Draw\n");
    }
    else if(a > b) {
        printf("Alice");
    }
    else if(a < b) {
        printf("Bob\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
vector<int>adj[100001];
int visited[100001];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    if(n%2==0)cout<<n/2;
    else cout<<n/2+1;
   
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string>

#define _CRT_SECURE_NO_WARNINGS

int main() {
	char s[11];
	scanf("%s",s);
	if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
int ar[200000];
int main()
{
    int n,i,k;
    long long sum;
    cin>>n>>k;
    for(i=0;i<n;i++)
        cin>>ar[i];
    sort(ar,ar+n);
    while(k--) n--;
    for(i=sum=0;i<n;i++)
        sum+=ar[i];
    cout<<sum<<endl;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int ans;
string s;

signed main() {
    cin >> s;
    rep(i,s.size()) ans += s[i]-'0';
    cout << ans << endl;
}












Measured memory_bytes: 256
a=[]
try:
    while True:
        a.append(int(input()))
except EOFError:
    pass
#print('@',a)

counts = [0]*101
# counts[n] nの個数を数える
#print('@',counts)

for n in a:
    counts[n] +=1
    
#print('@',counts)
#print('@',max(counts))

for n in range(len(a)):
    if counts[n]==max(counts):
        print(n)


Measured memory_bytes: 5596
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>

intmax_t gcd(intmax_t m, intmax_t n) {
  while (n) std::swap(m %= n, n);
  return m;
}

int main() {
  size_t n;
  scanf("%zu", &n);

  std::vector<intmax_t> a(n);
  for (auto& ai: a) scanf("%jd", &ai);

  std::vector<intmax_t> al(n+1), ar(n+1);
  for (size_t i = 0; i < n; ++i)
    al[i+1] = gcd(al[i], a[i]);
  for (size_t i = n; i--;)
    ar[i] = gcd(ar[i+1], a[i]);

  intmax_t res = 0;
  for (size_t i = 0; i < n; ++i)
    res = std::max(res, gcd(al[i], ar[i+1]));

  printf("%jd\n", res);
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int main() {
  long long N, tmp, ans=0;
  long long a[100000]={};
  scanf("%lld", &N);
  for(long long i=0;i<N;i++){
    scanf("%lld", &tmp);
    if(tmp>100000)ans++;
    else a[tmp-1]++;
  }
  for(long long i=0;i<100000;i++){
    ans+= (a[i]-i-1)>=0?a[i]-i-1:a[i];
  }
  printf("%lld\n", ans);
  
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int k[15],a[15][15],p[15],b[15];
int main(){
	int n,m,num=0;
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>k[i];
		for(int j=1;j<=k[i];j++){
			cin>>a[i][j];
		}
	}
	for(int i=1;i<=m;i++){
		cin>>p[i];
	}
	for(int i=0;i<(1<<n);i++){
		int tag=1;
		for(int t=1;t<=m;t++) b[t]=0;
		for(int j=1;j<=n;j++){
			if(((i>>(j-1))&1)==0) continue;
			for(int t=1;t<=m;t++){
				for(int g=1;g<=k[t];g++){
					if(a[t][g]==j) b[t]++;
				}
			}
		}
		for(int t=1;t<=m;t++){
			if(b[t]%2!=p[t]){
				tag=0;break;
			}
		}
		num+=tag;
	}
	cout<<num<<endl;
}

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


int main() {
	int a, b;
	cin >> a >> b;
	cout << 6 / (a * b) << endl;
}

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

int main(){
    int n; cin >> n;
    string ans = "";
    if(n == 0) ans = '0';
    while(n != 0){
        if(n % 2 != 0){
            ans += '1';
            n--;
        }
        else{
            ans += '0';
        }
        n /= -2;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}

Measured memory_bytes: 256
def dcount(n):
    c = 0
    for i in range(1, n+1):
        if n % i == 0:
            c += 1
    return c

N = int(input())
c = 0
for i in range(1, N + 1, 2):
    if dcount(i) == 8:
        c += 1
print(c)

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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <queue>
#include <stack>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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

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

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

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  int x;
  cin >> x;
  int  ans;
  for (int i=0; i<=1e+05; i++){
    vector<ll> tmp = divisor(x+i);
    if (tmp.size() == 2){
      ans = x+i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}



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

int main(){
    long long int n,sum=0;
    cin>>n;
    vector<int>a(10000000);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<i;j++){
        	sum+=a[i]*a[j];
        }
    }
    cout<<sum<<endl;
   return 0;
}

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

int main(void)
{
	int x,y ,i,j, max = 1;
	scanf("%d", &x);
	for (i = 2; i <= 31; i++) {
		for (j = 2;; j++) {
			y = (int)pow(i, j);
			if (x < y)break;
			if (max < y)max = y;
		}
	}
	printf("%d\n", max);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<cmath>
#include<algorithm>
#include<queue>
#include<set>
#include<stdio.h>
using namespace std;


queue<int> profit;
long long ans = 0;
int n, ai[200003];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> ai[i];
	}
	sort(ai, ai + n);
	profit.push(ai[n - 1]);
	for (int i = n - 2; i > -1; i--) {
		ans += profit.front();
		profit.pop();
		profit.push(ai[i]);
		profit.push(ai[i]);
	}
	cout << ans;
}



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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }
void yesOrNo(bool flg) {
  if (flg)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

void solve(ll N, ll K, std::vector<ll> A) {
  ll p = 0;
  rep(i, K) { p += A.at(i); }
  FOR(i, K, N) {
    ll q = p;
    p = p - A.at(i - K) + A.at(i);
    yesOrNo(q < p);
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  ll K;
  scanf("%lld", &K);
  std::vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, K, std::move(A));
  return 0;
}


Measured memory_bytes: 4864
#include <iostream>

int main() {
    int a, b;
    std::cin >> a >> b;

    if(a == 1) {
        a += 13;
    }
    if(b == 1) {
        b += 13;
    }

    if(a > b) {
        std::cout << "Alice" << std::endl;
    } else if(a < b) {
        std::cout << "Bob" << std::endl;
    } else {
        std::cout << "Draw" << std::endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
signed main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << max(c - a + b, 0) << endl;
}

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

#define int long long 
#define dou  double 
#define endl "\n"

const int MOD=1e9+7;

void solve()
{
	int n,i,cnt=0;
	cin >> n;
	vector<int> v(n+1);
	for(i=1;i<=n;i++)
		cin >> v[i];
	for(i=1;i<=n;i++)
	{
		if(i%2 and v[i]%2)
			cnt++;
	}
	cout << cnt << endl;
}

main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <thread>
#include <mutex>

#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))

using namespace std;

using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    int a, b;
    scanf("%d %d", &a, &b);

    int lb = max(10 * b, int(ceil(a / 0.08)));
    int ub = min(10 * (b + 1), int(ceil((a + 1) / 0.08)));

    if (lb < ub) {
        printf("%d\n", lb);
    } else {
        printf("-1\n");
    }
    return 0;
}

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

int main() {

	vector<int> a(3);
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}
	sort(a.rbegin(), a.rend());
	cout << a[1] + a[2] << endl;
	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define maxn 1000000
#define LL long long
LL fac[maxn+5],inv[maxn+5];
LL C(int n,int m){
	return fac[n]*inv[m]%mo*inv[n-m]%mo;
}
void Pre(int p,LL a[],int n){
    a[0]=fac[1]=a[1]=1;
    for(int i=2;i<=n;i++){
    	fac[i]=1ll*fac[i-1]*i%p;
        a[i]=1ll*(p-p/i)*a[p%i]%p;
    }
    for(int i=2;i<=n;i++)a[i]=a[i]*a[i-1]%p;
}
int main(){
	Pre(mo,inv,maxn);
	int x,y;scanf("%d%d",&x,&y);
	if((x+y)%3)return puts("0"),0;
	if(y>2*x||x>2*y)return puts("0"),0;
	int t=(x+y)/3;
	x-=t,y-=t;;
	printf("%lld",C(x+y,x));
	return 0;
}

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

using namespace std;

int main(){
  
  int N; cin >> N;
   
  deque<int> q;
  for(int i = 0; i < N; i++){
    int a; cin >> a;
    if( (i%2) != (N % 2)){
      q.push_front(a);}
    else{
      q.push_back(a);}}
  
  for(int i = 0; i < (int) q.size(); i++){
    cout << q[i] << " ";}
  cout << endl;
  
  return 0;}

Measured memory_bytes: 2944
quit() = exit(0)
in_1(ch) = parse(Int, take!(ch))
in_a(ch) = parse.(Int, split(take!(ch)))

quit() = exit(0)
in_1() = parse(Int, readline())
in_a() = parse.(Int, split(readline()))

function main()
  N = readline()
  println(any(isequal('7'), N) ? "Yes" : "No")
end

isempty(ARGS) && main()


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

int main()
{
    string s;
    cin>>s;
    queue<char>ch;

    for(int i=0; i<s.size(); i++)
    {
        ch.push(s[i]);
    }

    ll cnt=0;
    ll    bnt=-1;

    ll ans=0;

    ll dumb=0;
    char c;
    while(!ch.empty())
    {
        c=ch.front();

        if(c=='>')
        {
            if(bnt>0)
            {
                ans+=((bnt*(bnt+1))/2);
                dumb=bnt;
            }
            bnt=-1;
            ++cnt;
        }
        else
        {

            if(dumb>=cnt&&dumb!=0)
            {
                ans+=(dumb+1);
            }

            else
                ans+=cnt;
            --cnt;

            ans+=((cnt*(cnt+1))/2);
            ++bnt;
            dumb=0;
            cnt=0;


        }
        ch.pop();
    }


    if(bnt>0||cnt>0)
    {
        if(cnt>0)
        {
            if(dumb>=cnt)
            {
                ans+=(dumb+1);
            }

            else
                ans+=cnt;
            --cnt;

            ans+=((cnt*(cnt+1))/2);

        }

        else
        {
            ans+=((bnt*(bnt+1))/2);
            dumb=bnt;

        }
    }

    if(c=='<')
        ans+=(bnt+1);

    cout<<ans<<endl;



}


Measured memory_bytes: 1284
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
  ll ans=1;
  for(int i=1;i<=n;i++)
       ans*=a;
    return ans;
}

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

 ll n,k,a,ans=0;
 cin>>n>>k;
 for(int i=0;i<n;i++)
 {
     cin>>a;
     v.push_back(a);
 }
 sort(v.begin(),v.end());
 for(int i=0;i<k;i++)
 {
     ans+=v[i];
 }
 cout<<ans<<endl;

return 0;
}



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

using namespace std;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

int arr[3][2];

int main()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin >> n;
	arr[1][0] = 1;
	arr[1][1] = 1e9;
	arr[2][1] = (((n / arr[1][1] + 1)*arr[1][1]) - n);
	arr[2][0] = n / arr[1][1] + 1;
	if(n <= arr[1][1]){
		arr[1][0] = n;
		arr[1][1]  = 0;
		arr[2][0] = 0;
		arr[2][1] = 1;
	}
	else if(n == 1000000000000000000){

		arr[1][0] = 1000000000;
		arr[1][1]  = 0;
		arr[2][0] = 0;
		arr[2][1] = 1000000000;
	}
	lp(i, 3)
		lp(j, 2)
			cout << arr[i][j] << " ";
	return 0;
}


Measured memory_bytes: 256
mod=10**9+7

N,M=map(int,input().split())
dp=[[0 for i in range(N+1)] for j in range(N+1)]
dp[N][N]=1

for i in range(M-1,-1,-1):
    for k in range(1,N+1):
        for j in range(k,N+1):
            if j==k:
                if j<N:
                    dp[j][k]=(j*dp[j][k]+(N-j)*dp[j+1][k])%mod
                else:
                    dp[j][k]=(N*dp[j][k])%mod
            else:
                if j<N:
                    dp[j][k]=(k*dp[j][j]+(N-j)*dp[j+1][k]+(j-k)*dp[j][k])%mod
                else:
                    dp[j][k]=(k*dp[j][j]+(N-k)*dp[j][k])%mod

print(dp[1][1])


Measured memory_bytes: 74552
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  int a, b, c; std::cin >> a >> b >> c;
  if (a + b + c >= 22) std::cout << "bust" << std::endl;
  else                 std::cout << "win" << std::endl;
}


Measured memory_bytes: 256
def abc101_c():
    n, k = map(int, input().split())
    vs = list(map(int, input().split()))
    
    index = 0
    for i, v in enumerate(vs):
        if v == 1:
            index = i
            break
    len_l = index
    len_r = n - index - 1
    mod_l = len_l % (k-1)
    mod_r = len_r % (k-1)
    cnt_l = len_l // (k-1)
    cnt_r = len_r // (k-1)
    res = cnt_l + cnt_r
    if mod_l:
        res += 1
    if mod_r:
        res += 1
    if mod_l and mod_r and mod_l + mod_r <= (k-1):
        res -= 1
    return res
            
print(abc101_c())


Measured memory_bytes: 13880
#include<stdio.h>
int main(){
	int K;
	long long int a[100005];
	scanf("%d", &K);
	long long int min=2, max=2;
	for(int i=0; i<K; i++){
		scanf("%lld", &a[i]);
	}
	for(int i=K-1; i>=0; i--){
		long long int mini=(min/a[i]+1)*a[i];
	 	if(min%a[i]==0){
	 		mini-=a[i];
		}
		if(mini>max){
			printf("-1");
			return 0;
		}
		long long int maxi=(max/a[i])*a[i];
		if(maxi<min){
			printf("-1");
			return 0;
		}
		min=mini;
		max=maxi+a[i]-1;
	}
	printf("%lld %lld", min, max);
}

Measured memory_bytes: 896
loop{
	n = gets.to_i
	break if n == 0
	top, north, west = 1, 2, 3
	n.times{
		case gets.chomp
		when 'north'
			top, north, west = 7-north, top, west
		when 'west'
			top, north, west = 7-west, north, top
		when 'east'
			top, north, west = west, north, 7-top
		when 'south'
			top, north, west = north, 7-top, west
		end
	}
	puts top
}

Measured memory_bytes: 6100
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	int N,mini=99999999,ans=0;
	cin >> N;
	vector<int> P(N);
	for (int i = 0; i < N; i++)
	{
		cin >> P[i];
	}
	for (int i = 0; i < N; i++)
	{
		if (P[i] < mini) {
			ans++;
		}
		mini = min(mini, P[i]);
	}
	
	cout << ans << endl;
	return 0;
}

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

bool check(int a, int b , int c){
	if((a * a) == (b * b + c * c) ){ 
		return true ; 
	}
	return false ;
}

int main(){
	int i, a, b, c;

	cin >> i;
	for(int j = 0 ; j < i; j++){
		cin >> a >> b >> c;
		if(check(a, b, c) || check(b, c, a) || check(c, a, b) ){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int>a(M);
  vector<int>b(M);
  for (int i = 0; i < M; i++) {
    cin >> a.at(i) >> b.at(i);
  }
  vector<int>ans(N + 1);
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j < M; j++) {
      if (i == a.at(j) || i == b.at(j)) {
        ans.at(i)++;
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    cout << ans.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

const i64 MOD = 1'000'000'007;

struct mint {
  long long x;
  mint(long long 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(long long 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, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

// Combination nCk with MOD.
struct Factorials {
  // factorials and inverse factorials.
  vector<mint> fact, ifact;

  Factorials(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 C(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }

  mint P(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[n - k];
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M;
  cin >> N >> M;
  Factorials facts(M + 1);

  mint z = 0;
  for (int k = 1; k <= N; ++k) {
    mint x = facts.C(N, k) * facts.P(M - k, N - k);
    if (k % 2 == 1) {
      z += x;
    } else {
      z -= x;
    }
  }
  mint all = facts.P(M, N);
  mint ans = all * (all - z);
  cout << ans << endl;
}


Measured memory_bytes: 11060
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  int g;
  bool f = false;
  rep(i, n){
    int in;
    cin >> in;
    if(in >= k) f = true;
    if(i == 0) g = in;
    else g = __gcd(in, g);
  }
  if(f == true && k % g == 0) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  return 0;
}

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

ll f(vector<ll> &a, ll x){
    int n = a.size();
    ll ret = 0LL;
    rep(i,n) ret += (a[i] + x - 1)/x - 1;
    return ret;
}

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

    int n; ll k; cin >> n >> k;
    vector<ll> a(n); rep(i,n) cin >> a[i];
    sort(a.begin(), a.end(), greater<ll>());

    ll left = 0, right = a[0], mid;
    
    while(abs(left - right) > 1){
        mid = (left + right) / 2;
        if(f(a, mid) <= k) right = mid; // ok
        else left = mid; // false
    }

    cout << right << endl;
}

Measured memory_bytes: 4788
X, N = map(int, input().split())
P=list(map(int,input().split()))
if not X in P:
  print(X)
  exit()
for i in range(1,100):
  #小さい方向を探す
  if not X - i in P:
    print(X - i)
    exit()
  if not X + i in P:
    print(X + i)
    exit()

Measured memory_bytes: 9184
using System;
using System.Linq;

namespace ABC086
{
    class A
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).Aggregate(1, (n, next) => n * next);
            var res = ab % 2 == 0 ? "Even" : "Odd";
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 11220
N,T=(int(i) for i in input().split())
c=[]
t=[]
count=0
for i in range(N):
    c_tmp,t_tmp=input().split()
    if int(t_tmp)<=T:
        c.append(int(c_tmp))
        t.append(int(t_tmp))
        count+=1
if count!=0:
    print(min(c))
else:
    print("TLE")

Measured memory_bytes: 3060