akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr ll INF = 1ll << 55;

template <typename T> inline constexpr bool chmin(T &a, T b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <typename T> inline constexpr bool chmax(T &a, T b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}
template <typename ite>
void print_ite(ite start, ite end, char sp = ' ', char en = '\n') {
  for (auto i = start; i != end; i++)
    cout << *i << sp;
  cout << en;
}
template <typename ite> void scan_ite(ite start, ite end) {
  for (auto i = start; i != end; i++)
    cin >> (*i);
}
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

struct Edge {
  int to;
  ll time;
  ll cost;
};

int main() {
  int n, m;
  ll s;
  cin >> n >> m >> s;
  vector<Edge> Graph[n];
  for (int i = 0; i < m; i++) {
    int u, v, a;
    ll b;
    cin >> u >> v >> a >> b;
    u--, v--;
    Graph[u].push_back(Edge{v, b, -a});
    Graph[v].push_back(Edge{u, b, -a});
  }
  for (int i = 0; i < n; i++) {
    ll c, d;
    cin >> c >> d;
    Graph[i].push_back(Edge{i, d, c});
  }
  // cerr << "Input OK\n";
  vector<vector<ll>> dp(n, vector<ll>(20050, INF));
  priority_queue<tuple<ll, ll, int>, vector<tuple<ll, ll, int>>,
                 greater<tuple<ll, ll, int>>>
      pq;
  pq.push(make_tuple(0, s, 0));
  while (!pq.empty()) {
    auto t = pq.top();
    pq.pop();
    ll time = get<0>(t);
    ll coin = get<1>(t);
    int idx = get<2>(t);
    // cerr << time << ' ' << coin << ' ' << idx << '\n';
    if (coin > 20010) {
      pq.push(make_tuple(time, 20010, idx));
      continue;
    }
    if (dp[idx][coin] <= time) {
      continue;
    }
    dp[idx][coin] = time;
    for (auto e : Graph[idx]) {
      if (coin + e.cost >= 0) {
        pq.push(make_tuple(time + e.time, coin + e.cost, e.to));
      }
    }
  }
  for (int i = 1; i < n; i++) {
    ll ans = INF;
    for (auto j : dp[i])
      chmin(ans, j);
    cout << ans << '\n';
  }
}


Measured memory_bytes: 60072
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
int main(){
    string s;
    cin>>s;
    int t=s.size();
    bool g=true;
    rep(i,0,t/2){
        if(s[i]!=s[t-i-1]){
            g=false;
            break;
        }
    }
    if(g){//g=true;
        int t1=(t-1)/2;
        rep(i,0,t1/2){
            if(s[i]!=s[t1-i-1]){
                g=false;
                break;
            }
        }
        if(g){
            rep(i,(t+3)/2,t){
                if(s[i]!=s[t-i-1]){
                    g=false;
                    break;
                }
            }
            if(g)cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }else{
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 256
import sys
import math

_n = int(input())
heap = [int(i) for i in input().split()]
heap.insert(0, -sys.maxsize)

for ix, key in enumerate(heap):
    if ix == 0:
        continue

    p_ix = math.floor(ix / 2)
    p_key = heap[p_ix] if p_ix > 0 else sys.maxsize
    l_ix = ix * 2
    l_key = heap[ix * 2] if l_ix < len(heap) else sys.maxsize
    r_ix = ix * 2 + 1
    r_key = heap[ix * 2 + 1] if r_ix < len(heap) else sys.maxsize
    print(f'node {ix}: ', end='')
    print(f'key = {key}, ', end='')
    if p_ix != 0:
        print(f'parent key = {p_key}, ', end='')
    if l_ix < len(heap):
        print(f'left key = {l_key}, ', end='')
    if r_ix < len(heap):
        print(f'right key = {r_key}, ', end='')
    print()



Measured memory_bytes: 5792
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ll a,b;
  char op;
  cin >> a >> op >> b;

  cout << (op=='+' ? a+b : a-b) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}
const int N = 2e5 + 50;
ll mod = 998244353;
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937_64 mt(seed);
int fac[N],invf[N];
inline int add(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }
inline int sub(int x, int y) { return x - y >= 0 ? x - y : x - y + mod; }
inline int power(int x, int y, int res = 1) {
    for (; y; y >>= 1, x = 1ll * x * x % mod) {
        if (y & 1) { res = 1ll * res * x % mod; }
    } return res;
}
void initcombi(int n) {
    for (int i = fac[0] = 1; i <= n; i++) { fac[i] = 1ll * fac[i - 1] * i % mod; }
    invf[n] = power(fac[n], mod - 2);
    for (int i = n; i; i--) { invf[i - 1] = 1ll * invf[i] * i % mod; }
}
 
inline int NCR(int n, int m) {
    if (n < m) { return 0; }
    return 1ll * fac[n] * invf[m] % mod * invf[n - m] % mod;
}
int main() {
    io();
    initcombi(200005);
    
    int n, m;
    cin >> n >> m;
    int ans = NCR(n, 2) + NCR(m, 2);
    cout << ans;


}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

struct BellmanFordMax {
	BellmanFordMax() {}
	BellmanFordMax(int n) { init(n); }
	vector<vector<pair<int, int> > > E; 
    int N;
	void init(int n) { N = n; E.resize(0); E.clear(); E.resize(n); }
	void add(int a, int b, int c) { E[a].push_back({ b, c }); }
	vector<ll> solve(int s) {
		vector<ll> res(N, -L_INF); //最終的なコスト
		res[s] = 0;
 
        //最長経路を求める (辺に-1をかけると最短経路になる？)
		rep(i, N - 1) {
			rep(cu, N){
                if (-L_INF < res[cu]){
                    for(auto p:E[cu]) {
                        chmax(res[p.first], res[cu] + p.second);
                    }
                }
            }
		}

        //最長経路において正のサイクルの見つける
		vector<bool> pos(N);
		rep(i, N) {
			rep(cu, N) {
                if (-L_INF < res[cu]) {
                    for(auto p:E[cu]) {
                        if (chmax(res[p.first], res[cu] + p.second)) {
                            pos[p.first] = true;
                        }
                        if (pos[cu]) pos[p.first] = true;
                    }
                }
			}
		}
 
		rep(cu, N) if (pos[cu]) res[cu] = L_INF;
 
		return res;
	}
};

signed main()
{   
    gearup;
    int N, M; cin >> N >> M;
	BellmanFordMax bf(N);
	rep(i, M) {
		int a, b, c; cin >> a >> b >> c;
		a--; b--;
		bf.add(a, b, c);
	}
 
	ll ans = bf.solve(0)[N - 1];
 
	if (ans == L_INF){
        out("inf");
        return 0;
    }
 
	cout << ans << endl;
}


Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define plll pair<ll,pll>
#define ppll pair<pll, pll>
#define pii pair<int, int> 
#define pb push_back
#define mod 1000000007

ll power(ll a,ll b){
    ll res=1ll;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res%mod;
}
ll ncr(ll n,ll k){
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i))%mod;
        pro/=(i+1);
    }
    return (pro)%mod;
}

void swap(ll *a,ll *b) {
    ll temp=*a;
    *a=*b;
    *b=temp;
}
vector<ll> prime;
void seive(){
    vector<bool > isprime(1000001,true);
    for(int i=2;i*i<=1000000;i++){
        if(isprime[i]){
            for(int j=i*i;j<=1000000;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=1000000;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
vector<ll> parent;
ll find(ll p) {
    if(parent[p]==p) return parent[p];
    return parent[p]=find(parent[p]); 
}
void unun(ll a,ll b) {
    ll r1=find(a);
    ll r2=find(b);
    if(r1!=r2) parent[r2]=r1;
}
void solve() {
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans=0;
    ll x=min(a,k);
    k-=x;
    ll y=min(k,b);
    k-=y;
    ll z=min(k,c);
    // cout<<x<<" "<<y<<" "<<z;
    ans=x-z;
    cout<<ans;
}   


int main(void){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t=1;
    // cin>>t;
    while(t--) {
        solve();
        cout<<endl;
    }
    return 0; 

}


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

int main()
{
    int n;
    cin>>n;
    vector<int> h(n);
    for(int i=0; i<n; i++)
        cin>>h[i];
    vector<int> cost(n,INT_MAX);

    cost[0]=0;
    cost[1]=abs(h[0]-h[1]);

    for(int i=2; i<n; i++)
    {
        for(int j=1; j<=2; j++)
        {
            cost[i] = min( cost[i], abs(h[i]-h[i-j])+cost[i-j]);
        }
    }   
    cout<<cost[n-1];
    return 0;
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - (int)1e8;
const ll INFLL = numeric_limits<ll>::max() - (ll)1e17;

int main() {
    string S, T;
    cin >> S >> T;
    if (S == T.substr(0, S.length())) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

#define debug(x) cout <<"DEBUG"<<" "<<#x<<":"<<x<<'\n'

//↓0-indexか1-indexでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-index昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-index昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-index降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-index降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;

/*FUNCs=================================================*/
int mod = 998244353;

/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    bool can = true;
    int n; cin >> n;
    vll d(n+1, 0);
    ll maxi = -1;
    rep1(i,n) {
        ll p;
        cin >> p;
        chmax(maxi, p);
        if(i==1&&p!=0) can = false;
        if(i!=1&&p==0) can = false;
        ++d[p];
    }
    //rep1(i,maxi) debug(i);
    ll answer = 1;
    for(int i = 0; i < maxi; i++) {
        //debug(d[i]);
        //debug(d[i+1]);
        if(d[i] == 0 || d[i+1] == 0) {can = false; break;}
        //debug(i);
        ll q = 1;
        rep(j, d[i+1]) {
            q = (q*d[i]) % mod;
        }
        q = q%mod;
        answer = (answer*q) % mod;
        //debug(answer);
    }
    answer = answer%mod;
    //if(!can) cout << '!' << '\n';
    cout << (can?answer:0) << '\n';
}

Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;

namespace AtTest.ABC_105
{
    class D
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int m = int.Parse(input[1]);
            input = Console.ReadLine().Split(' ');
            var array = new int[n];
            var sums = new int[n];
            for (int i = 0; i < n; i++)
            {
                array[i] = int.Parse(input[i]);
                if (i == 0)
                {
                    sums[i] = array[i] % m;
                }
                else
                {
                    sums[i] = (sums[i - 1] + array[i]) % m;
                }
            }

            var marginDict = new Dictionary<int, int>();
            marginDict.Add(0, 1);
            long cnt = 0;
            for(int i = 0; i < n; i++)
            {
                if (marginDict.ContainsKey(sums[i]))
                {
                    cnt += marginDict[sums[i]];
                    marginDict[sums[i]]++;
                }
                else
                {
                    marginDict.Add(sums[i], 1);
                }
            }

            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 21088
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        long a = sc.nextLong();
        long b = sc.nextLong();
        long k = sc.nextLong();
        
        if(a >= k) {
            System.out.println((a - k) + " " + b);
        } else {
            System.out.println(0 + " " + Math.max(0, (b - (k - a))));
        }
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long A;
    string B;
    cin >> A >> B;
    string s = to_string(A * ((B[0] - '0') * 100 + (B[2] - '0') * 10 + B[3] - '0'));
    if (s.size() < 3)
    {
        cout << "0" << endl;
    }
    else
    {
        cout << s.substr(0, s.size() - 2) << endl;
    }
}

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

int n, a[200];
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) {
		char c;
		cin >> c;
		a[c]++;
	}
	if (a['R'] > a['B'])cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    int n; cin >> n;
    int k = (n+999)/1000;
    cout << k*1000 - n << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
  	cin >> s;
  	set< char > st;
  	st.insert(s[0]);
  	st.insert(s[1]);
  	st.insert(s[2]);
  	if(st.size() == 3)
      cout << "Yes" << endl;
  	else
      cout << "No" << endl;
  	return 0;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define ALL(x) (x).begin(),(x).end()
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

signed main(){
    int n,a,b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int l=0,m=0,r=1;
    REP(i,n){
        bool rull = false;
        if(s[i]=='a'&&l+m<a+b){
            rull = true;
            l++;
        }
        if(s[i]=='b'&&l+m<a+b&&r<=b){
            rull = true;
            m++;r++;
        }
        puts(rull?"Yes":"No");
    }
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
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; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    int X, Y, Z;IN(X,Y,Z);
    cout << (X - Z) / (Y + Z) << endl;

    return 0;
}

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  long int n;
  long int min = 1e15+1;
  cin >> n;
  long int cost[5];
  for(int i=0;i<5;i++){
    cin >> cost[i];
    if(cost[i] < min){
      min = cost[i];
    }
  }
  long int ans = 0;
  if(n%min != 0){
    ans = n/min+1;
  }
  else{
    ans = n/min;
  }
  cout << ans + 4 << endl;
  return 0;
}


Measured memory_bytes: 256
S = input()
T = input()

ans = ""
if len(T) > len(S):
    print("UNRESTORABLE")
else:
    ls = len(S)
    lt = len(T)
    for i in reversed(range(ls-lt+1)):
        tmp = S[i:i+lt]
        flag = True
        for j in range(lt):
            if tmp[j] != "?":
                if tmp[j] != T[j]:
                    flag = False
                    break
        if flag:
            ans = ""
            for h in range(i):
                if S[h] == "?":
                    ans += "a"
                else:
                    ans += S[h]
            ans += T
            for h in range(i+lt,ls):
                if S[h] == "?":
                    ans += "a"
                else:
                    ans += S[h]
            print(ans)
            exit()
    print("UNRESTORABLE")

Measured memory_bytes: 3064
#include <math.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <thread>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
#define endl '\n'
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define MOD 1000000007
#define pi acos(-1.0)
#define MAX 1000010
//////////////////////////////////////////////////////////////////////////
/* Custom function starts here */

/* Custom function ends here: */
//////////////////////////////////////////////////////////////////////////////

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  /* MAIN Code STARTS here: */
  string a, b;
  cin >> a >> b;
  int alen = a.size();
  int blen = b.size();

  if (alen == blen && a != b) {
    if ((a[0] - '0') > (b[0] - '0')) {
      cout << "GREATER" << endl;
    }
    else{
        cout << "LESS" << endl;
    }
  }

  else if (alen > blen) {
    cout << "GREATER" << endl;
  } else if (alen < blen) {
    cout << "LESS" << endl;
  } else if (a == b) {
    cout << "EQUAL" << endl;
  }

  /* MAIN Code ENDS here: */
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 2e5 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

string str;
int n;
ll mem[N][3];

ll add(ll a, ll b) {
  a += b;
  a %= MOD;
  return a;
}

ll mul(ll a, ll b) {
  a = (a * b) % MOD;
  return a;
}

ll solve(int idx, int smaller) {
  if(idx == n)
    return smaller != 0;
  ll& ret = mem[idx][smaller];
  if(~ret)
    return ret;
  ret = 0;
  if(smaller == 2) {
    if(str[idx] == '1') {
//      ret += solve(idx + 1, 1);
      ret = add(ret, solve(idx + 1, 1));
//      ret += solve(idx + 1, 2) * 2;
      ret = add(ret, mul(solve(idx + 1, 2), 2));
    } else {
//      ret += solve(idx + 1, 2);
      ret = add(ret, solve(idx + 1, 2));
    }
  } else if(smaller == 1) {
//    ret += solve(idx + 1, 1);
    ret = add(ret, solve(idx + 1, 1));
//    ret += solve(idx + 1, 1) * 2;
    ret = add(ret, mul(solve(idx + 1, 1), 2));
  } else {
    // NOOO
  }
//  ret += solve(idx + 1, smaller == 2 ? (str[idx] == '1') ? 1 : smaller : smaller);
//  ret += solve(idx + 1, smaller) * 2;
  return ret;
}

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  cin >> str;
  n = str.size();
  memset(mem, -1, sizeof mem);
  cout << solve(0, 2);
  return 0;
}


Measured memory_bytes: 8272
#include <stdio.h>
int n,k;
int aa[100010][40]={0},a[100010],b[100010],tt[100010],kk[40]={0};
int pan(int i)
{
    int gaoa=35,gaok=35;
    while (gaoa && aa[i][gaoa]==0 )gaoa--;
    while (gaok && kk[gaok]==0) gaok--;
    if (gaoa>gaok) return 0;
    if (gaoa==0) return 1;
    //if (gaoa<gaok) return 1;

    for (int j=gaoa;j>=0;j--)
    {
        if (aa[i][j]>kk[j]) return 0;
        //if (aa[i][j]<kk[j]) return 1;
    }
    return 1;


}

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

    for (int i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]),tt[i]=0;

    if (k==0)
    {
        long long ans=0;
        for (int i=1;i<=n;i++) if (a[i]==0) ans+=b[i];
        printf("%lld\n",ans);
        return 0;
    }

    int top=0;
    while (k)
    {
        kk[top]=k%2;k/=2;top++;
    }

    for (int i=1;i<=n;i++)
    {
        while (a[i])
        {
            aa[i][tt[i]]=a[i]%2;a[i]/=2;tt[i]++;
        }
    }

    long long ans=0;

    int keyi=0;
    for (keyi=0;keyi<top;keyi++)
    {
        if (keyi!=0)
            if (kk[keyi]==0) continue;
        if (keyi!=0){
            for (int i=0;i<keyi;i++)
                kk[i]=1;
            kk[keyi]=0;
        }
        long long temp=0;
        for (int i=1;i<=n;i++)
            if (pan(i)) temp+=b[i];
        if (temp>ans) ans=temp;

    }
    printf("%lld\n",ans);
}


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

using namespace std;
using ll = long long int;
using lc = complex<double>;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    ll n;
    cin >> n;
    ll a = 0, b = 0, c = 1000;
    for(ll i=0; i<n; i++) {
        ll x;
        cin >> x;
        c = max(c, a*x + b);
        a = c / x;
        b = c % x;
    }
    cout << c << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

const int N = 200009;

ll freq[2020], arr[N];

int main() {
	fastIO;
#ifdef LOCAL
//	freopen("input.in", "rt", stdin);
#endif
	string str;
	cin >> str;
	freq[0] = 1;
	int n = str.size();
	int tmp = 1;
	for (int i = n - 1; i >= 0; --i) {
		arr[i] = (arr[i + 1] % 2019 + ((str[i] - '0') * tmp) % 2019) % 2019;
		freq[arr[i]]++;
		tmp *= 10;
		tmp %= 2019;
	}
	ll ans = 0;
	for (int i = 0; i < 2019; ++i)
		ans += freq[i] * (freq[i] - 1) / 2;
	cout << ans;
	return 0;
}


Measured memory_bytes: 5264
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i,n)cin >> a[i];
  if(a[0]!=0){
    cout << -1 << endl;
    return 0;
  }
  rep(i,n-1)if(a[i]+1<a[i+1]){
    cout << -1 << endl;
    return 0;
  }
  ll ans=0;
  for(int i=1;i<n;i++){
    ans+=a[i]/(a[i-1]+1)+a[i]%(a[i-1]+1);
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }

    val res = IntArray(m) { 0 }

    repeat(n) {
        val a = readLine()!!.split(' ').map { it.toInt() }
        (1..a[0]).forEach {
            res[a[it] - 1]++
        }
    }

    println(res.filter { it == n }.count())
}

Measured memory_bytes: 38184
n = int(input())
aaa = list(map(int, input().split()))
MOD = 10 ** 9 + 7
dp = [0] * (n + 1)
dp[0] = 3
ans = 1
for a in aaa:
    ans = ans * dp[a] % MOD
    dp[a] -= 1
    dp[a + 1] += 1
print(ans)


Measured memory_bytes: 14396
class WarshallFloyd
  def initialize(e)
    @e = e
    @n = e.size
  end
  def solve
    (0...@n).each{|k|
      (0...@n).each{|i|
        (0...@n).each{|j|
          next if i == j || i == k || j == k
          next if @e[i][k].nil? || @e[k][j].nil?
          wk = @e[i][k] + @e[k][j]
          @e[i][j] = wk if @e[i][j].nil? || @e[i][j] > wk
        }
      }
    }
  end
end


N, M, RC = gets.chomp.split(" ").map(&:to_i)
V = Array.new(N).map{Array.new(N)}
R = gets.chomp.split(" ").map{|x| x.to_i - 1}
M.times{
  a, b, c = gets.chomp.split(" ").map(&:to_i)
  a -= 1
  b -= 1
  V[a][b] = c
  V[b][a] = c
}

wf = WarshallFloyd.new(V)
wf.solve

puts R.permutation.map{|r|
  (0..(R.size-2)).to_a.inject(0){|t, i|
    t + V[r[i]][r[i+1]]
  }
}.min


Measured memory_bytes: 15160
c=1
while 1:
    W=int(input())
    if W==0:break
    n=int(input())
    dp=[0]*(W+1)
    for i in range(n):
        v,w = map(int, input().split(','))
        for j in range(W,w-1,-1):
            dp[j]=max(dp[j-w]+v,dp[j])
    for i in range(W+1):
        if dp[W]==dp[i]:break
    print('Case %d:\n%d\n%d'%(c,dp[W],i))
    c+=1

Measured memory_bytes: 7612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <tuple>

using namespace std;

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(g.size(), INF);

  using Pi = pair< T, int >;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()) {
    T cost;
    int idx;
    tie(cost, idx) = que.top();
    que.pop();
    if(dist[idx] < cost) continue;
    for(auto &e : g[idx]) {
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}

int main(void) {
    int N;
    cin >> N;
    WeightedGraph<int64_t> g(N);
    while(--N) {
        int a, b, c;
        cin >> a >> b >> c;
        --a;
        --b;
        g[a].emplace_back(b, c);
        g[b].emplace_back(a, c);
    }

    int Q, K;
    cin >> Q >> K;
    --K;
    auto dist = dijkstra(g, K);

    while(Q--) {
        int x, y;
        cin >> x >> y;
        --x;
        --y;
        cout << dist[x] + dist[y] << endl;
    }
    return 0;
}


Measured memory_bytes: 11120
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ost;

const ll maxN = 1e7;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

void build(ll node, ll start, ll end){
	if(start == end)
		segtree[node] = A[start];
	else{
		ll mid = (start + end)/2;
		build(left(node), start, mid);
		build(right(node), mid+1, end);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

void update(ll node, ll start, ll end, ll l, ll r, ll val){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(start > end or l > start or r < end)
		return ;
	else if(start >= l and r >= end){
		segtree[node] += val;
		if(start != end){
			lazy[left(node)] += val;
			lazy[right(node)] += val;
		}
	}
	else{
		ll mid=(start + end)/2;
		update(left(node), start, mid, l, r, val);
		update(right(node), mid+1, end, l, r, val);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

ll sums(ll node, ll start, ll end, ll l, ll r){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(l > end or r < start or start > end)
		return 0;
	if(l <= start and r >= end)
		return segtree[node];
	ll mid = (start+end)/2;
	return sums(left(node), start, mid, l , r) + sums(left(node), mid + 1, end, l , r);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll n, m, k;
	cin >> n >> m >> k;
	ll a[k];
	for(ll i=0; i<k; i++)
		cin >> a[i];
	ll adjmat[n+1][n+1];
	for(ll i=0; i<=n; ++i)
		for(ll j=0; j<=n; ++j)
			adjmat[i][j] = INF;
	ll x, y, w;
	for(ll i=0; i<m; i++){
		cin >> x >> y >> w;
		adjmat[x][y] = min(adjmat[x][y], w);
		adjmat[y][x] = adjmat[x][y];
	}
	for(ll k=1; k<=n; k++){
		for(ll j=1; j<=n; j++){
			for(ll i=1; i<=n; i++){
				adjmat[i][j] = min(adjmat[i][j], adjmat[i][k] + adjmat[k][j]);
			}
		}
	}
	ll ans = INF;
	string st = "";
	for(ll i=0; i<k; i++)
		st += char(i+48);
	do{
		ll cur = 0;
		for(ll i=0; i<k-1; i++)
			cur += adjmat[a[st[i]-'0']][a[st[i+1]-'0']];
		ans = min(ans, cur);
	}while(next_permutation(begin(st), end(st)));
	cout << ans;
	return 0;
}

Measured memory_bytes: 3868
Module Program
  Sub Main
    Dim s=GetInts()
    Dim a=s(0),b=s(1)
    Dim ans=If(a Mod 3=0 Or b Mod 3=0 Or (a+b) Mod 3=0, "Possible", "Impossible")
    Console.WriteLine(ans)
  End Sub
  
  '/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  Function Gets() As String()
    Gets = Console.ReadLine().Split(" "c)
  End Function
  Function GetInts() As Integer()
    Dim s = Gets(), r(UBound(s)) As Integer
    For i As Integer=0 To UBound(s): r(i)=s(i): Next i
    GetInts = r
  End Function
End Module

Measured memory_bytes: 22352
<?php
fscanf(STDIN, "%d %d", $X, $N);
$p = array_map('intval', explode(' ', trim(fgets(STDIN))));
$m = [];
foreach ($p as $v) {
    $m[$v] = 1;
}

$dist = 0;
$target = 0;
$direct = "pos";
while(true) {
    if ($direct === "pos") {
        $direct = "neg";
        $target = $X - $dist;
    } else {
        $direct = "pos";
        $target = $X + $dist;
        $dist++;
    }
    // echo "target:" . $target . PHP_EOL;
    if (!isset($m[$target])) break;
}
printf("%d", $target);


Measured memory_bytes: 16032
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);++i)
#define REP(i,n) for (int i=0;i<=(n);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int INF = 10000000;

int main(){
    string s, t;
    cin >> s >> t;
    t = t.erase(t.size()-1);
    if(s == t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3520
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<map>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const int mod=1000000007;
const llint big=1e18+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-9;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}
vector<vector<int>>go;
vector<int>rev;
vector<int>gru;
int solve(int ter){
	if(gru[ter]!=-1){return gru[ter];}
	set<int>kaz;
	for(int i=0;i<go[ter].size();i++){
		kaz.ins(solve(go[ter][i]));
	}
	int ret=0;
	while(kaz.find(ret)!=kaz.end()){ret++;}
	return gru[ter]=ret;
}
int start=0;
int main(void){
	llint n,i,j,ans=0;cin>>n;
	go.res(n);
	rev.res(n);
	gru.res(n,-1);
	for(i=0;i<n;i++){cin>>rev[i];rev[i]--;go[rev[i]].pub(i);}
	for(i=0;i<n;i++){start=rev[start];}//n回戻れば閉路の中
	if(start==rev[rev[start]]){cout<<"POSSIBLE"<<endl;return 0;}
	gru[rev[start]]=9999;//とりあえず
	solve(start);
	int zan=gru[rev[rev[start]]];
	
	gru[rev[rev[start]]]=-1;
	gru[rev[start]]=-1;
	int ke=solve(rev[rev[start]]);
	if(zan==ke){cout<<"POSSIBLE"<<endl;return 0;}
	for(i=0;i<n;i++){gru[i]=-1;}
	gru[rev[start]]=zan;//影響があった時
	solve(start);
	int zant=gru[rev[rev[start]]];
	gru[rev[rev[start]]]=-1;
	gru[rev[start]]=-1;
	int ket=solve(rev[rev[start]]);
	if(zant==ket){cout<<"POSSIBLE"<<endl;return 0;}
	cout<<"IMPOSSIBLE"<<endl;
	return 0;
}

Measured memory_bytes: 33024
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

S = input()
sum = 0
sum_a = 0
expect = 'B'
for i in range(len(S)):
    #print(i, S[i], expect, sum)
    if S[i] == 'A':
        if expect == 'C':
            sum_a = 0
        sum_a += 1
        expect = 'B'
    elif S[i] == expect and expect == 'C':
        sum += sum_a
        expect = 'B'
    elif S[i] == expect and expect == 'B':
        expect = 'C'
    else:
        sum_a = 0
        expect = 'B'

print(sum)



Measured memory_bytes: 40432
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
 using namespace std;
 typedef long long ll;
 const int maxn=1e5+10;
 int main()
 {
 	ll n,sum=0;
 	cin>>n;
 	for(int i=1;i<=n;i++){
 		if(i%3&&i%5) sum+=i;
	 }
	 cout<<sum;
 	return 0;
 }

Measured memory_bytes: 3160
from bisect import bisect_right,bisect_left
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))
ans=0
for i in range(n):
  na=bisect_left(a,b[i])
  nc=bisect_right(c,b[i])
  ans+=na*(n-nc)
print(ans)

Measured memory_bytes: 23232
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll power(ll x,ll y,ll p) 
{ 
    ll res = 1;      
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;

	string s;
	cin >> s;
	if(s[2]==s[3] && s[4]==s[5])
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 256
def prime_decomposition(n):
  i = 2
  d = {}
  while i * i <= n:
    while n % i == 0:
      n /= i
      if i not in d:
          d[i] = 0
      d[i] += 1
    i += 1
  if n > 1:
    if n not in d:
        d[n] = 1
  return d

N,P = map(int, input().split())
d = prime_decomposition(P)

ans = 1
for key in d:
    ans *= key**(d[key]//N)

print(int(ans))

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MAX3(a, b, c) ((a) > (MAX(b, c)) ? (a) : (MAX(b, c)))
#define MIN3(a, b, c) ((a) < (MIN(b, c)) ? (a) : (MIN(b, c)))

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

int main()
{
    char map[26];
    bool used[26];
    for (int i = 0; i < 26; i++) {
        map[i] = 0;
        used[i] = false;
    }
    string s, t;
    cin >> s >> t;
    int len = s.size();
    for (int i = 0; i < len; i++) {
        if (used[t[i] - 'a']) {
            if (map[s[i] - 'a'] != t[i]) {
                cout << "No" << endl;
                return 0;
            }
        } else {
            used[t[i] - 'a'] = true;
            if (map[s[i] - 'a']) {
                cout << "No" << endl;
                return 0;
            }
            map[s[i] - 'a'] = t[i];
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    int a, b;
    int sum = 0;
    cin >> a >> b;
    if (a > b) {
        sum += a;
        a--;
    } else {
        sum += b;
        b--;
    }
    if (a > b) {
        sum += a;
        a--;
    } else {
        sum += b;
        b--;
    }
    cout << sum;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

vector<int> read_vec(int n){
    vector<int> ret(n);
    for (int i = 0; i < n; i++){
        cin >> ret[i];
    }
    return ret;
}

int main() {
    int n;
    cin >> n;
    vector<int>as(n);
    for (int i = 0; i < n; i++){
        cin >> as[i];
    }
    sort(as.begin(), as.end());
    cout << as[n / 2] - as[n / 2 - 1] << endl;
}

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

int main(){
  int N, M, a, b, f, f2;
  string A[100], B[100];
  cin>>N>>M;

  for(int i = 0; i < N; i++){
    cin>>A[i];
  }a = A[0].size();
  for(int i = 0; i < M; i++){
    cin>>B[i];
  }b = B[0].size();

  f2=0;
  for(int i = 0; i <= N-M; i++){
    for(int j = 0; j <= N-M; j++){
      f=0;
      for(int k = 0; k < M; k++){
	for(int l = 0; l < M; l++){// cout<<A[k][l];
	  if(A[i+k][j+l] != B[k][l]){f=1;break;}
	}//cout<<endl;
	 if(f)break;
      }
      //cout<<i<<" "<<j<<" "<<f<<endl;
      if(f==0)break;
    }
    if(f==0)break;
  }
  if(f)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
### SNIPPET
  # n = gets.split.map(&:to_i)
  # array = n.times.map { gets.split.map(&:to_i) }
  # [].all?(&:even?)
  # a = [*1..m].repeated_combination(n).to_a
  # [1,2,3,4,5].select { |num| num.even? }  # => [2, 4]
  # ["a","a","b"].group_by(&:itself).map{|k,v| [k, v.count]}.to_h #=> {"a"=>2, "b"=>1}
  # 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
  # 3.upto(6) do |i|, 6.downto(3) do |i|
  # 公約数125.gcd(100)、公倍数125.lcm(100)
  # PI = Math::PI
  # 高さ = a * Math.sin(w / 180.0 * Math::PI), 底辺 = a * Math.cos(w / 180.0 * Math::PI)
  # def chmax(a, b) a > b ? a : b end
  # INF = Float::INFINITY
  # def chmin(a, b) a < b ? a : b end

s = gets.chomp

puts s.slice(0,3)

Measured memory_bytes: 14444
from collections import deque
import sys
input = sys.stdin.buffer.readline

N = int(input())
INF = 10**18
edges = [[] for _ in range(N)]

for _ in range(N - 1):
    fr, to, w = map(int, input().split())
    fr -= 1
    to -= 1
    edges[fr].append((to, w))
    edges[to].append((fr, w))

dist = [INF] * N
que = deque([(0, 0)])

while que:
    now, d = que.pop()

    if dist[now] <= d:
        continue
    dist[now] = d
    for to, w in edges[now]:
        que.append((to, d + w))

ans = [dist[i] % 2 for i in range(N)]
print(*ans, sep='\n')

Measured memory_bytes: 45544
# from scipy.misc import comb

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def solve(n,m):
    maxdiv = int(m**0.5)
    l = []
    tmp = 2
    num = 0
    while tmp <= maxdiv:
        if m % tmp == 0:
            m /= tmp
            num += 1
        else:
            tmp += 1
            if num != 0:
                l.append(num)
                num = 0
    if m != 1:
        l.append(1)
    res = 1
    for div in l:
        tmp = cmb(n+div-1,div)%(10**9+7)
        res = res * tmp % (10**9+7)
    return int(res)
        

if __name__ == '__main__':
    n,m = map(int,input().split())
    print(solve(n,m))

Measured memory_bytes: 63824
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N, A, B, C;
	in >> N >> A >> B >> C;
	std::vector<LL>l(N);
	rep(i, N) in >> l[i];

	std::vector<std::pair<LL, std::pair<LL, LL>>>res;
	LL bit = 1, ans = 1145148101919364;
	rep(i, N) bit *= 4;
	rep(i, bit)
	{
		std::vector<LL>go(N);
		LL tmp = i;
		rep(j, N)
		{
			go[j] = i % 4;
			i /= 4;
		}
		i = tmp;

		LL a_cnt = 0, a_sum = 0, b_cnt = 0, b_sum = 0, c_cnt = 0, c_sum = 0;
		rep(j, N)
		{
			if (go[j] == 0)
			{
				++a_cnt;
				a_sum += l[j];
			}
			if (go[j] == 1)
			{
				++b_cnt;
				b_sum += l[j];
			}
			if (go[j] == 2)
			{
				++c_cnt;
				c_sum += l[j];
			}
		}
		if (a_cnt == 0 || b_cnt == 0 || c_cnt == 0) continue;
		LL cost = 10 * (a_cnt + b_cnt + c_cnt - 3);
		cost += std::abs(a_sum - A);
		cost += std::abs(b_sum - B);
		cost += std::abs(c_sum - C);
		ans = std::min(ans, cost);
	}

	out << ans << std::endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Solver {
    void solve(Scanner sc) {
        String S = sc.next();
        System.out.println(S.matches("A?KIHA?BA?RA?") ? "YES": "NO");
    }
}

class Main {
    public static void main(String... args) {
        Scanner in = new Scanner(System.in);

        new Solver().solve(in);

        in.close();
    }
}

Measured memory_bytes: 21844