akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//
//using namespace __gnu_pbds;
//template<typename dtype> using ordered_set = tree<dtype, null_type, less<dtype>, rb_tree_tag, tree_order_statistics_node_update>;

class Timer {
    clock_t start;
    string name;
public:
    Timer() {name = "";start = clock();}
    Timer(string s){name = s;start = clock();}
    ~Timer() {fprintf(stderr, "%s: %.3gs\n", name.c_str(), 1.0*(clock() - start) / CLOCKS_PER_SEC);}
};

//#define isValid(a, b) (a >= 0 && a < b)
//int dr[]  =  {0, -1, -1, -1,  0,  1, 1, 1};
//int dc[]  =  {1,  1,  0, -1, -1, -1, 0, 1};

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define what_is(x) cerr << fixed << setprecision(2) << boolalpha << #x << " = " << x << endl

const double EPS = 1e-9;
const double PI = acos(-1.0L);

template<typename dtype> inline dtype sq(dtype a){return a*a;}
template<typename dtype1, typename dtype2> inline pair<dtype1, dtype2> mp(dtype1 a, dtype2 b){return make_pair(a, b);}
template<typename dtype1, typename dtype2> inline dtype1 safeMod(dtype1 a, dtype2 m){return (a%m + m)%m;}/*handling negative sign of remainder*/
template<typename dtype1, typename dtype2> inline bool isEq(dtype1 a, dtype2 b){return abs(a - b) < EPS;}
template<typename dtype1, typename dtype2, typename dtype3> inline bool isEq(dtype1 a, dtype2 b, dtype3 eps){return abs(a - b) < eps;}
template<typename dtype> inline bool isKthBitOn(dtype n, int k){assert(n <= numeric_limits<dtype>::max());assert(k<=numeric_limits<dtype>::digits);dtype ONE = 1;return bool((n & (ONE<<k)));}
template<typename dtype> inline void setKthBit(dtype& n, int k){assert(n <= numeric_limits<dtype>::max());assert(k<=numeric_limits<dtype>::digits);dtype ONE = 1;n = (n|(ONE<<k));}

#define toRad(deg) ((deg)*PI/180.0)
#define toDeg(rad) ((rad)*180.0/PI)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int oo = 0x3f3f3f3f;
const int MAX = 200010;
const int MOD = 1000000007;
const int precision = 10;

int main(int argc, char* argv[])
{
    //assert(freopen("in.txt", "r", stdin));
    //assert(freopen("out.txt", "w", stdout));
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    //cout << fixed << setprecision(precision);
    int n;
    vector<int>v(3);
    for(int &x:v)
        cin >> x;
    sort(all(v));
    cout << v[0] + v[1];
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int n;
  scanf("%d", &n);

  char s;
  int four = 0;
  rep(i, 0, n) {
    scanf("%c", &s);
    if (s == 'Y') four = 1;
  }
  printf( four ? "Four\n" : "Three\n");
  return 0;
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
  string s;
  cin >> s;
  set<char> t;
  for(int i=0; i<s.size(); i++) t.insert(s[i]);
  if(s.size()==t.size()) cout << "yes" << endl;
  else cout << "no" << endl;
  return 0;
}

Measured memory_bytes: 3608
parseInt(x) = parse(Int, x)
parseFloat(x) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,t=parseMap(split(readline()))
    ct=[parseMap(split(readline())) for i in 1:n]
    ans=10^9+7
    for i in 1:n
        if ct[i][2]<=t
            ans=min(ct[i][1],ans)
        end
    end
    println(ifelse(ans==10^9+7,"TLE",ans))
end
main()

Measured memory_bytes: 112516
#include<iostream>
#include<numeric>
#include<cmath>
#include<cstdlib>
#include<string>
#include <limits>
using namespace std;

long long int lcm(long long int x, long long int y){
  int r;
  if(x==y)
    return x;
  else if(x>y){
    while((r = x % y) != 0){
      x = y;
      y = r;
    }
    return y;
  }
  else{
    while((r = y % x) != 0){
      y = x;
      x = r;
    }
    return x;
  }
}

int main(){
  int N,i,j;
  cin>>N;
  long long int A[N],a[N],min=1000000000;
  for(i=0;i<N;i++)
    cin>>A[i];

  a[0] = A[0];

  for(i=1;i<N;i++){
    a[i]= lcm(a[i-1],A[i]);
    //cout<<a[i]<<endl;;
    if(a[i]<min)
      min = a[i];
  }
  cout<<min<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  ll N,H;cin >> N >> H;
  vector<ll> v(N);
  vector<ll> S(N+1);
  S[0] = 0;
  ll M = 0;
  ll attack = 0;
  rep(i,N){
    ll x;cin >> x >> v[i];
    attack = max(attack,x);
  }
  sort(all(v),greater<ll>());
  rep(i,N) S[i+1] += S[i] + v[i];
  ll ans = MAX_LL;
  rep(i,N+1){
    ll count = 0;
    ll h = H-S[i];
    count += i;
    if(h>0){
      count += h/attack;
      if(h%attack)++count;
    }
    ans = min(ans,count);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
import numpy as np

n = int(input())
t, a = map(int,input().split())
li = list(map(int, input().split())) #数値

t = t*1000
a = a*1000
npli = np.array(li)
npli = t-npli*6

res = npli[0]
res_num = 1
for i in range(n):
    # print(abs(res),abs(npli[i]),res_num)
    if abs(a-res) > abs(a-npli[i]):
        res = npli[i]
        res_num = i+1
print(res_num)

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

const long long INF = 1000000000LL * 100000 + 10;
int N;
long long sum[100001];

int get_position(long long x){
	return upper_bound(sum, sum + N, x) - sum;
}

int main() {
	long long a[100001];
	cin >> N;
	for(int i = 0; i < N; ++i){
		scanf("%lld", &a[i]);
		sum[i + 1] = sum[i] + a[i];
	}
	
	long long res = 0;
	for(int i = 0; i < N; ++i){
		int p1, p2;
		while(1){
			p1 = get_position(res + sum[i]);
			p2 = get_position(res + sum[p1]);
			if(sum[p1] - sum[i] > res && sum[p2] - sum[p1] > res && sum[N] - sum[p2] + sum[i] > res){
				res = min(sum[p1] - sum[i], min(sum[p2] - sum[p1], sum[N] - sum[p2] + sum[i]));
			}
			else{
				break;
			}
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 2792
#include<iostream>

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

    if(a>=b&&b>=c){
        std::cout<<c<<" "<<b<<" "<<a<<std::endl;
    }
    else if(a>=c&&c>=b){
        std::cout<<b<<" "<<c<<" "<<a<<std::endl;
    }
    else if(b>=a&&a>=c){
        std::cout<<c<<" "<<a<<" "<<b<<std::endl;
    }
    else if(b>=c&&b>=a){
        std::cout<<a<<" "<<c<<" "<<b<<std::endl;
    }
    else if(c>=b&&b>=a){
        std::cout<<a<<" "<<b<<" "<<c<<std::endl;
    }
    else{
        std::cout<<b<<" "<<a<<" "<<c<<std::endl;
    }
    return 0;
}


Measured memory_bytes: 3096
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(a == 0 && b == 0)break;
            for(int i = 0; i<a; i++){
                for(int j=0;j<b;j++){
                    if((i%2 == 0 && j%2 !=0) || (i%2 != 0 && j%2 ==0)){
                        System.out.print(".");
                    }else{
                        System.out.print("#");
                    }
                }
                System.out.println();
            }
            sc.nextLine();
            System.out.println();
        }
    }
}


Measured memory_bytes: 35168
#アルファベットの1対1置換が存在すればYes
S=input()
T=input()
#dは、アルファベットの置換、置換は辞書で書く
d={}
#Sを順にみていって、d内になかったらSのi番目とdのi番目が置換関係にある
for i in range(len(S)):
    if S[i] not in d:
        d[S[i]]=T[i] 
    else:
      #1対1の置換でないと判明したらNoを出力
        if d[S[i]]!=T[i]:
            print('No')
            exit()
d={}
for i in range(len(T)):
    if T[i] not in d:
        d[T[i]]=S[i]
    else:
        if d[T[i]]!=S[i]:
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 3632
#include <stdio.h>
int main(void)
{
    int N;
    while (~scanf("%d", &N)) {
        while (N--) {
            int p, q, n, m, c;
            scanf("%d%d", &p, &q);
            c=0;
            for(n=0;n<143;++n) for(m=0;m<143;++m) if (m>0 || n>0) {
                int t=m*m+n*n, a=m*p+n*q, b=m*q-n*p;
                if (a%t==0 && b%t==0) ++c;
            }
            puts(c>4?"C":"P");
        }
    }
    
    return 0;
}

Measured memory_bytes: 580
MAX = 600000
MOD = 10 ** 9 + 7
fac = [0] * MAX
ifac = [0] * MAX
fac[0] = 1
for i in range(1,MAX):
    fac[i] = (fac[i-1] * i) % MOD
ifac[MAX-1] = pow(fac[MAX-1],MOD-2,MOD)
for i in reversed(range(1,MAX)):
    ifac[i-1] = (ifac[i] * i) % MOD

def combinations(n, k):
    if k < 0 or n < k:
        return 0
    else:
        return (fac[n] * ifac[k] * ifac[n-k]) % MOD

N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

def f(A):
    ans = 0
    for i in range(K-1,N):
        ans += A[i]*combinations(i,K-1)
        ans %= MOD
        #print(A[i],combinations(i,K-1))
    return ans

print((f(A) - f(list(reversed(A)))) % MOD )
#print(f(A))



Measured memory_bytes: 99716
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	for (int i = 0; i < 3; i++) {
		if (a.at(i) != b.at(2 - i)) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

using namespace std;

typedef long long int ll;
typedef vector<ll> V;
typedef vector<V> VV;

int main() {
  // Happy hacking!
  ll n;
  string s;
  map<char, int> c_count;
  ll qres = 1;

  cin >> n;
  cin >> s;
  for(ll i=0; i<n; i++) {
    auto retval = c_count.find(s[i]);
    if(retval == c_count.end()) {
      c_count[s[i]] = 1;
    } else {
      c_count[s[i]] += 1;
    }
  }

  for(auto itr = c_count.begin(); itr != c_count.end(); itr++) {
    qres *= itr->second + 1;
    qres %= 1000000007;
  }

  qres -= 1;

  cout << qres << endl;

  return 0;
}


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

const int64_t MOD = 998244353;
const int64_t ROOT = 3;
// MOD-1が何回2で割れるか
const int MX_PW = 23;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

vector<int64_t> zeta, zeta_inv;

void prepare_ntt(){
    zeta.resize(MX_PW);
    zeta_inv.resize(MX_PW);
    zeta[MX_PW-1] = power_mod(ROOT, (MOD-1)/(1<<MX_PW));
    zeta_inv[MX_PW-1] = inv_mod(zeta[MX_PW-1]);
    for(int k=MX_PW-2; k>=0; k--){
        zeta[k] = zeta[k+1] * zeta[k+1] % MOD;
        zeta_inv[k] = zeta_inv[k+1] * zeta_inv[k+1] % MOD;
    }
}

void dft(vector<int64_t>& f, int n, bool inverse){
    if(n==1) return;
    int c = 0;
    for(int i=1; i<n; i++){
        for(int j=(n>>1); j>(c^=j); j>>=1);
        if(c > i){
            swap(f[c], f[i]);
        }
    }

    for(int i=1, k=0; i<n; i<<=1, k++){
        int64_t w = (inverse ? zeta_inv[k] : zeta[k]);
        for(int j=0; j<n; j+=2*i){
            int64_t wn = 1;
            for(int k=0; k<i; k++){
                int64_t u = f[k+j];
                int64_t v = f[k+j+i] * wn % MOD;
                f[k+j] = (u+v) % MOD;
                f[k+j+i] = (u-v+MOD) % MOD;
                wn = wn * w % MOD;
            }
        }
    }
}
 
vector<int64_t> convolution(vector<int64_t> f, vector<int64_t> g){
    if(zeta.size() == 0) prepare_ntt();
    int sz = f.size() + g.size();
    int n = 1;
    while(n <= sz) n <<= 1;
	f.resize(n);
	g.resize(n);
    dft(f, n, false);
    dft(g, n, false);
 
    vector<int64_t> h(n);
    for(int i=0; i<n; i++) h[i] = f[i] * g[i] % MOD;
    dft(h, n, true);
    int64_t ninv = inv_mod(n);
    for(int64_t& a : h) mul(a, ninv);
    h.resize(sz-1);
    return h;
}

int main(){
    int N, M;
    cin >> N >> M;
    vector<int64_t> A(N), B(M);
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<M; i++) cin >> B[i];
    auto C = convolution(A, B);
    for(auto c : C) cout << c << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 60612
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int M=26;

vi f(string s){
	vi a(M);
	for(int i=0;i<s.size();i++) a[s[i]-'a']=1;
	return a;
}

int n;
string s;

int main(){
	cin>>n>>s;
	int res=0;
	for(int i=1;i<n;i++){
		vi a=f(s.substr(0,i)),b=f(s.substr(i,n));
		int t=0;
		for(int j=0;j<M;j++) t+=a[j]*b[j];
		res=max(res,t);
	}
	cout<<res<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <map>
#include <queue>
#include <cmath>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 1000000000
#define MOD 1000000007
#define ll long long
using namespace std;
int n;
int table[1000];
map<int,int> fact;
vector<int> prime;
int main(){
    cin>>n;
    for (int i=2;i<1000;i++){
        if (table[i]==0){
            table[i]=1;
            prime.push_back(i);
            for (int j=i*2;j<1000;j+=i) table[j]=1;
        }
    }
    for (auto p:prime){
        int i=1;
        while (n/pow(p,i)>0){
            fact[p]+=n/pow(p,i);
            i++;
        }
    }
    ll ans=1;
    for (auto p:prime){
        (ans*=fact[p]+1)%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
import bisect

s = input()
t = input()
s_length = len(s)
t_length = len(t)

def char2int(char):
    return ord(char) - 97

def search_index(t_atom, last_index, d_list):
    t_atom_int = char2int(t_atom)
    d = d_list[t_atom_int]

    if d == []:
        return -1

    c = bisect.bisect_right(d, last_index)

    if c != len(d):
        return d[c]
    else:
        return d[0]

def solve():
    last_index = -1
    t_index = []
    loop_cost = 1

    d = [[] for _ in range(26)]
    for i in range(s_length):
        char = s[i]
        d[char2int(char)].append(i)

    for i in range(t_length):
        t_atom = t[i]
        t_atom_index = search_index(t_atom, last_index, d)
        if t_atom_index == -1:
            return -1
        else:
            t_index.append(t_atom_index)
            last_index = t_atom_index

    remainder_cost = t_index[-1] + 1

    for i in range(1, t_length):
        if t_index[i - 1] >= t_index[i]:
            loop_cost += 1

    return s_length * (loop_cost - 1) + remainder_cost

print(solve())


Measured memory_bytes: 8436
#!/usr/bin/env python3
import sys


def solve(N: int):
    h = {2, 4, 5, 7, 9}
    p = {0, 1, 6, 8}
    b = {3}
    k = N % 10
    if k in h:
        print("hon")
    if k in p:
        print("pon")
    if k in b:
        print("bon")


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
  
int main()
{
	//input
	int N; cin >> N;
	int t[110000], x[110000], y[110000];
	t[0] = x[0] = y[0] = 0;
	for (int i = 0; i < N; i++){
		cin >> t[i+1] >> x[i+1] >> y[i+1]; 
	}
	//compute
	bool can = true;
	for (int i = 0; i < N; i++){
		int dt = t[i+1] - t[i];
		int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
		if (dist > dt) can = false;
		else{
			if (dt%2 != dist%2) can = false;
		}
	}
	
	//output
	cout << (can ? "Yes":"No") << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

ll moP(ll x, ll n) {
  ll res=1;
  while(n>0) {
    if(n&1) moC(res, *, x);
    moC(x, *, x);
    n>>=1;
  }
  return res;
}

ll H, W, K;

ll f(ll w) {
  if(w<0) return 1;
  ll i;
  ll res=0;
  
  for(ll S=0; S<1<<w; S++) {
    vector<ll> v;
    for(i=0; i<w; i++) {
      if(S>>i&1) v.push_back(i);
    }
    
    ll f=1;
    for(i=0; i<(ll)v.size()-1; i++) {
      if(v[i]+1==v[i+1]) f=0;
    }
    
    if(f) res++;
  }
  
  return res;
}

int main(void) {
  cin >> H >> W >> K;
  ll i, j, k, l;
  ll dp[111][11]={};
  
  dp[0][1]=1;
  for(i=0; i<H; i++) {
    for(j=1; j<=W; j++) {
      
      //left
      if(j==2||j==W) {
        moC(dp[i+1][j-1], +, dp[i][j]*f(W-3)%MOD);
      }else if(2<j && j<W) {
        moC(dp[i+1][j-1], +, dp[i][j]*f(j-3)%MOD*f(W-j-1)%MOD);
      }
      
      //right
      if(j==1||j==W-1) {
        moC(dp[i+1][j+1], +, dp[i][j]*f(W-3)%MOD);
      }else if(1<j && j<W-1) {
        moC(dp[i+1][j+1], +, dp[i][j]*f(j-2)%MOD*f(W-j-2)%MOD);
      }
      
      //down
      if(j==1||j==W) {
        moC(dp[i+1][j], +, dp[i][j]*f(W-2)%MOD);
      }else {
        moC(dp[i+1][j], +, dp[i][j]*f(j-2)%MOD*f(W-j-1)%MOD);
      }
      
      
    }
  }
  
  pt(dp[H][K]);
  
}




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

int main() {

    int n, m;
    map<string, int> mp;

    cin >> n;
    for(int i = 1; i <= n; i++){
        string s;
        cin >> s;
        mp[s]++;
    }

    cin >> m;
    for(int i = 1; i <= m; i++){
        string s;
        cin >> s;
        mp[s]--;
    }

    int ans = 0;
    for(map<string, int>::iterator it = mp.begin(); it != mp.end(); it++){
        ans = max(ans, it -> second);
    }
    cout << ans << endl; 

}

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> 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
 #include <ccomplex>
 #include <cfenv>
 #include <cinttypes>
 #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> 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
 #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 <system_error>
 #include <thread>
 #include <tuple>
 #include <typeindex>
 #include <type_traits>
 #include <unordered_map>
 #include <unordered_set>
 #endif
using namespace std;
int dp[50];

int main(){
    int n; cin >> n;
    dp[0] = 1;
    dp[1] = 1;
    for(int i=2;i<=n;++i){
        dp[i] = dp[i-1] + dp[i-2];
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 3096
#include<iostream>
#include<vector>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

li cost(li bs,vector<int>& c){
  li s=0,i=0;
  while(bs){
    if(bs%2)s+=c[i];
    bs/=2; i++;
  }
  return s;
}

int buy(li bs,vector<vector<int>>& a,int x){
  int m=a[0].size();
  vector<int> vec(m,0);
  int i=0;
  while(bs){
    if(bs%2) rep(j,m)vec[j]+=a[i][j];
    bs/=2; i++;
  }
  rep(i,m){
    if(vec[i]<x) return 0;
  }
  return 1;
}


int main(){
  int n,m,x; cin >>n >>m >>x;
  vector<int> c(n);
  vector<vector<int>> a(n,vector<int>(m));
  rep(i,n){
    cin >>c[i];
    rep(j,m){
      cin >>a[i][j];
    }
  }
  li lim = 1<<n,flag=1,ma;
  if(df)print(lim);
  rep(bs,lim){
    if(buy(bs,a,x)){
      if(flag){
        flag=0;
        ma=cost(bs,c);
      } else{
        li s= cost(bs,c);
        ma=min(ma,s);
      }
    }
  }
  print(flag?-1:ma);
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#include<assert.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")
#define charsize 100005 //10^5+5

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a= c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

/*aのb進数時の桁数*/
ll digits(ll a, ll b){return a/b?1+digits(a/b,b):1;}
/*nをa進数にしたときの、i桁目の数*/
ll placenai(ll n, ll a, ll i){return i==1?n%a:placenai(n/a,a,i-1);}
/*aのn乗(mod) 繰り返し二乗法*/
ll modpow(ll a, ll n, ll mod){
    ll s[digits(n,2)],ans=1;
    rep(i,0,digits(n,2)){
        s[i]= i==0 ? a : s[i-1]*s[i-1]%mod ;
        ans*=placenai(n,2,i+1)==1?s[i]:1; ans%=mod;
    }
    return n?ans:1;
}
ll inv[200005],finv[200005];
void makeinv(ll n){
    inv[1]=1;finv[0]=finv[1]=1;
    rep(i,2,n+1){
        inv[i]=MOD1 - inv[MOD1%i] * (MOD1 / i) % MOD1;
        finv[i] = finv[i - 1] * inv[i] % MOD1;
    }
}
ll modfac(ll n, ll mod){
    ll x=1;
    rep(i,2,n+1){x*=i%mod;x%=mod;}
    return x;
}


int main(void){
    // char ;
    ll n,m,ans=0;
    scanf("%lld%lld",&m,&n);
    // // ll [n];
    // rep(i,0,n){
    //     scanf("%lld",&[i]);
    // }

    ans = modpow(m,n,MOD1);
    printf("%lld\n",ans);
    return 0;
}



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

using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,a,b;
ll mem[5005][5005];
int p[5005], pos[5005];
ll dp(int id, int cur){
    if (mem[id][cur] != -1) return mem[id][cur];
    if (id == 0) return mem[id][cur] = 0;
    if (pos[id] > cur) {
        //printf("%d at %d needs to move to %d, cost %d\n",id,pos[id],cur,b);
        return mem[id][cur] = dp(id-1,cur)+b; ///move id to cur.
    }
    //printf("%d at %d, can move to %d, cost %d\n",id,pos[id],cur,a);
    return mem[id][cur] =  min(dp(id-1,pos[id]),dp(id-1,cur)+a);;
}
int main(){
    scanf("%d%d%d",&n,&a,&b);
    for (int i = 1; i <= n; i++){
        scanf("%d",&p[i]);
        pos[p[i]] = i;
    }
    memset(mem,-1,sizeof(mem));
    printf("%lld",dp(n,n));

}


Measured memory_bytes: 196352
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(1e9 + 7)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

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

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
	
    int n;
    cin >> n;
    vector<int> vec(n), left(n), right(n);
    rep(i,n)
    	cin >> vec[i];

    left[0] = vec[0];
    repA(i,1,n-1)
    	left[i] = max(vec[i], left[i - 1]);

    right[n - 1] = vec[n - 1];
    repD(i,n-2,0)
    	right[i] = max(vec[i], right[i + 1]);

    cout << right[1] << '\n';
    repA(i,1,n-2)
    	cout << max(left[i - 1], right[i + 1]) << '\n';
    cout << left[n - 2] << '\n';
}

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

int inspect(string s,string t,int i){
    int tmp=0;
    for(int k=0;k<t.size();k++){
        if(s.at(i+k)==t.at(k))tmp++;
    }
    return t.size()-tmp;
}
int main(void){
    string s,t;
    cin>>s>>t;
    int min=t.size();
    for(int i=0;i<s.size()-t.size()+1;i++)min=std::min(min,inspect(s,t,i));
    cout<<min<<endl;
    return 0;
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> v;
	for(int i = 0; i < n; i++ ) {
		int tmp;
		cin >> tmp;
		v.push_back(tmp);
	}
	sort( v.begin(), v.end() );
	int max = v[n-1]-v[0];
	cout << max << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int x = sc.nextInt();

        for(int i=1;i<=x;i++){
            int j = i;
            int a = j%10;
            j/=10;
            int b = j%10;
            j/=10;
            int c = j%10;
            j/=10;
            int d = j%10;
            j/=10;
            int e = j%10;

            if(i%3==0){
                System.out.print(" " + i);
                continue;
            }
            if(a==3 || b==3 || c==3 || d==3 || e==3){
                System.out.print(" " + i);
            }
        }
        System.out.println();
    }
}


Measured memory_bytes: 28988
#include <iostream>
#include <cstdlib>
#include <sstream>
#include <algorithm>

using namespace std;

int main(void) {
  int n,m;
  int t;
  int mi = 0;
  string line,item;
  cin >> n >> m;
  cin.ignore();
  int A[n][m],b[m],answer[n];
  fill(A[0], A[n], 0);
  fill(b, b + m, 0);
  fill(answer, answer + n, 0);
  for(int i = 0; i < n; i++) {
    getline(cin, line);
    stringstream ss(line);
    while(getline(ss, item, ' '))
      A[i][mi++] = atoi(item.c_str());
    mi = 0;
  }
  for(int i = 0; i < m; i++) {
    cin >> t;
    b[i] = t;
  }
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < m; j++) {
      answer[i] += A[i][j] * b[j];
    }
  }
  for(int i = 0; i < n; i++)
    cout << answer[i] << endl;
  return 0;
}

Measured memory_bytes: 3208
#include<iostream>
using namespace std;
char t[100][100];
int n,a,x,y,d,ny,nx,flg,cnt;
int dx[4]={0,1,0,-1};
int dy[4]={-1,0,1,0};

void rec(int y,int x,int d){

  
  /*
    for(int i=0;i<a;i++){
      for(int j=0;j<a;j++){
	cout<<t[i][j];
      }
      cout<<endl;
    }

    cout<<y<<' '<<x<<' '<<d<<endl;*/
  cnt=0;
  for(int i=0;i<a;i++){
    t[y][x]='#';cnt++;
    ny=y+dy[d]*2;
    nx=x+dx[d]*2;
    if(t[ny][nx]=='#'){
      break;
    }
    y=y+dy[d];
    x=x+dx[d];
  }
  if(cnt>=3)rec(y,x,(d+1)%4);
}

int main(){
  cin>>n;
  while(n--){
    cin>>a;
    if(a==1){
      cout<<'#'<<endl;
          if(n>=1)cout<<endl;
      continue;
    }else if(a==2){
      cout<<"##"<<endl;
      cout<<"# "<<endl;
    if(n>=1)cout<<endl;
      continue;
    }else if(a==4){
      cout<<"####"<<endl;
      cout<<"#  #"<<endl;
      cout<<"#  #"<<endl;
      cout<<"# ##"<<endl;
    if(n>=1)cout<<endl;
      continue;
    }

    for(int i=0;i<100;i++)
      for(int j=0;j<100;j++)
	t[i][j]=' ';
    
    t[a-1][0]=' ';
    x=0;y=a-1;
    
    for(int i=0;i<a;i++){
      t[a-1][i]=t[i][a-1]='#';
      t[0][i]=t[i][0]='#';
    }
    t[a-1][1]=' ';
    
    rec(a-1,2,0);
    



    for(int i=0;i<a;i++){
      for(int j=0;j<a;j++){
	cout<<t[i][j];
      }
      cout<<endl;
    }
    if(n>=1)cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
using namespace std;

int main(){
  int N; cin>>N;
  int ans = 0;
  vector <int> v;v.resize(N);
  vector <int> c;c.resize(N);
  for(int i=0;i<N;i++){
    cin>>v[i];
  }

   for(int i=0;i<N;i++){
    cin>>c[i];
  }
 
 for(int i=0;i<N;i++){
   ans = max(ans,ans + v[i] - c[i]);
 }

 cout<<ans<<endl;

 return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Aeroui
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int[] arr = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};

            out.println(arr[in.nextInt()] == arr[in.nextInt()] ? "Yes" : "No");
        }

    }
}



Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  string n;
  cin >> n;
  bool flag = true;
  for (int i = 0;i < 3; i++)
  {
    if (n.at(i) == '7')
    {
      cout << "Yes" << endl;
      flag = false;
      break;
    }
  }
  if (flag)
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3620
S = input()[::-1]
T = ["maerd", "remaerd", "esare", "resare"]

while len(S)>0:
    if S[:5] in T:
        S = S[5:]
    elif S[:6] in T:
        S = S[6:]
    elif S[:7] in T:
        S = S[7:]
    else:
        print("NO")
        exit()

print("YES")

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

typedef long long int64;
int n;
int64 a, b;

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

	for(int i = 2; i <= n; i++) {
		int64 c, d; scanf("%lld%lld", &c, &d);
		int64 k = max((a + c - 1) / c, (b + d - 1) / d);
		a = c * k;
		b = d * k;
	}

	printf("%lld\n", a + b);
	return 0;
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
#define VL vector<lol>
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{0};
    lol n; cin >> n;
    REP(i, n)
    {
        lol a; cin >> a;
        if(a%2 == 0 && (a%3 != 0 && a%5 != 0))
        {
            cout << "DENIED" << endl;
            result++;
            break;
        }

    }
    if(result == 0)
    {
        cout << "APPROVED" << endl;
    }
    return 0;
}

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

ll ans(int K){
  if(K==0){
    return 1;
  }
  ll s = ans(K-1)*2+1;
  return s;
}
int main(){
  ll H;
  int K=0;
  cin>>H;
  //cout<<H/2;//ガウス済み
  //計算量logNを目指す
  //三角形を書いたとき初めの数を除いた残りは対称である
  //(2*今までの回数+1)をK回
 
    
  while(1){
     if(H<2) break;
     H=H/2;
     K++;
  }

  
 // cout<<K<<endl;
  cout<<ans(K)<<endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    char s[4];
    scanf("%s",s);
    for (int i=0; i<3; i++){
        if (s[i]=='1'){
            s[i]='9';
        } else {
            s[i]='1';
        }
    }
    printf("%s\n",s);
	return 0 ;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1L << 30
#define long long long

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

long N, M;
int main(){
	cin >> N >> M;
	vector<long> A(N);
	rep(i, N) cin >> A.at(i);

	
	//sort
	sort(A.begin(), A.end(), greater<long>());
	long sigma = accumulate(A.begin(), A.end(), 0);
	double standart = sigma/(4.0*M);
	//cout << "standart " << standart << endl;
	//bool isYes = true;
	rep(i, M){
		//cout << A.at(i) << endl;
		if (A.at(i) < standart){
			cout << "No" << endl;
			exit(0);
		}
	}
	cout << "Yes" << endl;



}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main()
{
    int k,x,i;
    while(cin>>k>>x)
    {
        for(i=x-k+1;i<x+k-1;i++) cout<<i<<" ";
        cout<<x+k-1<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

int main(){
	string str;cin>>str;
	if(str[0]!='A'){cout<<"WA"<<endl;return 0;}
	
	bool flag = false;int kount = 0;
	if(str[1]<'a'||str[1]>'z')flag = true;
	for(int i=2;i<str.length();i++){
		if(i!=str.length()-1&&str[i]=='C'){kount++;continue;}
		if(str[i]<'a'||str[i]>'z')flag = true;
		
		//if(str[i]=='c')flag = true;
	}
	if(kount!=1)flag = true;
	if(flag)cout<<"WA"<<endl;
	else cout<<"AC"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
const ll INF = 1LL << 60; //MAX 9223372036854775807
void warshallfloyd(vector<vector<ll>> &d)
{
  for (int k = 0; k < d.size(); k++)
    for (int i = 0; i < d.size(); i++)
      for (int j = 0; j < d.size(); j++)
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

int main()
{
ll n ,mx=-1;
cin >> n ;
vector<ll> a(n);
rep(i, n){
  cin >> a[i];
}
vector<ll> b(n);
rep(i, n){
  cin >> b[i];
}
rep(i,n){
  if(!(a[i]==b[i]||a[i]>b[i]*2)){
    cout << -1 << endl;
    return 0;
  }
  if(a[i]!=b[i])mx=max(mx,a[i]);
}
if(mx==-1){
  cout << 0 << endl;
  return 0;
}
vector<bool> an(mx+1,1);
an[0]=0;
for (ll i = mx; i > 0; i--)
{
  an[i]=0;
  vector<vector<ll>> d(mx+1, vector<ll>(mx+1, INF));
  rep(j, mx+1)d[j][j] = 0;
  rep(k,mx)rep(l,mx){
    if(an[l+1])d[k+1][(k+1)%(l+1)]=0;
  }
  warshallfloyd(d);
  rep(k,n){
    if(d[a[k]][b[k]]!=0)an[i]=1;
  }
}
rep(i,an.size()){
  if(an[i])ans+=1LL<<i;
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,m,max=0,s,i,a;
  scanf("%d %d",&n,&m);
  while(n--){
    for(i=s=0;i<m;i++){
      scanf("%d",&a);
      s+=a;
    }
    if(max<s)max=s;
  }
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll R;
    cin >> R;

    if(R < 1200){
        cout << "ABC" << endl;
    }else if(R < 2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/

signed main(){
  int n,q;
  cin>>n>>q;
  string s;
  cin>>s;
  vi ac(n,0);
  rep(i,n-1){
    if(s[i]=='A'&&s[i+1]=='C') ac[i]=1;
  }
  // rep(i,n)cout<<ac[i];cout<<endl;
  rep(i,n-1) ac[i+1]+=ac[i];
  // rep(i,n)cout<<ac[i];cout<<endl;
  rep(i,q){
    int l,r;
    cin>>l>>r;
    l--;r--;
    int ans;
    if(l==0) ans=ac[r-1];
    else ans=ac[r-1]-ac[l-1];
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int mex=100005;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr[i]);
#define sz(x) x.size()
#define loop(x) for(auto it=x.begin();it!= x.end();it++) 


ll int power(ll int a,ll int b)
{
    ll int ans=1,f=a;
    while(b)
    {
        if(b&1ll) ans=(ans*f)%mod;
        b=b>>1ll;
        f=(f*f)%mod;
    }
    return ans;
}


int main()
{
  
    string s,t;
    cin>>s>>t;
    int ans=1e9;
    for(int i=0;i<s.size()-(t.size()-1);i++)
    {
        int cnt=0;
        for(int j=0;j<t.size();j++)
    {
        
        if(s[i+j]!=t[j]) cnt++;
    }
    ans=min(ans,cnt);
    }
    cout<<ans<<endl;

    

}

Measured memory_bytes: 3632
JPY = "JPY"
RATE = 380000
N = int(input())
my_list = []
for i in range(N):
    s = input()
    my_list.append((float(s.split()[0]), s.split()[1]))

# for i in range(N):
#     print("[{}] [{}] [{}]".format(i, my_list[i][0], my_list[i][1]))
ret = 0
for i in range(len(my_list)):
    if my_list[i][1] == JPY:
        ret += my_list[i][0]
    else:
        ret += my_list[i][0] * RATE
print(ret)

Measured memory_bytes: 3064
from functools import lru_cache
MOD = 10**9 + 7

def is_prime(n):
    assert n >= 1,  'Argument Error! n is "1 <= n".'
    for i in range(2, n + 1):
        if i ** 2 > n:
            break
        if n % i == 0:
            return False
    return n != 1

def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

@lru_cache(maxsize=MOD)
def modinv(a, mod):
    g, x, y = xgcd(a, mod)
    assert g == 1, 'modular inverse does not exist'
    return x % mod

factorials = [1]
def factorial(n, mod):
    # n! % mod
    assert n >= 0, 'Argument Error! n is "0 <= n".'
    if len(factorials) < n+1:
        for i in range(len(factorials), n+1):
            factorials.append(factorials[-1]*i % mod)
    return factorials[n]

def comb(n, r, mod):
    # nCr % mod
    assert n >= 0, 'Argument Error! n is "0 <= n".'
    assert n >= r >= 0, 'Argument Error! r is "0 <= r <= n".'
    
    return perm(n, r, mod) * modinv(factorial(r, mod), mod) % mod

def comb_with_repetition(n, r, mod):
    # nHr % mod
    assert n >= 0, 'Argument Error! n is "0 <= n".'
    assert n+r-1 >= r >= 0, 'Argument Error! r is "0 <= r <= n+r-1".'
    
    return comb(n+r-1, r, mod)

def perm(n, r, mod):
    # nPr % mod
    assert n >= 0, 'Argument Error! n is "0 <= n".'
    assert n >= r >= 0, 'Argument Error! r is "0 <= r <= n".'
    return factorial(n, mod) * modinv(factorial(n-r, mod), mod) % mod

x, y = sorted(list(map(int, input().split())))
MOD = 10 ** 9 + 7
q, r = divmod(x+y, 3)

if r != 0:
    print(0)
else:
    try:
        print(comb(q, y - q, MOD))
    except AssertionError:
        print(0)

Measured memory_bytes: 30020
#include <iostream>
#include <string>

using namespace std;

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

    for(int i = 9; i > 0; --i) {
        if(n % i == 0 && n / i <= 9){
            cout << "Yes";
            return 0;
        }
    }

    cout << "No";
    return 0;
}


Measured memory_bytes: 256
x,n=map(int,input().split())
if  n!=0:
    l=list(map(int,input().split()))
    for i in range(150):
        x1=x-i
        x2=x+i
        if not x1 in l:
            print(x1)
            break
        elif not x2 in l:
            print(x2)
            break
else:
    print(x)

Measured memory_bytes: 9188
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{ 
    static void Main(string[] args)
    {
        var nm = Input.ar; 
        var pp = new List<int>();
        for (var i = 1; i * i <= nm[1]; i++)
            if (nm[1] % i == 0)
            {
                pp.Add(i);
                if (i != nm[1] / i)
                    pp.Add(nm[1] / i);
            }
        WriteLine(pp.Where(v => v <= nm[1] / nm[0]).Max());
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const double eps = 1e-11;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

void dfs(int k, const vvi &map, vector<bool> &ald){
    if(ald[k] == true){return;}
    ald[k] = true;
    for(auto x: map[k]){
        dfs(x, map, ald);
    }
    return;
}

int main(){
    ll N, M; cin >> N >> M;
    vvi map(N, vi());
    vi Z(M);
    for(int i=0; i<M; i++){
        int a, b;
        cin >> a >> b >> Z[i];
        map[a-1].emplace_back(b-1);
        map[b-1].emplace_back(a-1);
    }
    vector<bool> ald(N, false);
    ll c = 0;
    for(int i=0; i<N; i++){
        if(ald[i] == false){
            dfs(i, map, ald);
            c++;
        }
    }
    cout << c;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, K;
int cnt[110];

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

  std::cin >> N >> K;

  for(int i=0;i<K;++i){
      int d;
      std::cin >> d;

      for(int j=0;j<d;++j){
          int A;
          std::cin >> A;

          cnt[A] += 1;
      }
  }

  int res = 0;

  for(int i=1;i<=N;++i){
      if(cnt[i] == 0){
          res += 1;
      }
  }

  std::cout << res << std::endl;
}


Measured memory_bytes: 3616
n,m=map(int, input().split())
mt=[0,2,5,5,4,5,6,3,7,6]
a=sorted(map(int, input().split()))[::-1]
dp=[-1]*(n+1)
dp[0]=0
for i in range(n+1):
    if dp[i]==-1:continue
    for j in a:
        if i+mt[j]<n+1:
            dp[i+mt[j]]=max(dp[i]*10+j,dp[i+mt[j]])
print(dp[-1])

Measured memory_bytes: 14708