akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include<queue>
#include <sstream>
#include <set>
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
using namespace std;
int main(){
    vector<int>vec(3);
    REP(i,3) cin >> vec[i];
    int cnt =0;
    SORT(vec);

    int min,mid,max;
    min = vec[0]; mid = vec[1]; max = vec[2];
    swap(vec[1],vec[2]);
    bool fl = true;
    while(fl){

        int x = vec[1] - vec[0];
        int y = vec[1] - vec[2];
        
        int a = guki(x);
        int b = guki(y);

        if(a != b){
            if(a==0) {vec[1]++; vec[2]++;}
            else {vec[0]++; vec[1]++;}
        }else if((a==0)&&(a==b)){
            cout << cnt + (x + y)/2 <<endl;
            return 0;
        }else{
            vec[0]++;
            vec[2]++;
        }

        if((vec[0]==vec[1])&&(vec[1]==vec[2])){
            fl = false;
        }
        cnt ++;
        


    }

    cout << cnt << endl;
}

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

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;
const ll INF = 1e9 + 7;

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


/////////////////////////////////////////////////////////////////////////////////////////

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

    return 0;
}


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

int64_t MOD = 1e9+7;

//---------- べき乗 ----------
int64_t power(int64_t a, int64_t n){
    if(n == 0) return 1;

    int64_t res = 1;
    while(n > 0){
        if(n % 2 == 1) res = res * a % MOD;
        a = a * a % MOD;
        n /= 2;
    }

    return res;
}

//---------- 逆元 ----------
int64_t inv(int64_t a){
    return power(a, MOD-2);
}


//--------- 組み合わせ ---------
int64_t comb(int64_t n, int64_t r){
  int64_t bunbo = 1, bunshi = 1;

  for(int i=0; i<r; i++){
    bunbo = bunbo * (r-i) % MOD;
    bunshi = bunshi * (n-i) % MOD;
  }

  return bunshi * inv(bunbo) % MOD;
}


int main(){
  int64_t N, A, B;
  cin >> N >> A >> B;
//  cout<<comb(N,A)<<" : " <<comb(N,B)<<endl;
//  cout <<power(2,N)<<endl;

  int64_t ans = power(2, N) - comb(N, A) - comb(N, B) - 1;
  while(ans < 0) ans += MOD;

  cout << ans << endl;
}


Measured memory_bytes: 256
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import copy as cp
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

n,a = imap()
x = np.array(iarr()) - a

# dp[i][和 + NA]
# 本来のSの範囲は、1N-NAから50N-NA
# 負の数はdp範囲外なのでNAたすと、1Nから50N
# 和０のときは dp[n][0+NA]
dp = np.zeros((n+1, 50*n+100)).astype(int)
dp[0][n*a] = 1

for i in range(n):
    for s in range(50*n+1):
        dp[i+1][s] = dp[i][s] + dp[i][s-x[i]] if s-x[i]>=0 else dp[i][s]

ans = dp[n][n*a] - 1 #実際は初期条件の０個選ぶパターンを除外
print(ans)




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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
map<string,ll> M;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>s;
		sort(ALL(s));
		M[s]++;
	}
	ll ret=0;
	FORR(m,M) {
		ret+=m.second*(m.second-1)/2;
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 11264
import numpy as np
import pprint
import itertools

c = []
for i in range(3):
    c.append([int(n) for n in input().split()])

C = np.asarray(c)

A = np.asarray([0, -1, -1])
B = C[0]

for i in range(1, 3):
    A[i] = C[i][0] - B[0]

yes = True
for i, j in itertools.product(range(3), range(3)):
    if A[i] + B[j] != C[i][j]:
        yes = False
        break

print('Yes' if yes else 'No')

Measured memory_bytes: 14456
import java.util.Scanner;

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

        if (a == 5 && b == 7 && c == 5) {
            System.out.println("YES");
        }
        else if (a == 7 && b == 5 && c == 5) {
            System.out.println("YES");
        }
        else if (a == 5 && b == 5 && c == 7) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }

    }
}

Measured memory_bytes: 25044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>

using namespace std;

int gcd(int n, int m) {
    if (n == 0) return m;
    return gcd(m % n, n);
}

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

    double win = 0;
    if (n >= k) {
        win = (double) (n - k + 1) / n;
        for (int i = 1; i < k; ++i) {
            win += 1.0 / n * pow(0.5, ceil(log2((double)k / i)));
        }
    } else {
        for (int i = 1; i <= n; ++i) {
            win += 1.0 / n * pow(0.5, ceil(log2((double)k / i)));
        }
    }

    printf("%.12f\n", win);
}


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

string s[500],b[500],r[500];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)
		cin>>s[i];
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			b[i]+=".",r[i]+=".";
	for(int i=0;i<n;i++)
		b[i][0]='#',r[i].back()='#';
	for(int i=0;i<n;i++)
		for(int j=1;j<m-1;j++)
			if(i&1)
				b[i][j]='#';
			else
				r[i][j]='#';
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			if(s[i][j]=='#')
				b[i][j]=r[i][j]='#';
	for(int i=0;i<n;i++)
		cout<<b[i]<<'\n';
	cout<<'\n';
	for(int i=0;i<n;i++)
		cout<<r[i]<<'\n';
	
}



Measured memory_bytes: 1536
#include <iostream>
#include <array>
//ヒットの数を数え上げる
int checkNumOfHit(std :: array<int, 4> x, std :: array<int, 4> y){
    int num = 0;
    for(int i = 0;i < 4;i++){
        if(x.at(i) == y.at(i)) num++;
    }
    return num;
}

//ブローの数を数え上げる
int checkNumOfBlow(std :: array<int, 4> x, std :: array<int, 4> y){
    int num = 0;
    for(int i = 0;i < x.size();i++){
        for(int j = 0;j < y.size();j++){
            if((i != j) && (x.at(i) == y.at(j))) num++;
        }
    }
    return num;
}
int main(){
    std :: array<int, 4> a, b;
    while(std :: cin >> a.at(0) >> a.at(1) >> a.at(2) >> a.at(3)>> b.at(0) >> b.at(1) >> b.at(2) >> b.at(3)){  
        std :: cout << checkNumOfHit(a, b) << " " << checkNumOfBlow(a, b) << std :: endl;
    }
}


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





int main() {

  int n;
  cin>>n;
  
  vector<vector<int>> data(26,vector<int>(n,0));
  
  for (int i=0;i<n;i++){
    
    string si;
    
    cin>>si;
    
    int size=int(si.size());
    
    for (int j=0;j<26;j++){
      
      int count=0;
      
      for (int k=0;k<size;k++){
        if (si.at(k)==(char)('a'+j)){
          count++;
        }
      }
      
      data.at(j).at(i)=count;
    }
  }
  
  for (int i=0;i<26;i++){
    sort(data.at(i).begin(),data.at(i).end());
    int tmp;
    tmp=data.at(i).at(0);
    
    for (int k=0;k<tmp;k++){
      cout<<(char)('a'+i);
    }
  }
  
  cout<<endl;
  
     
    
}












Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
ll MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}
ll modpow(ll x, ll y, ll m) {
    if (y == 0) return 1;
    ll res = modpow(x, y / 2, m);
    return res * res % m * (y & 1 ? x : 1) % m;
}
ll modinv(ll x) { return modpow(x, MOD - 2, MOD); }

ll func(ll N, ll x){
    ll s = 1,t = 1;
    rep1(i,x){
        s *= (N-i+1) % MOD;
        t *= i % MOD;
        s %= MOD;
        t %= MOD;
    }
    return (s * modinv(t)) % MOD;
}


int main(){
    ll N,a,b; cin >> N >> a >> b;
    ll ans = modpow(2,N,MOD);
    ans += MOD - 1;
    ans %= MOD;
    
    ans += MOD - func(N,a);
    ans %= MOD;
    
    ans += MOD -func(N,b);
    ans %= MOD;
    
    print(ans);
    
    return 0;
}

Measured memory_bytes: 256
#include <cassert>
#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>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#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>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#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>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
// const ll mod = 1000000007;
const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

bool solve(){
    ll n;cin>>n;
    string s;cin>>s;
    vector<ll>black(n+1,0);
    vector<ll>white(n+1,0);
    rep(i,n){
        black[i+1]=black[i]+(s[i]=='#');
        white[i+1]=white[i]+(s[i]=='.');
    }
    ll ans=INF;
    rep(i,n+1){
        chmin(ans,black[i]+white[n]-white[i]);
    }
    cout<<ans<<endl;
    return false;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(30);
    solve();
}


Measured memory_bytes: 3732
# Author: cr4zjh0bp
# Created: Sat Mar  7 11:50:59 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

s = ns()
ans = "No"
for i in range(len(s) - 1):
    if s[i] != s[i + 1]:
        ans = "Yes"

print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    vec<vec<char> > v(n+2,vec<char>(m+2));
    vec<vec<int> > ans(n+2,vec<int>(m+2,0));

    rep(i,1,n+1){
        rep(j,1,m+1){
            cin>>v[i][j];
            rep(k,-1,2){
                rep(l,-1,2){
                    if(v[i][j]=='#'){
                        if(k!=0||l!=0)ans[i+k][j+l]++;
                    }
                }
            }
        }
    } 
    rep(i,1,n+1){
        rep(j,1,m+1){
            if(v[i][j]=='.')cout<<ans[i][j];
            else cout<<'#';
        }
        cout<<endl;
    }
    
    return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    if(a<=b)
      cout<<min(b/a,c);
    else
      cout<<"0"<<endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
a,b,c = map(int,input().split())
k = int(input())
print((2**k-1)*max([a,b,c])+sum([a,b,c]))

Measured memory_bytes: 3060
import java.util.Scanner;

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

	int n = sc.nextInt();
	int k = sc.nextInt();

	int x = 1;
	for(int i = 0; i < n; i++) {
	    if(x < k) x *= 2;
	    else      x += k;
	}

	System.out.println(x);
    }
}


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


int main() {
  int n, m;
  cin >> n >> m;
  int ans = (n-1) * (m-1);
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int count = 0;
  
  for(int i = 0; i < S.length(); i++){
  	if(S.at(i) == 'o'){
    	count++;
    }
  }
  if(15 - S.length() >= 8 - count){
  	cout << "YES" << endl;
  }else{
  	cout << "NO" << endl;
  }
}

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

#define ll long long
#define nl '\n'
#define deb(x) cerr<<#x" = "<<x<<nl
#define in() ( { int a ; scanf("%d", &a); a; } )

const int N = 3e5 + 9;
const int mod = 1e9 + 7;

int32_t main()
{
    int n; cin >> n; cout << (n + 1) / 2 << nl;
    return 0;
}


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

int main()
{
    int n,i,a[200000],flag=1;
    cin>>n;
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    i=0;
    while(i!=n-1)
    {
        if(a[i]==a[i+1])
        {
            flag=0;
            break;
        }
        i++;
    }
    if(flag==0)
        cout<<"NO\n";
    else
        cout<<"YES\n";

    return 0;
}


Measured memory_bytes: 1024
#abc091c

N=int(raw_input())
ab=[]
cd=[]
for i in xrange(N):
 ab.append(map(int,raw_input().split()))
for i in xrange(N):
 cd.append(map(int,raw_input().split()))
ab.sort(key=lambda x:x[1],reverse=True)
cd.sort()
for c,d in cd:
 for a,b in ab:
  if a<c and b<d:
   ab.remove([a,b])
   break
print N-len(ab)


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
//const int mod = 1000000007;
const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  string s; cin >> s;
  if(s.back() != 's') s += "s";
  else s += "es";
  cout << s << endl;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int N, M;
    cin >> N >> M;
    int p[N];
    REP(i, N)
    {
        cin >> p[i];
        p[i]--;
    }

    UnionFind tree(N);
    int x, y;
    REP(i, M)
    {
        cin >> x >> y;
        x--;
        y--;
        // 同じ根となるように併合
        tree.unite(x, y);
    }

    int ans = 0;
    REP(i, N)
    {
        // iとp[i]が同じグループなら、連結成分内の入れ替えてp[i]=iとできる
        if (tree.same(i, p[i])) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int n,a[105],x[105],sum;
int main(){
	cin>>n;
	for(int i=1;i<n;i++)	cin>>a[i];
	a[0]=a[n]=0x3f3f3f3f;
	for(int i=1;i<=n;i++)	x[i]=min(a[i-1],a[i]),sum+=x[i];
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
typedef long long lint;

inline lint Bsize(lint n) { return (1LL << (n + 2)) - 3; }
inline lint patty(lint n) { return (1LL << (n + 1)) - 1; }

lint dfs(lint N, lint X) {

	if (X <= 1) return N == 0 && X == 1 ? 1LL : 0LL;
	else if (X <= Bsize(N - 1) + 1) return dfs(N - 1, X - 1);
	else if (X != Bsize(N)) return patty(N - 1) + dfs(N - 1, X - 2 - Bsize(N - 1)) + 1;
	else return 2 * patty(N - 1) + 1;

}

int main() {

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

	lint N, X;
	cin >> N >> X;

	cout << dfs(N, X) << "\n";

	return 0;
}


Measured memory_bytes: 256
import Data.List
import Data.Array.IArray

solve h k i = h!(i+k-1) - h!i 

main :: IO ()
main = do
    [n,k] <- map read . words <$> getLine :: IO [Int]
    h <- map read . lines <$> getContents :: IO [Int]
    let h' = listArray (0,n-1) (sort h) :: Array Int Int
    print . minimum $ map (solve h' k) [0..n-k]


Measured memory_bytes: 18684
#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()
{
	int A,B;
	cin >> A >> B;
	for (int i = 1; i <= 1500; ++i)
	{
		int tax8 = i * 8 / 100, tax10 = i * 10 / 100;
		if (tax8 == A && tax10 == B)
		{
			cout << i << endl;
			return 0;
		}
	}
	cout << "-1" << endl;
	return 0;
}

Measured memory_bytes: 3568
#include <iostream>
using namespace std;
 
int main()
{
    while(true){
        int h, w;
        cin >> h >> w;
 
        if(h==0 && w==0)
            break;
 
        int d = h*h+w*w;
 
        int H = 150;
        int W = 150;
        int D = 150*150+150*150;
 
        for(int y=1; y<=150; y++){
            for(int x=y+1; x<=150; x++){
                int z = y*y+x*x;
 
                if(z<=d){
                    continue;
                }
                else{
                    if(z<D){
                        H = y;
                        W = x;
                        D = z;
                    }
                    break;
                }
            }
        }
 
        for(int y=h+1; y<150; y++){
            bool flg = false;
 
            for(int x=y+1; x<=150; x++){
                int z = y*y+x*x;
 
                if(z==d){
                    H = y;
                    W = x;
                    D = z;
 
                    flg = true;
                }
 
                if(z>=d)
                    break;
            }
 
            if(flg)
                break;
        }
 
        cout << H << ' ' << W << endl;
    }
 
    return 0;
}


Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll maxi=a*c;
  chmax(maxi,a*d);
  chmax(maxi,b*c);
  chmax(maxi,b*d);
  print(maxi);
}


Measured memory_bytes: 3600
#include <iostream>
#include <cmath>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <vector>

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

using namespace std;
typedef unsigned long long ul;
typedef long long ll;
typedef pair<int, int> PAIR;

int main() {
  ll N, ga, gb, sa, sb, ba, bb;
  cin >> N;
  cin >> ga >> sa >> ba >> gb >> sb >> bb;
  ll gA = gb - ga;
  ll sA = sb - sa;
  ll bA = bb - ba;
  vector<ll> vals;
  vals.resize(N+1);
  vals[0] = 0;
  FOR (i, 1, N+1) {
    ll valA = i >= ga ? vals[i-ga] + gA : 0;
    ll valB = i >= sa ? vals[i-sa] + sA : 0;
    ll valC = i >= ba ? vals[i-ba] + bA : 0;
    ll val0 = vals[i-1];
    vals[i] = max(valA, max(valB, max(valC, val0)));
  }
  N = vals[N] + N;

  vals.clear();
  vals[0] = 0;
  vals.resize(N+1);
  FOR (i, 1, N+1) {
    ll valA = i >= gb ? vals[i-gb] - gA : 0;
    ll valB = i >= sb ? vals[i-sb] - sA : 0;
    ll valC = i >= bb ? vals[i-bb] - bA : 0;
    ll val0 = vals[i-1];
    vals[i] = max(valA, max(valB, max(valC, val0)));
  }

  N = vals[N] + N;
  cout << N;
  return 0;
}


Measured memory_bytes: 195584
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		String[] a = new String[h];
		String[] aa = null;
		List<Integer> line = new ArrayList<>();
		List<Integer> column = new ArrayList<>();
		for (int i = 0; i < h; i++) {
			a[i] = sc.next();
			if (a[i].indexOf('#') > -1) {
				line.add(i);
			}
		}
		for (int i = 0; i < w; i++) {
			for (int j = 0; j < line.size(); j++) {
				if (a[line.get(j)].charAt(i) == '#') {
					column.add(i);
					break;
				}
			}
		}
		String ans = "";
		for (int i = 0; i < line.size(); i++) {
			for (int j = 0; j < column.size(); j++) {
				ans += a[line.get(i)].charAt(column.get(j));
			}
			System.out.println(ans);
			ans = "";
		}
	}
}


Measured memory_bytes: 28844
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;
const LL MOD = 1e9 + 7;
void solve(int u, int p, auto &G, auto &dp) {
    for (auto &v : G[u]) {
        if (v == p)
            continue;
        solve(v, u, G, dp);
        (dp[u][0] *= (dp[v][0] + dp[v][1]) % MOD) %= MOD;
        (dp[u][1] *= dp[v][0]) %= MOD;
    }
}
void marmot0814() {
    int n; cin >> n;
    vector<vector<int>> G(n);
    for (int i = 1 ; i < n ; i++) {
        int u, v; cin >> u >> v; u--, v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    vector<vector<LL>> dp(n, vector<LL>(2, 1));
    solve(0, 0, G, dp);
    cout << (dp[0][0] + dp[0][1]) % MOD << '\n';
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int t = 1, kase = 0; // cin >> t;
    while (t--) {
        // cout << "Case #" << ++kase << ":";
        marmot0814();
    }
}

Measured memory_bytes: 21092
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;


int main(){

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

    vector<int> cntR(n + 1);
    vector<int> cntG(n + 1);
    vector<int> cntB(n + 1);

    for(int i = 0; i < n; i++){
        cntR[i + 1] = cntR[i];
        cntG[i + 1] = cntG[i];
        cntB[i + 1] = cntB[i];
        
        if( s[i] == 'R' ) cntR[i + 1] ++;
        if( s[i] == 'G' ) cntG[i + 1] ++;
        if( s[i] == 'B' ) cntB[i + 1] ++;
    }

    ll ans = 0;
    for(int i1 = 0; i1 < n; i1++){
        for(int i2 = i1 + 1; i2 < n; i2++){
            if(s[i1] == s[i2]) continue;
            char c;
            if( s[i1] != 'R' && s[i2] != 'R' ) c = 'R';
            if( s[i1] != 'G' && s[i2] != 'G' ) c = 'G';
            if( s[i1] != 'B' && s[i2] != 'B' ) c = 'B';

            ll tmp;
            if( c == 'R' ){
                tmp = cntR[n] - cntR[i2 + 1];
            }
            if( c == 'G' ){
                tmp = cntG[n] - cntG[i2 + 1];
            }
            if( c == 'B' ){
                tmp = cntB[n] - cntB[i2 + 1];
            }

            ans += tmp;
            if( i2 + i2 - i1 < n ){
                if(s[i2 + (i2 - i1) ] == c) ans --;
            }

        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

void rwFile() {
    freopen("INP.inp", "r", stdin);
    freopen("OUT.out", "w", stdout);
}

void solveA() {
    int m, n; cin >> m >> n;
    if (m == n) cout << "Yes";
    else cout << "No";
}

void solveB() {
    int a, b; cin >> a >> b;
    if (a > b) swap(a, b);
    for (int i = 0; i < b; i++) cout << a;
}

void solveC() {
    int n; cin >> n;
    int minn = 1e9, res = 0;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] <= minn) res++;
        minn = min(a[i], minn);
    }
    cout << res;
}

const int maxN = 1e6 + 1;
const long long MOD = 1e9 + 7;
int prime[maxN];

void Seive() {
    for (int i = 2; i < 1000; i++) {
        if (prime[i] == 0) {
            for (int j = i * i; j < maxN; j += i) prime[j] = i;
        }
    }
    for (int i = 2; i < maxN; i++) {
        if (prime[i] == 0) prime[i] = i;
    }
}

long long Pow(int b, int e = MOD - 2){
    if (e == 0) return 1LL;
    long long x = Pow(b, e / 2);
    if (e % 2 == 0) return x * x % MOD;
    return (x * x % MOD) * b % MOD;
}

void solveE() {
    Seive();
    int n; cin >> n;
    int arr[n];
    map<int, int> M;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        int tmp = arr[i];
        while (tmp != 1) {
            int c = 0;
            int p = prime[tmp];
            while (tmp % p == 0) {
                tmp /= p;
                c++;
            }
            M[p] = max(M[p], c);
        }
    }
    long long lcm = 1;
    for (auto i : M) {
        //cout << i.first << ' ' << i.second << '\n';
        lcm = lcm * Pow(i.first, i.second) % MOD;
    }
    long long res = 0;
    //cout << lcm << ' ';
    for (int i = 0; i < n; i++) {
        res = (res + lcm * Pow(arr[i])) % MOD;
    }
    cout << res;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    //rwFile();
    solveE();
}


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

using namespace std;

#define pb push_back
#define eb emplace_back
#define ll long long
#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair

const int N = (int)1007;
const int inf = (int)1e9 + 7;

char ans[N][N];
int n, m, a, b;

void no() {
  puts("NO");
  exit(0);
}

void yes() {
  puts("YES");
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      putchar(ans[i][j]);
    }
    putchar('\n');
  }
  exit(0);
}

int A, B;

main() {
  scanf("%d %d", &n, &m);
  scanf("%d %d", &a, &b);
  A = a;
  B = b;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      ans[i][j] = '.';
    }
  }

  if (m & 1) {
    int i = 1;
    while (i < n && b > 0) {
      ans[i][1] = '^';
      ans[i + 1][1] = 'v';
      i += 2;
      b--;
    }
  }
  if (n & 1) {
    int i = 1;
    if (ans[n][i] != '.') i++;
    while (i < m && a > 0) {
      ans[n][i] = '<';
      ans[n][i + 1] = '>';
      i += 2;
      a--;
    }
  }
  for (int i = n; i >= 1; i--) {
    for (int j = 1; j <= m; j++) {
      if (b > 0 && ans[i][j] == '.' && ans[i + 1][j] == '.') {
        ans[i][j] = '^';
        ans[i + 1][j] = 'v';
        b--;
      }
    }
  }
  for (int i = m; i >= 1; i--) {
    for (int j = 1; j <= n; j++) {
      if (a > 0 && ans[j][i] == '.' && ans[j][i + 1] == '.') {
        ans[j][i] = '<';
        ans[j][i + 1] = '>';
        a--;
      }
    }
  }
  if (a + b > 0) {
    a = A;
    b = B;
    if ((n & 1) && (m & 1)) {

    }
    if (a + b > 0)
      no();
    yes();
  }
  yes();
}
/*
5 4 7 2
*/


Measured memory_bytes: 2176
let () =
  let counting_sort a b k =
    let len = (Array.length a) -1 and
        c = Array.make (k+1) 0 in
    Array.iter (fun x -> c.(x) <- c.(x)+1) a;
    for i = 1 to k do
      c.(i) <- c.(i) + c.(i-1)
    done;
    for i = 0 to len do
      let j = len - i in
      b.(c.(a.(j))-1) <- a.(j);c.(a.(j)) <- c.(a.(j))-1
    done;b
  in
  let read x = Scanf.scanf " %d" (fun y -> y) in
  let n = read_int () in
  let a = Array.init n read in
  let res = counting_sort a (Array.make n 0) 10000 in
  Printf.printf "%d" res.(0);
  for i = 1 to n-1 do
    Printf.printf  " %d" res.(i)
  done;
  Printf.printf "\n"
;;

Measured memory_bytes: 36168
//CODECHEF :-
//coded by AMAN BHARTI NIT PATNA
//ALL RIGHTS RESERVED
//ECE 2K18

#include<bits/stdc++.h>
using namespace std;

//#define home
#define TASK "soln"
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define ll long long int
#define br cout<<endl;
#define fo for(int i=0;i<n;i++)
 

void solve(){
    int n;
    cin>>n;
    if(n>=1000){
        if(n%1000==0)cout<<0;
        else cout<<1000-(n%1000);
    }
    else
    cout<<1000-(n%1000);
    br;
}


int main(){
	#ifdef home
        assert(freopen(TASK".in", "r", stdin));
        assert(freopen(TASK".out", "w", stdout));
    #endif
 
    ios::sync_with_stdio(false);
    cin.tie(NULL);
 
    //int t;
    //cin>>t;
    //while(t-->0)
    solve();
 
    #ifdef home
        eprintf("Time: %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
    #endif
 
    return 0;
}

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

using namespace std;
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.12lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define mod 1000 * 1000 * 1000 + 7
#define pi 3.1415926536
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second

const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

pair<pair<string, int>, int> c[105];
int main()
{
    int n;
    cin >> n;
    string s;
    int x;
    for (int i = 0; i < n; ++i)
    {
        cin >> s >> x;
        c[i] = make_pair(make_pair(s, -1 * x), i + 1);
    }
    sort(c, c + n);
    for(int i=0;i<n;++i)
        cout<<c[i].S<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main(){
  int n;
  cin >> n;
  string s;
  cin.ignore();
  for(int i=0;i<n;i++){
    getline(cin,s);
    char c = s[0];
    char c1,c2,c3,c4;
    int j = 0;
    map<char,char> m;
    while(s[j+1]!='\0'){
      c1 = s[j];
      c2 = s[j+1];
      c3 = s[j+2];
      c4 = s[j+3];
      j += 3;
      if(c2=='<'){
	if(c==c1)
	  c = c4;
	m[c4] = c1;
      }
      else if(c3=='>')
	m[c1] = c4;
    }
    cout << c;
    while(m[c]!=0){
      cout << m[c];
      c = m[c];
    }
    cout << endl;
  }
  return 0;
}

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

int main()
{
	int n,i;
	int a[100000],b[100000];
	memset(b,0,sizeof(b));
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		b[a[i]]++;
		b[a[i]-1]++;
		b[a[i]+1]++;
	}
	int m=0;
	for(i=0;i<=a[n-1];i++){
		if(m<b[i]) m=b[i];
	}
	printf("%d",m);
	return 0;
}

Measured memory_bytes: 4608
import itertools
from collections import defaultdict


possible_numbers = [0, 1]
num_switch, num_lamp = map(int, input().split(' '))

lamp_connection = defaultdict(list)
for i in range(0, num_lamp):
    divided_input = input().split(' ')
    del(divided_input[0])
    connected_switches = [int(x)-1 for x in divided_input]

    for switch in connected_switches:
        lamp_connection[switch].append(i)

mods = tuple(map(int, input().split(' ')))

trials = itertools.product(possible_numbers, repeat=num_switch)


num_success = 0
for switch_state in trials:
    sums = defaultdict(int)
    for index, statement in enumerate(switch_state):
        targets = lamp_connection[index]
        for target in targets:
            sums[target] += statement

    for i in range(0, num_lamp):
        if sums[i] % 2 != mods[i]:
            break
    else:
        num_success += 1

print(num_success)
exit(0)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
unsigned int mod = 1;

struct ModInt{
	using uint = unsigned int;
	using ll = long long;
	using ull = unsigned long long;

	uint v;
	ModInt():v(0){}
	ModInt(ll v):v(normS(v%mod+mod)){}
	explicit operator bool() const {return v!=0;}
	static uint normS(const uint &x){return (x<mod)?x:x-mod;}		// [0 , 2*mod-1] -> [0 , mod-1]
	static ModInt make(const uint &x){ModInt m; m.v=x; return m;}
	ModInt operator+(const ModInt& b) const { return make(normS(v+b.v));}
	ModInt operator-(const ModInt& b) const { return make(normS(v+mod-b.v));}
	ModInt operator-() const { return make(normS(mod-v)); }
	ModInt operator*(const ModInt& b) const { return make((ull)v*b.v%mod);}
	ModInt operator/(const ModInt& b) const { return *this*b.inv();}
	ModInt& operator+=(const ModInt& b){ return *this=*this+b;}
	ModInt& operator-=(const ModInt& b){ return *this=*this-b;}
	ModInt& operator*=(const ModInt& b){ return *this=*this*b;}
	ModInt& operator/=(const ModInt& b){ return *this=*this/b;}
	ll extgcd(ll a,ll b,ll &x,ll &y) const{
		ll u[]={a,1,0},v[]={b,0,1};
		while(*v){
			ll t=*u/ *v;
			rep(i,3) swap(u[i]-=t*v[i],v[i]);
		}
		if(u[0]<0) rep(i,3) u[i]=-u[i];
		x=u[1],y=u[2];
		return u[0];
	}
	ModInt inv() const{
		ll x,y;
		extgcd(v,mod,x,y);
		return make(normS(x+mod));
	}
	bool operator==(const ModInt& b) const { return v==b.v;}
	bool operator!=(const ModInt& b) const { return v!=b.v;}
	friend istream& operator>>(istream &o,ModInt& x){
		ll tmp;
		o>>tmp;
		x=ModInt(tmp);
		return o;
	}
	friend ostream& operator<<(ostream &o,const ModInt& x){ return o<<x.v;}
};
using mint = ModInt;
int main(){
	int N,K;
	cin>>N>>K>>mod;
	VV<mint> dp(N+1,V<mint>(N+1));
	dp[0][0] = 1;
	rep(i,N){
		rep(j,i+1){
			dp[i+1][j+1] += dp[i][j] * (i-j+1);
			dp[i+1][j] += dp[i][j];
		}
	}
	VV<mint> dp2(K+1,V<mint>(N+1));
	dp2[0][0] = 1;
	rep(i,K) rep(j,N+1) if(dp2[i][j]){
		rep(x,N+1){
			int nj = j+x;
			if(nj>N) break;
			dp2[i+1][nj] += dp2[i][j] * dp[nj][x];
		}
	}
	cout<<dp2[K][N]<<endl;
}

Measured memory_bytes: 1024
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
def ddprint(x):
  if DBG:
    print(x)

a = inn()
b = inn()
c = inn()
d = inn()
e = inn()
t  = [a,b,c,d,e]
p = [ x//10 for x in t ]
r = [ x%10 for x in t ]
if max(r) == 0:
    rest = 0
else:
    rnz = [ x for x in r if x != 0 ]
    rmn = min(rnz)
    rest = 10 * (len(rnz)-1) + rmn

print(10*sum(p) + rest)


Measured memory_bytes: 38384
#pragma GCC compiler("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  ios_base::sync_with_stdio(0);
  ll a,b;
  cin>>a>>b;
  if(b-a+1>=2019){
    cout<<0<<endl;
    return 0;
  }
  ll mi=1e9;
  for(ll i=a;i<b;i++){
    for(ll j=i+1;j<=b;j++){
      if(((i%2019)*((j)%2019))%2019<mi)mi=((i%2019)*((j)%2019))%2019;
    }
  }
  cout<<mi<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
#include <string.h>
#include <cstring>
 
using namespace std;
int main() {
    
    char n[6];
    
    for(int i=0;i<6;i++){
        cin >> n[i];
    }
    if(n[2]==n[3] && n[4]==n[5]){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
int main(){
   int a,b,c;
   cin >> a >> b >> c;
   vector<int> vec(3);
   vec[0]=a;
   vec[1]=b;
   vec[2]=c;
   sort(vec.begin(),vec.end());
   cout<<vec[2]-vec[0]<<endl;
}

Measured memory_bytes: 256
arr = Array.new(4){Array.new(3){Array.new(10,0)}}
(gets.to_i).times do
  a=gets.split.map(&:to_i)
  arr[a[0]-1][a[1]-1][a[2]-1] += a[3]
end
4.times do |k|
  3.times do |j|
     print " ", arr[k][j].join(" "),"\n"
  end
  if k<3 then
    puts "#"*20
  end
end

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

int main() {

   string st1,st2;
   cin>>st1>>st2;
   int s1=st1.size();
   int s2=st2.size();
   int c=0;
  // cout<<s1;
   for(int i=0;i<s2;i++){
    if(st1[i]==st2[i]){
         c++;
         // cout<<c;
    }

    else if(st1[i]!=st2[i] && c==s1){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
        break;
    }
   }


}


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

using namespace std;

int a,b,c[10],s;

int pl(int x)
{
    int u=1, ans=0;
    while (x>0) c[u]=x%10, x/=10, u++;
    u--;
    for (int i = 1; i <= u; i++)
        if (c[i]==c[u+1-i]) ans++;
    if (ans==u) return 1;
    else return 0;
}

int main()
{
    cin >> a >> b;
    for (int i=a;i<=b;i++)
    s+=pl(i);
    cout << s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ls (o<<1)
#define rs (o<<1|1)
#define pb push_back
const double PI= acos(-1.0);
const int M = 1e5+7;
/*
int head[M],cnt;
void init(){cnt=0,memset(head,0,sizeof(head));}
struct EDGE{int to,nxt,val;}ee[M*2];
void add(int x,int y){ee[++cnt].nxt=head[x],ee[cnt].to=y,head[x]=cnt;}
*/

int a[15][15];
int c[15];
int lv[15];
int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	int n,m,x;
  	cin>>n>>m>>x;
  	for(int i=1;i<=n;i++)
  	{
  		cin>>c[i];
  		for(int j=1;j<=m;j++)cin>>a[i][j];
	}
	int mi=1e9+7;
	for(int i=0;i<(1<<n);i++)
	{
		memset(lv,0,sizeof(lv));
		int tp=0;
		for(int j=1;j<=n;j++)
		{
			if(i>>(j-1)&1)//买第j本书 
			{
				for(int k=1;k<=m;k++)
					lv[k]+=a[j][k];
				tp+=c[j];
			}
		}
		bool f=true;
		for(int i=1;i<=m;i++)if(lv[i]<x)f=false;
		if(f)mi=min(mi,tp);
	}
	if(mi==1e9+7)cout<<-1<<endl;
	else 
	cout<<mi<<endl;
	return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,v.size())
#define all(v) (v).begin(),(v).end()
#define bit(n) (1ll<<(n))
#define clamp(n,mi,ma) max(min(n,ma),mi)
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b) cout<<((n)?a:b)<<endl
#define YES(n) cho(n,"YES","NO")
#define Yes(n) cho(n,"Yes","No")
#define Poss(n) cho(n,"Possible","Impossible")
template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T&a,const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>ostream&operator<(ostream&o,const T&t){return o<<t;}
template<class T>istream&operator>(istream&i,T&t){return i>>t;}
#ifndef LOCAL
struct ostdmy{
template<class T>ostdmy&operator<<(const T&t){return*this;}
template<class T>ostdmy&operator<(const T&t){return*this;}};ostdmy cer_;
#define cerr cer_
#endif

template<typename T>
T gcd(T a,T b){ // log N
    if(a==INF)return b;
    if(b==INF)return a;

    while((a%=b)&&(b%=a));
    return a|b;
}
template<typename T>
T lcm(T a,T b){
    return a/gcd(a,b)*b;
}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int n;
    cin>n;
    vi a(n);
    cin>a;
    vi cs(n+1);
    vi csr(n+1);
    cs[0]=INF;
    cs[1]=a[0];
    csr[n]=INF;
    csr[n-1]=a[n-1];
    REP(i,1,n)cs[i+1]=gcd(cs[i], a[i]);
    REPR(i,n-1)csr[i]=gcd(csr[i+1], a[i]);
    cerr<<cs<<endl;
    cerr<<csr<<endl;
    int ma=1;
    REP(i,n){
        int ans=INF;
        if(cs[i]!=INF)ans=gcd(ans,cs[i]);
        if(csr[i+1]!=INF)ans=gcd(csr[i+1],ans);

        chmax(ma,ans);
    }
    cout<ma<endl;

    return 0;
}


Measured memory_bytes: 1408
// Bismillahirrahmanirrahim
// by Batrrr Tolkynbayev
#include <bits/stdc++.h>
// skripi krasava
#define respa return 0
#define all(x) x.begin(), x.end()
#define sz size
#define pb push_back
#define eb emplace_back
#define forn(i, x, n) for(int i = x; i <= n; ++i)
#define forr(i, n, x) for(int i = n; i >= x; --i)

using namespace std;
typedef long long ll;
typedef long double ld;
const int N = 3e5 + 17, M = N << 2, mod = 1e9 + 7; 

ll tt = 1, n, ct, res, a[N];
bool u[N];

void solve () {
	cin >> n;
	forn(i, 1, 3 * n) cin >> a[i];
	sort(a + 1, a + 3 * n + 1);
	ll i = 3 * n;
	while (i > 0) {
		if (u[i]) {
			--i; 
			continue;
		}
		u[i] = u[i - 1] = u[++ct] = true;
		res += a[i - 1]; --i;
	}
	cout << res;
}

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	// cin >> tt;
	while (tt--) solve();
	respa;
}

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

int c[4000];
signed main() {
	int a, b; scanf("%lld%lld", &a, &b);
	for (int d = 0; d < a; d++) {
		scanf("%lld", &c[d]);
		c[d + a] = c[d];
	}
	int MIN = LLONG_MAX;
	for (int i = 0; i < a; i++) {//i回回す
		int sum = b*i;
		deque<P>Q;//番号　値
		int k = LLONG_MAX;
		for (int j = 0; j <= i; j++) {
			while (Q.size() && Q.back().second >= c[j])Q.pop_back();
			Q.push_back({j,c[j]});
			k = min(k, c[j]);
		}
		sum += k;
		for (int j = 1; j < a; j++) {
			if(Q.front().first==j-1)Q.pop_front();
			while (Q.size() && Q.back().second >= c[i + j])Q.pop_back();
			Q.push_back({i+j,c[i+j]});
			sum += Q.front().second;
		}
		MIN = min(MIN, sum);
	}
	printf("%lld\n", MIN);
}

Measured memory_bytes: 256