akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int dp[41][401][401];

void run(){
    int n,ma,mb;
    cin>>n>>ma>>mb;
    vi a(n),b(n),c(n);
    rep(i,n){
        cin>>a[i]>>b[i]>>c[i];
    }
    rep(i,41){
        rep(j,401){
            rep(k,401){
                dp[i][j][k]=inf;
            }
        }
    }
    dp[0][0][0]=0;
    rep(i,n){
        rep(j,401){
            if(j+a[i]>400)continue;
            rep(k,401){
                if(dp[i][j][k]==inf)continue;
                if(k+b[i]>400)continue;
                dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
                dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
            }
        }
    }
    int ans=inf;
    REP(i,1,400){
        REP(j,1,400){
            if(i*mb==j*ma){
                ans=min(ans,dp[n][i][j]);
            }
        }
    }
    cout<<(ans!=inf?ans:-1)<<endl;
}

Measured memory_bytes: 51712
#include <iostream>
#include <string>
#include <algorithm>
#include <set>

using namespace std;

int main(){
	string s;
	cin >> s;
	
	set<char> se;
	for(int i = 0; i < s.length(); i++) se.insert(s[i]);
	
	bool flag = false;
	for(int i = 0; i < 26; i++){
		if(se.count(char('a' + i)) == 0){
			flag = true;
			cout << char('a' + i) << endl;
			break;
		
		}
	
	}
	
	if(!flag) cout << "None" << endl;
	
	return 0;
}
/*
+++++ +++++ +++++ +++++
+++++ +++++ ++
>,[[-<->]]

*/


Measured memory_bytes: 512
#include <stdio.h>
#include <stdint.h>

#ifdef DEBUG
#define DEBUG_LOG(fmt, ...)   printf(fmt, ##__VA_ARGS__)
#else
#define DEBUG_LOG(fmt, ...)
#endif

using namespace std;
int main()
{
    uint32_t X, n, r, n2;
    scanf(" %u", &X);
    n = X / 100;
    r = X % 100;

    n2 = 0;
    for (uint32_t p=5; p>0; p--) {
        n2 += r/p;
        if (n2 > n) {
            printf("0\n");
            return 0;
        }
        r = r%p;
        if (r == 0) {
            printf("1\n");
            return 0;
        }
    }
    return 0;
}


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

using namespace std;
#define int long long
#define all(a) (a).begin(), (a).end()
#define ms(a,v) memset(a, v, sizeof(a))
#define sz(v) ((int)(v).size())
#define mp make_pair
#define pb push_back
#define prev biiiiirl_sai_de_casa_comi_pra_caralho
#define next trapezio_descendente
#define index eh_ele_que_nos_vai_buscar
#define left aqui_eh_37_anos_porra
#define R32 ({i32 x; scanf("%d", &x); x;})
#define RL ({long long x; scanf("%lld", &x); x;})
#define RC ({char x; scanf(" %c", &x); x;})
#define RI RL
#define ff first
#define ss second
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef long long ll;

int32_t main(){
  int n = RI;
  string s, t;
  cin >> s >> t;

  for(int i = n; i; i--){
    if(t.substr(0, i) == s.substr(n-i, i)){
      cout << sz(s)+sz(t)-i << endl;
      return 0;
    }
  }

  cout << sz(s)+sz(t) << endl;
}


Measured memory_bytes: 256
// Nihesh Anderson - knandy

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
ll MOD=1000000007;

#define fast_cin() ios_base::sync_with_stdio(false)
#define pb push_back
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define debug1(x) cerr << x << endl;
#define debug2(x,y) cerr << x << " " << y << endl;
#define debug3(x,y,z) cerr << x << " " << y << " " << z << endl;
#define FOR(i, a, b) for (ll i=a; i<(b); i++)
#define FORR(i, a, b) for (ll i=a; i>=(b); i--)
ll INF = 2000000000000000001;
double EPS = 1e-9;
ll nextll(){ll inp; cin>>inp; return inp;}
string nextStr(){string inp; cin>>inp; return inp;}
double nextDouble(){double inp; cin>>inp; return inp;}
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{ll res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(ll* a, ll* b){shuffle(a,b,grndm);}

int main(){
	fast_cin();
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	vector<ll> v;
	FOR(i,0,3) v.pb(nextll());
	sort(v.begin(), v.end());
	cout<<v[2]-v[0]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

int calcphi(int n) {
	int ret = 1;
	for (int i = 2; i*i <= n; ++i) if (n%i == 0) {
		ret *= i - 1; n /= i;
		while (n%i == 0) n /= i, ret *= i;
	}
	if (n != 1) ret *= n - 1;
	return ret;
}
int pw(int x, ll n, int mod) { int ret = 1; while (true) { if (n & 1) ret = (ll)ret*x%mod; if ((n >>= 1) == 0) return ret; x = (ll)x*x%mod; } }

// a*x+b*y=ret
int egcd(int a, int b, int &x, int &y) {
	if (b == 0) { x = 1; y = 0; return a; }
	int g = egcd(b, a%b, y, x); // b*y+(a%b)*x=g -> a*x+b*y-(a/b)*b*x=g 
	y -= (a / b)*x;
	//printf("\t\t%d*%d+%d*%d=%d\n", a, x, b, y, g);
	return g;
}

int modsolve(int a, int b, int n) { // a*x=b (mod n)
	int x, y; int g = egcd(a, n, x, y); // a*x=g (mod n)
	assert(b%g == 0);
	int ret = (ll)x*(b / g) % n; if (ret < 0) ret += n; return ret;
}

// a^ret-ret | n, ret>=n
ll solve(int a, int n) {
	if (n == 1) return 1;
	// a^(x+y*phi(n))=a^x -> x+y*phi(n)=a^x (mod n) -> y*phi(n)=a^x-x (mod n) -> a^x-x | gcd(phi(n),n)
	int phi = calcphi(n), gg = gcd(n, phi);
	ll x = solve(a, gg);
	ll lhs = (pw(a, x, n) - x%n + n) % n;
	if (lhs%gg != 0) fprintf(stderr,"\terrsolve(%d,%d) [phi=%d, gg=%d lhs=%lld x=%lld]\n", a, n, phi, gg, lhs, x);
	assert(lhs%gg == 0);
	int y = modsolve(phi / gg, lhs / gg, n / gg);
	ll ret = x + (ll)y*phi;
	if (ret < n) ret += (ll)n*(phi / gg);
	//int chklhs = pw(a, ret, n), chkrhs = ret%n;	printf("\tsolve(%d,%d)=%lld [phi=%d, gg=%d lhs=%lld x=%lld y=%d] -> {%d,%d}\n", a, n, ret, phi, gg, lhs, x, y, chklhs, chkrhs);
	return ret;
}

void run() {
	int a, n;
	scanf("%d%d", &a, &n);
	ll ret = solve(a, n);
	printf("%lld\n", ret);
}

int main() {
	int n; scanf("%d", &n); FORE(i, 1, n) run();
	return 0;
}


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

using namespace std;

string solve(int N, const vector<int>& xs)
{
    int off = 0;

    for (int i = 1; i <= N; ++i)
        off += (xs[i] != i ? 1 : 0);

    return off <= 2 ? "YES" : "NO";
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<int> ps(N + 1);

    for (int i = 1; i <= N; ++i)
        cin >> ps[i];

    auto ans = solve(N, ps);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
#include <string.h>
#define ll long long
using namespace std;



int main(){
    string str;
    cin >> str;
    std::string n=str;
    
    size_t size = n.length();
    
    for(int i=0;i<size;i++){
        cout << "x";
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

long long int N, count, ans;

int main() {
  cin >> N;

  ans = 0;

  for (long long int i = 0; i <= N; i++) {
    count = 0;

    if (i % 2 == 0)
      continue;

    for (long long int j = 1; j <= sqrt(i); j++) {
      if (i % j == 0 && j == sqrt(i)) {
        count++;
      }
      else if (i % j == 0) {
        count += 2;
      }
    }

    if (count == 8)
      ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;

fn main() {
    input! {
        N: usize,
        abcs: [(i64, i64, i64); N],
    }

    // 状態としては、日付と、前に選んだ行動かなあ
    let mut dp_happiness: Vec<Vec<i64>> = Vec::new();
    for _n in 0..N {
        let arr: Vec<i64> = vec![0i64; 3];
        dp_happiness.push(arr);
    }

    for (n, &(a, b, c)) in abcs.iter().enumerate() {
        if n == 0 {
            dp_happiness[n][0] = a;
            dp_happiness[n][1] = b;
            dp_happiness[n][2] = c;
            continue;
        }


        // aを選ぶ場合
        dp_happiness[n][0] = std::cmp::max(dp_happiness[n - 1][1] + a, dp_happiness[n - 1][2] + a);

        // bを選ぶ場合
        dp_happiness[n][1] = std::cmp::max(dp_happiness[n - 1][0] + b, dp_happiness[n - 1][2] + b);

        // cを選ぶ場合
        dp_happiness[n][2] = std::cmp::max(dp_happiness[n - 1][0] + c, dp_happiness[n - 1][1] + c);
    }

    let mut ans = 0;
    for i in 0..3 {
        if dp_happiness[N - 1][i] > ans {
            ans = dp_happiness[N - 1][i];
        }
    }

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


Measured memory_bytes: 11476
#include "bits/stdc++.h"
using namespace std;

#define rep(i, n)  for (int i = 0; i < (int) (n); i++)
#define Rrep(i, n) for (int i = ((int) n - 1); i >= 0; i--)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
#define INF 2e15
#define MOD 10e9 + 7

typedef vector <int> vint;
typedef long long    ll;



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

    int h, w, k;
    cin >> h >> w >> k;
    char cake[h][w];
    int  mat[h][w];
    bool mark[h][w];
    bool fg  = false;
    int  num = 1;
    rep(i, h) {
        rep(j, w) {
            cin >> cake[i][j];
            mat[i][j]  = 0;
            mark[i][j] = false;
        }
    }
    int start = 0;
    rep(i, h) {
        rep(j, w) {
            if (cake[i][j] == '#') {
                fg = true; // その行にいちごがあった
                for (int k = start; k <= j; k++) {
                    mat[i][k] = num;
                    for (int l = 0; l <= i; l++) {
                        if (mark[l][k] == true) {
                            mat[l][k]  = num;
                            mark[l][k] = false;
                        }
                    }
                }
                num++;
                start = j + 1;
            }
        }
        if (fg) {
            // cout << start << endl;
            for (int k = start; k < w; k++) {
                mat[i][k] = num - 1;
                for (int l = 0; l <= i; l++) {
                    if (mark[l][k] == true) {
                        mat[l][k]  = mat[i][k];
                        mark[l][k] = false;
                    }
                }
            }
        }
        else {
            rep(j, w) {
                mark[i][j] = true;
            }
        }
        fg    = false;
        start = 0;
    }
    rep(i, h) {
        rep(j, w) {
            if (mark[i][j]) {
                mat[i][j]  = mat[i - 1][j];
                mark[i][j] = false;
            }
        }
    }
    /*rep(i, h) {
        rep(j, w) {
            cout << cake[i][j];
        }
        cout << endl;
    }*/
    rep(i, h) {
        rep(j, w) {
            cout << mat[i][j] << " ";
        }
        cout << endl;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 1280
n = int(input())
v = list(map(int,input().split()))
v_odd = []
v_even = []
d_odd = {}
d_even = {}
o = []
e = []
for i in range(n//2):
    a = v[2*i]
    b = v[2*i+1]
    if a in d_odd:
        d_odd[a] += 1
    else:
        d_odd[a] = 1
        o.append(a)
    if b in d_even:
        d_even[b] += 1
    else:
        d_even[b] = 1
        e.append(b)
O = 0
E = 0
o_max = 0
o_second = 0
e_max = 0
e_second = 0
for i in o:
    x = d_odd[i]
    if x >= o_max:
        O = i
        o_max = x
d_odd.pop(O)
o.remove(O)
for i in o:
    x = d_odd[i]
    if x >= o_second:
        o_second = x
for i in e:
    y = d_even[i]
    if y >= e_max:
        E = i
        e_max = y
d_even.pop(E)
e.remove(E)
for i in e:
    y = d_even[i]
    if y >= e_second:
        e_second = y
if O == E:
    m = max(o_max+e_second,e_max+o_second)
else:
    m = o_max + e_max
print(n-m)

Measured memory_bytes: 17312
#include <iostream>
#include <math.h>
using namespace std;

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

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        double x, y;
        cin >> x >> y;
        double dist = sqrt(x*x + y*y);
        if (dist <= D)
            cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3188
using System;
using System.Linq;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var L = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse).OrderByDescending(n => n).ToArray();

            var result = 0;
            for (int a = N - 1; a >= 0; a--)
            {
                for (int b = a - 1; b >= 0; b--)
                {
                    var left = lower_bound(L, L[a] + L[b]);
                    result += Math.Max(0, b - left);
                }
            }
            Console.WriteLine(result);
        }
        static int lower_bound(int[] array, int key)
        {
            int ng = -1;
            int ok = array.Length;
            while (Math.Abs(ok - ng) > 1)
            {
                int mid = (ok + ng) / 2;
                if (array[mid] < key) ok = mid;
                else ng = mid;
            }
            return ok;
        }
    }
}



Measured memory_bytes: 13408
import java.util.Scanner;
    public class Main{
        public static void main(String[] args) {
            Scanner in=new Scanner(System.in);
            int a=in.nextInt();
            int b=in.nextInt();
            int c=in.nextInt();
            if(a>b){
                int swap=a;
                a=b;
                b=swap;
            }int count=0;
            for (int i = a; i <=b; i++) {
                if(i%c==0){
                    count++;
                }
            }
            System.out.println(count);
            
        }
    }

Measured memory_bytes: 35344
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define maxn 200005
using namespace std;
typedef long long ll;
int n,a[maxn],b[maxn],k,numst[maxn],numed[maxn];
ll ans;
int main(){
	scanf("%d",&n);
	bool fl = false;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(a[i]) fl = true;
	}
	if(!fl){
		printf("%lld\n",n + (ll)n * (n-1) / 2);
		return 0;
	}
	int i=1;
	ll cnt = 0;
	while(a[i] == 0){
		i++;
		cnt++;
	}
	ans += cnt + cnt * (cnt-1) / 2;
	b[++k] = a[i];
	numst[1] = cnt + 1;
 	while(i <= n){
 		i++;
 		cnt = 0;
 		while(a[i] == 0 && i <= n){
 			i++;
			cnt++;
		}
		ans += cnt + cnt * (cnt-1) / 2;
		numed[k] = cnt + 1;
		if(i <= n){
			b[++k] = a[i];
			numst[k] = cnt + 1;
		}
	}
	for(int i=1;i<=k;i++){
		ll cur = 0;
		for(int j=i;j<=k;j++){
			if((cur ^ b[j]) == cur + b[j]){
				ans += (ll)numst[i] * numed[j];
				cur = cur + b[j];
			}else break;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
int dx[] = {-1, -1, -1, 0, 0, 0, 1, 1, 1};
int dy[] = {1, 0, -1, 1, 0, -1, 1, 0, -1};
// assign avl ncm dijkstra geo2 kruskal graph uf lca BIT
// matrix

signed main()
{
    int2(h, w);
    Int(n);
    vi ans(10, 0);

    map< i_i, int > funami;
    rep(i, n) {
        int2(a, b);
        rep(j, 9) {
            int nx = a + dx[j], ny = b + dy[j];
            if (1 < nx && nx < h && 1 < ny && ny < w) {
                funami[i_i(nx, ny)]++;
            }
        }
    }
    int sum = (h - 2) * (w - 2);
    auto it = funami.begin();
    while (it != funami.end()) {
        ans[it->sec]++;
        it++;
        sum--;
    }
    cout << sum << endl;
    Rep(i, ans.size()) {
        cout << ans[i] << endl;
    }

    return 0;
}




Measured memory_bytes: 56448
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    string S;
    cin >> S;
    
    map<pair<string, string>, int> m;
    int limit = 1 << N;
    for (int i = 0; i < limit; i++) {
        int bits = i;
        string tmp;
        string tmp2;
        for (int j = 0; j < N; j++) {
            if (bits & 1) {
                tmp.push_back(S[N+j]);
            } else {
                tmp2.push_back(S[N+j]);
            }
            bits /= 2;
        }
        reverse(tmp2.begin(), tmp2.end());
        if (m.find({tmp, tmp2}) == m.end()) m[{tmp, tmp2}] = 1;
        else m[{tmp, tmp2}] += 1;
    }
    
    long long ans = 0;
    for (int i = 0; i < limit; i++) {
        int bits = i;
        string tmp;
        string tmp2;
        for (int j = 0; j < N; j++) {
            if (bits & 1) {
                tmp.push_back(S[j]);
            } else {
                tmp2.push_back(S[j]);
            }
            bits /= 2;
        }
        reverse(tmp2.begin(), tmp2.end());
        if (m.find({tmp2, tmp}) != m.end()) ans += m[{tmp2, tmp}];
    }
    cout << ans << endl;
}


Measured memory_bytes: 43648
#include<iostream>
#include<map>
#include<algorithm>
#include<math.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<int, P > wear;
int n,d;
int h[1001];
wear w[1001];
int mem[202][202]={0};
int check(int day,int kinounohade){
  int maxs=0;
  if(mem[day][kinounohade]!=0){
    return mem[day][kinounohade];//メモ
  }
  if(day==d+1){
    return mem[day][kinounohade]=0;//最終日の１個前なので０いれとく
  }
  else{
    for(int i=1;i<=n;i++){
      if(h[day]>=w[i].second.first&&h[day]<=w[i].second.second){
	//気温と服のチェック
	maxs=max(maxs,check(day+1,w[i].first)+(day!=1?abs(kinounohade-w[i].first):0));
	//maxsにmaxsと最終日から足していった累積の値と今for文に入っている服と昨日の服の絶対値を

	//足して合した値の計の2つのおおきい方を入れる（day=1の時は昨日が存在しないので0を返す）
      }
    }
    return mem[day][kinounohade]=maxs;
  }
}
main(){
  cin>>d>>n;
  for(int i=1;i<=d;i++){
    cin>>h[i];
  }
  for(int i=1;i<=n;i++){
    cin>>w[i].second.first>>w[i].second.second>>w[i].first;
  }
  cout<<check(1,0)<<endl;
}

Measured memory_bytes: 1352
#include <bits/stdc++.h>
using namespace std;
#define ri register int
const int N=305;
int dp[N][N],sdp[N],c[N][N];
int main(){
	ri n,k,mod,s,t,i,j;
	scanf("%d%d%d",&n,&k,&mod);
	for(i=0;i<=n+1;++i){
		c[i][0]=1;
		for(j=1;j<=i;++j)
			c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
	}
	for(i=k;i>=0;--i){
		dp[i][1]=1;
		for(s=1;s<=n+1;++s){
			for(t=1;t<s;++t)
				dp[i][s]=(dp[i][s]+(long long)dp[i][s-t]*sdp[t]%mod*c[s-2][t-1])%mod;
		//	printf("dp %d %d %d\n",i,s,dp[i][s]);
		}
		for(s=1;s<=n+1;++s)
			sdp[s]=(sdp[s]+dp[i][s])%mod;
	}
	printf("%d\n",dp[0][n+1]);
	return 0;
}

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

int main() {
    long long X=0,Y=0,count=1;
    cin >> X >> Y;
    while(1){
        X *= 2;
        if(X > Y){
            cout << count << endl;
            break;
        }
        count += 1;
    }
    return 0;
}

Measured memory_bytes: 256
// C++ code to find number of distinct numbers
// in a subarray
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MAX = 1000001;

// structure to store queries
struct Query
{
    ll l, r, idx;
};

// cmp function to sort queries according to r
bool cmp(Query x, Query y)
{
    return x.r < y.r;
}

// updating the bit array
void update(ll idx, ll val,vector<ll>&bit, ll n)
{
    for (; idx <= n; idx += idx&-idx)
        bit[idx] += val;
}

// querying the bit array
int query(ll idx, vector<ll>&bit, ll n)
{
    ll sum = 0;
    for (; idx>0; idx-=idx&-idx)
        sum += bit[idx];
    return sum;
}

void answeringQueries(vector<ll>arr, ll n, vector<Query> queries, ll q)
{
    // initialising bit array
    vector<ll>bit(n+1,0);
    // holds the rightmost index of any number
    // as numbers of a[i] are less than or equal to 10^6
    vector<ll> last_visit(MAX,-1);
    // answer for each query
    vector<ll> ans(q);
    ll query_counter = 0;
    for (ll i=0; i<n; i++)
    {
        // If last visit is not -1 update -1 at the
        // idx equal to last_visit[arr[i]]
        if (last_visit[arr[i]] !=-1)
            update (last_visit[arr[i]] + 1, -1, bit, n);

        // Setting last_visit[arr[i]] as i and updating
        // the bit array accordingly
        last_visit[arr[i]] = i;
        update(i + 1, 1, bit, n);

        // If i is equal to r of any query  store answer
        // for that query in ans[]
        while (query_counter < q && queries[query_counter].r == i)
        {
            ans[queries[query_counter].idx] =
                     query(queries[query_counter].r + 1, bit, n)-
                     query(queries[query_counter].l, bit, n);
            query_counter++;
        }
    }

    // print answer for each query
    for (ll i=0; i<q; i++)
        cout << ans[i] << endl;
}

// driver code
int main()
{

    ll n,q;
    cin>>n>>q;
    vector<ll>a(n);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    vector<Query> queries(q);
    for(ll i=0;i<q;i++){
        ll u,v;
        cin>>u>>v;

    queries[i].l = u-1;
    queries[i].r = v-1;
    queries[i].idx = i;
    }
    sort(queries.begin(), queries.end(), cmp);
    answeringQueries(a, n, queries, q);
    return 0;
}


Measured memory_bytes: 50700
import java.util.Scanner;

/**
 * Created by User on 2017/03/18.
 */
public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);

        String a = s.next();
        String b = s.next();

        if (a.equals("H")) {
            System.out.println(aaa(b) ? "H" : "D");
        } else {
            System.out.println(!aaa(b) ? "H" : "D");
        }
    }

    public static boolean aaa(String s) {
        if (s.equals("H")) {
            return true;
        } else {
            return false;
        }
    }
}


Measured memory_bytes: 21716
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(true) {
			int N,M;
			N=sc.nextInt();
			M=sc.nextInt();
			if(N*M==0) {
				System.exit(0);
			}
			else {
				int r=sc.nextInt();
				int[][] students=new int[M][1440];
				for(int i=0; i<M; i++) {
					Arrays.fill(students[i],0);
				}
				for(int i=0; i<r; i++) {
					int t=sc.nextInt();
					int n=sc.nextInt();
					int m=sc.nextInt()-1;
					int s=sc.nextInt();
					if(s==1) {
						students[m][t]++;
					}
					else {
						students[m][t]--;
					}
				}
				for(int i=0; i<M; i++) {
					for(int j=1; j<1440; j++) {
						students[i][j]=students[i][j]+students[i][j-1];
					}
				}
				int[][] useage=new int[M][1440];
				for(int i=0; i<M; i++) {
					Arrays.fill(useage[i], 0);
				}
				for(int i=0; i<M; i++) {
					for(int j=1; j<1440; j++) {
						if(students[i][j]>0) {
							useage[i][j]=useage[i][j-1]+1;
						}
						else {
							useage[i][j]=useage[i][j-1];
						}
					}
				}
				int l=sc.nextInt();
				for(int i=0; i<l; i++) {
					int s=sc.nextInt();
					int g=sc.nextInt();
					int m=sc.nextInt()-1;
					if(students[m][g]>0) {
						System.out.println(useage[m][g]-useage[m][s-1]-1);
					}
					else {
						System.out.println(useage[m][g]-useage[m][s-1]);
					}
				}
			}
		}
	}
}

/*

import java.util.Arrays;
import java.util.Scanner;

class aj1148{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(true) {
			int N,M;
			N=sc.nextInt();
			M=sc.nextInt();
			if(N*M==0) {
				System.exit(0);
			}
			else {
				int r=sc.nextInt();
				int[][] students=new int[M][1260-540+1];
				for(int i=0; i<M; i++) {
					Arrays.fill(students[i], 0);
				}
				for(int i=0; i<r; i++) {
					int t=sc.nextInt()-540;
					int n=sc.nextInt();
					int m=sc.nextInt()-1;
					int s=sc.nextInt();
					if(s==1) {
						students[m][t]++;
					}
					else {
						students[m][t+1]--;
					}
				}
				//query proc
				for(int i=0; i<M; i++) {
					for(int j=1; j<=1260-540; j++) {
						students[i][j]=students[i][j]+students[i][j-1];
					}
				}
				int[][] useage=new int[M][1260-540+1];
				for(int i=0; i<M; i++) {
					Arrays.fill(useage[i], 0);
				}
				for(int i=0; i<M; i++) {
					for(int j=0; j<=1260-540; j++) {
						if(j==0) {
							if(students[i][j]>0) {
								useage[i][j]=1;
							}
						}
						else {
							if(students[i][j]>0) {
								useage[i][j]=useage[i][j-1]+1;
							}
							else {
								useage[i][j]=useage[i][j-1];
							}
						}
					}
				}
				//end of query proc
				int l=sc.nextInt();
				for(int i=0; i<l; i++) {
					int s=sc.nextInt()-540;
					int g=sc.nextInt()-540;
					int m=sc.nextInt()-1;
					if(s==0) {
						System.out.println(useage[m][g]);
					}
					else {
						System.out.println(useage[m][g]-useage[m][s-1]);
					}
					/*for(int j=s; j<=g; j++) {
						System.out.println(j+" "+useage[m][j]);
					}
					//System.out.println(useage[m][g]+" "+useage[m][s-1]);
					//System.out.println(students[m][g]+" "+students[m][s-1]);
				}
			}
		}
	}
}
*/


Measured memory_bytes: 532560
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;


    
int main(){
    long long n;
    cin>>n;
    vector<long long> a(n);
    rep(i,n) {
        cin>>a[i];
    }
    sort(ALL(a));
    rep(i,n-1){
        if(a[i]==a[i+1]){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 1792
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

using Flow = int;
struct FlowEdge {
  int src, dst;
  Flow cap;
  int rev;
  FlowEdge(const int s = 0, const int d = 0, const Flow c = 0, const int r = 0) : src(s), dst(d), cap(c), rev(r) {}
};

using FlowEdges = std::vector<FlowEdge>;

class FlowGraph {
  std::vector<FlowEdges> g;

public:
  FlowGraph(const int size = 0) : g(size) {}
  size_t size() const { return g.size(); }
  FlowEdges &operator[](const int i) & { return g[i]; }

  void addEdge(const int src, const int dst, const Flow c = 1) {
    g[src].emplace_back(src, dst, c, g[dst].size());
    g[dst].emplace_back(dst, src, 0, g[src].size() - 1);
  }
};

template<Flow inf = std::numeric_limits<Flow>::max() / 8> Flow fordFulkerson(FlowGraph g, const int source, const int sink) {
  std::vector<int> used(g.size());
  std::function<Flow(int, Flow)> dfs = [&](int v, Flow f) -> Flow {
    if (v == sink) return f;
    used[v] = true;
    for (auto &e : g[v]) {
      if (used[e.dst] || e.cap <= 0) continue;
      Flow d = dfs(e.dst, min(f, e.cap));
      if (d <= 0) continue;
      e.cap -= d;
      g[e.dst][e.rev].cap += d;
      return d;
    }
    return 0;
  };
  Flow s = 0;
  for (;;) {
    std::fill(used.begin(), used.end(), false);
    Flow f = dfs(source, inf);
    if (f == 0) return s;
    s += f;
  }
}

main {
  int n, m;
  cin >> n >> m;
  FlowGraph g(n);
  while (m--) {
    int a, b, c;
    cin >> a >> b >> c;
    g.addEdge(a, b, c);
  }
  cout << fordFulkerson(g, 0, n - 1) << endl;
}

Measured memory_bytes: 3232
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    int ans = inf;
    for(int i=-100; i<=100; i++){
        int sub=0;
        for(int j=0; j<n; j++){
            sub += (a[j]-i)*(a[j]-i);
        }
        ans = min(ans, sub);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    ll r, d, x; cin>>r>>d>>x;
    for(int i=1; i<=10; i++){
        ll num = r * x - d;
        x = num;
        cout << num << endl;
    }
}

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

signed main ( ) {

    int n;
    cin >> n;
    int prev;
    cin >> prev;
    bool flg = true;
    for ( int i = 1; i < n; i++ ) {
        int in;
        cin >> in;
        if ( prev <= in ) {
            if ( prev != in ) {
                prev = in-1;
            }
            else {
                prev = in;
            }
        }
        else {
            flg = false;
        }
    }

    puts((flg?"Yes":"No"));

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
const ll MODA=998244353;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
vector<ll> fac;
vector<ll> finv;
vector<ll> inv;
void COMinit(ll N,ll P){
    rep(i,N+1){
        if(i==0){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else if(i==1){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else{
            fac.push_back(fac.at(i-1)*i%P);
            inv.push_back(P-inv.at(P%i)*(P/i)%P);
            finv.push_back(finv.at(i-1)*inv.at(i)%P);
        }
    }
}

ll COM(ll n,ll k,ll P){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac.at(n)*(finv.at(k)*finv.at(n-k)%P)%P;
}
int main()
{
    ll N;
    cin>>N;
    cout<<(2199-N)/200<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

string s;
int ans[100000];

int coun(int x){
	int hoge = 0;
	while(s[x+hoge] == s[x+hoge+1]){
		hoge++;
	}
	return hoge+1;
}


int main(){
	cin >> s;
	for (int i = 0; i < s.length();){
		if (s[i] == 'R'){
			int temp = coun(i);
			ans[i+temp-1] += (temp+1)/2; 
			ans[i+temp] += temp/2;
			i += temp;
		}
		if (s[i] == 'L'){
			int temp = coun(i);
			ans[i-1] += temp/2;
			ans[i] += (temp+1)/2;
			i += temp;
		}
	}
	for (int i = 0; i < s.length(); i++){
		cout << ans[i] << " ";
	}
	cout << endl;
	return 0;
}



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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define ab(a) max((a),-(a))

typedef long long LL;

int main(){
  double d,e;
  cout << fixed << setprecision(4);
  while(1){
    cin >> d >> e;
    if(d==0) return 0;
    double ans2=10000000000;
    double tmp;
    for(double x=0;d-x>=0;x+=1){
      tmp=ab(sqrt(x*x+(d-x)*(d-x))-e);
      //cout << tmp << endl;
      if(ans2>tmp){
        ans2=tmp;
      }
    }
    if(ans2==0) ans2=0;
    cout << ans2 << endl;
  }
  return 0;
}



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

using namespace std;

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

    long long dp[2][2019];
    for(int i=0; i<2019; i++) {
        dp[0][i] = 0;
        dp[1][i] = 0;
    }

    long long count = 0;
    for(long long i=0; i<s.length(); i++) {
        int d = s[i] - '0';
        for(int j=0; j<2019; j++) dp[0][j] = dp[1][j];
        for(int j=0; j<2019; j++) dp[1][(10 * j + d) % 2019] = dp[0][j];
        if(d != 0) dp[1][d]++;

        count += dp[1][0];
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3756
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, K = MAP()
P = LIST()
C = LIST()

check = [0]*N 
score = []

i = 0
while 1:
	while i < N and check[i]:
		i += 1
	if i == N:
		break

	tmp = []
	while check[i] == 0:
		check[i] = 1
		i = P[i]-1
		tmp.append(C[i])
	score.append(tmp)

ans = -INF
for x in score:
	x_acc = list(accumulate([0] + x + x))
	n = len(x)
	tmp_max = -INF

	for i, j in combinations(range(2*n+1), 2):
		if j-i <= min(K, n):
			if tmp_max < x_acc[j]-x_acc[i]:
				tmp_max = x_acc[j]-x_acc[i]
				cnt = j-i
	tmp_ans = -INF

	if 0 >= x_acc[n]:
		tmp_ans = tmp_max

	else:
		if cnt <= K%n:
			tmp_ans = x_acc[n]*(K//n) + tmp_max
		else:
			tmp_max2 = 0
			for i, j in combinations(range(2*n+1), 2):
				if j-i <= K%n:
					if tmp_max2 < x_acc[j]-x_acc[i]:
						tmp_max2 = x_acc[j]-x_acc[i]
			tmp_ans = max(x_acc[n]*(K//n-1)+tmp_max, x_acc[n]*(K//n) + tmp_max2)

	ans = max(ans, tmp_ans)

print(ans)


Measured memory_bytes: 98160
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string S;
  cin >> S;

  bool ok1 = true;
  bool ok2 = true;
  bool ok3 = true;
  ll N = S.size();

  REP(i, N) {
    if (S[i] != S[N - 1 - i])
      ok1 = false;
  }
  REP(i, (N - 1) / 2) {
    if (S[i] != S[(N - 1) / 2 - 1 - i])
      ok2 = false;
  }
  FOR(i, (N + 1) / 2, N) {
    if (S[i] != S[N - 1 - i + (N + 1) / 2])
      ok3 = false;
  }
  if (ok1 && ok2 && ok3)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


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

using namespace std;

long long a[400001];
long long pref[400001];
                                       
int main () {
	int  n;
	cin >> n;
	for (int i = 1;i <= n;i ++) {
		cin >> a[i];
	}
	sort (a + 1, a + n + 1);
	for (int i = 1;i <= n;i ++) {
		pref[i] = pref[i - 1] + a[i];
	}
	int ans = 0;
	for (int i = n;i >= 1;i --) {
		if ((pref[i] * 2) >= a[i + 1]) {
			ans ++;
		}
		else break;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3072
import re
s = input()
ans = 'Yes'
s = re.split('(..)', s)[1::]
s = [x for x in s if x != '']
for c in s:
    if c == 'hi': continue
    ans = 'No'
    break
if len(s) == 0: ans = 'No'
print(ans)

Measured memory_bytes: 3188
(require :sb-queue)

(defmacro insert (a n val)
  (let ((arr (gensym))
        (nn (gensym)))
    `(let ((,arr ,a)
           (,nn ,n))
       (setf (aref ,arr ,nn) (cons ,val (aref ,arr ,nn))))))

(defun bfs (graph k n)
  (let ((dist (make-array n :element-type 'bignum :initial-element -1))
        (q (sb-queue:make-queue)))
    (sb-queue:enqueue (cons k 0) q)
    (labels
      ((proc () 
         (if (sb-queue:queue-empty-p q) (return-from proc))
         (let ((p (sb-queue:dequeue q))) 
           (setf (aref dist (car p)) (cdr p))
           (loop for x in (aref graph (car p)) 
                 if (= -1 (aref dist (car x)))
                 do (sb-queue:enqueue (cons (car x) (+ (cdr p) (cdr x))) q)))
         (proc))) 
      (proc))
    dist))

(let* ((n (read))
      (graph (make-array n :element-type 'list :initial-element nil))
      (q 0) (k 0)
      (dist (make-array n :element-type 'bignum)))
  (loop for i below (1- n)
        for a = (1- (read)) for b = (1- (read)) for c = (read)
        do (progn (insert graph a (cons b c))
                  (insert graph b (cons a c))))
  (setq q (read))
  (setq k (1- (read)))
  (setq dist (bfs graph k n))
  (loop for i below q
        for x = (1- (read)) for y = (1- (read))
        do (format t "~A~%" (+ (aref dist x) (aref dist y)))))

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

using namespace std;

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

	string s;
	cin >> s;
	sort(s.begin(), s.end());
	if( s == "abc" )cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	char a,b;
	scanf("%c %c",&a,&b); ///getchar();
	if(a=='H' && b=='H')
	{
		printf("H\n");
	}
	else if(a=='D' && b=='D')
	{
		printf("H\n");
	}
	else
	{
		printf("D\n");
	}
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    map<char,int> m;
    rep(i,4) m[s.at(i)]++;
    for(auto itr = m.begin(); itr != m.end(); ++itr){
        if (itr->second!=2) {cout << "No" << endl;return 0;}
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int n = scanner.next().length();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            sb.append('x');
        }
        System.out.println(sb.toString());
    }
}



Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N;
  cin >> N;
  long ans = 0, count = 1, sub = 10;
  if(N % 2 == 1);
  else {
    for(int i = 0; i < 26; i++){
      ans += N / sub;
      sub *= 5;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> void chmin(T& t, const U& u){if(t>u)t=u;}
template<typename T,typename U> void chmax(T& t, const U& u){if(t<u)t=u;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n,m,x,y;cin>>n>>m>>x>>y;
  vector<ll> v(n),u(m);
  rep(i,0,n)cin>>v[i];
  rep(i,0,m)cin>>u[i];
  sort(all(v));sort(all(u));
  ll z=v.back()+1;
  if(z<=u[0] && x<z && z<=y)puts("No War");
  else puts("War");
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

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

const int N = 100005;

int n, m, deg[N], head[N], tot;
struct edge { int to, nxt; } e[N << 1];

void link(int x, int y) {
	e[++tot] = { y, head[x] }, head[x] = tot;
	e[++tot] = { x, head[y] }, head[y] = tot;
}
int dfs(int x, int start, int target, int f = 0) {
	if (x == target) return 1;
	int ret = 0;
	for (int i = head[x]; i; i = e[i].nxt)
		if (e[i].to != start && e[i].to != f)
			ret += dfs(e[i].to, start, target, x);
	return ret;
}
int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> m;
	for (int i = 1, x, y; i <= m; ++i)
		std::cin >> x >> y, ++deg[x], ++deg[y], link(x, y);
	// partition Euler circuit into three circuits
	for (int i = 1; i <= n; ++i)
		if (deg[i] & 1) // no Euler circuit
			return std::cout << "No" << '\n', 0;
	for (int i = 1; i <= n; ++i)
		if (deg[i] >= 6) { // AAA => A + A + A 
			return std::cout << "Yes" << '\n', 0;
		}
	int cnt = 0;
	for (int i = 1; i <= n; ++i) cnt += deg[i] == 4;
	if (cnt >= 3) {
		// ABCABC, ABCACB, ABCBAC => AB + BC + CA
		// ABCBCA => A + ABC + BC
		// ABCCAB => AB + ABC + C
		// ABCCBA => A + ABCB + C
		return std::cout << "Yes" << '\n', 0;
	} else if (cnt <= 1) {
		// AA : no solution
		return std::cout << "No" << '\n', 0;
	}
	// ABBA => A + AB + B
	// ABAB : no solution
	int L = 0, R = 0;
	for (int i = 1; i <= n; ++i) if (deg[i] == 4) (L ? R : L) = i;
	std::cout << (dfs(L, L, R) == 2 ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 4224
# 2019-11-19 19:43:48(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
# import numpy as np 


def main():
    a, b = [int(x) for x in sys.stdin.readline().split()]
    print(-1 if a >= 10 or b >= 10 else a * b)

if __name__ == "__main__":
    main()


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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> A(M);
  int ALL = 0;
  for(int i = 0;i < M;i++){
    cin >> A[i];
    ALL += A[i];
  }
  if(N - ALL >= 0){
    cout << N - ALL << endl;
  }else{
    cout << -1 << endl; 
  }
}

Measured memory_bytes: 3624