akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;

using namespace std;

struct Info{
	int J,O,I;
};

int main(){

	int H,W;
	scanf("%d %d",&H,&W);

	char buf[W+1];
	Info** info = (Info**)malloc(sizeof(Info*)*(H+1));
	for(int i = 0; i <= H; i++){
		info[i] = (Info*)malloc(sizeof(Info)*(W+1));
	}

	for(int i = 0; i <= H; i++){
		for(int k = 0; k <= W; k++){
			info[i][k].J = 0;
			info[i][k].O = 0;
			info[i][k].I = 0;
		}
	}

	int Q;
	scanf("%d",&Q);

	for(int i = 1; i <= H; i++){
		scanf("%s",buf);
		for(int k = 0; k < W; k++){
			switch(buf[k]){
			case 'J':
				info[i][k+1].J++;
				break;
			case 'O':
				info[i][k+1].O++;
				break;
			case 'I':
				info[i][k+1].I++;
				break;
			}

			info[i][k+1].J += info[i][k].J;
			info[i][k+1].O += info[i][k].O;
			info[i][k+1].I += info[i][k].I;
		}
	}

	int a,b,c,d,J_num,O_num,I_num;

	for(int loop = 0; loop < Q; loop++){
		scanf("%d %d %d %d",&a,&b,&c,&d);

		J_num = 0,O_num =0,I_num = 0;
		for(int i = a; i <= c; i++){
			J_num += info[i][d].J - info[i][b-1].J;
			O_num += info[i][d].O - info[i][b-1].O;
			I_num += info[i][d].I - info[i][b-1].I;
		}
		printf("%d %d %d\n",J_num,O_num,I_num);

	}

	return 0;
}

Measured memory_bytes: 14336
#include<iostream>
#include<stdio.h>

void Number_3 (int a, int b, int c);

int main(){
    int a,b,c;
    
    scanf("%d %d %d",&a,&b,&c);
    Number_3(a,b,c);
    
    return 0;
}

void Number_3(int a, int b, int c){
    if(a<=b && b<=c) printf("%d %d %d\n",a ,b ,c);
    else if(a<=c && c<=b) printf("%d %d %d\n",a ,c ,b);
    else if(b<=a && a<=c) printf("%d %d %d\n",b ,a ,c);
    else if(b<=c && c<=a) printf("%d %d %d\n",b ,c ,a);
    else if(c<=a && a<=b) printf("%d %d %d\n",c ,a ,b);
    else if(c<=b && b<=a) printf("%d %d %d\n",c ,b ,a);
}


Measured memory_bytes: 3184
#include <iostream>
#include <deque>
#include <cstdio>
using namespace std;

int main() {
  int n;
  cin >> n;
  deque<int> b;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (i%2 == 0) {
      b.push_back(a);
    }
    else {
      b.push_front(a);
    }
  }
  if (n%2 == 0) {
    for (int i = 0; i < n; i++) {
      printf("%d%c", b[i], i == n - 1 ? '\n' : ' ');
    }
  }
  else {
    for (int i = n - 1; i >= 0; i--) {
      printf("%d%c", b[i], i == 0 ? '\n' : ' ');
    }
  }
  return 0;
}

Measured memory_bytes: 2944
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-10;

template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}

ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}

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

int main() {
	IOS();
	string s;
	cin >> s;
	int y = stol(s.substr(0, 4));
	int m = stol(s.substr(5, 2));
	int d = stol(s.substr(8, 2));
	if (y == 2019) {
		dump(m <= 4 ? "Heisei" : "TBD");
	} else
		dump(y < 2019 ? "Heisei" : "TBD");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <random>
#include <time.h>

using namespace std;

const int MAXN = 107;

int dp1[MAXN][MAXN], dp2[MAXN][MAXN];

int main(){
    ios_base::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    
    int r = b - a;

    if (r % 2){
        cout << "Borys\n";
    }
    else{
        cout << "Alice\n";
    }

    return 0;
}

Measured memory_bytes: 256
x = int(input())
if x >= 400 and x <= 599:
  print(8)
elif x >= 600 and x <= 799:
  print(7)
elif x >= 800 and x <= 999:
  print(6)
elif x >= 1000 and x <= 1199:
  print(5)
elif x >= 1200 and x <= 1399:
  print(4)
elif x >= 1400 and x <= 1599:
  print(3)
elif x >= 1600 and x <= 1799:
  print(2)
elif x >= 1800 and x <= 1999:
  print(1)

Measured memory_bytes: 9192
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int s[] = new int[13];
		int h[] = new int[13];
		int c[] = new int[13];
		int d[] = new int[13];
		for(int i=0;i<n;i++){
			String t = sc.next();
			if(t.equals("S")){
				int j = sc.nextInt();
				s[j-1]++;
			}else if(t.equals("H")){
				int j = sc.nextInt();
				h[j-1]++;
			}else if(t.equals("C")){
				int j = sc.nextInt();
				c[j-1]++;
			}else{
				int j = sc.nextInt();
				d[j-1]++;
			}
		}
		for(int i=0;i<13;i++){
			if(s[i]==0){
				int t = i+1;
				System.out.println("S "+t);
			}
		}
		for(int i=0;i<13;i++){
			if(h[i]==0){
				int t = i+1;
				System.out.println("H "+t);
			}
		}
		for(int i=0;i<13;i++){
			if(c[i]==0){
				int t = i+1;
				System.out.println("C "+t);
			}
		}
		for(int i=0;i<13;i++){
			if(d[i]==0){
				int t = i+1;
				System.out.println("D "+t);
			}
		}
	}

}

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

int main()
{
        long long n,m;
        long long x = 0;
        cin >> n;
        m = n;
        while(m>0)
        {
                x = m % 10 + x;
                m = m / 10;
        }

        if(n % x == 0)
                cout << "Yes" << endl;
        else
                cout << "No" << endl;
        return 0;
}


Measured memory_bytes: 256
(* O(n^2) *)
let n = read_int ()
let is_prime n =
  if n <= 1 then false
  else
    let rec loop i =
      if i * i > n then true
      else if n mod i = 0 then false
      else loop @@ i + 1 in
    loop 2
let rec div_count n i = if n mod i <> 0 then 0 else 1 + div_count (n / i) i
let ans = ref 1
let _ =
  for i = 2 to n do
    if is_prime i then 
      let c = ref 0 in
      for j = 2 to n do c := !c + div_count j i done;
      ans := !ans * (!c + 1) mod 1_000_000_007 done;
  Printf.printf "%d\n" @@ !ans

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



int main(){
	string O, E;
	cin >> O >> E;
	int N;
	N = O.size() + E.size();
	string ans;
	rep(i,E.size()){
		ans += O[i];
		ans += E[i];
	}
	if(N%2==1){
		ans += O[O.size()-1];
	}
		
	cout << ans << endl;



}













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

using namespace std;

#define OnlineJudge1

#define loop(x,a,n) for(int x = a;x < n;x++)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define readline(s) getline(cin,s)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
typedef pair<ll,ll> pll;

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#define time__(d) \
    for ( \
        auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second; \
        debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false \
    )

void init(){
    cin.tie(0);
    ios::sync_with_stdio(0);
#ifdef OnlineJudge
    freopen("in.in","r",stdin);
    freopen("out.txt","w",stdout);
#endif
}

const int N = 1e7 + 10, M = 55, OO = 0x3f3f3f3f;
const ll llOO = 1e18;


int main(){
    init();

    int n, k;   cin >> n >> k;
    int arr[n];
    for(int i = 0;i < n;i++)    cin >> arr[i];

    sort(arr, arr + n);

    ll sum = 0;
    for(int i = 0;i < n - k;i++)
        sum += (ll)arr[i];

    cout << sum;
}



Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
 
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int N,Q;
int a[200010];
int front[200010];
int cover[200010];
int covered;
 
void add(int x){
	int n = front[x]-1;
	if(n>0){
		if(cover[n]==0) covered++;
		cover[n]++;
	}
	front[x]--;
}
void erase(int x){
	int n = front[x];
	if(n>0){
		cover[n]--;
		if(cover[n]==0) covered--;
	}
	front[x]++;
}
 
int main(){
	cin>>N>>Q;
	rep1(i,N) front[i] = i+1;
	rep(i,N){
		cin>>a[i];
		add(a[i]);
	}
	rep(t,Q){
		int x,v;
		cin>>x>>v;
		x--;
		int pv = a[x];
		erase(pv);
		add(v);
		a[x] = v;
		cout<<N-covered<<endl;
	}
}

Measured memory_bytes: 4344
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;


int main(){
        int N;
        cin >> N;
        int ans1=0,ans2;
        vector <int> c(N),color(9,0);
        for(int i=0; i<N; i++) {
                cin >> c[i];
        }
        for(int i=0; i<N; i++) {
                if(c[i]>=3200) {
                        color[8]++;
                }else{
                        color[c[i]/400]++;
                }
        }

        for(int i=0; i<8; i++) {
                if(color[i]!=0) {
                        ans1++;
                }
        }
        if(ans1==0) {
                ans2=1;
        }else{
                ans2=ans1;
        }
        ans1+=color[8];




        cout << ans2 << ' ' << ans1 << endl;
        return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl;
#define INF 1ll<<60;
#include <map>
#include <math.h>

using ll = long long;
using namespace std;

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

    ll odd_count=0, odd_sum_count=0;
    reps(i, 0, n){
        odd_sum_count+=a[i];
        if(i%2==0){
        while(odd_sum_count>=0){
            odd_sum_count--;
            odd_count++;
        }
        }
        else{
            while(odd_sum_count<=0){
            odd_sum_count++;
            odd_count++;
            }
        }
    }
    

    ll even_count=0, even_sum_count=0;
    reps(i, 0, n){
        even_sum_count+=a[i];
        if(i%2==0){
        while(even_sum_count<=0){
            even_sum_count++;
            even_count++;
        }
        }
        else{
            while(even_sum_count>=0){
            even_sum_count--;
            even_count++;
            }
        }

    }
    cout << min(even_count, odd_count) << endl; 
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>
#include <functional>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
typedef long long ll;
using namespace std;
template <class T> void setmax(T & a, T const & b) { if (a < b) a = b; }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

template <typename T>
struct sliding_window {
    deque<pair<int, T> > data;
    function<bool (T const &, T const &)> cmp;
    template <typename F>
    sliding_window(F a_lt) : cmp(a_lt) {}
    T front() { return data.front().second; } // smallest
    void push_back(int i, T a) { while (not data.empty() and cmp(a, data.back().second)) data.pop_back(); data.emplace_back(i, a); }
    void pop_front(int i) { if (data.front().first == i) data.pop_front(); }
    void push_front(int i, T a) { if (data.empty() or not cmp(data.front().second, a)) data.emplace_front(i, a); }
};

const ll inf = ll(1e18)+9;
int main() {
    int n, m, k; cin >> n >> m >> k;
    vector<int> a(n); repeat (i,n) cin >> a[i];
    vector<vector<ll> > dp = vectors(k, n, - inf);
    repeat (j,n) dp[0][j] = a[j];
    repeat (i,k-1) {
        sliding_window<ll> rmq( (greater<ll>()) );
        rmq.push_back(-1, - inf);
        repeat (j,n) {
            if (j-m-1 >= -1) rmq.pop_front(j-m-1);
            setmax(dp[i+1][j], rmq.front() + (i+2) *(ll) a[j]);
            rmq.push_back(j, dp[i][j]);
        }
    }
    ll ans = *whole(max_element, dp[k-1]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 236672
from collections import Counter

a = input()

n_all_pairs = (len(a)*(len(a)-1))/2
counts = Counter(a)

n_other_chars = 0
for c in counts.values():
    n_other_chars += (c * (c-1))/2

print(int(n_all_pairs - n_other_chars) + 1)




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

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

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

#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> pii;
typedef double D;
typedef complex<D> P;
typedef vector<string> vs;

#define SZ(x) ((int)(x).size())

#define fill(x,y) memset(x,y,sizeof(x))

// with compile option -DLOCAL
#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

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

#define pcnt __builtin_popcount
#define pcntll __builtin_popcountll

#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};



#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

const int MOD = 1e9 + 7;

signed main() {
    Fast();

    int n, t, a;
    cin >> n >> t >> a;
    
    int ret;
    double minDiff = INT_MAX;
    rep(n)
    {
        double temp;
        int v;
        cin >> v;
        temp = (double)t - (double)v * 0.006;

        double diff = abs((double)a - temp);
        if(diff < minDiff) {
            minDiff = diff;
            ret = i + 1;
        }
    }
    
    cout << ret << endl;
    return 0;
}



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

#define MOD 1000000007

int main()
{
	int N, M, A, S;
	cin >> N >> M;
	int i;
	S = 0;
	for (i = 0; i < M; i++)
	{
		cin >> A;
		S += A;
	}
	if (S > N)
		cout << -1;
	else
		cout << N - S;
	return 0;
}

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

// N個(価値v, 重さw), 重さの総和W以下, O(n \sigma v_i)
ll knapsack2(int N, int W, vector<ll> v, vector<ll> w){
    ll INF = 10000000000000;
    ll V_MAX = 0; // 価値の総和の最大値V_MAX
    for (int x : v) {
        V_MAX += x;
    }

    // i+1番目以降で価値j以上の時の重さの最小値がdp[i][j]
    vector<vector<ll>> dp(N+1, vector<ll>(V_MAX + 1, INF));
    for (int i = N-1; i >= 0; --i) {
        dp[i][0] = 0;
        for (int j = 1; j <= V_MAX; ++j){
            if(j <= v[i]){
                // DP[][j-v[i]]が0になるので
                dp[i][j] = min(dp[i+1][j], w[i]);
            }else{
                dp[i][j] = min(dp[i+1][j], dp[i+1][j - v[i]] + w[i]);
            }
        }
    }

    // 価値で線形探索(二分探索もできるが必要ない)
    int res = 0;
    for (int i = 0; i <= V_MAX; ++i) {
        if(dp[0][i] <= W) res = i;
    }
    return res;
}

int main() {
    // 入力
    int N, W;
    cin >> N >> W;
    vector<ll>w(N);
    vector<ll>v(N);
    for (int i = 0; i < N; ++i) {
        cin >> w[i] >> v[i];
    }

    ll ans = knapsack2(N, W, v, w);
    cout << ans;
    return 0;
}

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

using namespace std;

const int MAXS = 1005;

int dp[MAXS][MAXS];

int main()
{
    int h, w;
    scanf("%i%i", &h, &w);
    vector<vector<char>> arr(h, vector<char>(w));
    dp[0][0] = 1;
    for (int x = 0; x < h; x++)
    {
        for (int y = 0; y < w; y++)
        {
            scanf(" %c", &arr[x][y]);
            if (arr[x][y] == '#')
                continue;
            if (x > 0)
                dp[x][y] += dp[x-1][y];
            if (y > 0)
                dp[x][y] += dp[x][y-1];
            dp[x][y] %= 1000000007;
        }
    }
    printf("%i\n", dp[h-1][w-1]);
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define print(x) for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<'\n';
#define in(x,n) for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
#define lower(sl)  transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 
//Available in Snips
#define fi(i, x, y)   for (__typeof(x) i = x; i < y; i ++)
#define fir(i, x, y)  for (__typeof(x) i = x; i > y; i --)
#define fv(x)   for (auto itr = x.begin(); itr != x.end(); itr ++)
#define fvr(x)  for (auto itr = x.end() - 1; itr != x.begin() - 1; itr --)

map<ll,ll>check,str;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//code here
	ll  n,i,cc=0;
    cin>>n;
    vector<ll>ara(n);
    ll j[n+10LL]={0};
    for(i=0;i<n;i++){
        cin>>ara[i];
        check[ara[i]]++;
    }
    for(i=0;i<n;i++){
        if(j[ara[i]]==0){
            ll x=check[ara[i]];
            cc+=(x*(x-1))/2;
            j[ara[i]]=1;
        }
    }
 
    for(i=0;i<n;i++){
        cout<<cc-check[ara[i]]+1<<endl;
    }
}


Measured memory_bytes: 14292
import java.util.Scanner;

public class Main{
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int S = scan.nextInt();
    int h, m, s;
    s = S%60;
    m = (S/60)%60;
    h = (S/60/60);
    System.out.println(h + ":" + m + ":" + s);
  }
}

Measured memory_bytes: 26184
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
long long p[110000];
long long q[110000];
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<a;i++){
		scanf("%lld",p+i);
	}
	for(int i=0;i<b;i++){
		scanf("%lld",q+i);
	}
	p[a++]=-inf;
	p[a++]=inf;
	q[b++]=-inf;
	q[b++]=inf;
	std::sort(p,p+a);
	std::sort(q,q+b);
	for(int i=0;i<c;i++){
		long long x;
		scanf("%lld",&x);
		long long ret=inf;
		int pat=lower_bound(p,p+a,x)-p;
		int qat=lower_bound(q,q+b,x)-q;
		ret=min(ret,max(p[pat],q[qat])-x);
		ret=min(ret,x-min(p[pat-1],q[qat-1]));
		ret=min(ret,p[pat]-x+p[pat]-q[qat-1]);
		ret=min(ret,q[qat]-x+q[qat]-p[pat-1]);
		ret=min(ret,x-p[pat-1]+q[qat]-p[pat-1]);
		ret=min(ret,x-q[qat-1]+p[pat]-q[qat-1]);
		
		printf("%lld\n",ret);
	}
}


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

typedef pair<double,int> P;
 
vector<vector<double>> edges(1010,vector<double>(1010,0));
vector<double> dist(1010,10000000000);

void dijkstra(int n) {
	priority_queue<P,vector<P>,greater<P>> que;
	dist[0] = 0;
	que.push(P(0.0,0));
 
	while (!que.empty()) {
		P p = que.top();
		que.pop();

		int v = p.second;
		if (dist[v] < p.first) continue;
		for (int i = 0;i < n;++i) {
			double e = edges[v][i];
			if (dist[i] > dist[v]+e) {
				dist[i] = dist[v]+e;
				que.push(P(dist[i],i));
			}
		}
	}
}

int main() {
	double x[1010],y[1010],r[1010],xt,yt;
	int n;
	cin >> x[0] >> y[0] >> xt >> yt >> n;
	for (int i = 1;i <= n;++i) cin >> x[i] >> y[i] >> r[i];
	x[n+1] = xt;
	y[n+1] = yt;
	r[0] = r[n+1] = 0;

	for (int i = 0;i < n+2;++i) {
		for (int j = 0;j < n+2;++j) {
			edges[i][j] = max(0.0,sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))-r[i]-r[j]);
		}
	}

	dijkstra(n+2);

	cout << setprecision(12) << dist[n+1] << endl;

	return 0;
}

Measured memory_bytes: 14572
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  ll a,b;
  cin >> n >> a >> b;
  vector<ll> x(n);
  REP(i,n) cin >> x[i];
  ll ans = 0;
  REP(i,n-1) ans += min((x[i+1]-x[i])*a,b);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	int max1=0, max2=0, max3=0;
	while(kbd.hasNext()){
	    int m = kbd.nextInt();
	    if(m > max1){
		max3 = max2;
		max2 = max1;
		max1 = m;
	    }
	    else if(m > max2){
		max3 = max2;
		max2 = m;
	    }
	    else if(m > max3){
		max3 = m;
	    }
	}
	System.out.println(max1);
	System.out.println(max2);
	System.out.println(max3);
    }
}

	    

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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define popcnt __builtin_popcount
#define getBit(x, k) ((x >> k) & 1)
#define all(x) (x).begin(),(x).end()
// ---------------------------------

void Main() {
  int n; cin >> n;
  vector<string> a, b, ab, o;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s[0] == 'B' && s.back() == 'A') ab.push_back(s);
    else if (s[0] == 'B') b.push_back(s);
    else if (s.back() == 'A') a.push_back(s);
    else o.push_back(s);
  }
  string t;
  if (a.size()) {
    t += a.back();
    a.pop_back();
  }
  for (auto &i : ab) t += i;
  if (b.size()) {
    t += b.back();
    b.pop_back();
  }
  int m = min(a.size(), b.size());
  for (int i = 0; i < m; i++) {
    t += a.back() + b.back();
    a.pop_back();
    b.pop_back();
  }
  for (auto &i : a) t += i;
  for (auto &i : b) t += i;
  for (auto &i : o) t += i;
  int ans = 0;
  for (int i = 0; i < (int)(t.size()) - 1; i++) {
    if (t.substr(i, 2) == "AB") ans++;
  }
  cout << ans << '\n';
}

signed main() {
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) Main();
}


Measured memory_bytes: 3952
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;

typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(NULL);
	
	int x; cin >> x;
	if (x >= 30) {
		cout << "Yes" << '\n';
	}
	else cout << "No" << '\n';
	


}

Measured memory_bytes: 3048
/*input
10000000
*/
 
 
 
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

typedef long long ll;

const int N = 1e7 + 10;

int f[N];

void init() {
    for (int i = 1; i < N; i++) {
        for (int j = i; j < N; j += i) {
            f[j]++;
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    init();

    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += (ll)i * f[i];
    }
    cout << ans << '\n';
}


Measured memory_bytes: 42708
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    for(ll b=k+1;b<=n;b++){
        ll p=(n+1)/b;
        ll r=(n+1)%b;
        ans+=p*(b-k)+max(r-k,0ll);
        if(k==0) ans--;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;


public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        String[] s = sc.nextLine().split(" ");
        sc.close();
        List<String> list = Arrays.asList(s);
        Collections.reverse(list);
        for(int i = 0; i<list.size();i++){
            if(i!=list.size()-1){
                System.out.print(list.get(i) + " ");
            }else{
                System.out.println(list.get(i));
                
            }
        }
    }
}




Measured memory_bytes: 26336
import std.stdio;
void main() {
	for (;;) {
		int m, f, r;
		"%d %d %d\n".readf(&m, &f, &r);
		if (m == -1 && f == -1 && r == -1) break;
		string g = "";
		int s = m + f;
		if (m == -1 || f == -1) g = "F";
		else if (s >= 80) g = "A";
		else if (65 <= s && s < 80) g = "B";
		else if (50 <= s && s < 65) g = "C";
		else if (30 <= s && s < 65) g = r >= 50 ? "C" : "D";
		else g = "F";
		g.writeln;
	}
}

Measured memory_bytes: 2428
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int t,n,m;
int a,b,c,d;
int main(){
	int i,j;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a+b>c+d)
		printf("Left\n");
	else if(a+b==c+d)
		printf("Balanced\n");
	else
		printf("Right\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007
#define INF 1e9

int ans = 1e9;
vector<vector<int>> dis(300,vi(300,INF));
vector<int> s(8);

void dfs(vi &s,vb seen,int depth,int now,int d,int r){
  //cout << now << endl;
  
  if(depth == r){
    //cout << d << " " << now << endl;
    ans = min(ans,d);
    return;
  }
  
  rep(j,r){
    int i = s.at(j);
    if(seen.at(i)) continue;
    seen.at(i) = true;
    int add;
    if(depth == 0) add = 0;
    else add = dis.at(now).at(i);
    dfs(s,seen,depth+1,i,d + add,r);
    seen.at(i) = false;
  }
}

int main(){
  int n,m,r;
  cin >> n >> m >> r;
  rep(i,r){
    cin >> s.at(i);
    s.at(i)--;
  }
  //rep(i,r) cout << s.at(i) << " ";
  rep(i,n) dis.at(i).at(i) = 0;
  rep(i,m){
    int a,b,c;
    cin >> a >> b >> c;
    dis.at(a-1).at(b-1) = c;
    dis.at(b-1).at(a-1) = c;
  }
  rep(k,n){
    rep(i,n){
      rep(j,n){
        dis.at(i).at(j) = min(dis.at(i).at(j) , dis.at(i).at(k) + dis.at(k).at(j));
      }
    }
  }
  vb seen(n,false);
  dfs(s,seen,0,-1,0,r);
  cout << ans << endl;
 // rep(i,r) cout << s.at(i) << " ";
}

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

int main() {
  string s, t;
  cin >> s >> t;
  
  int count = 0, n = s.length();
  for(int i = 0;i < n;i++){
    if(s.at(i) != t.at(i) )
      count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 3916
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define _1 first
#define _2 second
#define pb push_back
#define mod 1000000007LL
#define INF 105000000000

const int maxn = 1e5 + 10;

ll fac[maxn];
ll inv[maxn];

ll nCk(ll n, ll k)
{
	if (n < 0 || k < 0 || n < k) return 0LL;
	if (n == k || k == 0) return 1LL;
	ll ret = (fac[n] * inv[k]) % mod;
	ret = (ret * inv[n - k]) % mod;
	return ret;
}

ll beki(ll x, ll n)
{
	ll ans = 1;
	while (n > 0)
	{
		if ((n & 1) == 1)
		{
			ans = ans * x % mod;
		}
		x = x * x%mod;
		n >>= 1;
	}
	return ans;
}

void prepare()
{
	fac[0] = 1;
	inv[0] = 1;

	FOR(i,1, maxn)
	{
		fac[i] = (fac[i - 1] * i) % mod;
		inv[i] = beki(fac[i], mod - 2) % mod;
	}
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	prepare();
	int n; cin >> n;
	int a;
	int check[maxn];
	int idx1, idx2;
	memset(check, -1, sizeof check);
	rep(i, n + 1)
	{
		cin >> a;
		if (check[a] != -1)
		{
			idx1 = check[a];
			idx2 = i;
			break;
		}
		else {
			check[a] = i;
		}

	}
	idx1++, idx2++;
	int l = idx1, r = n - idx2;


	FOR(k, 1, n + 2)
	{
		Print((nCk(n+1,k)-nCk(l+r,k-1)+mod) % mod);
	}

	return 0;
	
}

Measured memory_bytes: 3200
#include<cstdio>

int N, a;

int main(){
	int min_a = 10000, max_a = -10000;
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		scanf("%d", &a);
		if(a < min_a) min_a = a;
		if(a > max_a) max_a = a;
	}
	printf("%d\n", max_a - min_a);
	return 0;
}


Measured memory_bytes: 128
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();

        if((a*b)%2==0){
            System.out.println("Even");
        }else{
            System.out.println("Odd");
        }


    }
}

Measured memory_bytes: 23764
N=int(input())
a=list(map(int,input().split()))
l=[0]*10**5
s=0
for i in range(N):
    if a[i]>10**5:
        s+=1
    else:
        l[a[i]-1]+=1
for i in range(10**5):
    if i+1>l[i]:
        s+=l[i]
    else:
        s+=l[i]-i-1
print(s)

Measured memory_bytes: 14672
#include <iostream>    
#include <algorithm>  
#include <cstring>   
  
using namespace std;  
  
bool cmp(string a,string b)  
{  
    return a<b;  
}  
  
int main()  
{  
    string s[100];
    int n,l;
	cin>>n>>l;  
    for(int i=0;i<n;i++)  
        cin>>s[i];  
    sort(s,s+n,cmp);  
    for(int i=0;i<n;i++)  
        cout<<s[i];
        cout<<endl;
    return 0;  
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}*/

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

	ll x, y;
	cin >> x >> y;

	ll ans = 0;

	// 最初はx
	// x *= 2としてyより大きくなったら終了

	while (x <= y) {
		x *= 2;
		ans++;
	}

	cout << ans << endl;

	return 0;
}

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

#define H_MAX 1000
#define W_MAX 1000

// 状態を表すクラスpairの場合、typedefしておくと便利
typedef pair<int, int> P;

int H, W;
int C_h, C_w; //スタート
int D_h, D_w; //ゴール
char S[H_MAX][W_MAX]; //迷路

int d[H_MAX][W_MAX]; //各点まで行くのに必要な魔法の回数
int dx_walk[4] = {1, 0, -1, 0};
int dy_walk[4] = {0, 1, 0, -1};

void input(){
    cin >> H >> W;
    cin >> C_h >> C_w;
    cin >> D_h >> D_w;
    for (int i=0;i<H;i++){
        for (int j=0;j<W;j++){
            cin >> S[i][j];
        }
    }
}

void solve(){
    queue<P> que;
    // 魔法回数マップを-1で初期化
    for (int i = 0; i < H; i++)
        for (int j = 0; j < W; j++)
            d[i][j] = -1;
    // スタート地点をキューに入れ、その点の距離を0にする
    que.push(P(C_h, C_w));
    d[C_h-1][C_w-1] = 0;



    int count_magic = 0;


    queue<P> que_walk;
    que_walk.push(P(C_h, C_w));

    while (que.size()){
        // 歩いていけるところをまず見つける。
        while (que.size())
        {
            // キューの先頭を取り出す
            P p = que.front();
            que.pop();
            // 取り出してきた状態がゴールなら探索をやめる
            if (p.first == D_h && p.second == D_w)
                break;

            // 歩行移動の４方向をループ
            for (int i = 0; i < 4; i++)
            {
                // 移動した後の点を(nx, ny)とする
                int nx = p.first + dx_walk[i], ny = p.second + dy_walk[i];
                // 移動が可能かの判定とすでに訪れたことがあるかの判定(d[nx][ny] != -1なら訪れたことがある)
                if (0 < nx && nx <= H && 0 < ny && ny <= W && S[nx-1][ny-1] != '#' && d[nx-1][ny-1] == -1)
                {
                    // 移動できるならキューに入れ、その点に行くのに必要な魔法の回数をpまでの回数で確定する
                    que.push(P(nx, ny));
                    que_walk.push(P(nx,ny));
                    d[nx-1][ny-1] = count_magic;
                }
            }
        }

        //ここまでで、歩行で歩ける領域は列挙されている。
        count_magic++;
        while (que_walk.size()){
            // キューの先頭を取り出す
            P p = que_walk.front();
            que_walk.pop();

            // que_walkの座標に対してワープ移動をループ
            for (int dx_warp = -2; dx_warp < 3; dx_warp++)
            {
                for (int dy_warp = -2; dy_warp < 3; dy_warp++)
                {
                    // 移動した後の点を(nx, ny)とする
                    int nx = p.first + dx_warp, ny = p.second + dy_warp;
                    // 移動が可能かの判定とすでに訪れたことがあるかの判定(d[nx][ny] != INFなら訪れたことがある)
                    if (0 < nx && nx <= H && 0 < ny && ny <= W && S[nx-1][ny-1] != '#' && d[nx-1][ny-1] == -1)
                    {
                        // 移動できるならキューに入れ、その点に行くのに必要な魔法の回数をpまでの回数+1で確定する
                        que.push(P(nx, ny));
                        d[nx-1][ny-1] = count_magic;
                    }
                }
            }
        }
        que_walk = que;
    }

    cout << d[D_h-1][D_w-1] << endl;
}

int main(){
    input();
    solve();
    return 0;
}


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

typedef unsigned long long ll;

#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
#define Vec(a) vector <int> a
#define F first
#define S second
const int INF = 1 << 20;
const int MOD = 1e9+7;

int main()
{
	char a, b, c, d;
	bool is1, is9, is7, is4;
	is1 = is9 = is7 = is4 = false;

	cin >> a >> b >> c >> d;
	if (a == '1' || b == '1' || c == '1' || d == '1')
		is1 = true;
	if (a == '9' || b == '9' || c == '9' || d == '9')
		is9 = true;
	if (a == '7' || b == '7' || c == '7' || d == '7')
		is7 = true;
	if (a == '4' || b == '4' || c == '4' || d == '4')
		is4 = true;

	if (is1 && is9 && is7 && is4)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
# input
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

# 考え方
# 目標：最大値の最小化
# にぶたん
# 必要条件：A[i] <= A[i+1] => F[i] >= F[i+1]

# sort
# Aは昇順、Fは降順(任意)
A = sorted(A)
F = sorted(F, reverse=True)

# にぶたん(参考：juppy)
ng = -1
ok = 10 ** 12  # 取り得る最大値

while ok - ng > 1:  # 収束判定
    mid = (ok + ng) // 2
    cost = 0

    for i, e in enumerate(A):
        cost += max(0, e - mid // F[i])
    
    if cost <= K:
        ok = mid
    
    else:
        ng = mid

print(ok)

Measured memory_bytes: 121164
#!/usr/bin/python
# coding: UTF-8

from math import *
import os
import sys

#import scipy.optimize
import numpy as np


##################################################################
if __name__ == "__main__":
    Input = [raw_input() for i in range(1)]
    #[a,b] = list(map(int,Input[0].split()))
    sss = str(Input[0])
    S = [int(sss[i]) for i in range(3)]
    ans = sum(S)
    print ans
        
    

Measured memory_bytes: 17012
#include<stdio.h>
#include<iostream>
#include<vector>
using namespace std;
int main(void) {

	int buff[5];
	scanf("%d%d%d%d%d", &buff[0], &buff[1], &buff[2], &buff[3], &buff[4]);
	for (int i = 0; i < 5; i++) {
		if (buff[i] == 0)
			printf("%d", i + 1);
	}
	return 0;
}

Measured memory_bytes: 3808
#include <stdio.h>

int out[6];
int main(void)
{
	int n, i, j;
	float h;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%f", &h);
		
		if (185.0 < h) out[5]++;
		else if (180.0 <= h) out[4]++;
		else if (175.0 <= h) out[3]++;
		else if (170.0 <= h) out[2]++;
		else if (165.0 <= h) out[1]++;
		else if (165.0 > h) out[0]++;
	}
	for (i = 0; i < 6; i++){
		printf("%d:", i + 1);
		for (j = 0; j < out[i]; j++){
			printf("*");
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define MAX_N 500100
using namespace std;

int score[MAX_N];
int n, last;
char s[MAX_N];

int main(void) {
  scanf("%d", &n);
	scanf("%s", s);
	for (int i = 2; i < n; ++i) {
		score[i] = score[i - 1];
		if(s[i - 2] == '1' && s[i - 1] == '0' && s[i] == '1') {
			last = i;
			for (int j = i - 2; (s[j] != '0' && j >= 0); --j) {
        score[i] = max(score[i], score[j - 1] + (i - j - 1));
      }
		}
		if(s[i] == '0') last = 0;
		if(last != 0) {
      score[i] = max(score[i], score[last - 3] + (i - last + 1));
    }
	}
	printf("%d\n", score[n - 1]);
	return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

struct mint {
    ll x;
    mint(ll x) : x(x % mod) {}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint temp(*this);
        return temp += a;
    }
    mint operator-(const mint a) const {
        mint temp(*this);
        return temp -= a;
    }
    mint operator*(const mint a) const {
        mint temp(*this);
        return temp *= a;
    }
    mint pow(const ll a) const {
        if (!a) return 1;
        mint ans = pow(a/2);
        ans *= ans;
        if (a % 2 == 1) ans *= *this;
        return ans;
    }

    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint temp(*this);
        return temp /= a;
    }
};

mint choose(ll n, ll r) {
    mint x = 1, y = 1;
    rep(i, r) {
        x *= n - i;
        y *= i + 1;
    }
    return x / y;
}

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    mint ans = 2;
    ans = ans.pow(n);
    ans -= 1;
    ans -= choose(n, a);
    ans -= choose(n, b);
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 256
//125B
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
int main(void){
    int n=0;
    cin >> n;
    int ans=0;
    vector<int>V(n,0);
    vector<int>C(n,0);
    rep(i, n) cin >> V[i];
    rep(i, n) cin >> C[i];
    rep(i, n){
        if(V[i]-C[i]>0) ans+= V[i]-C[i];
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	int d[5];
	int a,b,c;
	cin>>a>>b>>c;
	d[0]=abs(a-b);
	d[1]=abs(b-c);
	d[2]=abs(c-a);
	sort(d,d+3);
	cout<<d[0]+d[1]<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func pow(x, y int) int {
	return int(math.Pow(float64(x), float64(y)))
}
func main() {
	var N, K int
	var ans float64

	fmt.Scan(&N, &K)

	for i := 1; i <= N; i++ {
		var cnt int
		for {
			t := i * pow(2, cnt)
			if K <= t {
				break
			}
			cnt++

		}
		x := 1 / float64(N)
		y := 1 / float64(pow(2, cnt))
		ans += x * y
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
s = gets.chomp
if s[0] == "a"
    a = 1
elsif s[0] == "b"
    b = 1
elsif s[0] == "c"
    c = 1
end 
if s[1] == "a"
    a = 1
elsif s[1] == "b"
    b = 1
elsif s[1] == "c"
    c = 1
end 
if s[2] == "a"
    a = 1
elsif s[2] == "b"
    b = 1
elsif s[2] == "c"
    c = 1
end 
if (a == 1) && (b == 1) && (c == 1)
    puts("Yes")
else 
    puts("No")
end

Measured memory_bytes: 1788
H,W=map(int,input().split())
C=[0 for i in range(10)]
for i in range(10):
    C[i]=list(map(int,input().split()))
A=[0 for i in range(H)]
for i in range(H):
    A[i]=list(map(int,input().split()))

    
def mini(S,dic,ans):
    if(S=={0,1,2,3,4,5,6,7,8,9}):
        return ans
    min_val=min(dic.values())
    for i in dic.keys():
        if dic[i]==min_val:
            S.add(i)
            pos=i
            break
    ans[pos]=dic.pop(pos)
    for i in dic.keys():
        dic[i]=min([dic[i],ans[pos]+C[i][pos]])
    return mini(S,dic,ans)

dic={}
for i in range(10):
    dic[i]=C[i][1]
M=mini(set(),dic,{})
M[-1]=0

ans=0
for i in range(H):
    for j in range(W):
        ans+=M[A[i][j]]
print(ans)


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

int main()
{
	string s;
	cin >> s;
	long long ans=0,len=s.size()-1;
	
	for(int i=0;i<(1<<len);++i)
	{
		long long sum=s[0]-'0';
		for(int j=0;j<len;++j)
		{
			if(i & (1<<j))
			{
				ans+=sum;
				sum=0;
			}
			sum=sum*10+s[j+1]-'0';
		}
		ans+=sum;
	}
	cout << ans << endl;
}

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

int a[100001];
int main(){
	int N, M;
	cin >> N >> M;
	int sum = 0;
	for(int i = 0; i < M; i++){
		cin >> a[i];
		sum += a[i];
	}
 
	int val = N - sum;
	if(val < 0){
		cout << -1 << endl;
	} else {
		cout << val << endl;
	}
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
struct node{
	int a,b;
}p[100001];
bool cmp(node a,node b){
	return a.a>b.a;
}
int f[100001];
int getfa(int x){
	return x==f[x]?f[x]:f[x]=getfa(f[x]);
}
int main(){
	int n,m;
	int ans=0;
	cin>>n>>m;
	for(int i=1;i<=n;i++)scanf("%d%d",&p[i].b,&p[i].a);
	sort(p+1,p+n+1,cmp);
	for(int i=1;i<=m;i++)f[i]=i;
	for(int i=1;i<=n;i++){
		if(p[i].b>m)continue;
		int t=getfa(m-p[i].b+1);
		if(t!=0){
			ans+=p[i].a;
			f[t]=t-1;
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 1408
#include <iostream>

using namespace std;
struct point
{
    int m,n;
};

int main()
{
    struct point ha;
    int k,i,l,j;
    cin>>ha.m>>ha.n;
    k=ha.m;
    for(i=1;i<ha.n;i++)
    {

        ha.m=k+10*ha.m;
    }
    l=ha.n;

    for(j=1;j<k;j++)
    {

        ha.n=l+10*ha.n;

    }

    if(k>l)
        cout<<ha.n;
    else
        cout<<ha.m;

    return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    if(A > B){
        if(A > C) REP(i,K) A *= 2;
        else REP(i,K) C *= 2;
    }
    else{
        if(B > C) REP(i,K) B *= 2;
        else REP(i,K) C *= 2;
    }
    cout << A+B+C << endl;
}

Measured memory_bytes: 256
a = [True]*110000
n = 110000
for i in range(2, int(n**0.5) + 1):
	if a[i]:
		for i in range(i*i, n, i):
			a[i] = False
s = int(input())
ans = None
start = s
while not a[start] :
	start += 1
print(start)

Measured memory_bytes: 3828