akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

int main(){
    // read in integer 
    ll k, n;
    

    cin >> k >> n;
    vector<ll> a(n, 0);
    REP(i, n) cin >> a[i];

    
    // sort(a.begin(), a.end());
    // cout << a[]

    ll x = a[0];
    ll maxdist = a[1] - a[0];
    FOR(i, 1, n){
        if ((a[i] - a[i-1]) > maxdist){
            maxdist = a[i] - a[i-1];
            x = a[i-1];
        }
    }
    if ((k - a[n-1] + a[0]) > maxdist){
        maxdist = k - a[n-1] + a[0];
        x = a[n-1];
    }
    // cout << "x: " << x << endl;

    ll curr = 0;
    REP(i, n){
        if (i == n-1){
            // cout << "adfa" <<endl;
            if (a[i] != x){
                curr += (k - a[n-1] + a[0]);
            } 
        }
        else if (a[i] != x) {
            curr += a[i+1]-a[i];
            // cout << curr << endl;
        }
    }

    cout << curr << endl;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define l(i,a,b) for(auto i=a;i<b;i++)
#define lr(i,a,b) for(auto i=a;i>=b;i--)
#define sl(i,m) for(auto i=m.begin();i!=m.end();++i)
#define ll long long
#define lli long long int
#define ld long double
#define vec vector<int>
#define mii map<int,int>
#define vl vector<long long>
#define se set <long long int>
#define pii pair<long long,long long>
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define tc int t;i(t);while(t--)
#define all(v) v.begin(), v.end()
#define i(x) cin>>x
#define o(x) cout<<x
#define nl o("\n");
#define pi 3.14159265359
#define SYNC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    SYNC 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int sum=0;
    string n;
    i(n);
    l(i,0,n.length())
    {
        sum+=(n[i]-'0');
    }
    if(sum%9)
    o("No");
    else
    o("Yes");
}

Measured memory_bytes: 3740
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

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

    int A[n][d];

    for(int i = 0;i<n;i++)
    {
        for(int j = 0;j<d;j++)
        {
            cin>>A[i][j];
        }
    }

    int ans = 0;
    int distance = 0;
    double sq = 0;
    for(int i = 0;i<n;i++)
    {
        for(int j = i+1;j<n;j++)
        {
            for(int k = 0;k<d;k++)
            {
                distance += (A[i][k] - A[j][k])*(A[i][k] - A[j][k]);
            }
            if(ceil(sqrt(distance)) == floor(sqrt(distance)))
            {
                ans++;
            }
            distance = 0;
        }

 
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,K;
    cin >> N >> K;
    vector<ll> V(N),accum(N+1);
    rep(i,0,N){
        cin >> V[i];
        accum[i+1] = accum[i] + V[i];
    }
    vector<ll> cand;
    rep(i,0,N+1){
        rep(j,i+1,N+1){
            //cout << accum[j] - accum[i] << " ";
            cand.push_back(accum[j] - accum[i]);
        }
        //cout << endl;
    }
    for(int i = 42;i >= 0;i--){
        int cnt = 0;
        for(auto num:cand){
            if(num & (1LL << i))cnt++;
        }
        if(cnt < K)continue;
        vector<ll> next;
        for(auto num:cand){
            if(num & (1LL << i))next.push_back(num);
        }
        cand = next;
    }
    //cout << cand.size() << endl;
    //assert(K == cand.size());
    //for(auto num:cand)cout << bitset<6>(num) << " ";cout << endl;
    ll bit = (1LL << 43) - 1;
    //cout << bitset<10>(bit) << endl;
    rep(i,0,K)bit &= cand[i];
    cout << bit << endl;
}

Measured memory_bytes: 6260
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let ab = read_vec::<i32>();
    let (a,b) = (ab[0],ab[1]);
    let dif =  b -a;
    let v :i32= (0..dif+1).fold(0,|x,y| x +y);
    let ans  = v -b;
    println!("{}",ans);
}

Measured memory_bytes: 4352
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

int N, M;
V<int> a;
V<tuple<int,int>> cb;

int main(){
    INIT;
    cin >> N >> M;
    a.resize(N);
    REP(i,N) cin >> a[i];
    REP(i,M) {
        int b, c; cin >> b >> c;
        cb.push_back(make_tuple(c,b));
    }
    std::sort(ALL(a));
    std::sort(ALL(cb));
    int ci = 0;
    REP(i,M) {
        int c, b;
        std::tie(c,b) = cb[M-1-i];
        while(b > 0) {
            if(ci < N && a[ci] < c) a[ci++] = c, b--;
            else break;
        }
    }
    LL ans = 0;
    REP(i,N) ans += a[i];
    cout << ans;
}

Measured memory_bytes: 1912
#include <bits/stdc++.h>
#include <boost/foreach.hpp>
using namespace std;
#define pi 2*asin(1.0)
#define MAX 10000000
#define MOD 1000000007
#define _GLIBCXX_DEBUG
 
vector<long> fac(MAX);
vector<long> finv(MAX);
vector<long> inv(MAX);
vector<long> Primelist;
//template functions
/////////////////////////
void Prinit(){
long PR=10000001;
vector<long> P(PR,0);
for(long i=2;i*i<PR;i++){
    if(P.at(i)==0){
        long j=i;
      j+=i;
        while(j<PR){
            P.at(j)=1;
             j+=i;         
        }
    }
}

for(long i=2;i*i<PR;i++){//Primelist.size()=446
    if(P.at(i)==0){
        Primelist.push_back(i);
    }
}
}

void Cominit(){
  fac.at(0)=fac.at(1)=1;
  finv.at(0)=finv.at(1)=1;
  inv.at(1)=1;
  for(long i=2;i<MAX;i++){
      fac.at(i)=(fac.at(i-1)*i)%MOD;
      inv.at(i)=MOD-inv.at(MOD%i)*(MOD/i)%MOD;
      finv.at(i)=finv.at(i-1)*inv.at(i)%MOD;
  }
}

long facComb(long N,long M){// nCm%
if(N<M) return 0;
if(N<0||M<0) return 0;
return fac.at(N)*(finv.at(M)*finv.at(N-M)%MOD)%MOD;
}

long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}

long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}

long GCM(long A,long B){
            long W,r;
    if(A<B){

        W=B;
        B=A;
        A=W;
    }
    while(A%B!=0){
        r=A%B;
        A=B;
        B=r;
    }
    return B;
}
long LCM(long A,long B){
    return (A*B)/GCM(A,B);
}

long upDiv(long a,long b){
  return (a+b-1)/b;
}

long strtolong(string str){
istringstream ss;
ss=istringstream(str);
long num;
ss>>num;
return num;
}

long chartolong(char ch){
long num;
num=ch-'0';
return num;
}

long Max2(long a,long b){
if(a>b){
    return a;
}else{
    return b;
}
}

long Min2(long a,long b){
if(a>b){
    return b;
}else{
    return a;
}
}


string longtostr(long N){
    string str;
    str=to_string(N);
    return str;
}









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


//Answer




int main() {
Prinit();
long BIG=998244353;
long N,K;
cin>>N>>K;
typedef pair<long,long> P;
vector<P> LR(K+1);
P zero=make_pair(0,0);
vector<long> List(N,0);
vector<P> dp(N,zero);
for(long i=0;i<K;i++){
    cin>>LR.at(i).first>>LR.at(i).second;
}
dp.at(0).second=1;
for(long i=1;i<N;i++){
    for(long j=0;j<K;j++){
        if(i>LR.at(j).second){
            dp.at(i).first+=dp.at(i-LR.at(j).first).second-dp.at(i-LR.at(j).second-1).second;
            dp.at(i).first=(dp.at(i).first+BIG)%BIG;
        }else if(i>=LR.at(j).first){
            dp.at(i).first+=dp.at(i-LR.at(j).first).second;
            dp.at(i).first=(dp.at(i).first+BIG)%BIG;
        }
    }
    dp.at(i).second=dp.at(i).first+dp.at(i-1).second;
    dp.at(i).second=(dp.at(i).second+BIG)%BIG;
}

cout<<dp.at(N-1).first<<endl;


}








Measured memory_bytes: 315664
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_bakc
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


int main() {
	IO;
	int a,b,c;
	cin>>a>>b>>c;
	cout<<(b*c>=a?"Yes":"No")<<"\n";
	return 0;
}


Measured memory_bytes: 3644
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

count = 0
for idx in range(len(a)-1):
    if a[idx] > b[idx]:
        count += b[idx]
    else:
        count += a[idx]
        if a[idx+1] > b[idx] - a[idx]:
            a[idx+1] -= (b[idx] - a[idx])
            count += (b[idx] - a[idx])
        else:
            count += a[idx+1]
            a[idx+1] = 0
print(count)

Measured memory_bytes: 19156
#include<bits/stdc++.h>
using namespace std;
//define
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
#define elif else if
//vectordefine
#define vint vector<int>
#define vc vector<char>
#define vtr vector<string>
#define pb(n) push_back(n)
//queuedefine
#define qint queue<int>
#define qc queue<char>
#define qstr queue<str>
//mapdefine
#define mint map<int>
#define mc map<char>
//pairdefine
#define pint pair<int,int>
#define pis pair<int,str>
#define pic pair<int,char>
#define pci pair<char,int>
#define mod 100000007

string syugei(int N){
  string ST="b";
  for(int i=0;i<N;i++){
    if(i%3==0||i==0)ST="a"+ST+"c";
    else if(i%3==1||i==1)ST="c"+ST+"a";
    else if(i%3==2||i==2)ST="b"+ST+"b";
  }
  return ST;
}
//main
signed main(){
  int N,M,O,P,X,count=0,count2=0;
  double D;
  int c='A'-'a';
  char C;
  str S,T;
  cin>>N>>M;
  if((N+M)%2==0)cout<<(N+M)/2<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    int N; cin >> N;

    int msd = N/100;
    if (msd*100+msd*10+msd < N) {
        msd++;
    }

    cout << msd*100+msd*10+msd << endl;
    return 0;
}

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

int main(){
	int a,b,h;
	cin >> a;
	cin >> b;
	cin >> h;
	
	if(1>a || a>100 ||1>b || b>100 || 1>h || h>100)exit(1);
	if(h%2 != 0)exit(1);
	
	cout << (a+b)*h/2;

return 0;
}


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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ld> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n;
	cin >> n;

	int val = n / 1.08;
	for (int i = -20; i <= 20; ++i)
		if (val + i >= 0 && floor((val + i) * 1.08) == n)
		{
			cout << val + i << "\n";
			return 0;
		}

	cout << ":(\n";

	return 0;
}


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

typedef long long ll;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define yes "Yes"
#define yse "Yes"
#define no "No"

#define pb push_back
#define mp make_pair

#define rep(i, l, n) for (int i = (l); i < n; i++)
#define rep_cs(i, l, n) for (int i = (l); i <= n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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

const int MOD = 1000000007;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(v.begin(), v.end());
// int sum = accumulate(v, v + v.size(), 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

using Graph = vector<vector<int>>;
Graph G;
vector<bool> seen;
void dfs(const Graph &G, int v)
{
    seen[v] = true;

    for (auto next_v : G[v])
    {
        if (seen[next_v])
            continue;
        dfs(G, next_v);
    }
}

int main()
{
    int n, q, t;
    string name;
    queue<pair<string, int>> Q;

    cin >> n >> q;

    rep(i, 0, n)
    {
        cin >> name >> t;
        Q.push(mp(name, t));
    }

    pair<string, int> u;
    int elaps = 0;
    int a;

    while (!Q.empty())
    {
        u = Q.front();
        Q.pop();

        a = min(u.second, q);
        u.second -= a;
        elaps += a;

        if (u.second > 0)
        {
            Q.push(u);
        }
        else
        {
            cout << u.first << " " << elaps << endl;
        }
    }
}


Measured memory_bytes: 6336
#include <bits/stdc++.h>
using namespace std;
void solve(){
  
  
}
int main()
{
 
   int n,x;
   cin>>x>>n;
   int a[n];
   set<int>s;
   if(n==0)
    cout<<x<<endl;
    else
    {
        for(int i=0;i<n;i++)
         {
            cin>>a[i];
           s.insert(a[i]);
        }
        if(s.find(x)==s.end())
                cout<<x<<endl;
        else
        {
        int inc=1;
        int dec=1;
           while(true)
           {
                
                if(s.find(x-dec)==s.end())
                   { 
                    cout<<x-dec<<endl;
                    break;
                   }
                   else if(s.find(x+inc)==s.end())
                   {
                    cout<<x+inc<<endl;
                    break;
                   }
                
                inc++;
                dec++;
            }
        }
       }

  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int mod=1e9+7,N=4e5+5;
int n,ans,k,fac[N],inv[N];

int fpow(int x,int y){
	int res=1;
	for(;y;y>>=1,x=x*x%mod) if(y&1) res=res*x%mod;
	return res;
}

int C(int x,int y){
	if(x<y||x<0) return 0;
	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}

signed main(){
	read(n);read(k);
	fac[0]=1;
	for(int i=1;i<=n+n;i++) fac[i]=fac[i-1]*i%mod;
	inv[n+n]=fpow(fac[n+n],mod-2);
	for(int i=n+n-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	for(int i=max(1ll,n-k);i<=n;i++) ans=(ans+C(n,i)*C(n-1,i-1)%mod)%mod; 
	write(ans);
}

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

vector<int> p[1005];
int main(){
    int n;
    int in[3];
    int erase = 0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> in[0] >> in[1] >> in[2];
        sort(in,in+3);
        p[i].push_back(in[0]);
        p[i].push_back(in[1]);
        p[i].push_back(in[2]);
    }
    sort(p,p+n);
    for(int i=0;i<n-1;i++){
        if(p[i][0] == p[i+1][0] && p[i][1] == p[i+1][1] && p[i][2] == p[i+1][2]){
            erase++;
        }
    }
    cout << erase << "\n";
    return 0;
}


Measured memory_bytes: 3232
/*
*  Author: windystreet
*  Date  : 2018-09-12 21:26:29
*  Motto : Think twice, code once.
*/
#include<bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const int INF  = 1<<30;
const int mod  = 1e9+7;

void solve(){
    int x,y;
    cin>>x>>y;
    if((x*y)%2){
    	cout<<"Yes\n";
    }else{
    	cout<<"No\n";
    }
    
    return;
}

int main()
{
//    freopen("F:\\in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
    return 0;
}

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

int main(){
	int n,l[101],max=0,sum=0;
  	cin >> n;
  	for(int i=0;i<n;i++){
		cin >> l[i];
      	sum+=l[i];
      if(l[i]>max){
        	max=l[i];
      }
    }
  
  	if(2*max<sum){
	cout << "Yes" << endl;
    }else{
	cout << "No" << endl;
    }
}

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

int main() {
  string str1;
  cin >> str1;
  for (int i = 0; i < str1.size() - 1; i++) {
    
   if(str1.at(i) == str1.at(i + 1)) {
     cout << "Bad" << endl;
     return 0;
   }
  }
  cout << "Good" << endl;
}

Measured memory_bytes: 256
import math
n = int(input())

min_n = n

for i in range(1,int(math.sqrt(n))+1):
    if n % i == 0:
        a = len(str(i))
        b = len(str(int(n/i)))
        
        if min_n > max(a,b):
            min_n = max(a,b)


print(min_n)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define MOD (int) (1e9+7)
#define INF (int) 1e9
#define LLINF (ll) 1e18

int main(){
    ll n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];

    ll ans = 1000;
    for (int i = 1; i < n; i++){
        if(a[i] > a[i-1]){
            ll tmp = ans / a[i-1];
            ans += (a[i]-a[i-1])*tmp;
        }
    }
    
    cout << ans << endl;

    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

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; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()


int main() {
    ll N;
    cin >> N;
    for (ll h = 1; h <= 3500; h++) {
        for (ll n = 1; n <= 3500; n++) {
            ll p = 4 * h * n - N * n - N * h;
            if (p > 0 && N * h * n % p == 0) {
                ll w = N * h * n / p;
                printf("%d %d %d\n", h, n, w);
                exit(0);
            }
        }
    }
}

Measured memory_bytes: 384
n = int(input())
a= []
result = []
for i in range(0,n):
	a.append(list(input().split()))
#print(n)
#print(a)

for j in ('S','H','C','D'):
	for k in range(1,14):
		if [j, str(k)] not in a:
			result.append([j, str(k)])

for l in result:
	print('{0} {1}'.format(l[0], l[1]))


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

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for (size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

//Auther: Arin Roday
#define vec vector
#define i64 long long
#define endl '\n'
#define sz(x) (x).size()
#define times(n) for(int i = 0; i < (n); ++i)

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


Measured memory_bytes: 3612
ans [x1,y1,z1,w1,x2,y2,z2,w2] =
  let x = x1*x2 - y1*y2 - z1*z2 - w1*w2
      y = y1*x2 + x1*y2 - w1*z2 + z1*w2
      z = z1*x2 + w1*y2 + x1*z2 - y1*w2
      w = w1*x2 - z1*y2 + y1*z2 + x1*w2
  in
    [x,y,z,w]

ans' :: [[Int]] -> [[Int]]
ans' ([0]:x) = []
ans' ([n]:x) = 
  let a = map ans $ take n x
      y = drop n x
  in
    a ++ (ans' y)

main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Int]]
      o = ans' i
  mapM_ putStrLn $ map unwords $ map (map show) o

Measured memory_bytes: 4404
#include <iostream>
#include<vector>
using namespace std;
typedef long long int ll;

int main()
{
    int N;
    cin>>N;
     vector<ll> p;
    while(N--)
    {

    int n;
    cin>>n;
    switch(n)
    {
        case 0:int num;
        cin>>num;
        p.push_back(num);
        break;
        case 1: int num1;
        cin>>num1;
        cout<<p[num1]<<endl;
        break;
        case 2:
            p.pop_back();
            default: break;
    }

    }
}


Measured memory_bytes: 4936
#include<bits/stdc++.h>
#define int long long
using namespace std ;
int read() {
  int x = 0 , f = 1 ;
  char c = getchar() ;
  while(c < 48 || c > 57) {
    if(c == '-') f = -1 ;
    c = getchar() ;
  }
  while(c > 47 && c < 58) {
    x = (x << 1) + (x << 3) + (c & 15) ;
    c = getchar() ;
  }
  return x * f ;
}

int n ;
const int N = 3e5 + 5 ;
int a[N] ;
int c[N][62] ;
int mx = 0 ;
const int mod = 1e9 + 7 ;
signed main() {
  n  = read() ;
  for(int i = 1 ; i <= n ; i ++) a[i] = read() , mx = max(mx , a[i]) ;
  for(int i = 1 ; i <= n ; i ++)
    for(int j = 0 ; (1ll << j) <= a[i] ; j ++)
      if(a[i] & (1ll << j)) c[i][j] = 1 ;
  int ans = 0 ;
  for(int j = 0 ; (1ll << j) <= mx ; j ++) {
    int tot = 0 ;
    for(int i = 1 ; i <= n ; i ++) {
      if(c[i][j]) { tot ++ ; }
    }
    ans=(ans+(1ll<<j)%mod*((tot*(n-tot))%mod)%mod)%mod;  }
  cout << ans << '\n' ;
  return 0 ;
}


Measured memory_bytes: 147840
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var ca = S.ToCharArray();
		for(int i=0;i<S.Length;i++){
			ca[i] = (char)(ca[i] + N);
			if(ca[i] > 'Z') ca[i] -= (char)26;
		}
		Console.WriteLine(new String(ca));
		
		
	}
	int N;
	String S;
	public Sol(){
		N = ri();
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11152
#include <iostream>
#include <fstream>
#include <sstream>
#include <random>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>
#include <iostream>
#include <functional>
#include <stdio.h>
#include <string.h>
#include <unordered_map>
#include <set>
#include <iomanip>

#define ll long long
#define mod 1000000007
#define max_limit 1000005
using namespace std;

ll n;
ll k;
ll arr[max_limit];

ll inv[max_limit];
ll inv_factorial[max_limit];
ll factorial[max_limit];

ll C(ll n, ll k) {
    return (factorial[n] * inv_factorial[k] % mod * inv_factorial[n - k]%mod)%mod;
}


int main() {

    cin>>n>>k;
    ll max_num = 1;
    for(ll i = 0; i < n; i++) {
        cin>>arr[i];
        if(arr[i] > max_num) {
            max_num = arr[i];
        }

    }

    sort(arr, arr + n);

    factorial[0] = 1;
    for(ll i = 1; i <= n; i++) {
        factorial[i] = (factorial[i - 1] * i) % mod;

    }

    // Calculate inverses.
    inv[0] = 1;
    inv[1] = 1;
    for(ll i = 2; i <= n; i++) {
        inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;
    }

    inv_factorial[0] = 1;
    inv_factorial[1] = 1;
    for(ll i = 2; i <= n; i++) {
        inv_factorial[i] = (inv_factorial[i - 1]*inv[i])%mod;

    }


    ll sum = 0;
    for(ll i = 0; i < n; i++) {
        if(i >= k - 1) {
            sum = (sum + (arr[i]*C(i, k - 1)))%mod;
        }
        if(n - i - 1 >= k - 1) {
            sum = (sum - (arr[i]*C(n-i-1, k - 1)))%mod;
        }

    }


    cout<<sum<<'\n';

    return 0;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;

int main(){
  int n; cin>>n;
  int d[n];
  int res=0;
  REP(i,n)cin>>d[i];
  REP(i,n){
    for(int j=0;j<i;j++)res+=d[i]*d[j];
    }
  
 cout<<res<<endl;
}

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

using namespace std;
using namespace atcoder;

using lint = long long;
#define rep(i, n) for(lint i = 0; i < lint(n); i++)
#define repu(i, a, b, s) for(lint i = lint(a); i < lint(b); i += lint(s))
#define repd(i, a, b, s) for(lint i = lint(a); i > lint(b); i += lint(s))
#define endl "\n"
constexpr lint INF = 2e18;
constexpr lint MOD = 1e9 + 7;

void solve() {

    lint N, Q;
    cin >> N >> Q;
    fenwick_tree<lint> bit(N);

    rep(i, N) {
        lint t;
        cin >> t;
        bit.add(i, t);
    }

    rep(i, Q) {
        lint t, u, v;
        cin >> t >> u >> v;
        if(t == 0) {
            bit.add(u, v);
        } else {
            cout << bit.sum(u, v) << endl;
        }
    }
}

int main(int argc, char *argv[]) {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}

Measured memory_bytes: 8256
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.nextLine();
            out.println(s.replaceAll(",", " "));

        }
    }


    static class InputReader implements AutoCloseable {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            //reader = new BufferedReader(new FileReader(stream), 32768);
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return "";
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public void close() {
        }

    }
}

Measured memory_bytes: 23508
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
using namespace std;

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

    vector<int> a(n);
    a[0] = b[0];
    a[1] = b[0];
    for (int i = 1; i < n-1; i++) {
        if (b[i] < a[i]) a[i] = b[i];
        a[i+1] = b[i];
    }

    cout << accumulate(a.begin(), a.end(), 0) << endl;
}

Measured memory_bytes: 256
#include<cstdio>

int N, A;

int main() {
  scanf("%d", &N);
  scanf("%d", &A);

  if (A >= 500) {
    printf("Yes\n");
  } else if (N % 500 <= A) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}


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

int main(){
    string s;
    cin >> s;
    ll n;
    n=s.size();
    int k=0;
    rep(i,n){
        if(s[i]=='g'){
            ++k;
        }
    }

    ll k2;
    k2=k-(n+1)/2;

    cout << k2 << endl;
    

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> as(N);
  rep(i, N) cin >> as[i];

  map <int, bool> m;
  int ans = 1;
  int num = as[0];
  while (true) {
    if (num == 2) break;
    if (m.count(num)) {
      ans = -1;
      break;
    }
    m[num] = true;
    num = as[num-1];
    ans++;
  }

  cout << ans << endl;
  
}


Measured memory_bytes: 5376
n = int(input())
dat = list(map(int, input().split()))
inf = 10**10
dp = [inf] * (n + 10)
dp[0] = 0
for i in range(n):
    if i+1 > n-1:
        continue
    dp[i+1] = min(dp[i+1], dp[i] + abs(dat[i] - dat[i+1]))
    if i+2 > n-1:
        continue
    dp[i+2] = min(dp[i+2], dp[i] + abs(dat[i] - dat[i+2]))
print(dp[n-1])


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

int main(){
  string S;
  cin>>S;
  int len=S.length();
  int flag=-1;
  int cnt1=0;
  int cnt2=0;
  for(int i=0;i<len;i++){
    if((flag==-1)&&(S.at(i)=='0')){
      cnt1++;
    }
    if((flag==1)&&(S.at(i)=='1')){
      cnt1++;
    }
    flag=flag*(-1);
  }
  flag=-1;
  for(int i=0;i<len;i++){
    if((flag==-1)&&(S.at(i)=='1')){
      cnt2++;
    }
    if((flag==1)&&(S.at(i)=='0')){
      cnt2++;
    }
    flag=flag*(-1);
  }  
  cout<<min(cnt1,cnt2)<<endl;
  //cout<<cnt1<<" "<<cnt2<<endl;
  return 0;
}


Measured memory_bytes: 512
// inputに入力データ全体が入る
function Main(input) {
	ans = 0
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.trim().split("\n");
	N = input[0].split(' ').map((n) => (parseInt(n)))[1]
	s = input[1].split(' ').map((n) => (parseInt(n)))
	var ss = s.sort((a, b) => a - b )
	ans = 0
	a = ss.slice(0, N)
  a.forEach(n => {
		ans += n
	})


	//出力
	console.log(ans)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(require('fs').readFileSync('./input.txt', 'utf-8'));

Measured memory_bytes: 29620
s = input()
b = int(s[0:2])
a = int(s[2:])
if 0 < b < 13 and 0 < a < 13:
	print('AMBIGUOUS')
elif 0 < b < 13:
	print('MMYY')
elif 0 < a < 13:
  	print('YYMM')
else:
	print('NA')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}



template< typename T>
T power(T x,int k){
    T ret=1;
    while(k>0){
        if(k&1) (ret*=x);
        (x*=x); 
        k >>= 1;
    }
    return ret;
}

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

    int n;
    cin>>n;

    map<int,int> mp;

    FOR(i,1,n+1){
        if(i%10==0) continue;
        int j=i;
        int a=i%10;
        int b=0;
        int c=-1;
        int ji=j;
        while(ji){
            b=ji%10;
            ji/=10;
            c++;
        }
        mp[10*a+b]++;
    }

    int ans=0;
    for(auto m:mp){
        //cout<<m.F<<' '<<m.S<<endl;
        ans+=m.S*mp[m.F/10+(m.F%10)*10];
    }
 

    cout<<ans<<endl;


}

Measured memory_bytes: 256
import java.util.Scanner;
 
class Main{
public static void main(String[] args){
 
Scanner sc=new Scanner(System.in);
  int H=sc.nextInt();
  int A=sc.nextInt();
  int i=0;
 
  
  
  while(0<H){
    i++;
    H-=A; 
   }System.out.println(i);
 }
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int f(int n)
{
    return ((n % 2 == 0) ? n / 2 : 3 * n + 1);
}

int main()
{
    string s;
    cin >> s;

    int ans = 1001001001;
    rep(i, s.size() - 2)
    {
        int cnt = 0;
        rep(k, 3) cnt = cnt * 10 + s[i + k] - '0';
        ans = min(ans, abs(753 - cnt));
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3596
#define _CRT_SECURE_NO_WARNINGS

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

#define LOOP(i,s,e) for(int i=s;i<e;i++)
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define MAX3(a,b,c) (a>b)?MAX(a,c):MAX(b,c)
#define MIN3(a,b,c) (a>b)?MIN(b,c):MIN(a,c)

int intcmp(const int *a,const int *b) {return (*a - *b);}

int intrcmp(const int *a,const int *b) {return (*b - *a);}

int dblcmp(const double *a,const double *b) { return (*a < *b) ? -1 : (*a == *b) ? 0 : 1; }

int stcmp(const char *a[],const char *b[]) { return(strcmp(*a, *b)); }

int main() {
	int N=0;
	scanf("%d",&N);
	if(N%2==0)printf("%d\n",((N/2)-1));
	if(N%2==1)printf("%d\n",(N/2));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(void) {
	int h, w;
	for (;;) {
		std::cin >> h >> w;
		if (h == 0 && w == 0) { break; }
		for (int y = 0; y < h; ++y) {
			for (int x = 0; x < w; ++x) {
				std::cout << (x == 0 || x == w - 1 || y == 0 || y == h - 1
					? "#"
					: ".");
			}
			std::cout << "\n";
		}
		std::cout << std::endl;
	}
	return 0;
}

Measured memory_bytes: 2996
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B;
  rep(i,M){
    int b;
    cin >> b;
    B.push_back(b);
  }
  int ret = 0;
  rep(i,N){
    int val = C;
    rep(j,M){
      int a;
      cin >> a;
      val += a * B[j];
    }
    if(val > 0) ret++;
  }

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int dp[110][10];

signed main() {
	int H, W, K;
	cin >> H >> W >> K;
	K--;

	if (W == 1) {
		cout << 1 << endl;
		return 0;
	}

	dp[0][0] = 1;
	rep(i, H) {
		rep(j, 1 << (W - 1)) {
			bool ok = true;
			rep(k, W - 2) {
				int kbit = j & (1 << k);
				int k2bit = j & (1 << (k + 1));
				if (kbit != 0 && k2bit != 0) {
					ok = false;
					break;
				}
			}
			if (!ok) continue;
			rep(k, W) {
				if (k > 0 && (j & (1 << (k - 1)))) continue;
				if (j & (1 << k)) {
					dp[i + 1][k] += dp[i][k + 1];
					dp[i + 1][k + 1] += dp[i][k];
					dp[i + 1][k] %= MOD;
					dp[i + 1][k + 1] %= MOD;
				} else {
					dp[i + 1][k] += dp[i][k];
					dp[i + 1][k] %= MOD;
				}
			}
		}
	}

	cout << dp[H][K] << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
  public static void main(String args[]) throws IOException{
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   String[] surface =  br.readLine().split(" ");
   String ordern = br.readLine();
   int n = Integer.parseInt( ordern );


   Dise dice1 = new Dise();
   dice1.setSurface(surface);
   dice1.SetDice(1, 2 , 3);


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

	   String[] order = br.readLine().split(" ");
	   dice1.RegulateDice( Integer.parseInt( order[0] ) ,Integer.parseInt( order[1] ));
	   System.out.println(dice1.surface[dice1.Right] );
	   dice1.SetDice(1, 2 , 3);

   }

  }
}

class Dise{

	int[] surface = new int [6];
    int Top,Bottom,Right,Left,Front,Back;


	void setSurface(String[] SurfaceString){

		for(int i = 0; i < 6; i++){

			surface[i] = Integer.parseInt( SurfaceString[i] );

		}

	}

    void SetDice(int top, int front, int right){
	   Top  = top - 1;
       Front = front - 1;
       Right = right - 1;
       Bottom = 5- (top - 1);
       Back = 5- (front - 1);
       Left = 5- (right - 1);
    }//SetDice


    void RegulateDice( int setTop, int setFront  ){


    	if( surface[Left] == setTop )   {


    	    RollDice("E");

    	}else if( surface[Right] == setTop ){

    		RollDice("W");

    	}else if( surface[Front] == setTop ){

    		RollDice("N");

    	}else if( surface[Back] == setTop ){

    		RollDice("S");

    	}else if( surface[Bottom] == setTop ) {

    		RollDice("NN");

    	}

    	if( surface[Left] == setFront )   {

      	  RollDice("NES");

      	}else if( surface[Right] == setFront ){

      		RollDice("NWS");

      	}else if(surface[Back]== setFront){

      		RollDice("NEES");

      	}

    	
    }

    void RollDice(String RollString){

    	String[] SurfaceString =  RollString.split("");
    	for(int i = 0; i < SurfaceString.length ; i++){

    		if( SurfaceString[i].equals("W") ){

    			Bottom = Left;
    			Left = Top;
    			Top = 5 - Bottom;
    			Right = 5 - Left;

    		}else if( SurfaceString[i].equals("S")){

    			Bottom = Front;
    			Front = Top;
    			Top = 5 - Bottom;
    			Back = 5 - Front;

    		}else if( SurfaceString[i].equals("E")){

    			Bottom = Right;
    			Right = Top;
    			Top = 5 - Bottom;
    			Left = 5 - Right;

    		}else{

    			Bottom = Back;
    			Back = Top;
    			Top = 5 - Bottom;
    			Front = 5 - Back;

    		}
    	}


    }//RollDice

}

Measured memory_bytes: 24664
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())

A, B = 1, 1

for i in range(N):
    XA, XB = map(int, input().split())

    if A * XB > XA * B:
        d = (A + XA - 1) // XA
        A, B = d * XA, d * XB
    else:
        d = (B + XB - 1) // XB
        A, B = d * XA, d * XB

print(A + B)

Measured memory_bytes: 3700
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second 
#define pii pair<int,int>
#define afor(i,a,b) for(int i=a;i<b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define print(A,j,k) for(int ii=j;ii<k;ii++)cout<<A[ii]<<" ";cout<<"\n"
#define all(v) v.begin(),v.end()
#define ps cout<<"YES\n";
#define CASES int t;cin>>t;while(t--)
//ans = a ? b : c; // to simplify: if (a) ans = b; else ans = c;
using namespace std;
int MAX_SUM=1000;
bool is_prime[1001];
ll ans[100010];
vector < int > v;
void calc_primes() {
    for (int n = 2; n <= MAX_SUM; n++) {
        is_prime[n] = true;
    }
 
    for (int i = 2; i <= MAX_SUM; i++) {
        if (!is_prime[i]) {
            continue;
        }
 
        for (int j = i * 2; j <= MAX_SUM; j += i) {
            is_prime[j] = false;
        }
    }
    afor(i,2,1000)
    {
        if(is_prime[i])
            v.pb(i);
    }
}
void solve()
{
    ll a[1010]={0};
    ll k=v.size();
    afor(i,0,10000)
    {
        ans[i]=1;
    }
    afor(i,2,1001)
    {
        afor(j,0,k)
        {
            if(v[j]>i)
                break;
            ll c=0;
            ll x=i;
            while(x%v[j]==0)
            {
                c++;
                x/=v[j];
            }
            a[j]=(a[j]%mod+c%mod)%mod;
        }
        afor(j,0,k)
        {
            ans[i]=(ans[i]%mod*(a[j]+1)%mod)%mod;
        }
    }
}
int main()
{
    fast
    calc_primes();
    solve();
    int n;
    cin>>n;
    cout<<ans[n]<<"\n";
    return 0;
}


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

using namespace std;

using ll = long long;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"

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

    string s;
    cin >> s;
    cout << s[0] << s[1] << s[2] << "\n";
    return 0;
}


Measured memory_bytes: 3628
N = int(input())
check = []
for i in range(N):
  D1, D2 = list(map(int, input().split()))
  if(D1 == D2):
    check.append(1)
  else:
    check.append(0)

for i in range(N-2):
  zoromeflag = 0
  for j in range(i,i+3):
    if(check[j]==0):
      zoromeflag = 0
      break
    else:
      zoromeflag = 1
  if(zoromeflag == 1):
    break
if(zoromeflag == 1):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9200
#include<bits/stdc++.h>
#define rep(i,N) for(ll i=0; i<N; i++)
using namespace std;
using ll = long long;
int main(){
    ll N; cin >> N;
    ll B[N-1]; rep(i,N-1) cin >> B[i];

    ll sum = B[N-2] + B[0];
    for(int i = N-2; i>=1; i--){
        sum += min(B[i],B[i-1]);
    }
    cout << sum;
}


Measured memory_bytes: 256
# D - Multiple of 2019

from collections import defaultdict
d = defaultdict(int)

mod = 2019
s = str(input())[::-1]

ssum = 0
d[0] = 1
for i in range(len(s)):
    ssum = (ssum + int(s[i])*pow(10, i, mod))%mod
    d[ssum] += 1

ans = 0
for n in d.values():
    ans += n*(n-1)//2

print(ans)


Measured memory_bytes: 9600
s = gets.chomp

def get_count keta, max
  ret = 0
  flg = max.to_s.length > keta ? false : true
  (3 ** keta).times do |i|
    tmp = i.to_s(3).rjust(keta, '0')
    if tmp.include?('0') && tmp.include?('1') && tmp.include?('2')
      if flg
        ret += 1 if tmp.gsub('0', '3').gsub('1', '5').gsub('2', '7').to_i <= max
      else
        ret += 1
      end
    end
  end
  ret
end

ret = 0
s.length.times do |i|
  ret += (get_count (i+1), s.to_i)
end
puts ret


Measured memory_bytes: 1788
// 失敗するからこそ そこから立ち向かって行く強さがあって そんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/pavan/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

int main(){
	FIO
	
	int n,k;cin >> n >> k;
	vi a(n);forn(i, n)cin >> a[i];
	sort(rall(a));
	ll ans = 0;
	forn(i, a.size()){
		if(k){k--;continue;}
		else ans += a[i];
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1024