akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
const int MAX_N_Int = 1000000000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
#define rep(i,a,n) for(Int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(Int (i)=(a); (i)<=(n); (i)++)

template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}


Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}


Int fact_mod(Int n, Int mod) {
    Int f = 1; repq(i,2,n) f = f * (i % MOD) % MOD;
    return f;
}

// 繰り返し二乗法 (modの世界での累乗)
Int mod_pow(Int x, Int n, Int mod) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return res;
}

// 組み合わせ nCr を求める
Int combination_mod(Int n, Int r, Int mod) {
    if(r > n-r) r = n-r;
    if(r == 0) return 1;
    Int a = 1;
    rep(i, 0, r) a = a * ((n-i) % mod) % mod;
    Int b = mod_pow(fact_mod(r, mod), mod-2, mod);
    return (a % mod) * (b % mod) % mod;
}

bool rev(string s){
    string t=s;
    reverse(s.begin(),s.end());
    return s==t;
}
int main() {
    //COMinit();
    IOS;
    prec;
    Int a=0,b=0,n,m,k,x,y=0,ans=0;
    string str,s,t,u;
    cin>>n;
    a=0;
    while(a*(a+1)/2<n){
        a++;
    }
    cout<<a;






    cout<<endl;
    return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
     
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,n) for(int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for(int i=(a)-1;i>=b;--i)
#define range(i,a,b,c) for(int i=a;							\
												 c>0?i<b:							\
												 i>b;								\
												 i+=c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define int long long
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif
     
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 1 << 28;
const ll INFL = (ll)1 << 58;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real& r) { return (r > eps) - (r < -eps); }
int sgn(const Real& a, const Real &b) { return sgn(a - b); }
     
//.....................
const int MAX = (int)2e5 + 5;
     
vector<string> split(const string &str, char sep) {
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}
     
template<class InputIterator>
int sum(InputIterator begin, InputIterator end) {
	return accumulate(begin, end, 0ll);
}

void solve();

signed main() {
	cout << fixed << setprecision(20);
	solve();
	while(true) {
		char s[MAX];
		if (scanf("%s", s) == EOF) break;
		int n = strlen(s);
		for (int i = n - 1; i > -1; i--) {
			ungetc(s[i], stdin);
		}
		solve();
	}
	return 0;
}

int a, b, c;

void solve() {
	cin >> a >> b >> c;
	if (b - a == c - b) cout << "YES" << endl;
	else cout << "NO" << 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 a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		int c=0;
		if(a==1 && b==2 || a==2 && b==1) {
			c=3;
		}else if(a==1 && b==3 || a==3 && b==1) {
			c=2;
		}else if(a==3 && b==2 || a==2 && b==3) {
			c=1;
		}
		System.out.println(c);
	}

}

Measured memory_bytes: 21204
#include<iostream>

using namespace std;

int main(){
  int n,val,B,C;
  cin >> n;
  while(n-- >0){
    B = 0;
    C = 0;
    bool fin=false;
    for(int i=0;i<10;i++){
      cin >> val;
      if(val > B && val > C){
	if(B>=C)B=val;
	else C=val;
      }
      else if(val > B)B=val;
      else if(val > C)C=val;
      else fin=true;
    }
    if(fin) cout << "NO" << endl;
    else cout << "YES" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
N,K = [int(c) for c in input().split()]
h = [int(c) for c in input().split()]

dp=[0]*N
for i in range(1,N):
    dp[i] = min([dp[j] + abs(h[i]-h[j]) for j in range(max(0,i-K),i) ])
print(dp[-1])



Measured memory_bytes: 20640
def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0
    for i in range(N):
        if i % 2 == 0 and A[i] % 2 == 1:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61952
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
const int MAX_N = 1<<20;
//セグメント木を持つグローバル配列
LL n,dat[2*MAX_N-1];
//初期化
void init(int n_){
   //簡単のために要素数を2のべき乗に
   n=1;
   while(n<n_)n*=2;
   //全ての値をINT_MAXに
   for(int i=0;i<2*n-1;i++)dat[i]=1e12;
}

//k番目の値(0-index)をaに変更
void update(int k,LL a){
   //葉の節点
   k+=n-1;
   dat[k]=a;
   //登りながら更新
   while(k>0){
      k=(k-1)/2;
      dat[k]=min(dat[k*2+1],dat[k*2+2]);
   }
}

//[a,b]の最小値を求める
//後ろの方の引数は計算の簡単のための引数
//kは節点番号，l.rはその節点が[l,r]に対応づいていることを表す
//従って外からはquery(a,b,0,0,n-1)として呼ぶ
LL query(int a,int b,LL k,int l,int r){
    //[a,b]と[l,r]が交差しなければINT_MAX
    if(r<a||b<l)return 1e12;
    //[a,b]が[l,r]を完全に含んでいればこの節点の値
    if(a<=l&&r<=b)return dat[k];
    else{
       //そうでなければ2つの子の最小値
       LL vl=query(a,b,k*2+1,l,(l+r)/2);
       LL vr=query(a,b,k*2+2,(l+r)/2+1,r);
       return min(vl,vr);
    }
}

int h[200001];
LL a[200001];
typedef pair<int,int>P;
vector<P>v;
LL dp[200001];

int main(){
	int N;
	cin>>N;
	init(200010);
	REP(i,N+5){
		update(i,0);
	}
	REP(i,N){
		cin>>h[i];
		v.push_back(P(h[i],i));
	}
	sort(v.begin(),v.end());
	REP(i,N){
		cin>>a[i];
	}
	REP(i,v.size()){
		int x=v[i].second;
		//cout<<v[i].first<<v[i].second<<endl;
		if(x==0){
			dp[x]=a[x];
			update(x,-dp[x]);
		}else{
			LL aa=query(0,x-1,0,0,n-1);
			dp[x]=a[x]-aa;
			update(x,-dp[x]);
		}
	}
	LL ans=0;
	REP(i,N){
		//cout<<dp[i]<<endl;
		ans=max(ans,dp[i]);
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 10096
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (w, a, b) = scan!(usize, usize, usize);
    if a + w < b {
        println!("{}", b - (a + w));
    } else if b + w < a {
        println!("{}", a - (b + w));
    } else {
        println!("0")
    }
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int A[10000000]={},B[1000000]={};
char a[10000000],b[10000000];
void ssort(int n){
    for(int i=0;i<n;i++){
        int minj=i;
        for(int j=i;j<n;j++){
            if(A[j]<A[minj]){
                minj=j;
            }
        }
        if(minj!=i){
            int tm=A[i];
            char TM=a[i];
            A[i]=A[minj];
            a[i]=a[minj];
            A[minj]=tm;
            a[minj]=TM;
        }
    }
}
void bsort(int n){
    for(int i=0;i<n;i++){
        for(int j=n-1;j>0;j--){
            if(B[j]<B[j-1]){
                int tp=B[j];
                char TP=b[j];
                B[j]=B[j-1];
                b[j]=b[j-1];
                B[j-1]=tp;
                b[j-1]=TP;
            }
        }
    }
}
int main(){
    int n,f=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i]>>A[i];
        b[i]=a[i];
        B[i]=A[i];
    }
    ssort(n);
    bsort(n);
    for(int i=0;i<n;i++){
        if(i==n-1){
            cout<<b[i]<<B[i];
        }
        else{
            cout<<b[i]<<B[i]<<" ";
        }
    }
    cout<<endl;
    cout<<"Stable"<<endl;
    for(int i=0;i<n;i++){
        if(i==n-1){
            cout<<a[i]<<A[i];
        }
        else{
            cout<<a[i]<<A[i]<<" ";
        }
    }
    cout<<endl;
    for(int i=0;i<n;i++){
        if(a[i]!=b[i] && A[i]==B[i]){
            f=1;
        }
    }
    if(f==0){
        cout<<"Stable"<<endl;
    }
    else if(f==1){
        cout<<"Not stable"<<endl;
    }
    return 0;
}


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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int n, k;
    cin >> n >> k;

    //Max can be a star graph obviously
    vector<pair<int, int>> edges;
    for (int i = 2; i <= n; i++)edges.emplace_back(1, i);
    int net = (n - 1) * (n - 2) / 2 - k;
    if (net < 0) {
        cout << -1 << endl;
        return;
    }
    int cur = 2, ele = 3;
    while (cur <= n and net) {
        edges.push_back({cur, ele});
        ele++;
        if (ele == n + 1)
            cur++, ele = cur + 1;
        net--;
    }
    cout << edges.size() << endl;
    for(auto x: edges)cout << x.first << " " << x.second << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    int N; cin >> N;
    for (int i = 1; i <= 50000; i++) {
        if (i * 108 / 100 == N) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long read()
{
    long long f=1,x=0;
    char ss=getchar();
    while(ss<'0'||ss>'9'){if(ss=='-')f=-1;ss=getchar();}
    while(ss>='0'&&ss<='9'){x=x*10+ss-'0';ss=getchar();}
    return f*x;
}
int main()
{
    int a,b;
    cin>>a>>b;
    if(a<=2*b)cout<<0;
    else cout<<a-2*b;
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
#include<queue>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

#define rep(i,n) for (int i = 0; i < (n); ++i)

typedef struct info {
  int x;
  int y;
  ll h;
} info;

int main()
{
  ll n;
  cin >> n;
  vector<info> a;
  rep(i,n) {
    info tmp;
    cin >> tmp.x >> tmp.y >> tmp.h;
    a.push_back(tmp);
  }

  sort(a.begin(), a.end(),
       [](const info& i, const info& j) { return i.h > j.h; });

  vector<vector<ll>> man(101, vector<ll>(101));
  for (int i = 0; i <= 100; i++) {
    for (int j = 0; j <= 100; j++) {
      man[i][j] = a[0].h + abs(a[0].x - i) + abs(a[0].y - j);
    }
  }

  vector<vector<bool>> check(101, vector<bool>(101, true));
  for (int u = 1; u < n; u++) {
    for (int i = 0; i <= 100; i++) {
      for (int j = 0; j <= 100; j++) {
        if (max(man[i][j] - abs(a[u].x - i) - abs(a[u].y - j), (ll)0) == a[u].h) continue;
        else {
          check[i][j] = false;
        }
      }
    }
  }

  rep(i,101) rep(j,101) {
    if (check[i][j] && man[i][j] > 0) printf("%d %d %lld\n", i, j, man[i][j]);
  }
}


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

using namespace std;

using ll = long long;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> a(N);
    int sum = 0;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    int x = round((double)sum / N);
    int ans = 0;
    for (int i = 0; i < N; ++i) ans += (a[i] - x) * (a[i] - x);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 200001
#define maxa 1000005
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

ll power(ll a, ll b = MOD-2){
    if(b == 0) return 1;
    ll r = power(a, b/2);
    r = (r*r)%MOD;
    if(b%2 == 1) r = (r*a)%MOD;
    return r;
}

void solve(){
    ll n, k;
    cin >> n >> k;
    ll a[n];
    for(ll i = 0; i < n; i++) cin >> a[i];
    sort(a, a+n);

    ll f[n+1], finv[n+1];
    f[0] = finv[0] = 1;
    for(ll i = 1; i <= n; i++){
        f[i] = (f[i-1]*i)%MOD;
        finv[i] = (finv[i-1]*(power(i)))%MOD;
    }
    ll mn = 0, mx = 0;
    for(ll i = 0; i <= n-k; i++){
        ll ff = (f[n-i-1]* ((finv[k-1]*finv[n-i-k])%MOD))%MOD;
        if(a[i] < 0) a[i] += MOD;
        mn += (a[i]*ff)%MOD; mn %= MOD;
    } //cout << mn << " ";
    for(ll i = k-1; i < n; i++){
        ll ff = (f[i]* ((finv[k-1]*finv[i-k+1])%MOD))%MOD;
        if(a[i] < 0) a[i] += MOD;
        mx += (a[i]*ff)%MOD; mx %= MOD;
    } //cout << mx << " ";
    cout << (mx - mn+MOD)%MOD;

}

int main()
{
    fast();
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
#define r(i,a,n) for(int i=a;i<(int)(n);i++)
typedef long long ll;
int main(){
    int N;
    cin>>N;
    int MAX_C=100/4;
    int MAX_D=100/7;
    r(i,0,MAX_C+1){
        r(j,0,MAX_D+1){
            if(4*i+7*j==N){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
// Remeber Choose Compiler: GCC9
#include <bits/stdc++.h>

using namespace std;

// Debug Output Utility
#ifdef LOCAL
#define dbg(args...)             \
    do {                         \
        cout << #args << " -> "; \
        err(args);               \
    } while (0)
void err() { std::cout << std::endl; }
template <typename T, typename... Args>
void err(T a, Args... args) {
    std::cout << a << ' ';
    err(args...);
}
template <template <typename...> class T, typename t, typename... A>
void err(const T<t> &arg, const A &... args) {
    for (auto &v : arg)
        std::cout << v << ' ';
    err(args...);
}
#else
#define dbg(...)
#endif

// Macro Definitions:
#define mp make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

// Type Alias:
using int64 = long long;
using PII   = pair<int, int>;

// Global Const Variable
const int INF  = 0x3f3f3f3f;
const int MOD  = 1000000007;
const int MAXN = 100005;


void run() {
    int64 a,v,b,w,t;
    cin >> a >> v >> b >> w >> t; 
    if((v-w)*t>=abs(a-b)) cout << "YES" << endl;
    else cout << "NO" << endl;
}

// Debug Input Redirection
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif
    run();
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 105
#define __TRUE "YES"
#define __FALSE "NO"
#define cout(x) cout << (x) << endl
#define reps(i,s,n) for(i=s;i<n;i++)
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;

int main() {
  char c;
  cin >> c;
  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o') cout("vowel");
  else cout("consonant");

  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = [(A[i],1) for i in range(N)]
for j in range(M):
    a, b = map(int, input().split())
    B.append((b,a))
B.sort()
B.reverse()
ans, cnt = 0, N
for (c, d) in B:
    use = min(d,cnt)
    ans += use*c
    cnt -= use
print(ans)

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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  
  int card = r * 100 + g * 10 + b;
  
  if (card % 4 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  
}

Measured memory_bytes: 256
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
c=Counter(a)
t=0
for k,v in c.items():
    t+=v*(v-1)//2
for i in range(n):
    ans=t
    x=c[a[i]]
    ans-=x*(x-1)//2
    x-=1
    ans+=x*(x-1)//2
    print(ans)

Measured memory_bytes: 26780
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MOD=1e9+7,N=21;
int dp[1<<N],n,matr[N][N],ok[1<<N];
vector<pair<int,int> > pos1;
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            scanf("%d",&matr[i][j]);
        }
    }
    pos1.push_back({1,0});                   //samo moguca stanja pamtim first je za broj mogucnosti, second je mask
    for(int i=0;i<n;i++){
        fill(dp,dp+(1<<n),0);
        fill(ok,ok+(1<<n),0);
        for(int j=0;j<pos1.size();j++){             //iteriras kroz moguca stanja
            for(int k=0;k<n;k++){
                if((!(1<<k & pos1[j].second)) && matr[i][k]){
                    dp[1<<k | pos1[j].second]=(dp[1<<k | pos1[j].second]+pos1[j].first)%MOD;
                    ok[1<<k | pos1[j].second]=1;
                }
            }
        }
        pos1.clear();
        for(int j=0;j<(1<<n);j++){
            if(ok[j])   pos1.push_back({dp[j],j});
        }
    }
    cout<<dp[(1<<n)-1];
    return 0;
}


Measured memory_bytes: 22768
/*
	JOI 2006 　予選 問2		
	言語	：	C++
	必須知識：	

*/

#include <iostream>

using namespace std;




int main(void)
{
	int N,M;


	while(	cin >> N, N > 0){

	char change[1000]={};		//　大雑把に配列確保

	char a,b;
	for(int i = 0; i < N; i++){
		cin >> a >> b;

		change[a] = b;
	}

	cin >> M;

	char c;
	for(int i = 0; i < M; i++){
		cin >> c;

		if(change[c] > 0)
			cout << change[c];
		else
			cout << c;
	}

	cout << endl;

	}
	return 0;

}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
    #define int ll
    #define M 1000000007
    #define hell 998244353
    #define big 1e18
    #define pb push_back
    #define pi 3.1415926536
    #define mp make_pair
    #define ub upper_bound
    #define lb lower_bound
    #define mem0(a) memset(a,0,sizeof(a))
    #define memf(a) memset(a,false,sizeof(a))
    #define mem1(a) memset(a,1,sizeof(a))
    #define all(a) a.begin(),a.end()
    #define ll long long
    #define vec vector <int>
    #define pii pair<int,int>
    #define endl "\n"
    #define gcd __gcd
    using namespace std;
    int power(int x, unsigned int y, unsigned int m) 
	{ 
    	if (y == 0) 
        	return 1; 
    	int p = power(x, y/2, m) % m; 
    	p = (p * p) % m; 
  
 	   return (y%2 == 0)? p : (x * p) % m; 
	} 
	int modInverse(int a, int m) 
	{   
    	return power(a, m-2, m);
	}
    signed main()
    {
    	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    	ll t=1;
    	// cin >> t;
    	/*SAARE INPUTS LENA*/
    	/*VARIABLES KI RANGE DEKHLENA*/
    	while(t-->0)
    	{
    		ll n=0;
    		cin>>n;
    		set <string> s;
    		string x;
    		for (int i = 0; i < n; ++i)
    		{
    			cin>>x;
    			s.insert(x);
    		}
    		cout<<s.size();
    	}
    	return 0;
    }

Measured memory_bytes: 19276
<?php

//$_input = explode(
//    "\n",
//    '30
//40
//50
//6000'
//);

function getNext() {
    return trim(
        isset($GLOBALS['_input'])
            ? array_shift($GLOBALS['_input'])
            : fgets(STDIN)
    );
}

$nCoinA = (int) getNext(); // 500
$nCoinB = (int) getNext(); // 100
$nCoinC = (int) getNext(); // 50
$amount = ((int) getNext());

$count = 0;
for ($a = 0; $a <= $nCoinA; $a++) {
    for ($b = 0; $b <= $nCoinB; $b++) {
        $temp = $a * 500 + $b * 100;
        if ($temp <= $amount && (($amount - $temp) / 50) <= $nCoinC) {
            ++$count;
        }
    }
}

//$nCoinA = (int) getNext(); // A * 1 or B * 5 or C * 10
//$nCoinB = (int) getNext(); //          B * 1 or C * 2
//$nCoinC = (int) getNext(); //                   C * 1
//$amount = ((int) getNext()) / 50;

//$coinA = (int) ($amount / 10);
//$amount = $amount - $coinA * 10;
//$coinB = (int) ($amount / 2);
//$amount = $amount - $coinB * 2;
//$coinC = $amount;
//
//$cases = 0;
//
//if ($coinC <= $nCoinC) {
//    for ($b = 1; $b < $coinB; $b++) {
//        $_c = $nCoinC - $coinC;
//        $_b = $nCoinB;
//        $_a = $nCoinA;
//
//
//
//        for ($a = 1; $a < $coinA; $a++) {
//
//
//
//        }
//    }
//}

printf("%d\n", $count);


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

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

int main() {
    int N; cin >> N;
    ll ans = 0;
    rng(i,1,N+1) {
        if (i%3 != 0 and i%5 != 0) ans += i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
import math
if __name__ == "__main__":
    H, W = map(int, input().split())
    ret = H * W
    if H == 1 or W == 1:
        ret = 1
    elif ret % 2 == 0:
        ret = ret / 2
    else:
        ret = math.floor(ret / 2) + 1
    print(int(ret))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define lowbit(x) ((x)&(-x))
#define mem(i, a) memset(i, a, sizeof(i))
#define sqr(x) ((x)*(x))
#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)
typedef long long ll;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 7;
using namespace std;
int sum[maxn], prime[maxn], tot, mod = 1e9 + 7;
bool check[maxn];
void init(int n){
    tot = 0; sum[1] = 1;
    for(int i = 2; i <= n; i++){
        if(!check[i]) {
            prime[tot++] = i;
            sum[i] = i - 1;
        }
        for(int j = 0; j < tot && prime[j] <= n / i; j++){
            check[i * prime[j]] = 1;
            if(i % prime[j])
                sum[i * prime[j]] = sum[i] * (prime[j] - 1);
            else{
                sum[i * prime[j]] = sum[i] * prime[j];
                break;
            }
        }
    }
    for(int i = 1; i<= n; i++) sum[i] = (sum[i] + sum[i - 1]) % mod;
}
ll qpow(ll a, ll n){
    ll ans = 1;
    for(a %= mod; n; n >>= 1){
        if(n & 1) ans = ans * a % mod;
        a = a * a % mod;
    }
    return ans % mod;
}
int main(void){
#ifdef ljxtt
freopen("data.in", "r", stdin);
#endif
    init(maxn - 1);
    int n, k; scanf("%d", &n);
    k = 3;
    ll ans = 0;
    for(int i = 1, r; i <= n; i = r + 1){
        r = min(n / (n / i), n);
        ans += qpow(n / i, k) * (sum[r] - sum[i - 1]) % mod;
        ans %= mod;
    }
    printf("%lld\n", (ans + mod) % mod);
    return 0;
}

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


def main():
    n = int(input())
    ab = [list(map(int, input().split())) for _ in range(n)]
    mod_ab = sorted(ab, key=lambda x: (x[1], x[0]))
    time = 0
    b_max = mod_ab[-1][1]

    for ai, bi in mod_ab:
        time += ai

        if time > b_max or time > bi:
            print('No')
            exit()

    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 67900
require 'matrix'
require 'bigdecimal'
require 'bigdecimal/util'
require 'bigdecimal/ludcmp'
include LUSolve

def len3d(x, y)
  l2=0.0
  0.upto(3-1){|i|
    l2 += (x[i] - y[i])**2
  }
  return Math.sqrt(l2)
end

def heron(a,b,c)
  s = (a + b + c) / 2.0
  return  Math.sqrt(s*(s-a).abs*(s-b).abs*(s-c).abs)
end

Eps=1e-9
def solve(a,b,c,d,e)   # returns true if beam hits barrier.
  # a, b, c: ????????¢???????§???¢??????????????????????????????
  # d:???????????????????????????
  # e:???????????????????????????
  # a + s*u + t*v = d + x*w ????§£??????(0<x<1) ???P(d+xw)???????§???¢ABC????????¨???????????°??????????????????????????????
  # ??????????????????true?????§???????????°false????????????
  u = c - a
  v = b - a
  w = e - d
  m = Matrix.columns([u, v, -w])

#  abort("Impssible case") if m.determinant.abs <Eps
  return false if m.determinant.abs <Eps
  #parms = m.inv * (d - a)
  parms = m.lup.solve(d - a)

  s = parms[0]
  t = parms[1]
  x = parms[2]
# ???P???????§???¢ABC??????????????¢??¨??´???DE??¨?????????
  return false if x < 0 or x > 1.0
  p = d + x*w
# ????§???¢ PAC, PAB, PBC?????¢???????????¨????§???¢ABC?????¢????????????????????°???P???ABC???????????????
  pa = len3d(a, p)
  pb = len3d(b, p)
  pc = len3d(c, p)

  ab = len3d(b, a)
  ac = len3d(c, a)
  bc = len3d(c, b)

  s0=heron(ab,ac,bc)
  s1=heron(pa,pc,ac)
  s2=heron(pa,pb,ab)
  s3=heron(pb,pc,bc)

  return  (s1+s2+s3-s0).abs <Eps
end

def main
  if true then
#  if false then
    fh=STDIN
  else
    #fh=open("in1_0115a.txt")
    #fh=open("in1_0115b.txt")
    fh=open("in1_0115c.txt")
  end
  d1,d2,d3=fh.gets.chomp.split.map{|x| x.to_i}
  e1,e2,e3=fh.gets.chomp.split.map{|x| x.to_i}

  a1,a2,a3=fh.gets.chomp.split.map{|x| x.to_i}
  b1,b2,b3=fh.gets.chomp.split.map{|x| x.to_i}
  c1,c2,c3=fh.gets.chomp.split.map{|x| x.to_i}

  d=Vector[d1,d2,d3]
  e=Vector[e1,e2,e3]
  a=Vector[a1,a2,a3]
  b=Vector[b1,b2,b3]
  c=Vector[c1,c2,c3]

  if solve(a,b,c,d,e) then
    puts "MISS"
  else
    puts "HIT"
  end

end

if $0 == __FILE__ then
  main
end

Measured memory_bytes: 9480
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,x=0,ans=0;
  string s;
  cin >> n>>s;
  for(int i=0;i<n;i++){
    if(s[i]=='I') x++;
    else x--;
    ans = max(ans,x);
  }
  cout <<ans <<endl;
}


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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    string s, t;
    cin >> s >> t;
    string ss = ' ' + s + s;
    vector<vector<int>> dp(s.size() * 2 + 1, vector<int>(26));
    for(int i = s.size() * 2 - 1; i >= 0; --i){
        for(int j = 0; j < 26; ++j){
            if(ss[i+1] - 'a' == j) dp[i][j] = 1;
            else dp[i][j] = dp[i+1][j] + 1;
        }
    }
    ll ans = 0;

    for(auto && c : t){
        if(dp[ans % s.size()][c - 'a'] > s.size()) {
            cout << "-1\n";
            return 0;
        }
        ans += dp[ans % s.size()][c - 'a'];
    }

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

Measured memory_bytes: 27216
#include <bits/stdc++.h>
#define int long long
#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1

using namespace std;

const int INF = 1e18;

#define GRAY 400
#define BROWN 800
#define GREEN 1200
#define SKY 1600
#define BLUE 2000
#define YELLOW 2400
#define ORANGE 2800
#define RED 3200
#define WHITE -1

void solve()
{
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("./sample.txt");
    std::cin.rdbuf(in.rdbuf());

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

    int n;
    cin >> n;
    int t[n + 1], x[n + 1], y[n + 1];
    rep(i, n + 1)
    {
        if (i == 0)
        {
            t[i] = 0;
            x[i] = 0;
            y[i] = 0;
        }
        else
        {
            cin >> t[i] >> x[i] >> y[i];
        }
    }

    bool isAns = true;
    for (int i = 0; i < n; i++)
    {
        int dt, dx, dy;
        dt = t[i + 1] - t[i];
        dx = abs(x[i + 1] - x[i]);
        dy = abs(y[i + 1] - y[i]);

        bool isPossible = (dt >= (dx + dy) && (dx + dy - dt) % 2 == 0);
        if (isPossible == false)
            isAns = false;
    }

    cout << ((isAns) ? "Yes" : "No") << endl;
}

signed main()
{
    solve();
    return 0;
}


Measured memory_bytes: 2560
import math


def main():
    N, M = list(map(int, input().split(' ')))
    if N >= M // 2:
        print(M // 2)
    else:
        t = math.ceil(((M // 2) - N) / 2)
        print((M - 2 * t) // 2)



if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
from collections import defaultdict

n = int(input())
a = list(map(int,input().split()))
a2 = list(set(a))
a2.sort(reverse=True)

d = defaultdict(int)
for i in a:
    d[i] += 1

ans = 0
for i in a2:
    next = 2**(i-1).bit_length()
    if(i==next):
        ans += d[i]//2
    else:
        pair = min(d[i],d[next-i])
        d[next-i] -= pair
        ans += pair
print(ans)

Measured memory_bytes: 164224
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main(){
    ll N, M;
    cin >> N >> M;
    ll A;
    ll sum = 0;

    for(ll i=0; i<M; i++){
        cin >> A;
        sum += A;
    }

    if(sum > N){
        cout << -1 << endl;
    }
    else{
        cout << N-sum << endl;
    }




}

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

using namespace std;

int main(void){
  vector<int>num;
  char ch[10];
  int n,maxn,minn;

  cin >> n;
  cin.ignore();
  while(n--){
    scanf("%[^\n]%*c",ch);

 for(int i=0;i<8;i++)num.push_back(ch[i]-'0');
      
    sort(num.begin(),num.end(),greater<int>());
 
    maxn=0;
    for(int i=0;i<8;i++)
      maxn*=10,maxn+=num[i];

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

    minn=0;
    for(int i=0;i<8;i++)
      minn*=10,minn+=num[i];

    cout << maxn-minn << endl;
    num.clear();
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
int main() {
    int N,K,Q; cin>>N>>K>>Q;
    vi score(N,0);
    for (int i = 0; i < Q; i++){
        int a; cin>>a; a--;
        score[a]++;
    }
    for (int i = 0; i < N; i++){
        if(score[i]>Q-K)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3776
#include <iostream>
#include <cmath>
#include <iomanip>

#define PI 3.1415926535

using namespace std;

int main(void){
	
	double a, b, c, angle, s, l, h;
	cin >> a >> b >> angle;

	angle = angle*PI / 180.0;
	s = a*b*sin(angle)/2.0;
	c = sqrt(pow(a, 2)+pow(b, 2) - 2*a*b*cos(angle));
	l = a + b + c;
	h = b*sin(angle);

	cout << fixed << setprecision(10);
	cout << s << "\n" << l << "\n" << h << "\n";
	cin >> a;
	return 0;
}

Measured memory_bytes: 3480
#include <iostream>
#include <stdlib.h>
using namespace std;
#define REP(i, n) for (int i = 1; i <= (n); i++)

int main() {
  int N, K;
  cin >> N >> K;
  int x[101];
  REP(i, N) cin >> x[i];

  int total = 0;
  REP(i, N) {
    int distA = x[i];
    int distB = abs(K - x[i]);
    total += distA < distB ? 2*distA : 2*distB;
  }
  cout << total << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int A = in(),B = in();
    cout << in() << " " << A << " " << B << "\n";
}

Measured memory_bytes: 256
def solve(a, b, c, d):
    while True:
        c -= b
        if c <= 0:
            return "Yes"
        a -= d
        if a <= 0:
            return "No"


def main():
    a, b, c, d = map(int, input().split())
    res = solve(a, b, c, d)
    print(res)


def test():
    assert solve(10, 9, 10, 10) == "No"
    assert solve(46, 4, 40, 5) == "Yes"


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 9196
N = int(input())

As = list(map(int, input().split()))

product = 1
flag = 0

if(0 in As):
  print (0)
else:
  for i in range(N):
    product*= As[i]
    if(product > 10** 18):
      print(-1)
      flag = 1
      break
  if(flag == 0):
    print(product)

Measured memory_bytes: 21560
from bisect import bisect_left
n,k = (int(i) for i in input().split())
x = [int(i) for i in input().split()]
a,ans = bisect_left(x,0),float("inf")
if 0 in x and k==1: ans = 0
elif 0 in x: x,k = x[:a]+x[a+1:],k-1 
for i in range(k+1):
	if -1<a-k+i<n and -1<a+i-1<n:
		if i==0: ans = min(-x[a-k+i],ans)
		elif i==k: ans = min(x[a+i-1],ans)
		else: ans = min(-2*x[a-k+i]+x[a+i-1],2*x[a+i-1]-x[a-k+i],ans)
print(ans)

Measured memory_bytes: 14368
#![allow(unused)]

use std::cmp::min;
use itertools::Itertools;

//
// Based on EbTech's Scanner https://stackoverflow.com/q/56449027
//
struct Scanner<'a, R: std::io::BufRead> {
    reader: R,
    buf: String,
    iter: std::str::SplitWhitespace<'a>,
}

impl<'a, R: std::io::BufRead> Scanner<'a, R> {
    fn new(reader: R) -> Self {
        Self { reader, buf: String::new(), iter: "".split_whitespace() }
    }

    fn get_str(&mut self) -> &str {
        if let Some(t) = self.iter.next() {
            return t;
        }
        self.buf.clear();
        self.reader.read_line(&mut self.buf).expect("I/O error");
        self.iter = unsafe { std::mem::transmute(self.buf.split_whitespace()) };
        self.get_str()
    }

    fn get<T: std::str::FromStr>(&mut self) -> T {
        self.get_str().parse().ok().expect("Parse error")
    }
}

const N_MAX: usize = 500;

static mut PS: [usize; N_MAX * N_MAX] = [0; N_MAX * N_MAX];
static mut COSTS: [i32; (N_MAX + 2) * (N_MAX + 2)] =
    [0; (N_MAX + 2) * (N_MAX + 2)];
static mut EXITED: [bool; (N_MAX + 2) * (N_MAX + 2)] =
    [false; (N_MAX + 2) * (N_MAX + 2)];
static mut QUEUE: [usize; N_MAX * N_MAX] = [0; N_MAX * N_MAX];

#[proconio::fastout]
fn main() {
    let stdin = std::io::stdin();
    let mut sc = Scanner::new(stdin.lock());

    unsafe {
        let n: usize = sc.get();
        for i in 0..(n * n) {
            PS[i] = sc.get::<usize>() - 1;
        }

        for x in 1..=n {
            for y in 1..=n {
                COSTS[x * (n + 2) + y] =
                    min(min(x - 1, n - x), min(y - 1, n - y)) as i32;
            }
        }

        let mut ans = 0;
        for i in 0..(n * n) {
            let p = PS[i];

            let x = p / n;
            let y = p % n;
            let p = (x + 1) * (n + 2) + (y + 1);

            EXITED[p] = true;
            ans += COSTS[p];

            let mut nelem = 1;
            QUEUE[0] = p;

            while nelem > 0 {
                nelem -= 1;
                let p1 = QUEUE[nelem];

                let c = COSTS[p1] + if EXITED[p1] { 0 } else { 1 };

                let p2 = p1 - 1;
                if COSTS[p2] > c {
                    COSTS[p2] = c;
                    QUEUE[nelem] = p2;
                    nelem += 1;
                }

                let p2 = p1 + 1;
                if COSTS[p2] > c {
                    COSTS[p2] = c;
                    QUEUE[nelem] = p2;
                    nelem += 1;
                }

                let p2 = p1 - (n + 2);
                if COSTS[p2] > c {
                    COSTS[p2] = c;
                    QUEUE[nelem] = p2;
                    nelem += 1;
                }

                let p2 = p1 + (n + 2);
                if COSTS[p2] > c {
                    COSTS[p2] = c;
                    QUEUE[nelem] = p2;
                    nelem += 1;
                }
            }
        }

        println!("{}", ans);
    }
}


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

#ifndef ONLINE_JUDGE
	#define W(x, y) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << y;
#else
	#define W(x, y)
#endif


#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vll vector<pll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi acos(-1)
#define ld long double
#define prime (1000000000 + 7)

using namespace std;

#define INF 1000000000

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

    ll n, m;
	cin >> n >> m;

	map<ll, ll> mapa;

	vl vet{0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
	vll vet2;
	for(int i = 1; i <= m; ++i){
		ll  a;
		cin >> a;
		vet2.push_back({a, vet[a]});
	}
	ll o = vet2.size();
	
	vector<pair<pll, ll>> mat(n+1);
	for(int i = 0; i < o; ++i){
		mat[vet2[i].ss] = max(mat[vet2[i].ss], {{1, vet2[i].ff}, 0});
	}

	for(int i = 1; i <= n; ++i){
		for(int j = 0; j < o; ++j){
			if(i - vet2[j].ss >= 0 && mat[i - vet2[j].ss].ff.ff != 0){
				mat[i] = max(mat[i], {{mat[i - vet2[j].ss].ff.ff+1, vet2[j].ff}, i - vet2[j].ss});
			}
		}
	}

	string s;
	pair<pll, ll> u{mat.back()};
	while (u.ff.ff != 0){
		W(u.ff.ff, " | ");
		s.push_back(u.ff.ss + '0');
		u = mat[u.ss];
	}
	cerr << endl;
	W(u.ff.ss, endl);
	W(s.size(), endl);
	
	sort(s.rbegin(), s.rend());
	
	cout << s << endl;
	



	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
        
#define pb push_back
#define ll long long
#define f first
#define s second
#define ld long double
#define fa fflush(stdout); 
#define mp make_pair
using namespace std;
void data() {
    #ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);;                                                      
} 
const int N = 1e5 + 100;
const ll mod = 1e9 + 7;
const ll big = 1e16;
const int p = 37;

int main() 
{
	data();              
	string s;
	cin >> s;
	if (s.find("RRR") != -1)
	{
		cout << 3;
		return 0;
	}
	else if (s.find("RR") != -1)
	{
		cout << 2;
		return 0;
	}
	else if (s.find("R") != -1)
	{
		cout << 1;
		return 0;
	}
	cout << 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {
	in(string, s);
	in(ll, K);
	vector<string> t;
	loop(p, s.size()) {
		loop(i, K) {
			if (p + i+1 <= s.size()) {
				t.push_back(s.substr(p, i+1));
			}
		}
	}
	sort_v(t);
	unique_v(t);
	out(t[K - 1]);
	return 0;
}


Measured memory_bytes: 1660
def check(a,b,c,d):
	while(a>0 and c>0):
		c-=b
		if(c<=0):
			return 1
		a-=d
		if(a<=0):
			return 0
inp1=list(map(int,input().strip().split()))[:4]
a,b,c,d=inp1[0],inp1[1],inp1[2],inp1[3]
if(check(a,b,c,d)):
	print("Yes")
else:
	print("No")

Measured memory_bytes: 9144
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    int cnt4=0,cnt2=0,cnt1=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]%4==0)cnt4++;
        if(a[i]%4!=0&&a[i]%2==0)cnt2++;
        if(a[i]%4!=0&&a[i]%2!=0)cnt1++;
    }
    if(cnt2!=0)cnt1++;
    if(cnt1<=cnt4+1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 640
//Heaplax
#include<bits/stdc++.h>
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
int n,k,mx,a,b;
int main()
{
	re(n),re(k);
	re(a);
	mx=a;
	for(int i=2;i<=n;++i)
	{
		re(b);
		mx=max(mx,b);
		a=__gcd(a,b);
	}
	puts(mx>=k&&k%a==0?"POSSIBLE":"IMPOSSIBLE");
}


Measured memory_bytes: 256
n,l=map(int, input().split())
a=list(map(int, input().split()))

f = -1
for i in range(n-1):
    if a[i] + a[i+1] >= l:
        f = i
        break
if f == -1:
    print('Impossible')
    exit()
print('Possible')
for i in range(1,f+1,1):
    print(i)
for i in range(n-1,f,-1):
    print(i)

Measured memory_bytes: 14152
l,r = map(int,input().split())
dp = [0]*2019
L = []
cur = l
for i in range(r-l+1):
    t = cur%2019
    if dp[t] == 0:
        dp[t] = 1
        L.append(t)
        cur += 1
    else:
        break
ans = 10**9
for i in range(len(L)):
    for j in range(i+1, len(L)):
        ans = min(ans, (L[i]*L[j])%2019)
print(ans)


Measured memory_bytes: 41452
#include<stdio.h>

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


Measured memory_bytes: 1992
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
template<class T>
void compress(vector<T> v, map<T, int>& zip, vector<T>& unzip)
{
	sort(ALL(v));
	v.erase(unique(ALL(v)), v.end());
	unzip.resize(v.size());
	REP(i, v.size())
	{
		zip[v[i]] = i;
		unzip[i] = v[i];
	}
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int d, n, m; 
	while (cin >> d >> n >> m, d)
	{
		vi shop(n), query(m), v;
		FOR(i, 1, n) cin >> shop[i];
		REP(i, m) cin >> query[i];
		sort(ALL(shop));
		v = shop;
		//v.insert(v.end(), ALL(query));
		map<int, int> zip; vi unzip;
		compress(v, zip, unzip);
		ll ans = 0;
		for (auto i : query)
		{
			auto it = zip.lower_bound(i);
			int t;
			if (it == zip.end()) t = (*zip.begin()).second;
			else t = (*it).second;
			ll tmp;
			if (it == zip.begin())
			{
				tmp = min(unzip[0] - i, i - unzip[t] + d);
			}
			else if (it == zip.end())
			{
				tmp = min(unzip[0] + d - i, i - unzip.back());
			}
			else tmp = min(unzip[t] - i, i - unzip[t - 1]);
			ans += tmp;
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
   int a,b;
   cin>> a >> b;
   if(a<b) {
      cout<<  "a < b"  <<endl;
  }
   if(a>b) {
      cout<< "a > b"  <<endl;
   }
  if(a==b) {
      cout<< "a == b"  <<endl;
   } 
  return 0;
  
  
  
}


Measured memory_bytes: 3096
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <bitset>
using namespace std;
const int MOD_P = 1000000000 + 7;
const int MAX_N = 20 + 2;
int dp[1 << MAX_N];
int a[MAX_N][MAX_N];

int popcount(int S, int N) {
  int res = 0;
  for (int i = 0; i < N; i++) {
    if (S >> i & 1) res++;
  }
  return res;
}

int main() {

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

  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++)  {
      cin >> a[i][j];
    }
  }

  dp[0] = 1;

  for (int S = 0; S < (1 << N); S++) {
    int i = popcount(S, N);
    for (int j = 0; j < N; j++) {
      if ( !(S >> j & 1) && a[i][j] == 1) {
	int nextS = S | (1 << j);
	dp[nextS] += dp[S];
	dp[nextS] %= MOD_P;
      }
    }
  }
  

  cout << dp[(1 << N) - 1] << endl;
  
  return 0;
}



Measured memory_bytes: 11388