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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

const int MAX_N = 1<<20;

class SegmentTree {
private:
  int size_;
  vector<PII> dat;

  PII calc(PII d1, PII d2) {return min(d1, d2);}
  PII query(int a, int b, int k, int l, int r) {
    if(r <= a || b <= l) return {INT_MAX, INT_MAX};
    if(a <= l && r <= b) return dat[k];
    return calc(query(a, b, 2*k+1, l, (l+r)/2),
                  query(a, b, 2*k+2, (l+r)/2, r));
  }

public:
  SegmentTree() {}
  SegmentTree(int n) {
    for(size_ = 1; size_ < n; size_ *= 2);
    dat.assign(2*size_-1, {INT_MAX, INT_MAX});
  }

  void update(int k, PII a) {
    k += size_ - 1;
    dat[k] = a;
    while(k > 0) {
      k = (k-1) / 2;
      dat[k] = calc(dat[k*2+1], dat[k*2+2]);
    }
  }

  PII query(int a, int b) {return query(a, b, 0, 0, size_);}
};

SegmentTree seg[2];
vector<PII> piece;
VI nxt[100010];
map<PII, int> toId;

void func(int l, int r, int par) {
  if(l >= r) return;

  PII a = seg[l%2].query(l, r-1),
      b = seg[(l+1)%2].query(a.second+1, r);

  if(par != -1) nxt[par].PB(piece.size());
  toId[{a.first, b.first}] = piece.size();
  piece.PB({a.first, b.first});

  int cur = piece.size() - 1;
  if(l < a.second) func(l, a.second, cur);
  func(a.second+1, b.second, cur);
  if(b.second+1 < r) func(b.second+1, r, cur);
}

signed main(void)
{
  int nn;
  cin >> nn;
  seg[0] = seg[1] = SegmentTree(nn);
  REP(i, nn) {
    int p; cin >> p;
    seg[i%2].update(i, {p, i});
  }
  func(0, nn, -1);

  VI ans;
  priority_queue<PII, vector<PII>, greater<PII>> que;
  que.push(piece[0]);

  while(que.size()) {
    PII p = que.top(); que.pop();
    ans.PB(p.first);
    ans.PB(p.second);
    for(int i: nxt[toId[p]]) que.push(piece[i]);
  }
  REP(i, ans.size()) {
    cout << ans[i];
    if(ans.size()-1 != i) cout << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 196596
#include <iostream>
#include <fstream>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int,int> PP;

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

ll MOD = 1E9 + 7;

ll F[20000], I[20000];

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

void init() {
    F[0] = 1;
    for (ll i = 1;i < 20000;i++) {
        F[i] = F[i - 1] * i;
        F[i] %= MOD;
    }
    I[19999] = power(F[19999], MOD - 2);
    for (ll i = 19998;i >= 0;i--) {
        I[i] = I[i + 1] * (i + 1);
        I[i] %= MOD;
    }
    return;
}

ll nchoosek(int a, int b) {
    ll ans = F[a] * I[b];
    ans %= MOD;
    ans *= I[a - b];
    ans %= MOD;
    return ans;
}

int main() {
    ios::sync_with_stdio(false);
    int N, A, B, C;
    init();
    cin >> N >> A >> B >> C;
    if (B % 2) {
        cout << 0 << endl;
        return 0;
    }
    ll res = 0;
    for (int x = 0;x <= A;x++) {
        int y = A - x;
        int rem_c = C - y;
        for (int c = 0;c * 3 <= rem_c;c++) {
            ll crt = 1;
            int all = x + y + c + B/2;
            crt *= nchoosek(all, x);
            crt *= nchoosek(all - x, y);
            crt %= MOD;
            crt *= nchoosek(all - x - y, c);
            crt %= MOD;
            if (B > 0) crt *= nchoosek(rem_c - c * 3 + B/2 - 1, B/2 - 1);
            else if (rem_c - 3 * c != 0) crt = 0;
            crt %= MOD;
            res += crt;
            res %= MOD;
        }
    }
    cout << res << endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> L(N);
  for(int i = 0; i < N; i++){
    cin >> L.at(i);
  }
  
  sort(L.begin(),L.end());
  int sum = 0;
  for(int i = 0; i < N-1; i++){
    sum += L.at(i);
  }
  
  if(sum > L.at(N-1)){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
  
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;



int main()
{
	int n, y;
	cin >> n >> y;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			int b = i * 1000 + j * 5000 + (n - i - j) * 10000;
			if (b == y && (n - i - j) >= 0) {
				cout << n - i - j << " " << j << " " << i;
				return 0;
			}
		}
	}

	cout << "-1 -1 -1" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int a = 0;
	int flag = 0;
	int i,j = 0;

	scanf("%d",&a);
	for(i = 1 ; i < 10;i++){
		for(j = 1;j < 10;j++){
			if(i*j == a){
				flag = 1;
				printf("Yes\n");
				break;
			}else{
				flag = 0;
			}
		}
		if(flag == 1) break;
	}

	if(flag == 0){
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 128
use proconio::input;
use std::cmp::min;

#[allow(unused_mut)]
fn main() {
    input! {
        n: usize
    }
    let sqrt_n = (n as f64).sqrt().ceil() as usize;
    let mut res = std::usize::MAX;
    for i in 1..sqrt_n + 1 {
        if n % i != 0 {
            continue;
        }
        res = min(res, i + n / i - 2);
    }
    println!("{}", res);
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    unordered_set<int> s;
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (auto &i:a) {
        cin >> i;
    }
    ld ans = 0, cur = 0;
    for (int i = 0; i < n; ++i) {
        if (i >= k) {
            cur -= (a[i - k] + 1.0) / 2;
        }
        cur += (a[i] + 1.0) / 2;
        ans = max(ans, cur);
    }
    cout << fixed << setprecision(10) << ans;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    if (n == 1) {
        cout << "YES" << endl;
        return 0;
    }


    int e = 0, o = 0;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        if (a % 2) ++o;
        else ++e;
    }

    if(o % 2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int p, q, r;
  scanf("%d %d %d", &p, &q, &r);
  int max;
  if(p > q){
    if(p > r){
      max = p;
    }else{
      max = r;
    }
  }else{
    if(q > r){
      max = q;
    }else{
      max = r;
    }
  }
  printf("%d\n", p + q + r - max);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<utility>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n,a,b,work_start;
  vector<pair<int,int>> p;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    p.push_back(make_pair(b,a));
  }
  sort(p.begin(),p.end(),greater<pair<int,int>>());
  work_start=p[0].first;
  for(int i=0;i<n;i++){
    if(work_start>=p[i].first){
      work_start=p[i].first;
    }
    work_start = work_start - p[i].second;
    if(work_start<0){
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
}


Measured memory_bytes: 2420
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) a[i] = s.nextInt();
		long min = Long.MAX_VALUE;
		for(int i = -100; i <= 100; i++) {
			long total = 0;
			for(int j = 0; j < n; j++) {
				long diff = Math.abs(i - a[j]);
				total += diff * diff;
			}
			min = Math.min(min, total);
		}
		System.out.println(min);
	}
}


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

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0; i < N; i++){
        cin >> vec.at(i);
    }
    set<int> s;
    int num = 0; 
    for(int i = 0; i < N; i++){
        if(vec.at(i) >= 3200){
            num++;
        }
        else{
            int div;
            div = vec.at(i) / 400;
            s.insert(div);
        }
    }
    int ans;
    ans = s.size() + num;
    int s2 = s.size();
    cout << max(1, s2) << " ";
    cout << ans << endl;
}
    

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;



int main() {
 int a,b,c,d;
  cin >>a>>b>>c>>d;
  cout << max(0,min(b,d)-max(a,c)) << endl;
}
     

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

def solve(a, i, prev):
  r = N - len(prev) - i + 1
  p = -i*a
  for j, s in enumerate(prev):
    yield p+abs(j-i)*a, s+abs(j+r)*a
    p = s
  yield s+abs(len(prev)-i)*a,

pd = [0]
A = map(int, input().split())
for a,i in sorted(((a, i) for i, a in enumerate(A, 1)), reverse=True):
  pd = [*map(max, solve(a,i, pd))]

print(max(pd))


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

int main() {
    int n;
    scanf("%d", &n);
    vector<int> v(n);
    rep(i, n) {
        scanf("%d", &v[i]);
    }
    sort(v.rbegin(), v.rend());
    double ans;
    rep(i, n) {
        if (i != n-1) ans += v[i] / pow(2, i+1);
        else ans += v[i] / pow(2, n-1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4240
import java.util.*;
 
 
class Main {
 
    public static void main (String args[])
    {
        Scanner in = new Scanner(System.in);
       
        int th = in.nextInt();
        int as=in.nextInt();
        int tth = in.nextInt();
        int aas=in.nextInt();
        
        while(th>0)
        {   
            tth-=as;
            if(tth<=0)
            {
                System.out.println("Yes");
                break;
            }
            th-=aas;
            if(th<=0)
            {
                System.out.println("No");
                break;
            }
        }
    }
}

Measured memory_bytes: 35752
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a;
		int b;
		a = sc.nextInt();
		b = sc.nextInt();
		if(a % 2 != b % 2) {
			System.out.println("IMPOSSIBLE");
		} else {
			System.out.println((a + b) / 2);
		}
		sc.close();
	}

}


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

int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++) cin>>A[i];
  long long ans=0;
  int MaxNum=0;
  
  for(int i=0; i<N; i++){
    MaxNum=max(MaxNum,A[i]);
    int Bi=MaxNum;
    ans+=Bi-A[i];
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3932
#include <stdio.h>

int main(void){

  int S,h,m,s;
  scanf("%d",&S);

  h = S / 3600;
  m = S % 3600 / 60;
  s = S % 60;

  printf("%d:%d:%d\n",h,m,s);

  return 0;

}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){
        IsPrime.resize(max+1,true);
    } 
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(size_t i=2; i*i<=max; ++i){
        if(IsPrime[i]){
            for(size_t j=2; i*j<=max; ++j){
                IsPrime[i*j] = false;
            }
        }
    }
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<pair<ll, ll> > p(n);
    for(ll i=0;i<n;++i){
        ll a, b;
        cin>>a>>b;
        p[i] = make_pair(b, a);
    }
    sort(p.begin(), p.end());

    string ans = "Yes";
    ll now = p[n-1].first;
    for(ll i=n-1;i>=0;--i){
        now = min(p[i].first - p[i].second, now - p[i].second);
        if(now < 0){
            ans = "No";
            break;
        }
        //cout<<now<<endl;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 6424
#include <math.h>
#include <iostream>
#include<string>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>
#include <stdlib.h>
using namespace std;

int main()
{
char c;
int N;cin >> N;
string S;cin >> S;
for(int i=0;i<S.size();i++)
{
  c=S.at(i)+N;
  if(!isupper(c))c=c-'Z'+'A'-1;
  cout << c;
}
}

Measured memory_bytes: 256
'use strict'

const main = (input) => {
    input = input.split('\n')[0].split(' ').map(i => parseInt(i))
    const a = input[0]
    const b = input[1]
    const diff = b - a

    let arr = []
    for(let i = 1; i < diff; i++){
        arr.push(i)
    }
    const sum = arr.reduce((a, v) => a + v)
    console.log(sum - a)
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
ll dp[100100100];

signed main(){
	//cout << fixed << setprecision(10);
	ll n; cin >> n;
	ll l = 0, r = 1e7+1;
	while(r - l > 1){
		ll mid = (r + l)/2;
		if(mid *  (mid + 1)/2>=n)r = mid;
		else l = mid;
	}
	vl ans;
	for(int i = r;i>=1; --i){
		if(i<=n){
			n-=i;
			ans.push_back(i);
		}
	}
	rep(i,0,ans.size())cout << ans[i] << endl;
	


	return 0;
}


Measured memory_bytes: 3576
N = int(input())
robots = {}
for _ in range(N):
    pos,armlen = map(int,input().split())
    robots[pos] = armlen

robots = sorted(robots.items(),key=lambda x:x[0])
range_min = robots[0][0] + robots[0][1]
ans = 1
for robot in robots[1:]:
    pos,armlen = robot
    if range_min <= (pos-armlen):
        ans += 1
        range_min = pos+armlen
    else:
        if range_min > (pos+armlen):
            range_min = pos+armlen

print(ans)
    


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

int main() {
	int n;

	cin >> n ;

	vector<int> vec(n);
	
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		vec[i]=--a;
	}
	
	int now = 0;
	int cnt = 0;
	int ans = -1;

	for (int i = 0; i < 100000; i++) {
		now = vec[now];
		cnt++;
		if (now == 1) {
			ans = cnt;
			break;
		} 
	}

	cout << ans << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repi(i, j, n) for(int i = j;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define F first
#define S second

// #define COMMENT

/*

const int NN = 200090;
ll fact[NN];
ll finv[NN];
ll inv[NN];

void inverse_modulao() {
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;

  for(int i = 2;i < NN;i++) {
    fact[i] = fact[i-1]*i%mod;
    inv[i] = mod-mod/i*inv[mod%i]%mod;
    finv[i] = finv[i-1]*inv[i]%mod;
  }
}

ll nCr(int n, int r) {
  return fact[n]*finv[r]%mod*finv[n-r]%mod;
}

*/

int N;string s;

int main() {

//  freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

  cin >> N >> s;
  bool ans = 0, one = 0;
  rep(i, N) {
    bool ib = (s[i]-'1') & 1;
    if(ib) {
      // https://math.stackexchange.com/questions/11002/cn-p-even-or-odd
      ans ^= !((N-1-i) & i);
      one = true;
    }
  }
  if(ans) {cout << 1 << endl;return 0;}
  if(one) {cout << 0 << endl;return 0;}

  rep(i, N) {
    bool ib = (s[i]-'1') >> 1;
    if(ib) {
      // https://math.stackexchange.com/questions/11002/cn-p-even-or-odd
      ans ^= !((N-1-i) & i);
    }
  }

  cout << (ans ? 2 : 0) << endl;


  return 0;
}


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

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

    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    sort(h.begin(), h.end(), greater<int>());
    long long res = 0;
    for (int i = k; i < n; i++) {
        res += h[i];
    }

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


Measured memory_bytes: 1024
#include <queue>
#include <cstdio>

#pragma warning(disable : 4996)

using namespace std;

int n, q, c[1000000], a, v;

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

	priority_queue<pair<int, int> > que;

	for (int i = 0; i < q; i++)
	{
		scanf("%d", &a);
		scanf("%d", &v);

		c[a - 1] += v; que.push(make_pair(c[a - 1], -a));

		pair<int, int> maximum;

		while (true)
		{
			maximum = que.top();

			if (maximum.first != c[-maximum.second - 1])
			{
				que.pop();
			}
			else
			{
				break;
			}
		}

		printf("%d %d\n", -maximum.second, maximum.first);
	}

	return 0;
}

Measured memory_bytes: 7388
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0,i<n,i++)
int main(){
vector<int>a(32);a={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
  int i;cin>>i;
  cout<<a.at(i-1)<<endl;
  return 0;
}

Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
S = input()
ln = len(S)
if S == S[::-1]:
    if S[:(ln-1)//2] == S[:(ln-1)//2][::-1]:
        if S[(ln+3)//2 - 1:] == S[(ln+3)//2 - 1:][::-1]:
            print('Yes')
            exit()
print('No')


Measured memory_bytes: 10364
#include <bits/stdc++.h> 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
typedef long long ll;
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int h[n];
  rep(i,n){cin>>h[i];}
  int l=0;
  rep(i,n){
    if(h[i]>=k){l++;}}
  cout<<l<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,M,V,P,a[N],i,l,r,m;
int main(){
	scanf("%d%d%d%d",&n,&M,&V,&P);
	for(i=1;i<=n;++i)scanf("%d",a+i);
	sort(a+1,a+n+1);
	l=1;r=n;
	for(;l<r;){
		m=l+r>>1;
		int ct=0,tot=V-1,res=0;
		for(i=n;i;--i)if(i!=m){
			if(++ct<P || a[i]<=a[m]){--tot;continue;}
			if(a[i]>a[m]+M)break;
			res-=a[m]+M-a[i];if(res<0)res+=M,--tot;
		}
		if(!i && 1ll*tot*M+res<=0)r=m;else l=m+1;
	}
	printf("%d\n",n-l+1);
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using i64 = long long;

int dp[1000010][2];
std::string s;

int rec(int d, int f) {
    if (d < 0) return f * 100000000;
    if (dp[d][f] >= 0) return dp[d][f];

    if (f) {
        int ret = std::min(
            rec(d - 1, 0) + ('9' - s[d] + 1),
            rec(d - 1, 1) + ('9' - s[d])
        );
        return dp[d][f] = ret;
    } else {
        int ret = rec(d - 1, 0) + (s[d] - '0');
        if (s[d] < '9') ret = std::min(ret, rec(d - 1, 1) + (s[d] - '0' + 1));
        return dp[d][f] = ret;
    }
}

int main() {
    for (auto &v : dp) v[0] = v[1] = -1;
    std::cin >> s;
    const int n = s.size() - 1;
    std::cout << std::min(rec(n, 0), rec(n, 1) + 1) << std::endl;

    return 0;
}


Measured memory_bytes: 56068
import bisect
inf = 10**15
mod = 10**9+7
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans=0
for i in range(n-2):
    a = l[i]
    for j in range(i+1, n-1):
        b = l[j]
        indc = bisect.bisect_left(l,a+b)
        ans+=(indc-j-1)
print(ans)

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  long double a,b; cin>>a>>b;

  cout<<(ll)(a*b)<<endl;

  return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
#include <string>
#include <sstream>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define clr(a) memset(a, 0, sizeof(a))
#define set(a) memset(a, -1, sizeof(a))
#define pb push_back
#define sz(a) ((ll)a.size())
#define all(a) a.begin(), a.end()
#define mp make_pair
#define rep(i, a, y) for (ll i = a; i <= y; i++)
#define rep2(i, b) for (ll i = 0; i < b; i++)
#define repl(i, a, b) for (ll i = a; i <= b; i++)
#define ppi pair<int, int>
#define scl(x) scanf("%d", &x)
#define pcl(x) printf("%d", x)
#define FastRead                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0)
/*
 
     ██╗██╗   ██╗██╗  ██╗ █████╗ ███╗   ██╗
     ██║██║   ██║██║  ██║██╔══██╗████╗  ██║
     ██║██║   ██║███████║███████║██╔██╗ ██║
██   ██║██║   ██║██╔══██║██╔══██║██║╚██╗██║
╚█████╔╝╚██████╔╝██║  ██║██║  ██║██║ ╚████║
 ╚════╝  ╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═══╝
 
*/
map<string,int> p;
// ll lcm(ll a ,ll b)
// {
//     return (a*b)/__gcd(a,b);
// }
int main()
{
    FastRead;
    ll n,m;
    cin>>n>>m;
    int x=n-(2*m);
    if(x>0) cout<<x<<endl;
    else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"

using namespace std;

int main()
{
	while(1)
	{
		int n;
		cin>>n;
		if(n==0)
			break;
		
		string s[50];
		string hs[50];
		string boin="aeiuo";
		for(int i=0;i<n;i++)
		{
			cin>>s[i];
			hs[i]+=s[i][0];
			int j=0;
			while(j<s[i].size())
			{
				bool f=true;
				for(int k=0;k<5;k++)
				{
					if(s[i][j]==boin[k])
					{
						f=false;
						j++;
						if(j==s[i].size())
							break;
						hs[i]+=s[i][j];
						break;
					}
				}
				if(f)
				{
					j++;
				}
			}
			//cerr<<hs[i]<<endl;
		}
		
		sort(hs,hs+n);
		int ans=0;
		bool f=true;
		for(int i=1;i<n;i++)
		{
			if(hs[i]==hs[i-1])
			{
				f=false;
				cout<<-1<<endl;
				break;
			}
			int tmp=min(hs[i].size(),hs[i-1].size());
			for(int j=0;j<tmp;j++)
			{
				if(hs[i][j]!=hs[i-1][j])
				{
					tmp=j;
					break;
				}
			}
			ans=max(tmp+1,ans);
		}
		if(f)
			cout<<ans<<endl;
	}
	return 0;
}


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

using namespace std;
int main() {
	long long int H, W, N;
	cin >> H >> W >> N;
	map<pair<long long int, long long int>, long long int>MLL;
	for( int i = 0; i < N; i++ ) {
		long long int a, b;
		cin >> a >> b;
		a--; b--;
		for( int j = -1; j <= 1; j++ ) {
			for( int k = -1; k <= 1; k++ ) {
				MLL[make_pair( a + j, b + k )]++;
			}
		}
	}
	vector<long long int>ans( 10 );
	for( auto n : MLL ) {
		if( 1 <= n.first.first&&n.first.first < H - 1 && 1 <= n.first.second&&n.first.second < W - 1 ) {
			ans[n.second]++;
		}
	}
	ans[0] = (H - 2)*(W - 2);
	for( size_t i = 1; i < 10; i++ ) {
		ans[0] -= ans[i];
	}
	for( size_t i = 0; i < 10; i++ ) {
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 56448
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Security.Policy;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
        checked {
#if DEBUG
            MyDebugger.Test(process, "../TextFile1.txt");
            //TestCaseMaker.MakeTestCase1("../TextFile2.txt");
            //MyDebugger.Test(process, "../TextFile2.txt");
#else
            object ret = process(new StreamReader(Console.OpenStandardInput()));
            Console.WriteLine(ret);
#endif
        }
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var h = int.Parse(spl[0]);
        var w = int.Parse(spl[1]);
        var m = int.Parse(spl[2]);

        var hash = new HashSet<Tuple<int, int>>();

        var vbom = new int[w];
        var hbom = new int[h];

        int vmax = 0;
        int hmax = 0;

        var vmaxPoint = new List<int>();
        var hmaxPoint = new List<int>();

        for (int i=0; i<m; i++) {
            spl = input.ReadLine().Split(' ');
            var ph = int.Parse(spl[0]) -1;
            var pw = int.Parse(spl[1]) -1;

            //hash.Add(((long)ph << 32) | (long)pw);
            hash.Add(new Tuple<int, int>(ph, pw));

            hbom[ph]++;
            vbom[pw]++;

            if (vbom[pw] > vmax) {
                vmax = vbom[pw];
            }

            if (hbom[ph] > hmax) {
                hmax = hbom[ph];
            }
        }

        for(int i=0; i<vbom.Length; i++) {
            if(vbom[i] == vmax) vmaxPoint.Add(i);
        }
        for (int i = 0; i < hbom.Length; i++) {
            if (hbom[i] == hmax) hmaxPoint.Add(i);
        }

        foreach (var ph in hmaxPoint) {
            foreach(var pw in vmaxPoint) {
                //long p = ((long)ph << 32) | (long)pw;
                //string p = ph + ":" + pw;
                var p = new Tuple<int,int>(ph, pw);
                if (!hash.Contains(p)){
                    return (long)vmax + (long)hmax;
                }
            }
        }

        return (long)vmax + (long)hmax - 1;
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 68464
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int M = 5e3 + 5;
int x, pw[2 * M];
 
int32_t main() 
{
	ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
	for(int i = -M + 1; i < M; i++)
		pw[i + M] = pow(i, 5);
	cin >> x;
	for(int i = 0; i < M; i++)
	{
		int a = pw[i + M];
		for(int j = -M; j < M; j++)
		{
			int b = pw[j + M];
			if(a - b == x)
				return cout << i << " " << j, 0;
		}
	}
    	return 0;
}

Measured memory_bytes: 4304
import sys,math,collections,itertools
input = sys.stdin.readline
m = 10**9+7
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
Aaf = []
Aall = []
for i in range(N):
    cntall= 0
    cntaf = 0
    for j in range(N):
        if A[i]>A[j]:
            cntall +=1
            if i < j :
                cntaf += 1
    Aaf.append(cntaf)
    Aall.append(cntall)

cnt=0
for a0,a1 in zip(Aaf,Aall):
    cnt += (K*a0+a1*K*(K-1)//2)%m
print(cnt%m)


Measured memory_bytes: 9596
// #pragma GCC optimize(3)
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <vector>
#include <cstdio>
#include <bitset>
#include <cstring>
#include <iostream>
#include <algorithm>
#define maxn 100010
// #define int long long
using namespace std;
void write(int x){if(x<0){putchar('-');x=-x;}if(x>9) write(x/10);putchar(x%10+'0');}
int read(){int d=0,w=1;char c=getchar();for(;c<'0'||c>'9';c=getchar())if(c=='-')
w=-1;for(;c>='0'&&c<='9';c=getchar())d=(d<<1)+(d<<3)+c-48;return d*w;}
void wln(int x){write(x);putchar('\n');}
void wrs(int x){write(x);putchar(' ');}
int n,f,vis[maxn];
vector<int> b[maxn];
void dfs(int k,int fa)
{
	for(int i=0;i<b[k].size()&&!f;i++)
		if(b[k][i]!=fa) dfs(b[k][i],k);
	if(!vis[k]&&!f)
	{
		if(vis[fa])
		{
			f=1;
			puts("First");
			return;
		}
		vis[k]=vis[fa]=1;
	}
}
signed main()
{
	// freopen(".in","r",stdin);
	// freopen(".out","w",stdout);
	n=read();
	for(int i=1;i<n;i++)
	{
		int x=read(),y=read();
		b[x].push_back(y);
		b[y].push_back(x);
	}
	dfs(1,0);
	if(!f) puts(vis[0]?"First":"Second");
	return 0;
}


Measured memory_bytes: 6144
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int main(){
        vector<int>a(3);
        for(int i=0;i<3;i++){
                cin>>a[i];
        }
        sort(a.begin(),a.end());
        if(a[0]==a[1]&&a[1]==a[2]){
                cout<<"No"<<endl;
        }
        else if(a[0]==a[1]&&a[1]!=a[2]){
                cout<<"Yes"<<endl;
        }else if(a[0]!=a[1]&&a[1]==a[2]){
                cout<<"Yes"<<endl;
        }else{
                cout<<"No"<<endl;
        }
        return 0;
}


Measured memory_bytes: 256
N,M,X= map(int,input().split())
m = 10000000

A = [[0 for i in range(M)]for i in range(N)]
C=[0]*(2**N)
for i in range(N):
    A[i] = list(map(int,input().split()))
for i in range(2 ** N):
    Ad = []
    for j in range(N):
        if (i >> j) & 1  == 1:
            Ad.append(A[j])

    
    xs = [0]*(M+1)
    for k in range(len(Ad)):
        C[i]+=Ad[k][0]
        for l in range(1,M+1):
            xs[l] += Ad[k][l]      
        
    flag = True

    for l in range(1,M+1):
        if xs[l] >= X:
            continue
        else:
            flag = False
            

    if flag and m > C[i]:

        m = C[i]

if m < 10000000:
    print(m)
else:
    print(-1)



Measured memory_bytes: 9308
#include <iostream>

using namespace std;

int main() {
	char C;
	cin >> C;

	switch (C) {
		case 'A': case 'T':
			cout << char('A' + 'T' - C) << endl;
			break;
		case 'C': case 'G':
			cout << char('C' + 'G' - C) << endl;
	}

	return 0;
}

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

int main()
{
  int d, n;
  cin >> d >> n;
  int ans;
  if(n == 100) n++;
  if (d == 0){
    ans = n;
  }
  else if(d == 1){
    ans = (n * 100);
  }
  else ans = (n * 10000);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>

int main() {
	int n, i;
	int a[52] = {0};
	scanf("%d", &n); getchar();
	for(i = 0; i < n; i++) {
		char c;
		int b, num;
		scanf("%c %d", &c, &num); getchar();
		if(c == 'S') b = 0;
		else if (c == 'H') b = 1;
		else if (c == 'C') b = 2;
		else b = 3;
		a[b * 13 + num-1] = 1;
	}
	for(i = 0; i < 52; i++) {
		if(!a[i]) {
			if(i / 13 == 0) {
				printf("S ");
			} else if(i / 13 == 1) {
				printf("H ");
			} else if(i / 13 == 2) {
				printf("C ");
			} else {
				printf("D ");
			}
			printf("%d\n", i % 13 + 1);
		}
	}
	return 0;
}

Measured memory_bytes: 1028
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>
#include <string>
using namespace std;
int N,K,way;
int main() {
	cin >> N >> K;
	way = K*pow((K - 1),(N - 1));
	cout << way << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int N, Q;
	char S[500001];
	scanf("%d", &N);
	scanf("%s", S);
	scanf("%d", &Q);
	
	int i, j, count[251][26] = {};
	for (i = 0; i < N / 2000; i++) {
		for (j = 0; j < 2000; j++) count[i][S[i*2000+j] - 'a']++;
	}
	for (j = 0; j < N % 2000; j++) count[i][S[i*2000+j] - 'a']++;

	int l, r, q, type, flag[26], ans;
	char c;
	for (q = 0; q < Q; q++) {
		scanf("%d", &type);
		if (type == 1) {
			scanf("%d %c", &i, &c);
			i--;
			count[i/2000][S[i] - 'a']--;
			count[i/2000][c - 'a']++;
			S[i] = c;
		} else {
			scanf("%d %d", &l, &r);
			l--;
			r--;
			for (j = 0; j < 26; j++) flag[j] = 0;
			for (i = (l + 1999) / 2000; i < (r + 1) / 2000; i++) {
				for (j = 0; j < 26; j++) if (count[i][j] > 0) flag[j] = 1;
			}
			for (j = l; j <= r && j % 2000 != 0; j++) flag[S[j] - 'a'] = 1;
			for (j = r; j >= l && (j + 1) % 2000 != 0; j--) flag[S[j] - 'a'] = 1;
			for (j = 0, ans = 0; j < 26; j++) ans += flag[j];
			printf("%d\n", ans);
		}
	}
	
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2220
import java.util.Scanner;

public class Main{
 public static void main(String[] args) {
   Scanner kbd =new Scanner(System.in);
   int l=kbd.nextInt();
   int r=kbd.nextInt();
    int d=kbd.nextInt();
    int a=(l-1)/d;
    int b=r/d;
    System.out.println(b-a);

 }

}

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

#define ll long long

int n;
ll ans;
char s[100005];

class Trie{
    public:
        Trie(){}
        ~Trie(){}
        inline void get(){
            scanf("%lld",&l),cnt=0;
        }
        inline void insert(const int &n,char *s){
            int now=0,i;
            for(i=1;i<=n;++i){
                if(nxt[now][s[i]-'0']==0)nxt[now][s[i]-'0']=++cnt;
                now=nxt[now][s[i]-'0'];
            }
        }
        ll search(int x,int d){
            if(x==0&&d!=0)return (l-d+1)&(d-l-1);
            return search(nxt[x][0],d+1)^search(nxt[x][1],d+1);
        }
    private:
        ll l;int now,nxt[100005][2],cnt;    
}trie;

int main(void){
    register int i;
    scanf("%d",&n),trie.get();
    for(i=1;i<=n;++i)
        scanf("%s",s+1),trie.insert(strlen(s+1),s);
    ans=trie.search(0,0);
    if(ans==0)puts("Bob");
    else puts("Alice");
    return 0;
}

Measured memory_bytes: 9160
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<cstring>
#include<string>
#include<bitset>
#include<iomanip>
using namespace std;
#define ri register int
#define il inline
#define pb push_back
#define LL long long
#define pairint pair<int,int>
#define fi first
#define se second
#define mp make_pair

namespace i207M
{

template<class T>il void in(T &x)
{
    x=0; bool f=0; char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-') f=1;
        c=getchar();
    }
    while(c>='0'&&c<='9') x=x*10+(c^'0'),c=getchar();
    if(f) x=-x;
}

#define N 100005
int n;
int a[N],b[N],c[N],d[N];
int f[N];
int findfa(int x)
{
	return x==f[x]?x:f[x]=findfa(f[x]);
}
int cu,cnt,rems;
bool app[N];
signed main()
{
#ifdef M207
	freopen("in.in","r",stdin);
//	freopen("out.out","w",stdout);
#endif
	in(n);
	int s=0;
	for(ri i=1;i<=n;++i) in(a[i]),s^=a[i],c[i]=a[i];
	c[n+1]=rems=s;
	s=0;
	for(ri i=1;i<=n;++i) in(b[i]),s^=b[i],d[i]=b[i];
	d[n+1]=s;
	sort(c+1,c+n+2); sort(d+1,d+n+2);
	for(ri i=1;i<=n+1;++i)
		if(c[i]!=d[i]) 
		{
			puts("-1");
			return 0;
		}
	cu=unique(c+1,c+n+2)-c-1;
	for(ri i=1;i<=cu;++i) f[i]=i;
	for(ri i=1;i<=n;++i)
		if(a[i]!=b[i])
		{
			a[i]=lower_bound(c+1,c+cu+1,a[i])-c;
			b[i]=lower_bound(c+1,c+cu+1,b[i])-c;
			f[findfa(a[i])]=findfa(b[i]);
			app[a[i]]=app[b[i]]=1;
			++cnt;
		}
	rems=lower_bound(c+1,c+1+cu,rems)-c;
	if(!app[rems]) ++cnt;
	for(ri i=1;i<=cu;++i)
		if(app[i]&&f[i]==i) ++cnt;
	printf("%d",--cnt);
    return 0;
}

}

int main()
{
    i207M::main();
    return 0;
}

Measured memory_bytes: 3840
import java.util.*;

public class Main{
        public static void main(String[] args){
                try(Scanner sc = new Scanner(System.in)){
                        int N = sc.nextInt();
                        int count = 0;
                        for(int i = 0; i < N; i++){
                                String s = sc.next();
                                if(s.equals("A")){
                                        count++;
                                }else{
                                        count--;
                                        if(count<0){
                                                System.out.println("NO");
                                                return;
                                        }
                                }
                        }
                        if(count!=0){
                                System.out.println("NO");
                        }else{
                                System.out.println("YES");
                        }
                }
        }
}

Measured memory_bytes: 26368
import java.util.*;
import java.io.*;
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // int d[]=new int[n];
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

        int n=sc.nextInt();
        int a[]=new int[n];
        long ans=0;
        for(int i=0; i<n; i++) {a[i]=sc.nextInt(); }
        int l[] = new int[n];
        int r[] = new int[n];
        r[n-1]=n-1;

        Stack<Integer> st = new Stack<Integer>();
        st.push(0);
        for(int i=1,x; i<n; i++) {
            while(!st.isEmpty()){
                x = st.peek();
                if(a[x]<a[i]){l[i]=x+1; st.push(i); break;}
                else st.pop();
            }
            if(st.isEmpty()){l[i]=0;st.push(i);}
        }
        st.clear();
        st.push(n-1);
        for(int i=n-2,x; -1<i; i--) {
            while(!st.isEmpty()){
                x = st.peek();
                if(a[x]<a[i]){r[i]=x-1; st.push(i); break;}
                else st.pop();
            }
            if(st.isEmpty()){r[i]=n-1;st.push(i);}
        }

        // db(l);
        // db(r);
        
        for(int i=0; i<n; i++) {
            l[i]=i-l[i]+1;
            r[i]=r[i]-i+1;
            ans+=(long)l[i]*r[i]*a[i];
        }
  
        out.println(ans);
        out.flush();
    }


    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

class P implements Comparable<P>{
    int id, d;
    P(int  id, int d) {
        this.id=id;
        this.d=d;
    }
    public int compareTo(P p){
        return d-p.d; //des
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

Measured memory_bytes: 50924
S = str(input())
S_len = len(S)

DP = [[0 for j in range(13)] for i in range(S_len + 1)]
DP[S_len][0] = 1
num = 1

for i in reversed(range(S_len)):

    

    if S[i] != "?":
        for j in range(13):
            DP[i][(j + int(S[i]) * num) % 13] += DP[i + 1][j] % 1000000007
    else:
        for j in range(13):
            for k in range(10):
                DP[i][(j + k * num) % 13] += DP[i + 1][j] % 1000000007

    num = (num * 10) % 13

print(DP[0][5] % 1000000007)



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

int power(int a,int b) {
	long long int mul=1;
	while(b>0) {mul*=a; b--;}
	return mul;
}

int main() {
	int n,a,d=0,sum=0; cin>>n;
	a=n;
	while(a>0) { a/=10; d++; }
	if(d%2==0)  d--;
	else {
		sum = n-(power(10,d-1))+1;
		d-=2;
	}
  while(d>0) { sum+=power(10,d)-power(10,d-1); d-=2;}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
N,M,X=map(int,input().split())
count=0
for i in range (N+1):
	for j in range(M+1):
		if i==0:
			count=N*j
			if count==X:
				print("Yes")
				exit()
		else:
			count=(N*j-(i*j)+M*i-(i*j))
			if count==X:
				print("Yes")
				exit()
print("No")

Measured memory_bytes: 3064
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        String str=scan.nextLine();
        StringBuffer sb = new StringBuffer(str);
        for (int i=0; i<sb.length(); i++) 
        { 
            char c = sb.charAt(i);
            if (Character.isLowerCase(c)) {
                sb.setCharAt(i, Character.toUpperCase(c));
            } else {
                sb.setCharAt(i, Character.toLowerCase(c));
            }
        } 
        System.out.println(sb); 
    }
}


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

int main(){
  while(1){
    string s;
    int i;
    getline(cin, s);
    int N = s.size();
//    printf("N = %d\n", N);
    if(s[0] == '.' && N == 1){
      return 0;
    }
    stack<char> st;
    int f = 1;
    for(i = 0; i < N; i++){
//      printf("i = %d\n", i);
      if(s[i] == '(' || s[i] == '['){
        st.push(s[i]);
      }
      if(s[i] == ')'){
        if(st.size() == 0 || st.top() != '('){
          printf("no\n");
          f = 0;
          break;
        }
        else{
          st.pop();
        }
      }
      if(s[i] == ']'){
        if(st.size() == 0 || st.top() != '['){
          printf("no\n");
          f = 0;
          break;
        }
        else{
          st.pop();
        }
      }
    }
    if(st.size() == 0 && f == 1){
      printf("yes\n");
    }
    else if(f == 1){
      printf("no\n");
    }
  }
}



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

inline int gi()
{
	char c = getchar(); bool f = 1;
	while (c != '-' && (c < '0' || c > '9')) c = getchar();
	if (c == '-') c = getchar(), f = 0;
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return f ? sum : -sum;
}

const int maxn = 200005;
const double eps = 1e-12;

int n;

struct Vector
{
	double x, y;
	Vector() {x = y = 0;}
	Vector(int _x, int _y) {x = _x; y = _y;}
} O, p1, p2;

Vector operator + (Vector a, Vector b) {return Vector(a.x + b.x, a.y + b.y);}
Vector operator - (Vector a, Vector b) {return Vector(a.x - b.x, a.y - b.y);}

double dot(Vector a, Vector b)
{
	return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b)
{
	return a.x * b.y - a.y * b.x;
}

double length(Vector a)
{
	return sqrt(dot(a, a));
}

int main()
{
	O.x = gi(); O.y = gi(); p1.x = gi(); p1.y = gi(); p1 = p1 - O;
	double Len = length(p1);
	int q = gi();
	while (q--) {
		p2.x = gi(); p2.y = gi(); p2 = p2 - O;
		double len = dot(p1, p2) / length(p1), x = p1.x * len / Len, y = p1.y * len / Len;
		printf("%.10lf %.10lf\n", x + O.x, y + O.y);
	}
	
	return 0;
}



Measured memory_bytes: 3216
#include <iostream>
using namespace std;
 
int main() {
  int ans=700;
  string s;
  cin >> s;
  if (s.at(0) == 'o') ans += 100;
  if (s.at(1) == 'o') ans += 100;
  if (s.at(2) == 'o') ans += 100;
  
  cout << ans << endl;
}

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

int sum(int x) {
    return (x*(x+1))/2;
}

int main(void){
    int x;
    cin >> x;
    
    int t = 1;
    //int dist = 0;
    //int dif = 0;
    
    while (sum(t) < x) {
        t++;
    }
   
    while (sum(t) > x) {
        if (sum(t) - x < t) {
            cout << t;
            return 0;
        } 
        
    }
    
    cout << t;
    // 1 3 6 10 15 21 28 35 43 52 
    /*
    while (dist != x){
        ++t;
        if(dist < x && dist + t + t + 1 > x) {
            dif = 0; // 何もしない
            cout << "hoge";
        } else if(dist < x) {
            dif = t;// 右に移動
            cout << "fuga";
        } else if(dist > x){
            dif = (-1) * t;// 左に移動
            cout << "piyo";
        }
        dist = dist + dif;
        //cout << "hoge" << endl;
    }*/
    
    //cout << t;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    int cnt = 0;
    rep(i, N) {
        cin >> a[i];
        while (a[i] % 2 == 0) {
            a[i] /= 2;
            cnt++;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
from collections import Counter
from itertools import combinations

n = int(input())
s = Counter([input()[0] for _ in range(n)])
m = []
for i in "MARCH":
    if i in s:
        m.append(s[i])
ans = 0
for a, b, c in combinations(m, 3):
    ans += a * b * c
print(ans)

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans = (n / (a + b)) * a;
  if (n % (a + b)) {
    ll tmp = n % (a + b);
    if (tmp > a) tmp = a;
    ans += tmp;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	long mod = 1000000007;

	long f(long m, long n) {
		if (n == 1) {
			return m;
		} else {
			return (f((m * m) % mod, n / 2) * (n % 2 == 1 ? m : 1)) % mod;
		}
	}

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		long m = sc.nextLong();
		long n = sc.nextLong();

		sc.close();

		out.println(f(m, n));

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}



Measured memory_bytes: 26296
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
A, B = input().split()
A = int(A)
B = B.replace('.', '')
B = int(B)
ans = A*B
ans = str(ans)
# 文字列の入力
#s = input()
#開業されたN個要素を受け付ける
#input_list = [list(map(int, input().split())) for i in range(N)]
result = ans[0:-2]
if result == "":
    result = "0"
print(result)


Measured memory_bytes: 9176