akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000ll;

void sssp(int s, const vector< vector<pll> > &conn, vector<ll> &result){
	int n = conn.size();
	result = vector<ll>(n, INF);
	priority_queue< pll, vector<pll>, greater<pll> > pq;
	result[s] = 0;
	pq.push(pll(0, s));
	while(!pq.empty()){
		pll p = pq.top();
		pq.pop();
		ll c = p.first;
		int v = p.second;
		if(c > result[v]){ continue; }
		for(int i = 0; i < conn[v].size(); ++i){
			int nv = conn[v][i].first;
			ll nc = c + conn[v][i].second;
			if(nc < result[nv]){
				result[nv] = nc;
				pq.push(pll(nc, nv));
			}
		}
	}
}

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	vector< vector<pll> > conn(n);
	while(m--){
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		conn[a].push_back(pll(b, c));
		conn[b].push_back(pll(a, c));
	}
	vector<ll> ds, dg, dsl, dgl;
	sssp(0, conn, ds);
	sssp(n - 1, conn, dg);
	dsl = ds;
	sort(dsl.begin(), dsl.end());
	dsl.erase(unique(dsl.begin(), dsl.end()), dsl.end());
	dgl = dg;
	sort(dgl.begin(), dgl.end());
	dgl.erase(unique(dgl.begin(), dgl.end()), dgl.end());
	int sqds = static_cast<int>(ceil(sqrt(dsl.size() + 1)));
	int sqdg = static_cast<int>(ceil(sqrt(dgl.size() + 1)));
	vector< vector<int> > large_buckets(sqds, vector<int>(sqdg));
	vector< vector< vector<pii> > >
		inner_buckets(sqds, vector< vector<pii> >(sqdg));
	for(int i = 0; i < n; ++i){
		ds[i] = lower_bound(dsl.begin(), dsl.end(), ds[i]) - dsl.begin();
		dg[i] = lower_bound(dgl.begin(), dgl.end(), dg[i]) - dgl.begin();
		int ls = ds[i] / sqds, lg = dg[i] / sqdg;
		++large_buckets[ls][lg];
		inner_buckets[ls][lg].push_back(pii(ds[i], dg[i]));
	}
	int q;
	scanf("%d", &q);
	while(q--){
		ll fs, fg;
		scanf("%lld%lld", &fs, &fg);
		int s = upper_bound(dsl.begin(), dsl.end(), fs) - dsl.begin();
		int g = lower_bound(dgl.begin(), dgl.end(), fg) - dgl.begin();
		int answer = 0;
		int libegin = 0, liend = s / sqds;
		int ljbegin = (g + sqdg - 1) / sqdg, ljend = sqdg;
		for(int i = libegin; i < liend; ++i){
			for(int j = ljbegin; j < ljend; ++j){
				answer += large_buckets[i][j];
			}
		}
		if(g % sqdg != 0){
			for(int i = libegin; i < liend; ++i){
				const vector<pii> &v = inner_buckets[i][ljbegin - 1];
				for(int j = 0; j < v.size(); ++j){
					if(v[j].first < s && v[j].second >= g){ ++answer; }
				}
			}
		}
		if(s % sqds != 0){
			for(int i = g % sqdg ? ljbegin - 1 : ljbegin; i < ljend; ++i){
				const vector<pii> &v = inner_buckets[liend][i];
				for(int j = 0; j < v.size(); ++j){
					if(v[j].first < s && v[j].second >= g){ ++answer; }
				}
			}
		}
		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 15600
#include<iostream>
using namespace std;
int main(){
int W,H,x,y,r;
cin>>W>>H>>x>>y>>r;
	if(W<x+r||H<y+r||0>x||0>y){
	cout<<"No"<<endl;
	}else{
	cout<<"Yes"<<endl;
	}
	return 0;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] V = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int[] C = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int tmp = 0;
            for(int i = 0; i < N; i++)
            {
                if(V[i] > C[i])
                {
                    tmp += V[i] - C[i];
                }
            }
            Console.WriteLine(tmp);
        }
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

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

    map<string, int> vote;
    vector<string> s(n);
    for(auto &x:s){
        cin >> x;
        vote[x]++;
    }

    int maxval=0;
    for(auto x:vote){
        maxval=max(maxval, x.second);
    }

    for(auto it=vote.begin();it!=vote.end();it++){
        if(it->second==maxval)cout << it->first << endl;
    }

    return 0;
}


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

using namespace std;

typedef long long ll;
#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))
const double pi=acos(-1);
int main()
{
    int m1,d1,m2,d2;
    cin>>m1>>d1>>m2>>d2;
    if(m1!=m2)
        cout<<1;
    else
        cout<<0;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll mpow(ll base, ll n)
{
    if (n == 0)
        return 1;
    ll prev = mpow(base, n / 2);
    if (n % 2 == 1)
    {
        return (prev * prev * base) % MOD;
    }
    else
    {
        return (prev * prev) % MOD;
    }
}

int main()
{
    // 前処理
    COMinit();
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];
    sort(ALL(v));
    ll ans = 0;
    rep(i, n)
    {
        ll tmp = v[i];
        int x = n - i - 1;
        if (x != 0)
        {

            tmp *= mpow(2, x - 1);
            tmp %= MOD;
            tmp *= (x + 2);
            tmp %= MOD;
        }
        else
        {
            tmp *= 1;
        }
        tmp *= mpow(2, i);
        tmp %= MOD;

        ans += tmp;
        ans %= MOD;
    }
    ans *= mpow(2, n);
    ans %= MOD;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 13824
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = []
    c = {}
    answer = 0
    for i in range(n):
        b.append(a[i] + i + 1)
        tmp = -a[i] + i + 1
        if tmp in c:
            c[tmp] += 1
        else:
            c[tmp] = 1
    for i in range(n):
        if b[i] in c:
            answer += c[b[i]]
    print(answer)


if __name__ == '__main__':
    main()



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

#define io ios::sync_with_stdio(false)
#define pb push_back
#define pqueue priority_queue
#define fi first
#define se second
#define ls rt<<1
#define rs rt<<1|1
#define sz(x) (int)(x).size()
#define dbg(x) cout<<#x<<" --- "<<x<<endl
#define mst(x,a) memset(x,a,sizeof(x))
#define fin(a) freopen(a,"r",stdin)
#define fout(a) freopen(a,"w",stdout)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b); }
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r; }
const int inf=0x7fffffff;
ll n,a,b;

int main(){
	io;
	cin>>n>>a>>b;
	if(a==0){
		cout<<0<<endl;
		return 0;
	}
	ll c=a+b;
	ll d=n/c,e=n%c;
	ll ans=d*a;
	ans+=min(e,a);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string s;
  cin >> s;
  for (int i = 0; i < 4; i++) cout << s[i];
  cout << ' ';
  for(int i = 4; i < 12; i++) cout << s[i];
  cout << '\n';
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

#define INF 1e8

using namespace std;

struct edge {
    int to,cost;
    edge(){}
    edge(int to,int cost):to(to),cost(cost){}
};

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k; cin>>k;
    vector<vector<edge> > adj(k);
    rep(i,k){
        adj[i].pb(edge((i+1)%k,1));
        adj[i].pb(edge((i*10)%k,0));
    }
    priority_queue<pi,vector<pi>,greater<pi> > que;
    que.emplace(0,1);
    vi dist(k,INF);
    dist[1] = 0;
    while(!que.empty()){
        int d,v;
        tie(d,v) = que.top(); que.pop();
        if (d>dist[v]) continue;
        for(auto e:adj[v]){
            if (dist[e.to]>dist[v]+e.cost){
                dist[e.to] = dist[v]+e.cost;
                que.emplace(dist[e.to],e.to);
            }
        }
    }
    cout<<dist[0]+1<<"\n";
    return 0;
}


Measured memory_bytes: 6780
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(void)
{
    int N, K;
    cin >> N >> K;

    if (K == 1)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << N - K << endl;
    }
}

Measured memory_bytes: 256
n = int(input())
if n%10 == 2 or n%10 == 4 or n%10 == 5 or n%10 ==7 or n%10 == 9:
  print("hon")
elif n%10 == 0 or n%10 == 1 or n%10 == 6 or n%10 == 8:
  print("pon")
else:
  print("bon")

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for(int i = 0; i < N; i++)
const int LLINF = 1LL << 60;
const int mod = 1e9 + 7;

signed main()
{
  int pos[2][100005];
  string S[2];
  int Q;
  
  cin >> S[0] >> S[1];
  
  Rep(p, 2) {
    int cnt = 0;
    Rep(i, S[p].size()) {
      pos[p][i] = cnt;
      if(S[p][i] == 'A') cnt++;
      else cnt += 2;
    }
    pos[p][S[p].size()] = cnt;
  }
  
  cin >> Q;
  while(Q--) {
    int A, B, C, D;
    cin >> A >> B >> C >> D; A--, C--;
    if((pos[0][B] - pos[0][A]) % 3 == (pos[1][D] - pos[1][C]) % 3) cout << "YES" << endl;
    else cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 2432
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll mod = 998244353;



ll N,ans;
ll cnt[5];
map<ll,ll> mp;
int main() {
	cin >> N;


	FOR(i, 2, N+1) {
		ll cur = i;
		for (ll j = 2; j*j <= cur; j++) {
			while (cur%j == 0) {
				mp[j]++;
				cur /= j;
			}
		}
		if (cur != 1)mp[cur]++;
	}
	FOR(i, 2, 101) {
		if (mp[i] >= 2) {
			cnt[0]++;
			if (mp[i] >= 4) {
				cnt[1]++;
				if (mp[i] >= 14) {
					cnt[2]++;
					if (mp[i] >= 24) {
						cnt[3]++;
						if (mp[i] >= 74) {
							cnt[4]++;
						}
					}
				}
			}
		}
	}

	ans += cnt[4];
	ans += cnt[2] * (cnt[1] - 1);
	ans += cnt[3] * (cnt[0] - 1);
	ans += cnt[1] * (cnt[1] - 1)*(cnt[0]-2)/2;

	cout << ans << endl;
	return 0;
}

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

ans = 0
for i in range(1, len(p) - 1):
    if p[i] > p[i - 1] and p[i] < p[i + 1]:
        ans += 1
        continue
    
    if p[i] > p[i + 1] and p[i] < p[i - 1]:
        ans += 1

print('{}'.format(ans))



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MIN -10000


int main(){
    string str;
    cin >> str;
    int n = str.size()-1;
    ll sum = 0;
    for(int bit=0;bit<(1<<n);bit++){
        ll num = str[0]-'0';
        for(int i=0;i<n;i++){
            if(bit>>i & 1){
                sum += num;
                num = str[i+1]-'0';
            }
            else{
                num = num*10+str[i+1]-'0';
            }
        }
        sum += num;
    }
    cout << sum << endl;

}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	
int i,n,H,W;

while(1){

scanf("%d %d",&H,&W);
if(H==0 && W==0) break;

for(i=1;i<=H;i++){
	for(n=1;n<=W;n++){
		if(i%2==0){
			if(n%2==0){
				printf("#");
			}
			else{
				printf(".");
			}
		}
		else{
			if(n%2==0){
				printf(".");
			}
			else{
				printf("#");
			}
		}
	}
printf("\n");
}

printf("\n");

}
return 0;

}

Measured memory_bytes: 572
$primes = [2,3]

def is_prime?(n)
	i = 0
	while $primes[i] <= Math.sqrt(n).to_i
		return false if n % $primes[i] == 0
		i += 1
	end
	return true
end

def next_prime(n)
	n += 1 if n % 2 == 0
	loop do
		return n if is_prime?(n)
		n += 2
	end
end

def make_prime(n)
	while $primes[-1] <= n
		$primes << next_prime($primes[-1]+1)
	end
end

while gets
	n = $_.to_i
	make_prime(n)
	puts $primes[0,$primes.index{|x| x>n}].size
end

Measured memory_bytes: 7316
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  string s;
  cin >> s;
  ll price = 700;
  rep(i,3){
    if(s[i]=='o'){
      price += 100;
    }
  }
  print(price);
}

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

int main() {
  int n; cin >> n;
  while (n--) {
    vector<int> a(10); for (int i = 0; i < 10; ++i) cin >> a[i];
    stack<int, deque<int>> s0({a[0]}), s1({0});
    for (int i = 1; i < 10; ++i) {
      int m = 10, mpos = -1;
      if (s0.top() < a[i]) {
        if (a[i] - s0.top() < m) {
          m = a[i] - s0.top();
          mpos = 0;
        }
      }
      if (s1.top() < a[i]) {
        if (a[i] - s1.top() < m) {
          m = a[i] - s1.top();
          mpos = 1;
        }
      }
      if (mpos == -1) {
        cout << "NO" << endl;
        break;
      }
      ( (mpos) ? s1 : s0 ).push(a[i]);
      if (i == 9) cout << "YES" << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 2988
#include<bits/stdc++.h>
using namespace std;
int n,k,a,i,ans;
int main(){
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++){
		scanf("%d",&a);
		ans+=min(a,k-a);
	}
	printf("%d\n",ans*2);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a[110];
	int n;
	cin >> n;
	
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	for (int i = n - 1; i >= 0; i--)
	{
		cout << a[i];
		if (i)cout << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 3032
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 998244353;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n,s;
    cin >> n >> s;
    vector<int> a(n+1, 0);
    for(int i=0;i<n;++i) {
        cin >> a[i+1];
    }

    ll ans = 0LL;
    vector<vector<ll>> cnt(n+1, vector<ll>(s+1, 0));
    for(int i=1;i<=n;++i) {
        if(a[i] < s) {
            ans += (cnt[i-1][s-a[i]] * ll(n-i+1)) % MOD;
            ans %= MOD;
        } else if(a[i] == s) {
            ans += (ll(i) * ll(n-i+1)) % MOD;
            ans %= MOD;
        }

        if(a[i] <= s) {
            cnt[i][a[i]] += i;
            cnt[i][a[i]] %= MOD;
        }
        for(int j=0;j<=s;++j) {
            cnt[i][j] += cnt[i-1][j];
            cnt[i][j] %= MOD;
            if(j+a[i] <= s) {
                cnt[i][j+a[i]] += cnt[i-1][j];
                cnt[i][j+a[i]] %= MOD;
            }
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 70784
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int d = sc.nextInt();
      int n = sc.nextInt();
      int x = (int) Math.pow(100,d);
      if(n <= 99)
      System.out.println(x*n);
      else
        System.out.println(x*101);
    }
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int ans = 0;
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            if (a[i] >= h && b[i] >= w) {
                ans++;
            }
        }


        System.out.println(ans);
    }

}


Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(int i=0;i<N;i++)
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin>>N>>K;
    vector<int>V(N);
    for(int i=0;i<N;i++){
        cin>>V[i];
    }
    int M=min(K,N);//取れる最大個数
    priority_queue<int,vector<int>,greater<int>>fromL;
    priority_queue<int,vector<int>,greater<int>>fromR;
    ll value=0;
    ll sub=0;
    for(int i=0;i<=M;i++){
        for(int j=0;j<=M-i;j++){
            value=0;
            for(int k=0;k<i;k++){
                fromL.push(V[k]);
                value+=V[k];
            }
            for(int k=0;k<j;k++){
                fromR.push(V[N-k-1]);
                value+=V[N-k-1];
            }
            for(int k=0;k<K-(i+j);k++){
                if(!fromL.empty()&&!fromR.empty()){//両方からじゃない
                    if(fromL.top()>=0&&fromR.top()>=0){break;}
                    else if(fromL.top()<fromR.top()){value-=fromL.top();fromL.pop();}
                    else{value-=fromR.top();fromR.pop();}
                }
                else if(fromL.empty()&&fromR.empty()){break;}
                else if(fromL.empty()){
                    if(fromR.empty())break;
                    value-=fromR.top();
                    fromR.pop();
                }
                else{
                    if(fromL.top()>=0)break;
                    value-=fromL.top();
                    fromL.pop();
                }
            }
            sub=max(sub,value);
            while (!fromL.empty()) fromL.pop();
            while (!fromR.empty()) fromR.pop();
        }
    }
    cout<<sub<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

signed main(){
    ll M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;
    if(M1 + 1 == M2) PRINT("1");
    else PRINT("0");
    return 0;   
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) (1 + (int)((a) - 1)/(int)(b))
//#define int long long

signed main(){
    int n; cin >> n;
    vector<pair<int, int>> v(n);
    rep(i, n){
        v[i].second = i+1;
        cin >> v[i].first;
    }
    sort(ALL(v));
    
    vector<int> ans(n);
    rep(i, n){
        auto p = v[i];
        int idx = p.second - 1;
        ans[idx] = (i < n/2) ? v[n/2].first : v[n/2-1].first;
    }
    
    for(int i : ans){
        cout << i << endl;
    }
}

Measured memory_bytes: 4480
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int N = 3005;
int n, m, k, f[N][N], p[N][N];
char s[N], t[N], a[N];

int main()
{

    cin >> (s+1) >> (t+1);
    n = strlen(s+1);
    m = strlen(t+1);

    for(int i=1; i<=n; ++i) for(int j=1; j<=m; ++j)
    if (s[i] == t[j]) {
        f[i][j] = f[i-1][j-1] + 1;
        p[i][j] = -1;
    } else {
        f[i][j] = max(f[i-1][j], f[i][j-1]);
        p[i][j] = f[i-1][j] > f[i][j-1];
    }

    while (n && m) {
        if (p[n][m] == -1) {
            a[++k] = s[n];
            --n; --m;
        } else {
            if (p[n][m]) --n; else --m;
        }
    }
    reverse(a+1, a+1+k);
    cout << (a+1);
}


Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long long unsigned int llu;
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define YUGEN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define lp(i,start,end) for(int i=start;i<end;i++)
#define MAX 105
#define BPC(x)  __builtin_popcountll(x)
#define test() ll t; cin>>t; while(t--)
#define gcd(a,b)  __gcd(a,b)
#define SIZE 26
ll gcd(ll a,ll b) {if (a==0) return b;return gcd(b%a,a);}

int main()
 {
    YUGEN;
    int n;
    cin>>n;
    int d[n][2];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<2;j++)
        cin>>d[i][j];
    }
    int count=0,ans=0;
    for(int i=0;i<n;i++)
    {
            if(d[i][0]==d[i][1])
            count++;
            else
            count=0; 
            ans=max(ans,count);     
    }
    ans=max(ans,count);
    if(ans>=3)
    cout<<"Yes";
    else
    {
        cout<<"No";
    }
    

    

 }




Measured memory_bytes: 3644
#include<stdio.h>
#include<stdlib.h>
#define M 100000

int A[M];

int partition(int p, int r){

  int x,i,j,k;

  x = A[r];
  i = p-1;

  for(j = p;j<r;j++){
    if(A[j] <= x){
      i = i+1;
      k = A[i];
      A[i] = A[j];
      A[j] = k;
    }
  }
  k = A[i+1];
  A[i+1] = A[r];
  A[r] = k;

  return i+1;
}

int main(){

  int i,j,k,n;

  scanf("%d",&n);

  for(i=0;i<n;i++) scanf("%d",&A[i]);

  k =  partition(0,n-1);

  for(i=0;i<n;i++){
    if(i==n-1) printf("%d\n",A[i]);
    else if(i == k) printf("[%d] ",A[i]);
    else printf("%d ",A[i]);
  }

  return 0;
}



Measured memory_bytes: 2184
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


MOD = 2019
# INF = int(1e15)


def solve():
    S = Scanner.string()
    S = S[::-1]
    cnt = [0 for _ in range(MOD)]
    tmp = 0
    ans = 0
    x = 1
    for s in S:
        cnt[tmp] += 1
        tmp += int(s) * x
        tmp %= MOD
        x *= 10
        x %= MOD
        ans += cnt[tmp]
    print(ans)


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 10784
# def easy_step
#   # p gets().chomp.split("")
#   steps = gets().chomp.split("")
  
#   steps.each_with_index do |step, index|
#     next if (index.modulo(2) > 0 && step != "R") || (index.modulo(2) == 0 && step != "L")
#     return false
#   end

#   steps.size() > 0 ? true : false
# end

# easy_step ? p("Yes") : p("No")

s = gets.chomp.split('')
s.length.times do |n|
  if n.odd? && s[n] == 'R' || n.even? && s[n] == 'L'
    puts 'No'
    exit
  end
end

puts 'Yes'

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

int main()
{
  int W, H;
  int N;

  cin >> W >> H;
  cin >> N;
  int x = W * 2 + H - 2;
  int y = (W - 1) * 2 + H - 4;
  int ret = 0;

  while(N--) {
    int P;
    cin >> P;
    if(P == 0) --x;
    else --y;

    if(x < W) {
      if(x == y) ++ret;
    } else if(x == W) {
      
    } else if(x < W + H - 1) {
      if(x == y + 2) ++ret;
    } else if(x == W + H - 1) {
    
    } else {
      if(x == y + 4) ++ret;
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 1160
///
// File:  0009.cpp
// Author: ymiyamoto
//
// Created on Wed Nov  8 23:17:22 2017
//

#include <cmath>
#include <cstdint>
#include <iostream>

using namespace std;

static int32_t primes[1000000];

bool is_prime(uint32_t val)
{
  if (primes[val] == 1) return true;
  if (primes[val] == -1) return false;

  for (uint32_t i = 2; i <= sqrt(val); i++) {
    if (val % i == 0) {
      primes[val] = -1;
      return false;
    }
  }

  primes[val] = 1;
  return true;
}

int32_t main()
{
  while (true) {
    uint64_t n;
    cin >> n;
    if (cin.eof()) break;

    uint32_t count = 0;
    for (uint32_t i = 2; i <= n; i++) {
      if (is_prime(i)) count++;
    }
    cout << count << endl;
  }

  return 0;
}

Measured memory_bytes: 6980
#include<bits/stdc++.h>
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
#define lowbit(x) ((x)&(-x))
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
int n;
long long k;
long long a[2000100];
long long INF=1e9+1;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	INF=INF*INF;
	long long cl,cr,cm,l,r,m,tot;
	cl=-INF;
	cr=INF;
	while(cl+1<cr){
		cm=(cl+cr)/2LL;
		tot=0LL;
		for(int i=0;i<n;i++){
			if(a[i]<0){
				l=-1;
				r=n;
				while(l+1<r){
					m=(l+r)/2LL;
					if(a[i]*a[m]<cm)
						r=m;
					else
						l=m;
				}
				tot+=(long long)(n)-r;
			}
			else{
				l=-1;
				r=n;
				while(l+1<r){
					m=(l+r)/2LL;
					if(a[i]*a[m]<cm)
						l=m;
					else
						r=m;
				}
				tot+=r;
			}
			if((a[i]*a[i])<cm)
				tot-=1LL;
		}
		tot/=2LL;
		if(tot<k)
			cl=cm;
		else
			cr=cm;
	}
	cout<<cl<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
using namespace std;

int main(){
    string s; cin >> s;
    string a = "Sunny";
    if(s == "Sunny") a = "Cloudy";
    if(s == "Cloudy") a = "Rainy";
    cout << a << endl;

    return 0;
}




Measured memory_bytes: 256
#include<cstdio>
int main(void){
int a,b,c,n;
scanf("%d",&n);
while(n--!=0){
 scanf("%d%d%d",&a,&b,&c);
 puts(a*a==b*b+c*c || b*b==a*a+c*c || c*c==a*a+b*b?"YES":"NO");
}
return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ff                first
#define ss                second
#define int               long long
#define pb                push_back
#define mp                make_pair
#define li                list<int>
#define pii               pair<int,int>
#define vi                vector<int>
#define mii               map<int ,int>
#define setbits(x)        _builtin_popcountll(x)
#define zrobits(x)        _builtin_ctzll(x)
#define mod               1000000007
#define inf               1e18
#define ps(x,y)           fixed<<setprecision(y)<<x
#define mk(arr,n,type)    type *arr=new type(n);
#define w(x)              int x; cin>>x; while(x--)
#define all(x)            (x).begin(), (x).end()
#define PI                3.14159265358979
void c_p_c()
{
#ifndef ONLINE_JUDGE
	freopen("new2.txt", "r", stdin);
	freopen("halua.txt", "w", stdout);
#endif
}
// int aa[111111], bb[11111], c[1111111];
void solve()
{

	int n; cin >> n;
	cout << ceil(n / (1000 * 1.0)) * 1000 - n;

}
int32_t main()

{
	c_p_c();
	solve();
}


Measured memory_bytes: 3784
a,b,c=gets.split.map(&:to_i)
as=[]; flg=true; i=1
while flg do
  k=(a*i)%b
  if as.include?(k)
    flg=false
  else
    as<<k
  end
  i+=1
end
puts as.include?(c) ? 'YES':'NO'

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

int n,K=-1;
int main () {
    cin>>n;
    for (int i=1; i<=9; i++){
        for (int j=1; j<=9; j++){
            if (n==i*j){
        K=1;
    }
        }
     
    }
    if(K==1){
    cout << "Yes" << endl;
    }
    else{
        cout<<"No"<<endl;
    }
        
 
}

Measured memory_bytes: 3544
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

struct Info{
	Info(){
		num_of_fixed = 0;
		for(int i = 1; i <= 9; i++)check[i] = false;
	}

	int array[9],num_of_fixed;
	bool check[10];

};

int ans = 0;

void recursive(Info info){
	if(info.num_of_fixed == 9){

		int A = info.array[0];
		int B = 10*info.array[1]+info.array[2];
		int C = 100*info.array[3] + 10*info.array[4] + info.array[5];
		int D = 100*info.array[6] + 10*info.array[7] + info.array[8];

		if(A + B + C == D)ans++;

		return;
	}

	Info next_info[9-info.num_of_fixed];

	for(int i = 0; i < 9-info.num_of_fixed; i++){
		next_info[i].num_of_fixed = info.num_of_fixed;
 		for(int k = 0; k < 9; k++){
			next_info[i].array[k] = info.array[k];
			next_info[i].check[k+1] = info.check[k+1];
		}
	}

	int index = 0;
	for(int i = 0; i < 9; i++){
		if(info.array[i] == -1){
			for(int k = 1; k <= 9; k++){
				if(info.check[k] == false){
					next_info[index].array[i] = k;
					next_info[index].check[k] = true;
					next_info[index].num_of_fixed++;
					recursive(next_info[index]);
					index++;
				}
			}
			break;
		}
	}
}


int main(){

	Info first;

	for(int i = 0; i < 9; i++){
		scanf("%d",&first.array[i]);
		if(first.array[i] != -1){
			first.check[first.array[i]] = true;
			first.num_of_fixed++;
		}
	}

	recursive(first);

	printf("%d\n",ans);

    return 0;
}

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

int main() {
	int N, x[10000],n=0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> x[i];
		while (x[i] % 2 == 0) {
			x[i] = x[i]/2;
			n++;
		}
	}
	cout << n;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	const char t[] = "CF_";
	int answer = 0;
	for(const char c : s){
		if(c == t[answer]){ ++answer; }
	}
	cout << (answer == 2 ? "Yes" : "No") << endl;
	return 0;
}



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

const int maxn = 110;
const long double pi = acos(-1.0);

int n;
long double x[maxn], y[maxn], ans;


long double solve() {
	long double r = rand(), nx, ny, ax=0, ay=0;
	r /= RAND_MAX;
	r *= 2*pi;
	for (int i = 0; i < n; ++i) {
		nx = cos(r)*x[i]-sin(r)*y[i];
		ny = sin(r)*x[i]+cos(r)*y[i];
		if (nx >= 0) {
			ax += nx;
			ay += ny;
		}
	}
	return sqrt(ax*ax+ay*ay);
}

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> x[i] >> y[i];
	for (int i = 0; i < 10000; ++i)
		ans = max(ans, solve());
	cout << setprecision(13) << ans;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  string a, b, c;
  cin >> a >> b >> c;

  vector<vector<int> > dp(n+2, vector<int>(26));
  for (int i = 0; i < n; i++) {
    int minimum = 1000000007;
    for (int j = 0; j < 26; j++) minimum = min(minimum, dp[i][j]);
    for (int j = 0; j < 26; j++) {
      dp[i+1][j] = minimum;
      if (a[i] != 'a'+j) dp[i+1][j]++;
      if (b[i] != 'a'+j) dp[i+1][j]++;
      if (c[i] != 'a'+j) dp[i+1][j]++;
    }
  }
  int ans = 1000000007;
  for (int j = 0; j < 26; j++) ans = min(ans, dp[n][j]);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i,a,n) for(ll i=a;i<(ll)(n);i++)

int main(){
    int A,B,K;
    cin>>A>>B>>K;
    int count = 0;
    for(int i=max(A,B); i>=1; i--){
        if(A%i==0 && B%i==0){
            count++;
        }

        if(count == K){
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <complex>
 
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>
 
#define REP(i,e) for(int i=0;i<(int)(e);i++)
#define FOR(i,b,e) for(int i=(int)(b);i<(int)(e);i++)
#define ALL(c) (c).begin(), (c).end()
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define RALL(c) (c).rbegin(), (c).rend()
#define ALLA(a,n) ((a)+0), ((a)+n)
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstring;
typedef vector<double> vdouble;
 
template<class T>void pp(T v,int n){ REP(i,n)cout<<v[i]<< ' ' ; cout << endl; }
template<class T>void pp(T v){ EACH(it,v) cout << *it << ' ' ; cout << endl;  }
template<class T>T& ls(T& a,T b){ if(b<a) a=b; return a; }
template<class T>T& gs(T& a,T b){ if(b>a) a=b; return a; }
inline ll to_i(const string& s){ll n;sscanf(s.c_str(),"%lld",&n);return n;}
inline string to_s(ll n){char buf[32];sprintf(buf,"%lld",n);return string(buf);}

int main() {
  ll r, d, x;
  while (cin >> r >> d >> x) {
    REP(i,10) {
      x = x * r - d;
      cout << x << endl;
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
#include<set>
#include<cmath>
#include<string>
using namespace std;
#define LL long long

int n;
char s[55];

int main()
{
    while(~scanf("%d",&n))
    {
        map<char,int> m[50];
        for(int i=0;i<n;++i)
        {
            scanf("%s",s);
            int len=strlen(s);
            for(int j=0;j<len;++j)
                m[i][s[j]]++;
        }
        string ans="";
        for(int i='a';i<='z';++i)
        {
            int minn=10000000;
            for(int j=0;j<n;++j)
                minn=min(m[j][i],minn);
            if(minn==0) continue;
            else
            {
                for(int k=0;k<minn;++k)
                    ans+=i;
            }
        }
        cout<<ans<<endl;
    }
}


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

using namespace std;
#define ll         long long
#define f(n)       for(int i = 0; i < n; i++)
#define pb         push_back
#define mp         make_pair
#define vi         vector<int>
#define w(t)       while(t--)
#define all(v)     v.begin(),v.end()

int main()
{
    int n;
    cin >> n;
    int a = n / 5;
    int b = n / 500;
    cout << (a * 5) + (b * 500) << endl;
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  int t = n, c = 0;
  while(t > 0){
    c += t % 10, t /= 10;
  }
  if(n % c == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -10010
#define bql 2147483647
#define ll long long
#define maxn 100010
using namespace std;
int main(){
	fast;
	ll a,b;
	cin>>a>>b;
	if(a>b)swap(a,b);
	int c=(b-a)/2;
	if(c*2!=(b-a)){
		cout<<"IMPOSSIBLE"<<endl;
		return 0;
	}
	cout<<a+c<<endl;
}/*『你强归你强，我用不示弱』*/


Measured memory_bytes: 256
/*
* @author:  codancer
* @createTime:  2020-02-09, 20:16:44
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
typedef vector<int> VI;
typedef pair<int,int> pii;
int cal(int n){
	int ans=0;
	while(n){
		ans+=(n%10!=0);
		n/=10;
	}
	return ans;
}
int main(){
	string s;
	int k;
	cin>>s>>k;
	int l=(int)s.length();
	if(l<=4){
		int n=0;
		int ans=0;
		for(char c:s){
			n=n*10+c-'0';
		}
		for(int i=1;i<=n;i++){
			if(cal(i)==k) ans++;
		}
		cout<<ans<<endl;
	}else{
		int x1=s[0]-'0';
		int x2=0;
		int x3=0;
		int id2=-1,id3=-1;
		int ans=0;
		for(int i=1;i<l;i++){
			if(s[i]!='0'){
				id2=i;
				x2=s[i]-'0';
				break;
			}
		}
		if(id2!=-1){
			for(int i=id2+1;i<l;i++){
				if(s[i]!='0'){
					id3=i;
					x3=s[i]-'0';
					break;
				}
			}
		}
		if(k==1){
			for(int len=1;len<=l-1;len++){
				ans+=9;
			}
			ans+=x1;
		}
		if(k==2){
			for(int len=2;len<=l-1;len++){
				ans+=9*9*(len-1);
			}
			ans+=(x1-1)*9*(l-1);
			if(x2) ans+=(l-id2-1)*9;//x1 0 ????
			ans+=x2;
		}
		if(k==3){
			for(int len=3;len<=l-1;len++){
				ans+=9*9*9*(len-1)*(len-2)/2;
			}
			if(x2==0&&x3==0){
				ans+=(x1-1)*9*9*(l-1)*(l-2)/2;//<x1 ?????
			}
			if(x2&&x3==0){
				ans+=(x1-1)*9*9*(l-1)*(l-2)/2;//<x1 ?????
				ans+=9*9*(l-id2-1)*(l-id2-2)/2;// x1 0 ????
				ans+=(x2-1)*9*(l-id2-1);// x1 <x2 ?????
			}
			if(x2==0&&x3){
				ans+=(x1-1)*9*9*(l-1)*(l-2)/2;//<x1 ?????
				ans+=(x3-1)*9*(l-id3-1);
				ans+=9*9*(l-id3-1)*(l-id3-2)/2;
			}
			if(x2&&x3){
				ans+=(x1-1)*9*9*(l-1)*(l-2)/2;//<x1 ?????
				ans+=9*9*(l-id2-1)*(l-id2-2)/2;// x1 0 ????
				ans+=(x2-1)*9*(l-id2-1);// x1 <x2 ?????
				ans+=9*(l-id3-1);//x1 x2 0 ???
				ans+=x3;//x1x2x3000000
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

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

using Graph = vector<vector<char>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}

int main(){
  string S;
  cin >> S;
  int N = S.size();
  cout << S.substr(0,N-8);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second

const int N = 3e5 + 7, mod = 998244353;

int n, type[N], ans = 1, cnt[3];
string s;
vector <int> r, g, b;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	cin >> s;
	for(int i = 1; i <= 3 * n; i++){
		if(s[i - 1] == 'R') r.pb(i);
		else if(s[i - 1] == 'G') g.pb(i);
		else b.pb(i);
		type[i] = 1;
	}
	for(int i = 0; i < n; i++){
		type[min(r[i], min(g[i], b[i]))] = 0;
		type[max(r[i], max(g[i], b[i]))] = 2;
	}
	for(int i = 1; i <= 3 * n; i++){
		cnt[type[i]]++;
		if(type[i] == 0) ans = (1LL * ans * cnt[0]) % mod;
		else ans = (1LL * ans * (cnt[type[i] - 1] - cnt[type[i]] + 1)) % mod;
	}
	cout << ans;
}


Measured memory_bytes: 3340
def main():
    N = int(input())
    d = {};
    for i in range(N):
        s = input()
        if s not in d:
            d[s] = 1
        else:
            d[s] += 1
    M = int(input())
    for i in range(M):
        s = input()
        if s not in d:
            d[s] = -1
        else:
            d[s] -= 1

    print(max(0, max(d.values())))



if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import scala.math._

object Main extends App {
  val scanner = new java.util.Scanner(System.in)

  val x1 = scanner.nextDouble
  val y1 = scanner.nextDouble
  val x2 = scanner.nextDouble
  val y2 = scanner.nextDouble

  val output = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2))

  println(output)
}

Measured memory_bytes: 45880
#include <iostream>
#include <string>
using namespace std;
using ll = long long;
int main(){
    string s;
    int n;
    ll r=0,g=0,b=0,ans=0;
    cin >> n;
    cin >> s;
    for (auto c:s){
        if (c == 'R') r+=1;
        if (c == 'G') g+=1;
        if (c == 'B') b+=1;
    }
    ans = r*g*b;
    for (int i=0; i<n; i++){
        for(int j=i+1; 2*j-i<n; j++){
            if (s.c_str()[i] != s.c_str()[j]){
                if (s.c_str()[j] != s.c_str()[2*j-i]){
                    if (s.c_str()[2*j-i] != s.c_str()[i]){
                        ans -=1;
                    }
                }
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3160
#include<stdio.h>
#define N 100

int main(){
  int n,p[N+1],m[N+1][N+1],i,j,l,k;
  scanf("%d",&n);
  for(i=1;i<=n;i++) scanf("%d %d",&p[i-1],&p[i]);
  for(i=1;i<=n;i++)m[i][i]=0;
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=2097152;
      for(k=i;k<=j-1;k++){
        if(m[i][k]+m[k+1][j] + p[i-1] * p[k] * p[j] < m[i][j]) m[i][j]=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
      }
    }
  }
  printf("%d\n",m[1][n]);
  return 0;
}


Measured memory_bytes: 2052
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

set<string>st;
int n;
void go(string s) {
	if (s.size() == n) {
		st.insert(s);
		return;
	}
	vector<char>kek;
	for (char c : s) {
		kek.push_back(c);
	}
	sort(all(kek));
	kek.erase(unique(all(kek)), end(kek));
	kek.push_back(kek.back() + 1);
	for (char c : kek) {
		go(s + c);
	}
}


signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	go("a");
	for (const auto& s : st) {
		cout << s << '\n';
	}
	return 0;
}

/*


*/

Measured memory_bytes: 14208
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      a: usize,
      b: usize,
      c: usize,
    }
    let ans = min(a+b+1, c) + b;
    println!("{}", ans);
}


Measured memory_bytes: 4352