akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;

int K, N;
long long h[100100];
long long dh[100100];
long long ans;

int main() {
    cin >> N >> K;
    for (int i=0; i<N; ++i) cin >> h[i];

    sort(h, h+N);
    for (int i=0; i<=N-K; ++i) dh[i] = h[i+K-1] - h[i];
    ans = dh[0];
    for (int i=1; i<=N-K; ++i) ans = min(ans, dh[i]);

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

Measured memory_bytes: 1792
//#include<bits/stdc++.h>
#define ll long long
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mp make_pair
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<utility>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>
#include<stack>
ll z = 998244353 ;
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
ll power(ll a ,ll b){if(b == 0) return 1 ; ll c = power(a , b/2) ; if(b%2 == 0) return ((c*c)%z) ; else return ((((c*c)%z)*a)%z) ;}
ll inverse(ll a ,ll n){return power(a , n-2) ;}
ll max(ll a , ll b){if(a > b) return a ; return b ;}
//ios_base::sync_with_stdio(0);
//cin.tie(0); cout.tie(0);
using namespace std ;



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

    ll n , a,b ;
	cin >> n >> a >> b ;
	ll c = min(a , b) ;
	ll d = max(a , b) ;
	if((d - c)%2 == 0)
		cout << (d-c)/2 << endl ;
	else
	{
		ll ans =0 ;
		ans += min(c-1 , n-d) ;
		ans++ ;
		ans += (d-c)/2 ;
		cout << ans << endl;
	}
    return 0 ;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    from statistics import pstdev

    while True:
        # ??????????????\???
        data_count = int(input())
        if data_count == 0:
            break
        scores = [int(x) for x in input().split(' ')]

        # ?¨??????????????¨????
        result = pstdev(scores)

        # ???????????????
        print('{0:.8f}'.format(result))

Measured memory_bytes: 10264
N,C,K = map(int,input().split())
Ts = sorted([int(input()) for _ in range(N)])

#print(Ts)

ans = 0
firstFlag = True
passenger = []	#limit lastNum
for i in range(N):
	if firstFlag:
		passenger = [Ts[i] + K,C-1]
		firstFlag = False
		ans += 1
		#print("first",str(passenger),Ts[i],ans)
	
	if passenger[1] <= 0:
		#print("full",str(passenger),Ts[i],ans)
		firstFlag = True
	elif i+1 < N and passenger[0] < Ts[i+1]:
		#print("time over",str(passenger),Ts[i],ans)
		firstFlag = True
	else:
		#print("other",str(passenger),Ts[i],ans)
		passenger[1] -= 1

print(ans)

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

// ====================================================================

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

  vector<int> ball(n);
  for (int i = n - 1; i >= 0; i--) {
    int res = 0;
    for (int j = i; j < n; j += i + 1) res += ball[j];
    res %= 2;

    // このままだと結果がずれる→ボールを入れる
    if (res != v[i]) ball[i] = 1;
  }

  int count = accumulate(ball.begin(), ball.end(), 0);
  cout << count << endl;
  vector<int> ans;
  for (int i = 0; i < ball.size(); i++)
    if (ball[i]) ans.push_back(i + 1);

  if (ans.size()) cout << ans << endl;
}


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

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


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

using namespace std;

#define ll long long
#define mx 0
#define mn 1e9
#define v(dt) vector<dt>
#define pr(x, y) pair<x,y>
#define loop(x, s, n) for(int x = s; x < n; ++x)
#define in_arr(n) loop(i,0,n){cin>>a[i];}
#define out_arr(n) loop(i,0,n){cout<<a[i];}

const int N = 1e5 + 7;

inline void boost() {
    cin.tie(0), cout.tie(0), cin.sync_with_stdio(0), cout.sync_with_stdio(0);
}

int a[N];

int main() {
    boost();
    ll n;
    cin >> n;
    in_arr(n);
    ll cnt = 0;
    ll res = 0;
    for (int i=0;i<n-1;i++)
    {
        if (a[i]>=a[i+1])
        {
            ++cnt;
        } else
        {
            res = max(res,cnt);
            cnt=0;
        }
    }
    res = max(res,cnt);
    cout << res;

}

Measured memory_bytes: 640
using System;

public class Hello{
  public static void Main(){
    string s = Console.ReadLine();
    
    string cnt = "yes";
    
    int i, j;
    
    for( i = 0 ; i < s.Length ; i++){
      
      for(j = i+1 ; j < s.Length ; j++){
        if( s[i] == s[j] ){
          cnt = "no";
        }
        
      }
      
    }
    
    Console.WriteLine(cnt);
  }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define ll long long
#define REV(v) reverse(v.begin(), v.end());
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, start, stop) for (ll i = start; i < stop; i++)
#define FORR(i, start, stop) for (ll i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<ll>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<ll>());
#define REMOVE(v,n) remove(vector<ll> v,v+v.size(),ll n)
#define ERASE(v,n) v.erase(v.begin()+n);
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const int MOD = 1000000007;
void chmin(int &a, int b) { if (a > b) a = b; }

//vector< vector<int> > v (size1, vector<int>(size2) );



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

    ll N,K;
    cin>>N>>K;
    vector<ll> A(N);
    FOR(i,0,N) cin>>A[i];

    ll ans0=0;
    ll ans1=0;
    ll ans2=0;
    ll ans=0;

    FOR(i,0,N){
        ans1=0;ans0=0;ans2=0;
        FOR(j,0,N){
            if(A[i]>A[j]){
                if(i<j) ans0++;
                ans1++;
            }
        }
        ans+=ans0*(K%MOD);
        ans%=MOD;
        ans2=(K*(K-1) / 2ll) % MOD;
        (ans2 *= ans1) %= MOD;
        ans+=ans2;
        ans%=MOD;
        //cout<<A[i]<<' '<<ans0<<' '<<ans1<<ans<<endl;
    }
    
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
# ABC158
# D - String Formation

from collections import deque

def ChangeState(Is_normal):
    if Is_normal==True:
        return False
    else:
        return True

S=deque(input().split())
Q=int(input())
Is_normal=True

for _ in range(Q):
    q = input()
    if len(q)== 1 :
        Is_normal = ChangeState(Is_normal)
    else:
        if q[2]=='1':
            if Is_normal==True:
                # S=q[4]+S
                S.appendleft(q[4])
            else :
                # S=S+q[4]
                S.append(q[4])

        else :
            if Is_normal==True:
                # S=S+q[4]
                S.append(q[4])

            else:
                # S=q[4]+S
                S.appendleft(q[4])

    # print(Is_normal, S)
S=''.join(S)
if Is_normal==False:
    S=S[::-1]
print(S)


Measured memory_bytes: 12748
#include<bits/stdc++.h>
using namespace std;
int main(){
	int i,j,n,ans=0;
	cin>>n;
	for(i=1;i<=n;i++){
		for(j=i+1;j<=n;j++){
			if((i%2==0&&j%2==1)||(i%2==1&&j%2==0)) ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
	}


Measured memory_bytes: 256
class Node:
    def __init__(self, key):
        self.key = key
        self.parent = self.left = self.right = None

    def _get_most_left_node(self):
        x = self
        while x.left is not None:
            x = x.left
        return x
    
class Tree():
    def __init__(self, root=None):
        self.root = root
    
    def insert(self, node):
        y = None
        x = self.root
        while x is not None:
            y = x
            if node.key < x.key:
                x = x.left
            else:
                x = x.right
        
        node.parent = y
        if y is None:   # Tree が空だった場合
            self.root = node
        elif node.key < y.key:
            y.left = node
        else:
            y.right = node
    
    def print_inorder_tree_walk(self):
        def work(node):
            if node is None:
                return
            work(node.left)
            print('', node.key, end='')
            work(node.right)

        work(self.root)
        print()
    
    def print_preorder_tree_walk(self):
        def work(node):
            if node is None:
                return
            print('', node.key, end='')
            work(node.left)
            work(node.right)

        work(self.root)
        print()

    def find(self, key):
        """Tree 中に key をもつノードがあればそのノードを返す。なければ None を返す。"""
        x = self.root
        while x is not None:
            if key == x.key:
                return x
            elif key < x.key:
                x = x.left
            else:
                x = x.right
        return None

    def delete(self, key):
        """削除できたら True、存在せず削除できない場合は False を返す。"""
        x = self.find(key)
        if not x:
            return False
        y = x if x.left is None or x.right is None else x.right._get_most_left_node()
        z = y.left if y.left is not None else y.right
        if z is not None: z.parent = y.parent
        if y.parent is None:
            self.root = z
        elif y is y.parent.left:
            y.parent.left = z
        else:
            y.parent.right = z
        
        if x is not y:
            x.key = y.key
        
        return True

if __name__ == '__main__':
    import sys

    n = int(input())
    T = Tree()
    for _ in range(n):
        command, *args = sys.stdin.readline().split()
        if command[0] == 'i':   # insert key
            T.insert(Node(int(args[0])))
        elif command[0] == 'f': # find key
            if T.find(int(args[0])):
                print('yes')
            else:
                print('no')
        elif command[0] == 'd': # delete key
            T.delete(int(args[0]))
        else:   # print
            T.print_inorder_tree_walk()
            T.print_preorder_tree_walk()


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



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

	vector<int> D(N);

	for(int i=0;i<N;i++)cin>>D[i];

	sort(D.begin(), D.end(),greater<int>());

	int ans=1;


	for(int i=1;i<N;i++){
		if(D[i-1]!=D[i]){
			ans++;
		}

	}

	cout << ans;
	
	
}


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

#define ll          long long
#define ull         unsigned long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)      (a).rbegin(),(a).rend()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define mod        1000000007
//#define mod        998244353
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define INF         numeric_limits<ll>::max();
#define NINF        numeric_limits<ll>::min();
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))
const long double pi=3.14159265359;
inline ll add(ll a,ll b,ll m){
    if((a+b)>=m)return (a+b)%m;
    return a+b;
}
inline ll mul(ll a,ll b,ll m){
    if((a*b)<m)return a*b;
    return (a*b)%m;
}



void solve(){
    int n;cin>>n;
    vector<int> a(n+1,0);
    int temp;
    rep(i,0,n-1){
        cin>>temp;
        a[temp]++;
    }
    for(int i=1;i<=n;i++){
        cout<<a[i]<<endl;
    }

}

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


Measured memory_bytes: 3996
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;


void solve(long long X, long long Y, long long Z, long long K, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C){
    vector<long long> ab_ans;
    for (int i = 0; i < X; i++) {
        for (int j = 0; j < Y; j++) {
            ab_ans.push_back(A[i] + B[j]);
        }
    }
    std::sort(ab_ans.begin(), ab_ans.end(), std::greater<long long>() );
    long long ab_max = 3000;
    vector<long long> abc_ans;
    long long min_num = min(ab_max, X * Y);
    for (int i = 0; i < min_num; i++) {
        for (int j = 0; j < Z; j++) {
            abc_ans.push_back(ab_ans[i] + C[j]);
        }
    }
    std::sort(abc_ans.begin(), abc_ans.end(), std::greater<long long>() );
    for (int i=0; i<K; i++) {
        cout << abc_ans[i] << endl;
    }
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    long long Y;
    long long Z;
    long long K;
    cin >> X >> Y >> Z >> K;
    std::vector<long long> A(X);
    for(int i = 0 ; i < X ; i++){
        cin >> A[i];
    }
    std::vector<long long> B(Y);
    for(int i = 0 ; i < Y ; i++){
        cin >> B[i];
    }
    std::vector<long long> C(Z);
    for(int i = 0 ; i < Z ; i++){
        cin >> C[i];
    }
    solve(X, Y, Z, K, std::move(A), std::move(B), std::move(C));
    return 0;
}


Measured memory_bytes: 43240
N,K=map(int,input().split())
R,S,P=map(int,input().split())
L=input()
T=[]
for i in range(N):
    T.append(L[i])
for i in range(K,N):
    if T[i]==T[i-K]:
        T[i]="0"
T=str(T)
p=0
for i in T:
    if i=="r":
        p+=P
    elif i=="s":
        p+=R
    elif i=="p":
        p+=S
print(p)

Measured memory_bytes: 10580
#include<iostream>
long n,k,a,i,j,v[9<<9];main(){for(std::cin>>n>>k;i++<n;)for(j=0;j++<n;v[i]>v[j]?(a+=k*(k-1)/2+(i<j)*k)%=(int)1e9+7:0)i-1||std::cin>>v[j];std::cout<<a;}


Measured memory_bytes: 256
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

    ll num[2010];

int main(void){
    ll n;
    cin >> n;
    ll x;
    cin >>x;
    ll y;
    cin >>y;
    for(ll i=1; i<=n; i++){
        for(ll j=i+1; j<=n; j++){
            if(x >= i){
                ll tmp1 = (j-i);
                ll tmp2 =  (x-i) + 1 + abs(y-j);
                CHMIN(tmp1, tmp2);
                num[tmp1]++;
            }else if( i>=x && y>=i){
                ll tmp1 = j-i;
                ll tmp2 = (i-x) + 1 + abs(y-j);
                CHMIN(tmp1, tmp2);
                num[tmp1]++;
            }else{
                num[j-i]++;
            }
        }
    }
    for(ll i=1; i<n; i++){
        cout << num[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
    #include <iomanip>
    #include <vector>
    #include <algorithm>
    #include <cstring>
    #include <map>
    #include <queue>
    #include <cmath>
    #include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
    using namespace std;

    #define MOD 1000000007
    #define EPS 1e-10
    #define ll long long
    #define ld long double
    #define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
    #define rep(i,n) FOR(i,0,n)
    #define pb push_back
    #define mp make_pair
    #define all(a) a.begin(),a.end()
    #define rall(a) a.rbegin(),a.rend()
    #define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
    #define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
    #define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
    #define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
    #define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
    #define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
    template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
    ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
    ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
    ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
    ll dx[]={0, 0, -1, 1};
    ll dy[]={1, -1, 0, 0};// up,down,left right


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

        string inp; cin >> inp;
        if(inp[2] == inp[3] and inp[4] == inp[5]) cout << "Yes" << endl;
        else cout << "No" << endl;

        //cout << fixed << setprecision(16) << ans << endl;
        return 0;
    }


Measured memory_bytes: 256
N = int(input())
S = input()
L = list(S)
for i in range(0, 2*N, 2):
  L[i] = "B" if L[i] == "W" else "W"
S = "".join(L)
#print(S)
r = 1
i = 0
nw = 0
nb = 0
while i < 2*N:
  j = S.find("B", i)
  if j < 0:
    j = 2*N
  k = S.find("W", j)
  if k < 0:
    k = 2*N
  #print(i, j, k)
  nw += j-i
  nb += k-j
  for i in range(nb):
    r = r*nw%1000000007
    nw -= 1
    nb -= 1
  i = k
if not(nw == 0 and nb == 0):
  print(0)
  exit()
for i in range(1, N+1):
  r = r*i%1000000007
print(r)


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   ll a,b;cin >>a>>b;
   ll ans=max({a+b,a*b,a-b});
   cout <<ans <<endl;
   return 0;
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int d=c/(a*7+b);
    int e=c%(a*7+b);
    if(e%a!=0){
        if(e>a*7){
            cout << d*7+7 << endl;
            return 0;
        }
        cout << d*7+e/a+1 << endl;
        return 0;
    }
    else
    {
        if(e>a*7){
            cout << d*7+7 << endl;
            return 0;
        }
        cout << d*7+e/a << endl;
        return 0;
    }
    
}


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

using ll=long long;
const ll MOD=1000000007;

int main() {
  int n;
  cin >> n;
  if(n==1)
    cout << "Hello World" << endl;
  else{
    int a,b;
    cin >> a >> b;
    cout << a+b << endl;
}
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,k;
	int t;
	cin>>n>>k;
	long long sum=0;
	for(int i=1;i<=k;i++)
		{
			int j=k-(i%k);
			long long b=(n-j+k)/k;
			for(t=k-(i%k);t<=n;t+=k)
				if((t+j)%k==0)
				{
					long long d=(n-t+k)/k;
					sum+=b*d;
					break;
				}
		}
		sum*=(n/k);
	for(int i=1;i<=n%k;i++)
		{
			int j=k-(i%k);
			long long b=(n-j+k)/k;
			for(t=k-(i%k);t<=n;t+=k)
				if((t+j)%k==0)
				{
					long long d=(n-t+k)/k;
					sum+=b*d;
					break;
				}
		}
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	float height , high = 0 , low = 10000;
	while(1){
		if(scanf("%f" , &height)==EOF) break;
		if(height > high) high = height;
		if(height < low) low = height;
	}
	printf("%.1f\n" , high - low);
	return 0;
}

Measured memory_bytes: 0
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"
#include "cmath"
typedef long long ll;

int main(int argc, char const *argv[]) {
  ll NN;

  std::cin >> NN;

  // std::cout << "NN is "<< NN << '\n';

  ll nn = 0;

  for (size_t i = 0; i * (i-1) / 2  <= NN; i++) {
    if (i * (i-1)/2 == NN) {
      nn = i;
    }
  }

  if (nn == 0) {
    std::cout << "No" << '\n';
    return 0;
  }

  // std::cout << "nn is "<<nn << '\n';

  int ans[nn][nn-1];


  int count = 1;
  for (size_t i = 0; i < nn; i++) {
    for (size_t i2 = 0; i2 < nn-i-1; i2++) {
      ans[i][i2 + i] = count;
      ans[i2 + 1 + i][i] = count;
      count++;
    }
  }

  std::cout << "Yes" << '\n';
  std::cout << nn << '\n';

  for (size_t i = 0; i < nn; i++) {
    std::cout << nn-1 << ' ';
    for (size_t j = 0; j < nn-1; j++) {
      std::cout << ans[i][j] << ' ';
    }
    std::cout  << '\n';
  }


  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
using ld = long double;
using cd = complex<ld>;

const int max_n = 1e6 + 500;
const int p1 = 29;
const int mod1 = 1362131291;
const int p2 = 244;
const int mod2 = 1e9 + 7;

int main() {
    cout.precision(20); cout << fixed;
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<string> v(n);
    map<pair<ll, ll>, ll> cntH;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        v[i] = s;
        ll hash1 = 0;
        ll hash2 = 0;
        reverse(s.begin(), s.end());
        for (int j = 0; j < s.size(); j++) {
            hash1 = (hash1 * p1 + s[j] - 'a' + 1) % mod1;
            hash2 = (hash2 * p2 + s[j] - 'a' + 1) % mod2;
        }
        cntH[{hash1, hash2}]++;
    }
    ll ans = 0;
    for (int j = 0; j < n; j++) {
        string s = v[j];
        vector<int> has(27);
        for (int i = 0; i < s.size(); i++) {
            has[s[i] - 'a' + 1]++;
        }
        ll cur = 0;
        ll hash1 = 0;
        ll hash2 = 0;
        for (int i = s.size() - 1; i >= 0; i--) {
            for (int d = 0; d < 27; d++) {
                if (has[d]) {
                    pair<ll, ll> u = {(hash1 * p1 + d) % mod1, (hash2 * p2 + d) % mod2};
                    if (cntH.count(u)) {
                        cur += cntH[u];
                    }
                }
            }
            hash1 = (hash1 * p1 + (s[i] - 'a' + 1)) % mod1;
            hash2 = (hash2 * p2 + (s[i] - 'a' + 1)) % mod2;
            has[s[i] - 'a' + 1]--;
        }
        ans += cur;
    }
    cout << ans - n << "\n";
}

Measured memory_bytes: 21940
#include <stdio.h>

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

	scanf("%d%d%d", &a, &b, &c);
	if (a > b) tmp = a, a = b, b = tmp;
	if (b > c)
		tmp = b, b = c, c = tmp;
		if (a > b) tmp = a, a = b, b = tmp;
	printf("%d %d %d\n", a, b, c);
	return 0;
}



Measured memory_bytes: 2716
#include <bits/stdc++.h>
using namespace std;
#define maxn 10000000
#define mod 1000000007 
int n, ans, f[maxn], sum[maxn];

int read() {
    int x = 0, k = 1;
    char c; c = getchar();
    while(c < '0' || c > '9') { if(c == '-') k = -1; c = getchar(); }
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar(); 
    return x * k;
}

void Upd(int &x, int y) { x = (x + y) % mod; }
int Up(int x, int y) { x += y; if(x >= mod) x -= mod; return x; }
int Down(int x, int y) { x -= y; if(x < 0) x += mod; return x; }
int mul(int x, int y) { return 1ll * x * y % mod; }

int main() {
    n = read(); f[0] = sum[0] = 1; 
    for(int i = 1; i <= n; i ++) {
        Upd(f[i], i >= 3 ? sum[i - 3] : 0);
        Upd(f[i], f[i - 1]); Upd(sum[i], Up(f[i], sum[i - 1]));
    }
    for(int i = 1; i < n; i ++) Upd(ans, mul(Up(mul(n - 1, n - 1), i), f[i - 1]));
    Upd(ans, 1ll * f[n - 1] * (n - 1) % mod); Upd(ans, f[n]);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 8448
import Control.Applicative

main = do _ <- getLine
          xs <- map (map read . words) . lines <$> getContents
          putStr . unlines . map (unwords . map show) . addRow $ map sumRow xs

sumRow :: [Int] -> [Int]
sumRow x = x ++ ((sum x):[])

addRow :: [[Int]] -> [[Int]]
addRow xs = xs ++ (makeRow xs:[])

makeRow :: [[Int]] -> [Int]
makeRow (x:_) | x==[] = []
makeRow xs = (sum $ map head xs) : makeRow (map tail xs)

sample :: [[Int]]
sample = [[1,1,3,4,5],[2,2,2,4,5],[3,3,0,1,1],[2,3,4,4,6]]

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

using namespace std;

int main(){
	int t;
	string c;
	cin>>t>>c;
	vector<int> a(t,0);
	int r=0;
	for(int i=0;i<t;i++){
		if(c[i]=='R'){
			r++;
		}
		a[i]=r;
	}
	cout<<r-a[r-1];
}



Measured memory_bytes: 4440
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <stack>
using namespace std;
int main(){
  int a,b;
  char ch[1000];
  stack<int> S;
  while(scanf("%s",ch)!=EOF){
    if(ch[0]=='+'){
      a=S.top();S.pop();
      b=S.top();S.pop();
      S.push(a+b);
    } else if(ch[0]=='-'){
      b=S.top();S.pop();
      a=S.top();S.pop();
      S.push(a-b);
    } else if(ch[0]=='*'){
      a=S.top();S.pop();
      b=S.top();S.pop();
      S.push(a*b);
    } else {
      S.push(atoi(ch));
    }
  }
  printf("%d\n",S.top());
  return 0;
}

Measured memory_bytes: 3204
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string.h>
#include <deque>
#define REP(i,j,n) for(int i=j;i<n;i++)
#define SORT(x) sort(x.begin(),x.end())

using namespace std;

int main() {
	int n, m, sum = 0,allsum=0;
	cin >> n >> m;
	vector<vector<int>> v(n+1, vector<int>(m+1));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> v[i][j];
			sum += v[i][j];
		}
		v[i][m] = sum;//right
		allsum += sum;
		sum = 0;
	}
	v[n][m] = allsum;

	for (int i = 0; i < m; i++) {
		for (int j = 0; j < n; j++) {
			sum += v[j][i];
		}
		v[n][i] = sum;
		sum = 0;
	}

	for (int i = 0; i < n + 1; i++) {
		for (int j = 0; j < m + 1; j++) {
			if (j != m) cout << v[i][j] << " ";
			else cout << v[i][j] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
#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 (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int main(){
	int A,B,C;
	cin>>A>>B>>C;
	cout<<max(max(A*10+B+C,A+B*10+C),A+B+C*10)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
const in INF=1<<30;
#define vec2(a,y,x) vector<vector<int>> a(y,vector<int>(x))
#define vec1(a,n) vector<int> a(n);rep(i,n)cin>>a[i]

int main(){
int a,b;
  string s,t,u;
  cin>>s>>t>>a>>b>>u;
  if(s==u) a --;
  if(t==u) b --;
  cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
/*
AizuOnline A0072
Title Lantern

*/
#include <stdio.h>
// Select Below
#include <stdlib.h>
#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
#define TOWN 100
#define MAXBRIDGE (TOWN*(TOWN-1)/2)
int n,m;
struct b_st {int a;  //from
  int b;             //to
  int cost;} bridge[MAXBRIDGE];
int c_f[TOWN];
//
comp(void *a,void *b)
{
  return(((struct b_st *)a)->cost - ((struct b_st *)b)->cost);
}
int nearest(int * t_cost)
{
  int i;

  for(i=0;i<m;i++)
    if(c_f[bridge[i].a]+c_f[bridge[i].b]==1)
      {
	*t_cost += (bridge[i].cost/100-1);
#ifdef DEBUG
	printf("%d %d %d\n",bridge[i].a,bridge[i].b,bridge[i].cost);
#endif
	if(c_f[bridge[i].a])
	  return(bridge[i].b);
	else
	  return(bridge[i].a);
     }
}
int total_cost()
{
  int i,t,t_cost;
  
  c_f[0]=1;t_cost=0;
  for(i=1;i<n;i++)
    {
      t=nearest(&t_cost);
      c_f[t]=1;
    }
  return(t_cost);
}
main()
{
  int i;
  int ret;

  while(EOF!=scanf("%d ",&n) && n)
    {
      scanf("%d ",&m);
      for(i=0;i<m;i++)
	scanf("%d,%d,%d",&(bridge[i].a),&(bridge[i].b),&(bridge[i].cost));
      memset(c_f,0,sizeof(c_f));
      qsort(bridge,m,sizeof(struct b_st),(__compar_fn_t)comp);
      ret=total_cost();
      printf("%d\n",ret);
    }
return(0);
}

Measured memory_bytes: 756
N = int(input())
a = [0] + list(map(int, input().split()))
b = [0]*(N+1)

for i in range(N, 0, -1):
  sum = 0
  for j in range(i+i, N+1, i):
    sum ^= b[j]
  b[i] = sum ^ a[i]

ans = []
for i in range(1, N+1):
  if b[i] == 1:
    ans.append(i)

count = len(ans)
print(count)
for i in range(0, count):
  if i == count - 1:
    print(ans[i])
  else:
    print(ans[i], end=" ")


Measured memory_bytes: 12460
import math
n = int(input())
sq = math.floor(pow(n, 0.5))
ans = []
for i in range(2, sq + 1):
    if n % i == 0:
        ans.append((i - 1) + ((n // i) - 1))
if len(ans) > 0:
    print(min(ans))
else:
    print(n - 1)


Measured memory_bytes: 3060
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=1; i<=N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

//最大公約数GCD
ll gcd_ori(ll a, ll b){
    if(a<b) swap(a, b);
    if(b == 0){
        return a;
    }

    return gcd_ori(b, a % b);
}

int main() {
   int k; cin >> k;
   ll sum = 0;
   rep(i, k){
      rep(j, k){
         rep(l, k){
           sum += gcd_ori(i, gcd_ori(j, l)); 
         }
      }
   }
   cout << sum << endl;
   return 0;
}


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

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

  std::vector<int> pn(n);

  for (auto &p : pn) {
    std::cin >> p;
  }

  int count = 0;
  for (int i = 0; i < n; ++i) {
    if (pn[i] != i + 1) {
      ++count;
    }
  }

  if (count == 2 || count == 0) {
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
cards = {}
%w(S H C D).each do |mark|
     for num in 1..13
        k = "#{mark} #{num}"
        cards[k] = false
    end
end

n = gets.chomp.to_i
n.times do |i|
    card = gets.chomp
    cards[card] = true
end

cards.select!{|k,v|
    puts k unless v
}

Measured memory_bytes: 6096
#include <stdio.h>

int stack1[ 50 ], stack2[ 49 ], stack3[ 50 ];
int sp1, sp2 = 0, sp3 = 0;

int main( void ) {
	int i, n, r, p, c;

	for ( ; scanf( "%d %d", &n, &r ), n; printf( "%d\n", stack1[ n - 1 ] ) ) {
		sp1 = 0;

		for ( i = 1; i <= n; i++ )
			stack1[ sp1++ ] = i;

		while ( r-- ) {
			scanf( "%d %d", &p, &c );

			while ( p-- - 1 )
				stack2[ sp2++ ] = stack1[ --sp1 ];

			while ( c-- )
				stack3[ sp3++ ] = stack1[ --sp1 ];

			while ( sp2 )
				stack1[ sp1++ ] = stack2[ --sp2 ];

			while ( sp3 )
				stack1[ sp1++ ] = stack3[ --sp3 ];
		}
	}

	return 0;
}

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

#define int long long
#define double long double

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e18;
const int MOD = 1e9+7;

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

vi node;

int root(int x)
{
    if(node[x] == x) return x;
    return node[x] = root(node[x]);
}

bool same(int x, int y)
{
    return root(x) == root(y);
}

void unite(int x, int y)
{
    int rx = root(x);
    int ry = root(y);
    node[rx] = ry;
}

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    using edge = tuple<int, int, int>;
    int N; cin >> N;
    node.resize(N); REP(i, N) node[i] = i;
    vpi x(N), y(N);
    REP(i, N)
    {
        int a, b; cin >> a >> b;
        x[i] = mp(a, i);
        y[i] = mp(b, i);
    }
    sort(ALL(x));
    sort(ALL(y));

    vector<edge> edges;
    REP(i, N-1)
    {
        edges.pb(edge(x[i+1].fi-x[i].fi, x[i].se, x[i+1].se));
        edges.pb(edge(y[i+1].fi-y[i].fi, y[i].se, y[i+1].se));
    }
    sort(ALL(edges));

    int ans = 0;
    REP(i, edges.size())
    {
        if(!same(get<1>(edges[i]), get<2>(edges[i])))
        {
            ans += get<0>(edges[i]);
            unite(get<1>(edges[i]), get<2>(edges[i]));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 12528
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < n; i++)
#define int long long
signed main(signed argc, char* argv[]) {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, u, v;
	cin >> n >> u >> v;
	vector<vector<int>> e(n + 1);
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	vector<int> memo_v(n+1);
	vector<bool> vec(n+1,false);
	queue<int> que;
	que.push(v);
	vec[v]=true;
	memo_v[v]=0;
	while(!que.empty()){
	    int it=que.front();que.pop();
	    rep(i,e[it].size()){
	        if(vec[e[it][i]])continue;
            vec[e[it][i]]=true;
            memo_v[e[it][i]]=memo_v[it]+1;
            que.push(e[it][i]);
	    }
	}
	vector<int> memo_u(n+1);
	vec=vector<bool>(n+1,false);
	que.push(u);
	vec[u]=true;
	memo_u[u]=0;
    while(!que.empty()){
        int it=que.front();que.pop();
        rep(i,e[it].size()){
            if(vec[e[it][i]])continue;
            vec[e[it][i]]=true;
            memo_u[e[it][i]]=memo_u[it]+1;
            que.push(e[it][i]);
        }
    }

	int ans=0;
    rep(i,n){
        if(e[i+1].size()==1){
            if(memo_v[i+1]-memo_u[i+1]>0){
                ans=max(ans,memo_v[i+1]-1);
            }
        }
    }
    cout<<ans<<endl;
}


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

typedef vector<int> VI;
typedef vector<VI> VVI;

int H, W, C;
VVI p;

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

int ans;

inline bool inF(int x, int y) {
  return 0<=x && x<W && 0<=y && y<H;
}

void dfs2(int x, int y, int now, int next) {
  
  p[y][x] = next;
    
  for(int i=0; i<4; i++) {
    int nx = x+dx[i], ny = y+dy[i];
    if(inF(nx, ny) && p[ny][nx] == now) {
      dfs2(nx, ny, now, next);
    }
  }
}

vector<vector<bool> > vis;
int cnt_panel(int x, int y) {
  int res = 0;
  vis[y][x] = true;
  for(int i=0; i<4; i++) {
    int nx = x+dx[i], ny = y+dy[i];
    if(inF(nx, ny) && !vis[ny][nx] && p[ny][nx] == C) {
      res += cnt_panel(nx, ny);
    }
  }
  return res+1;
}

void change(int cnt) {
  if(cnt == 5) {
    vis.clear(); vis.resize(H); for(int i=0; i<H; i++) vis[i].resize(W);
    ans = max(ans, cnt_panel(0, 0));
    return;
  }
  
  if(cnt == 4) {
    if(p[0][0] == C) return;
    dfs2(0, 0, p[0][0], C);
    change(cnt+1);
  }
  else {
    VVI tmp(p);
    for(int next=1; next<=6; next++) {
      if(p[0][0] == next) continue;
      dfs2(0, 0, p[0][0], next);
      change(cnt+1);
      p = tmp;
    }
  }
  
}

int main() {
  
  for(;cin >> H >> W >> C && (H|W|C);) {
    p.clear();
    p.resize(H); for(int i=0; i<H; i++) p[i].resize(W);
    for(int i=0; i<H; i++)
      for(int j=0; j<W; j++)
        cin >> p[i][j];
    
    ans = 0;
    change(0);
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,s1,s3,s2;
	char A=0,B=0,C=0;
	int x=0,n,m;
	getline(cin,s);
	int len=s.length();
	for(int z=0;z<len;z++)
    {
        A=toupper(s[0]);
        if(s[z]==32&&x==0)
        {
            B=toupper(s[z+1]);
            x=1;
        }
        if(x==1&&s[z]==32)
        {
            C=toupper(s[z+1]);
            x==2;
        }
        if(x==2)
            break;
    }
    cout<<A<<B<<C;
}


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;

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

    int N;
    cin >> N;
    if (N/10==9 || N%10==9)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
#include <sstream>
typedef long long ll;
int main(){
string s;
	cin>>s;
	for (int i = s.length()-1; i >= 0; --i) {
		cout<<s[i];
	}
	cout<<endl;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
const double eps = 1e-8;
const int MOD = 1000000007;
// int main() {
//     cin.tie(0);
//     ios::sync_with_stdio(false);
//     cout << fixed << setprecision(10);
//
// }
ll powm(ll a, ll n, ll m) {
    ll ret = 1;
    while (n > 0) {
        if (n & 1) (ret *= a) %= m;
        (a *= a) %= m;
        n >>= 1;
    }
    return ret;
}
ll invm(ll a, ll m) {
    return powm(a, m-2, m);
}
vector<ll> fact;
void init_fact(int n, ll m) {
    fact.assign(n+1, 1);
    for (int i = 2; i <= n; ++i) {
        (fact[i] = fact[i-1] * i) %= m;
    }
}
// require init_fact(GREATER THAN OR EQUAL TO n, m)
ll C(ll n, ll r, ll m) {
    return (fact[n] * invm((fact[r] * fact[n-r]) % m, m)) % m;
}
// Stirling number
// Stirling(n, k) := the number of cases
//            to split n balls(distinguished)
//            into k boxes(not distinguished)
//            s.t. each box contains at least one ball.
//
// require init_fact(GREATER THAN OR EQUAL TO k, m)
ll Stirling(ll n, ll k, ll m) {
    ll ret = 0;
    for (ll l = 0; l <= k; ++l) {
        ll tmp = (C(k, l, m) * powm((k-l) % m, n, m)) % m;
        if (l & 1) tmp = (-tmp + m) % m;
        (ret += tmp) %= m;
    }
    return (ret *= invm(fact[k], m)) %= m;
}
// Bell number
// Bell(n, k) := the number of cases
//            to split n balls(distinguished)
//            into k boxes(not distinguished)
//
// require init_fact(GREATER THAN OR EQUAL TO k, m)
ll Bell(ll n, ll k, ll m) {
    ll ret = 0;
    for (ll l = 0; l <= k; ++l) {
        (ret += Stirling(n, l, m)) %= m;
    }
    return ret;
}
// Partition function
// Partition[k][n] := the number of cases
//            to split n balls(not distinguished)
//            into k boxes(not distinguished)
vector<vector<ll>> Part;
void init_partition(ll k, ll n, ll m) {
    Part.assign(k+1, vector<ll>(n+1, 0));
    Part[0][0] = 1;
    for (int i = 1; i <= k; ++i) {
        for (int j = 0; j <= n; ++j) {
            if (j-i >= 0) {
                Part[i][j] = (Part[i-1][j] + Part[i][j-i]) % m;
            } else {
                Part[i][j] = Part[i-1][j];
            }
        }
    }
}
int main() {
    ll n, k; cin >> n >> k;
    const ll mod = 1e9+7;
    init_fact(k, mod);
    cout << Bell(n, k, mod) << endl;
}



Measured memory_bytes: 3136
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n; cin >> n;
  rep(i, n+1) {
    if (i * 108 / 100 == n) {
      cout << i << endl;
      return;
    }
  }
  cout << ":(" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int r; scanf("%d", &r);
	
	printf("%d\n", 3 * r * r);
	return 0;
}


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

int main() {
  int N,M;
  cin>>N>>M;
  vector<pair<int, int>> a;
  for (int i=0;i<N;i++){
    a.push_back(make_pair(0,0));
  }
  for(int i=0;i<M;i++){
    int q;
    string S;
    cin>>q>>S;
    if(a.at(q-1).second==0&&S=="WA"){
      a.at(q-1).first+=1;
    }
    if(a.at(q-1).second==0&&S=="AC"){
      a.at(q-1).second=1;
    }
  }
  int wa=0,ac=0;
  for(int i=0;i<N;i++){
    wa+=a.at(i).first*a.at(i).second;
    ac+=a.at(i).second;
  }
  cout<<ac<<" "<<wa<<endl;
}

Measured memory_bytes: 1400
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n;
    cin >> n;
    long long sum = 0;
    rep(i, 1, n + 1)
    {
        if (not((i % 3 == 0) or (i % 5 == 0)))
        {
            sum += i;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3636
#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;

int main()
{
	string S;
	cin >> S;
	if (S[0] != 'A')
	{
		cout << "WA" << endl;
		return 0;
	}
	else
	{
		int cnt = 0;
		for (int i = 2; i < S.size()-1; ++i)
		{
			if (S[i] == 'C') cnt++;
		}

		if (cnt != 1)
		{
			cout << "WA" << endl;
			return 0;
		}
		else
		{
			cnt = 0;
			rep(i,S.size())
			{
				if (S[i]-'A' >= 0 && S[i]-'A' <= 25) cnt++;
			}
			if (cnt != 2)
			{
				cout << "WA" << endl;
				return 0;
			}
		}
		cout << "AC" << endl;
		return 0;
	}
	return 0;
}

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

const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
	int sx, sy, tx, ty;
    cin >> sx >>  sy >> tx >> ty;
    char fx, bx, fy, by;
    if(sx <tx){fx='R';bx='L';}
    else{fx='L';bx='R'; swap(sx, tx);}
    if(sy < ty){fy='U';by='D';}
    else{fy='D';by='U';swap(sy,ty);}

    for(int i = 0; i < ty-sy; ++i){
    	cout << fy;
    }
    for(int j = 0; j < tx-sx; ++j){
    	cout << fx;
    }
    for(int i = 0; i < ty-sy; ++i){
    	cout << by;
    }
    for(int j = 0; j < tx-sx; ++j){
    	cout << bx;
    }
    
    cout << bx;
    for(int i = 0; i < ty-sy+1; ++i){
    	cout << fy;
    }
    for(int j = 0; j < tx-sx+1; ++j){
    	cout << fx;
    }
    cout << by;
    cout << fx;
    for(int i = 0; i < ty-sy+1; ++i){
    	cout << by;
    }
    for(int j = 0; j < tx-sx+1; ++j){
    	cout << bx;
    }
    cout << fy << endl;
}

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

#define HUNDRED 100
#define THOUSAND 10000
#define TENTHOUSAND 10000
#define HUNDREDTHOUSAND 100000

int main() {
	int n;
	int a[THOUSAND];
	int b[THOUSAND];
	int c[THOUSAND];
	vector<int> v(THOUSAND , 0);
	int sum = 0;

	cin >> n;

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

		c[i] = b[i] - a[i] + 1;

		sum += c[i];
	}

	cout << sum;



}


Measured memory_bytes: 256
N = int(input())
TA = []
for i in range(N):
    TA.append(list(map(int,input().split())))

L = [[0]*2 for i in range(N)]

L[0][0] = TA[0][0]
L[0][1] = TA[0][1]

for i in range(1,N):
    T = TA[i][0]
    A = TA[i][1]
    Tm = L[i-1][0]
    Am = L[i-1][1]

    Tamari = Tm%T
    if Tamari==0:
        Tn = Tm
    else:
        Tn = Tm + (T-Tamari)

    Aamari = Am%A
    if Aamari==0:
        An = Am
    else:
        An = Am + (A-Aamari)

    if T<A:
        L[i][0],L[i][1] = Tn,Tn//T*A
        if L[i][1]<L[i-1][1]:
            L[i][0],L[i][1] = An//A*T,An
    elif T>A:
        L[i][0],L[i][1] = An//A*T,An
        if L[i][0]<L[i-1][0]:
            L[i][0],L[i][1] = Tn,Tn//T*A
    else:
        L[i][0],L[i][1] = max(L[i-1][0],L[i-1][1]),max(L[i-1][0],L[i-1][1])

print(L[-1][0]+L[-1][1])

Measured memory_bytes: 39280