akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }


    Scanner cin;

    int[] A, B, C;
    int N;

    void calc()
    {
        cin = new Scanner();
        N = cin.nextInt();
        A = cin.ArrayInt(N);
        B = cin.ArrayInt(N);
        C = cin.ArrayInt(N);
        dicB = new long[N];
        dicB2 = new int[N];
        dicC = new long[N];
        Array.Sort(A);
        Array.Sort(B);
        Array.Sort(C);
        Array.Reverse(A);
        Array.Reverse(B);
        Array.Reverse(C);
        for (int i = 0; i < N; i++)
        {
            dicB[i] = dicC[i] = -1;
        }
        long ans = 0;
        for (int i = 0; i < N; i++)
        {
            ans += dfsB(i);
        }
        Console.WriteLine(ans);
    }

    long[] dicB;
    int[] dicB2;
    long[] dicC;

    long dfsB(int aid)
    {
        if (dicB[aid] != -1) return dicB[aid];
        long ans = 0;
        int cnt = 0;
        if (aid != 0)
        {
            ans = dfsB(aid - 1);
            cnt = dicB2[aid - 1];
        }

        while (cnt < N)
        {
            if (B[cnt] <= A[aid]) break;
            ans += dfsC(cnt);
            cnt++;
        }
        
        dicB2[aid] = cnt;
        return dicB[aid] = ans;
    }

    long dfsC(int bid)
    {
        if (dicC[bid] != -1) return dicC[bid];
        int cnt = 0;
        if (bid != 0)
        {
            cnt = (int)dfsC(bid - 1);
        }
        while (cnt < N)
        {
            if (C[cnt] <= B[bid]) break;
            cnt++;
        }
        return dicC[bid] = cnt;
    }



}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 39220
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
using namespace std;
using ll=long long;
int main(){
  ll x;
  cin >> x;
  ll a=100;
  int cnt=0;
  while(x>a){
    a = a*1.01;
    cnt+=1;
    //cout << a << endl;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3640
#include<stdio.h>
int main()
{
	int a,b;
	for(int i=0;;i++)
  {
	  scanf("%d %d",&a,&b);
	  if(a==0&&b==0) break;
	  int sum=0;
	 for(int x=1;x<=a;x++)
	 {
		for(int y=x+1;y<=a;y++)
		{
			for(int z=y+1;z<=a;z++)
			{
				if(x+y+z==b) 
				{
				  sum++;
				}
			}
		}
	 }
     printf("%d\n", sum);
  }
	return 0;
}

Measured memory_bytes: 1028
N = int(input())
p = list(map(int, input().split()))

count = 0
now = 0
for i in range(len(p)):
    if len(p) == 0:
        break
    if now+1 == p[0]:
        p.pop(0)
        count += 1
        now += 1
    if len(p) == 0:
        break
    p.pop(0)
    now += 1
print(count)


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

int main(){

int a,b;

	scanf("%d %d",&a,&b);
if((1<=a<=13)&&(1<=a<=13)){

	if((a!=b)&&(a==1))
	printf("Alice");
	else if((a!=b)&&(b==1))
	printf("Bob");
	else if(a==b)
	printf("Draw");
	else if(a>b)
	printf("Alice");
	else if (b>a)
	printf("Bob");
}
	
	return 0;
} 


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

int main() {
	int k;
	cin>>k;
	int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

	cout<<a[k-1]<<endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _for(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define FOR(...)   _for (__VA_ARGS__)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;
static constexpr ll inf = 2e18;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  size_t A, B, M;
  cin >> A >> B >> M;
  vector <ll> a (A), b (B);
  ll min_a = inf, min_b = inf;
  vector <tuple <size_t, size_t, ll>> m (M);
  rep (i, A)
  {
    cin >> a [i];
    min_a = min (min_a, a [i]);
  }
  rep (i, B)
  {
    cin >> b [i];
    min_b = min (min_b, b [i]);
  }
  auto ans = min_a + min_b;
  rep (i, M)
  {
    size_t x, y;
    ll c;
    cin >> x >> y >> c;
    -- x;
    -- y;
    auto t = a [x] + b [y] - c;
    ans = min (ans, t);
  }
  cout << ans << endl;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
vector<ll> divisor(ll n){
  vector<ll> res;
  for(ll i=1; i*i<=n ; i++){
    while(n%i==0){
      ++res[i];
      n /= i;
    }
  }
  if(n!=1) res[n]=1;
  return res;
}
int isOk(string s, int N){
    int ok = 1;
    char c = s[0];
    rep(i,0,N) if(s[i]!=c) ok=0;
    return ok;
}
int main(){
  int N;  cin>>N;
  vector<int> v(N), visitd(N, 0);
  rep(i,0,N){
    cin>>v[i];
    v[i]--;
  }
  int now = 0;
  int cnt = 0;
  while(now != 1){
    cnt++;
    if(visitd[now]){
      cout<<-1<<endl;
      return 0;
    }
    visitd[now] = 1;
    now = v[now];
  }
  cout<<cnt<<endl;
  return 0;
}   

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

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;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll N;
  IN(N);
  string S;
  IN(S);
  string T = "";
  REP(i,N/2) T += S[i];
  ll N2 = T.size();
  REP(i,N2) T += T[i];

  if(T==S){
    OUT("Yes");
  }else{
    OUT("No");
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef map<int,ll> mil;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MAX_P=1e+6;
const ll MOD=1e+9+7;
ll fact[MAX_P];

void make_fact(){
  fact[0]=fact[1]=1;
  for(ll i=2;i<MAX_P;i++){
    fact[i]=(fact[i-1]*i)%MOD;
  }
}
ll Extgcd(ll a,ll b,ll &x,ll &y){
  ll d=a;
  if(b!=0){
    Extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }
  else{
    x=1;y=0;
  }
  return d;
}

ll mod_inv(ll a,ll p){//mod pでのaの逆元を求める
  ll x,y;
  Extgcd(a,p,x,y);
  return (x%p+p)%p;
}
//n!=a*p^e (a,p互いに素,p素数) とした時のeとa mod p を求める
ll mod_fact(ll n,ll p,ll& e){
  e=0;
  if(n==0) return 1;
  
  ll res=mod_fact(n/p,p,e);
  e+=n/p;

  if(n/p%2!=0) return res*(p-fact[n%p])%p;
  return res*fact[n%p]%p;
}

//nCk mod pを求める
ll mod_comb(ll n,ll k,ll p){
  if(n<0||k<0||n-k<0) return 0;
  ll e1,e2,e3;
  ll a1=mod_fact(n,p,e1),a2=mod_fact(k,p,e2),a3=mod_fact(n-k,p,e3);
  if(e1>e2+e3) return 0;
  return a1*mod_inv(a2*a3%p,p)%p;
}
mil prime_factor(int a){
  mil res;
  for(int i=2;i*i<=a;i++){
    while(a%i==0){
      res[i]++;
      a/=i;
    }
  }
  if(a!=1) res[a]=1;
  return res;
}

int main(){
  ll n;
  int m;
  cin>>n>>m;
  make_fact();
  mil pf=prime_factor(m);
  vector<ll> v;
  for(auto ite=pf.begin();ite!=pf.end();ite++){
    v.push_back(ite->second);
  }
  ll res=1;
  rep(i,v.size()){
    res=(res*mod_comb(n-1+v[i],v[i],MOD))%MOD;
  }
  prin(res);
      
  
  
  

  return 0;
}


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

int main(){
    int num;
    cin >> num;
    num = num % 10;

    if(num==2 || num==4 || num==5 || num==7 || num==9){
        cout << "hon";
    }
    else if(num==0 || num==1 || num==6 || num==8){
        cout << "pon";
    }
    else if(num==3){
        cout << "bon";
    }
}


Measured memory_bytes: 3100
stdin = input().split()
a = int(stdin[0]) # 高橋君のクッキー
b = int(stdin[1]) # 青木君のクッキー
k = int(stdin[2]) # 繰り返し回数

if a > k:
  a -= k
else:
  k -= a
  a = 0
  
  if k > b:
    b = 0
  else:
    b -= k
  
print('{} {}'.format(a, b))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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 namespace std;

int main(){
    Init();
    string s; cin >> s;
    for(ll i=0; i<s.size(); i+=2) cout << s[i];
    cout << endl;
}

Measured memory_bytes: 592
/*
    @Author: TieWay59
    @Date: 2019/11/22 13:38
    @Link: https://atcoder.jp/contests/agc040/tasks/agc040_b
    @Tags:
*/

#include <bits/stdc++.h>

#define  debug(x)  cerr <<#x << " = "<<x<<endl

#define endl '\n'
#define STOPSYNC ios::sync_with_stdio(false);cin.tie(nullptr)
#define MULTIKASE int Kase=0;cin>>Kase;for(int kase=1;kase<=Kase;kase++)
typedef long long ll;
const int MAXN = 2e5 + 59;
const int MOD = 1e9 + 7;
const int INF = 0x3F3F3F3F;
const ll llINF = 0x3F3F3F3F3F3F3F3F;
using namespace std;

int n, m;
struct node {
    ll l, r;
} a[MAXN];
ll maxL;
ll minR;
ll ans;
ll ansInLeft[MAXN];
ll ansInRight[MAXN];
pair<int, int> pairInLeft[MAXN];
pair<int, int> pairInRight[MAXN];

void solve(int kaseId = -1) {

    cin >> n;

    for (int i = 1; i <= n; ++i) {
        cin >> a[i].l >> a[i].r;
        ans = max(ans, a[i].r - a[i].l + 1);
    }

    sort(a + 1, a + 1 + n, [](node x, node y) {
        if (x.l == y.l)return x.r < y.r;
        return x.l < y.l;
//        return (x.r - x.l) < (y.r - y.l);
    });

    maxL = 0;
    minR = llINF;
    for (int i = 1; i <= n; ++i) {
        maxL = max(maxL, a[i].l);
        minR = min(minR, a[i].r);
        if (maxL <= minR) {
            ansInLeft[i] = minR - maxL + 1;
            pairInLeft[i] = {maxL, minR};
        } else {
            break;
        }
    }

    maxL = 0;
    minR = llINF;
    for (int i = n; i >= 1; --i) {
        maxL = max(maxL, a[i].l);
        minR = min(minR, a[i].r);
        if (maxL <= minR) {
            ansInRight[i] = minR - maxL + 1;
            pairInRight[i] = {maxL, minR};
        } else {
            break;
        }
    }

    for (int i = 1; i < n; ++i) {
        ans = max(ans, ansInLeft[i] + ansInRight[i + 1]);
    }

    for (int i = 2; i < n; ++i) {
        ll len = a[i].r - a[i].l + 1;
        if (pairInRight[i + 1].first > 0 &&
            pairInLeft[i - 1].first > 0 &&
            pairInRight[i + 1].first <= pairInLeft[i - 1].second) {
            ans = max(ans, len +
                           min(pairInLeft[i - 1].second, pairInRight[i + 1].second)
                           - pairInRight[i + 1].first + 1);
        }
    }

    cout << ans << endl;
}

/*void solves() {
    MULTIKASE {
        solve(kase);
    }
}*/

int main() {
    STOPSYNC;
//    solves();
    solve();
    return 0;
}
/*

 */

Measured memory_bytes: 7680
N,M=gets.split.map(&:to_i)

as = N.times.map { gets.chomp }
bs = M.times.map { gets.chomp }

0.upto(N-M) do |i|
    0.upto(N-M) do |j|
        if bs.zip(as[i...i+M]).all? {|b,a| a[j...j+M]==b}
            puts 'Yes'
            exit
        end
    end
end

puts 'No'

Measured memory_bytes: 1788
#include<stdio.h>
int main(void){
int a,b,c;
int sum;
int i;
scanf("%d %d %d",&a,&b,&c);
sum = (100*a) + (10*b)+ c;
i=sum%4;
if(i==0){
printf("YES");
}
else{
printf("NO");
}return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int a[6],k;
string check()
{
    for(int i=1;i<=5;i++)
        for(int j=1;j<=5;j++)
            if(abs(a[i]-a[j])>k)return ":(";
    return "Yay!";
}
int main()
{
    for(int i=1;i<=5;i++)cin>>a[i];
    cin>>k;
    cout<<check();
    return 0;
}

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

int main()
{
  string w;
  cin >> w;
  
  int s = w.size();
  vector<int> a(26);
  
  for (int i = 0; i < s; i ++)
  {
    a.at((int)w.at(i) - 97) ++;
  }
  
  for (int i = 0; i < 26; i ++)
  {
    if (a.at(i) % 2 != 0)
    {
      cout << "No";
      return 0;
    }
  }
  
  cout << "Yes";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <climits>
#include <algorithm>
#define MAX_H 200
#define MAX_W 200
#define INF (INT_MAX / 2)
using namespace std;

typedef pair< int, int > P;

class edge{
  public:
    int u, v;
    int w;
    edge(int u, int v, int w): u(u), v(v), w(w) {}
};

vector< int > dijkstra(vector< edge > graph[], int n, int s){
  vector< int > dist(n);
  priority_queue< P, vector< P >, greater< P > > pq;

  fill(dist.begin(), dist.end(), INF);
  dist[s] = 0;
  pq.push(P(0, s));

  while(!pq.empty()){
    P p = pq.top(); pq.pop();
    int v = p.second;
    if(dist[v] < p.first) continue;
    for(int i = 0; i < graph[v].size(); i++){
      edge e = graph[v][i];
      if(dist[e.v] > dist[v] + e.w){
        dist[e.v] = dist[v] + e.w;
        pq.push(P(dist[e.v], e.v));
      }
    }
  }

  return dist;
}

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

  int h, w;
  int c[10][10];
  int a[MAX_H][MAX_W];
  cin >> h >> w;
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      cin >> c[i][j];
    }
  }
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> a[i][j];
    }
  }

  vector< edge > graph[10];
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      graph[i].push_back(edge(i, j, c[j][i]));
    }
  }
  vector< int > cost = dijkstra(graph, 10, 1);
  int sum = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(a[i][j] != -1){
        sum += cost[a[i][j]];
      }
    }
  }

  cout << sum << endl;

  return 0;
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define INF 0x3f3f3f3f
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
template<class num> inline void rd(num &x) {
	char c;
	while(isspace(c = getchar()));
	bool neg = false;
	if(!isdigit(c)) neg = (c == '-'), x = 0;
	else x = c - '0';
	while(isdigit(c = getchar()))
		x = (x << 3) + (x << 1) + c - '0';
	if(neg) x = -x;
}
const int N = 212345;
int a[N], b[N], pos[N][2];
int main (void) {
	int n; rd(n);
	for (int i = 1; i <= n; i++) rd(a[i]), rd(b[i]);
	vector<pii> v;
	vector <int> w;
	ll ax = 0, bx = 0;
	for (int i = 1; i <= n; i++) {
		v.eb(a[i], -i);
		v.eb(b[i], i);
		ax += a[i];
		bx += b[i];
	}
	sort(begin(v), end(v));
	for (int i = 0; i < v.size(); i++) {
		int k = v[i].se;
		w.pb(v[i].fi);
		if (k < 0)
			pos[-k][0] = i;
		else
			pos[k][1] = i;
	}
	ll sum = 0;
	for (int i = 0; i < n-2; i++)
		sum += v[i].fi;
	ll best = LLONG_MAX;
	for (int i = 1; i <= n; i++) {
		int x1 = pos[i][0], x2 = pos[i][1];
		if (x1 > x2) swap (x1, x2);
		ll at = sum + w[x1] + w[x2];
		if (x1 < n-2)
			at = at - w[x1] + w[n-2];
		if (x2 < n-1)
			at = at - w[x2] + w[n-1];
		best = min(best, at);
	}
	best = min(best, ax);
	best = min(best, bx);
	cout << best << endl;

	return 0;
}

Measured memory_bytes: 5232
p = 2019
s = list(map(int, list(input())))[::-1]
n = len(str(s))

sum = 0
cnt = [0] * p
cnt[0] = 1
n = len(s)
for i in range(n):
    d = s[i] * pow(10, i, p)
    sum = (sum + d) % p
    cnt[sum] += 1

ans = 0
if p in [2, 5]:
    if p == 2:
        ok_list = [0, 2, 4, 6, 8]
    if p == 5:
        ok_list = [0, 5]

    for i in range(n):
        d = s[i]
        if d in ok_list:
            ans += n - i
           
else:
    for i in range(p):
        ans += cnt[i] * (cnt[i]-1) // 2


print(ans)


Measured memory_bytes: 99256
import java.util.*;

public class Main {

    private static int N;
    private static int MA;
    private static int MB;
    private static Drag[] D;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        MA = sc.nextInt();
        MB = sc.nextInt();
        D = new Drag[N];
        for (int i = 0; i < N; i++) {
            D[i] = new Drag(sc.nextInt(), sc.nextInt(), sc.nextInt());
        }
        System.out.println(solve());
    }

    private static final int INF = 1_000_000;

    static int solve() {
        int[][][] dp = new int[N+1][N*10+1][N*10+1];
        for (int i = 0; i < N+1; i++) {
            for (int j = 0; j < N*10+1; j++) {
                Arrays.fill(dp[i][j], INF);
            }
        }
        dp[0][0][0] = 0;

        for (int i = 1; i <= N; i++) {
            Drag d = D[i-1];

            for (int a = 0; a <= N*10; a++) {
                for (int b = 0; b <= N*10; b++) {
                    int prev = dp[i-1][a][b];
                        // 追加購入
                    if( a + d.a <= N*10 && b + d.b <= N*10 ) {
                        dp[i][a+d.a][b+d.b] = Math.min(dp[i-1][a+d.a][b+d.b], prev + d.cost);
                    }

                    // 買わない
                    dp[i][a][b] = Math.min(prev, dp[i][a][b]);
                }
            }
        }

        // MA:MBになる場所で一番コストの少ない箇所を探す
        int n = 1;
        int cost = INF;
        while(true) {
            int a = n * MA;
            int b = n * MB;
            if( a > N*10 || b > N*10 ) break;

            if( Math.min(dp[N][a][b], cost) != 0 ) {
                cost = Math.min(dp[N][a][b], cost);
            }
            n++;
        }

        if( cost == INF ) return -1;
        else return cost;
    }

    private static class Drag {
        private final int a;
        private final int b;
        private final int cost;

        public Drag(int a, int b, int cost) {
            this.a = a;
            this.b = b;
            this.cost = cost;
        }
    }
}


Measured memory_bytes: 52692
import statistics
from decimal import Decimal, ROUND_HALF_UP

pricelist = []
numlist = []
while 1:
    try:
        price, num = map(int, input().split(","))
        pricelist.append(price)
        numlist.append(num)
    except:
        break

sum = 0
mean = statistics.mean(numlist)
for price, num in zip(pricelist, numlist):
    sum += price * num

print(sum)
print(Decimal(str(mean)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))



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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
    int a,b;
    cin>>a>>b;
    rep(i,3){
        if(i+1!=a&&i+1!=b){
            cout<<i+1<<endl;
            return 0;
        }
    }
    
	return 0;
}

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

using namespace std;

int main() {

	string data;

	cin >> data;

	for (int i = 0; data != "-"; i++) {

		int m = 0;
		int h = 0;
		

		cin >> m;

		for (int u = 0; u < m; u++) {

			string str;
			cin >> h;

			for (int y = 0; y < h; y++) {

				str += data[0];
				data.erase(data.begin());

			}

			data += str;


		}

		cout << data << endl;
		cin >> data;

	}



	return 0;

}



Measured memory_bytes: 3212
using System;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var b = int.Parse(input[0]);
            var c = int.Parse(input[1]);
            var a = b * c;
            if (a % 2 == 0)
            {
               Console.WriteLine("Even");
               return;
            }
            Console.WriteLine("Odd");
        }
    }
}

Measured memory_bytes: 13140
import math
import sys
input = sys.stdin.readline
def main():
	H,N = map(int,input().split())
	A,B = [],[]
	ap = A.append
	bp = B.append
	for _ in range(N):
		a,b = map(int,input().split())
		ap(a)
		bp(b)
	
	dp = [[0 for _ in range(H+1)] for _ in range(N)]
	
	for i in range(1,H+1):
		dp[0][i] = math.ceil(i/A[0])*B[0]

	for i in range(1,N):
		for j in range(1,H+1):
			if j<=A[i]:
				dp[i][j] = min(dp[i-1][j],B[i])
			else:
				dp[i][j] = min(dp[i-1][j],dp[i][j-A[i]]+B[i])

	print(dp[N-1][H])
if __name__ == '__main__':
	main()

Measured memory_bytes: 278408
#include <stdio.h>
int main(void){
    int N,K,A[2001],i,j;
    long int a=0,b=0,sum;

    scanf("%d %d",&N,&K);
    for(i=0;i<N;i++){
        scanf("%d ", &A[i]);
    }

    for(i=0;i<N;i++){
        for(j=i+1;j<N;j++){
            if(A[i] > A[j]){
                a++;
            }
        }
        for(j=0;j<i;j++){
            if(A[i] > A[j]){
                b++;
            }
        }
    }

  
  sum = (a+b)*(((long int)K*(K-1)/2)%1000000007)+a*K;
  printf("%ld\n",sum%1000000007);
  
  return 0;
}


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

int main(){
  ll x;cin >> x;
  if( x )
    cout << 0 << endl;
  else 
    cout << 1 << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <cstdio>
#include <cstring>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
#define maxn 100010
#define mod 1000000007

int n;
int ksm(int x,int y){int re=1;for(;(y&1?re=1ll*re*x%mod:0),y;y>>=1,x=1ll*x*x%mod);return re;}

int main()
{
	scanf("%d",&n);
	if(n==1)printf("0");
	else{
		long long ans=ksm(10,n)-2ll*ksm(9,n)+ksm(8,n);
		ans=(ans%mod+mod)%mod;
		printf("%lld",ans);
	}
}

Measured memory_bytes: 1732
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
	string s, t;
	int ans = 0;
	cin >> s >> t;
	for (int i = 0; i < 3; i++)
	{
		if (s[i] == t[i]) { ans++; }
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<functional>
#include<algorithm>
using namespace std;
#define INF (1<<30)

int dp[11][2012], ans;
vector<int> books[11];

int main(){
  int n, k;
  scanf("%d%d", &n, &k);
  for(int i = 0;i < n;i++){
    int c, g;
    scanf("%d%d", &c, &g);
    books[g].push_back(c);
  }
  for(int i = 1;i <= 10;i++){
    sort(books[i].begin(), books[i].end(), greater<int>());
    for(int j = 1;j < books[i].size();j++){
      books[i][j] += books[i][j - 1];
    }
    for(int j = 0;j < books[i].size();j++){
      books[i][j] += j * (j + 1);
    }
  }
  for(int i = 0;i <= 10;i++){
    for(int j = 0;j < 2012;j++){
      dp[i][j] = -INF;
    }
  }
  dp[0][0] = 0;
  for(int i = 1;i <= 10;i++){
    dp[i][0] = 0;
    for(int j = 1;j <= k ;j++){
      dp[i][j] = dp[i - 1][j];
      for(int l = 1;l <= j && l <= books[i].size();l++){
	dp[i][j] = max(dp[i][j], dp[i - 1][j - l] + books[i][l - 1]);
      }
      ans = max(ans, dp[i][j]);
    }
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 1156
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    vector<string> a(h);
    for(int i=0;i<h;i++){
        cin >> a[i];
    }
    vector<char> b(w+2,'#');
    for(int i=0;i<w+2;i++){
        cout << b[i];
    }
    cout << endl;
    for(int i=0;i<h;i++){
        cout << "#" << a[i] << "#" << endl;
    }
    for(int i=0;i<w+2;i++){
        cout << b[i];
    }
    cout << endl;
}

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

int main(){
    string s;
    int c=0;
    cin>>s;
    int maxi=0;
    for(int i=0; s[i]!='\0'; i++){
        if( s[i]=='A'|| s[i]=='G'|| s[i]=='C'|| s[i]=='T' ){
            c++;
            maxi=max(maxi,c);
            continue;
        }

        c=0;
    }
    printf("%d\n",maxi);
    return 0;
}


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

vector<ll> to[100010];


int main(){
    ll n;cin>>n;
    if(n%2==0){
        cout<<n*(n-1)/2-n/2<<endl;
        rep(i,1,n+1){
            rep(j,i+1,n+1){
                if(i+j!=n+1)cout<<i<<" "<<j<<endl;
            }
        }
    }
    if(n%2==1){
        cout<<n*(n-1)/2-n/2<<endl;
        rep(i,1,n+1){
            rep(j,i+1,n+1){
                if(i+j!=n)cout<<i<<" "<<j<<endl;
            }
        }
    }
}







Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x;
    cin>>x;
    int ans=0,f=x%500;
    ans+=x/500*1000+f/5*5;
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807/2;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n;
ll k;
ll a[200100];
ll f[200100];

bool check(ll t){
	ll cou=0;
	for(int i=0;i<n;i++){
		if(a[i]*f[i]<=t)continue;
		cou+=(a[i]*f[i]-t+f[i]-1)/f[i];
	}
	if(cou<=k)return true;
	else return false;
}
int main(){
	cin>>n>>k;
	REP(i,n){
		cin>>a[i];
	}
	REP(i,n){
		cin>>f[i];
	}
	sort(a,a+n);
	sort(f,f+n,greater<ll>());
	
	ll lb=-1,ub=1e12+1;
	while(ub-lb>1){
		ll mid=(lb+ub)/2;
		if(check(mid)){
			ub=mid;
		}else{
			lb=mid;
		}
	}
	cout<<ub<<endl;
	return 0;
}

Measured memory_bytes: 3328
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int m=sc.nextInt();
    double sel=0.0;
    ArrayList<Integer> a=new ArrayList<>();
    double sum=0;
    int flag=0;
    //if(m<n&&m==0) System.out.println("Yes")
    for(int i=0;i<n;i++){
      int t=sc.nextInt();
      sum+=t;
      a.add(t);
    }
    Collections.sort(a);
    sel=(double)(sum/(4*m));
    //System.out.println(sel);
    int count=0;
    for(int i=n-1;i>-1;i--){
      if((double)a.get(i)>=sel) count++;
      if(count==m) {
        flag=1;break;
      }
    }
	if(flag==1||m==0)System.out.println("Yes");
    else System.out.println("No");
  }
}

Measured memory_bytes: 22996
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			// nがあり、nの数だけの整数の入力
			int n = sc.nextInt();
			List<Integer> pn = new ArrayList<>();
			for (long i = 0; i < n; i++) {
				pn.add(sc.nextInt());
			}
			List<Integer> qn = new ArrayList<>();
			for (long i = 0; i < n; i++) {
				qn.add(sc.nextInt());
			}

			Map<Integer, Integer> myMap = new HashMap<>();
			myMap.put(2, 1);
			myMap.put(3, 2);
			myMap.put(4, 6);
			myMap.put(5, 24);
			myMap.put(6, 120);
			myMap.put(7, 720);
			myMap.put(8, 5040);

			int pnCnt = 0;

			for (int i = 0; i < n - 1; i++) {
				int myNum = pn.get(i);
				int base = 0;
				for (int j = i + 1; j < n; j++) {
					int otherNum = pn.get(j);
					if (myNum > otherNum) {
						base++;
					}
				}
				pnCnt = pnCnt + myMap.get(n - i) * base;
			}

			int qnCnt = 0;
			for (int i = 0; i < n - 1; i++) {
				int myNum = qn.get(i);
				int base = 0;
				for (int j = i + 1; j < n; j++) {
					int otherNum = qn.get(j);
					if (myNum > otherNum) {
						base++;
					}
				}
				qnCnt = qnCnt + myMap.get(n - i) * base;
			}

			System.out.println(pnCnt > qnCnt ? pnCnt - qnCnt : qnCnt - pnCnt);
		}
	}
}

Measured memory_bytes: 24020
/*.....Bismillahir Rahmanir Rahim.....*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld long double
#define   pb push_back
#define  sz(x)  (int)x.size()
#define  ff first
#define  ss second
#define  pii  pair<int,int>
using namespace std;

int  gcd(int a,int b) {
	return  (b==0)? a: gcd(b,a%b);
}

void solve(){ 
	ld  n;  cin >> n ;
	printf("%0.7Lf\n",(n/3*n/3*n/3)); 
}

signed main() {
	solve();
    return 0;
}


Measured memory_bytes: 256
X, N = gets.split.map(&:to_i)
P = gets.split.map(&:to_i)

if P.index(X).nil?
    puts X
    exit
end

diff = 1
ans = -1
while true do
    if P.index(X-diff).nil?
        ans = X-diff
        break
    end
    if P.index(X+diff).nil?
        ans = X+diff
        break
    end
    diff += 1
end
puts ans

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

using namespace std;

using ll = long long int;
using ld = long double;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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

	int n;
	cin >> n;

	list<int> b;
	int addNum = (n % 2 == 0 ? 1 : 2);
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if ((i + addNum) % 2 == 0) {
			b.push_front(a);
		} else {
			b.push_back(a);
		}
	}

	int i = 0;
	for (auto value : b) {
		if (i) cout << " ";
		cout << value;
		i++;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 8448
fun main(args: Array<String>){
  val n = readInt()
  val x_y = (1..n).map { readInts()?.let { it[0] to it[1] } }
  
  val list = (0 until n).map { it }
  val permList = permute(list)
  var sum = 0.0
  for(perm in permList) {
    var s = 0.0
    for (i in 0 until n - 1) {
      val a = x_y[perm[i]]
      val b = x_y[perm[i + 1]]
      val dx = a.first - b.first
      val dy = a.second - b.second
      val d = Math.sqrt((dx * dx + dy * dy).toDouble())
      s += d
    }
    sum += s
  }
  
  var fact = 1
  for (i in 1..n) {
    fact *= i
  }
  println(sum / fact)
}

fun <Int> permute(list:List <Int>):List<List<Int>>{
  if(list.size==1) return listOf(list)
  val perms=mutableListOf<List <Int>>()
  val sub=list[0]
  for(perm in permute(list.drop(1)))
    for (i in 0..perm.size){
      val newPerm=perm.toMutableList()
      newPerm.add(i,sub)
      perms.add(newPerm)
    }
  return perms
}


fun readString() = readLine()!!
fun readStrings() = readString().split(' ')
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }



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

using namespace std;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'

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

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;

int main(){ _
	ll n, k;
	cin >> n >> k;
	map<ll, ll> freq;
	while (n--){
		ll a, b;
		cin >> a >> b;
		freq[a] += b;
	}
	ll i = 1;
	for (auto it : freq){
		if (i <= k && k <= i+it.second-1) cout << it.first << endl;
		i += it.second;
	}
	
	exit(0);
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define MAX 2000001

typedef long long ll;

int heap[MAX];
int size = 0;

void MaxHeepify(const int &index) {
  int left_index = 2 * index + 1;
  int right_index = 2 * index + 2;
  int largest_index;
  if (left_index < size && heap[left_index] > heap[index]) {
    largest_index = left_index;
  } else {
    largest_index = index;
  }
  if (right_index < size && heap[right_index] > heap[largest_index]) {
    largest_index = right_index;
  }
  if (largest_index != index) {
    swap(heap[index], heap[largest_index]);
    MaxHeepify(largest_index);
  }
}

void HeapIncreseKey(const int &index) {
  if (index == 0) {
    // Index is root.
    return;
  }
  int parent_index = (index + 1) / 2 - 1;
  if (heap[index] > heap[parent_index]) {
    swap(heap[index], heap[parent_index]);
    HeapIncreseKey(parent_index);
  }
}

void Insert(const int &x) {
  size++;
  heap[size - 1] = x;
  HeapIncreseKey(size - 1);
}

int Extract() {
  int max_ = heap[0];
  heap[0] = heap[size - 1];
  size--;
  MaxHeepify(0);
  return max_;
}

int main() {
  while (true) {
    string str;
    cin >> str;
    if (str == "insert") {
      int x;
      cin >> x;
      Insert(x);
    } else if (str == "extract") {
      cout << Extract() << endl;
    } else if (str == "end") {
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 6948
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  int M;
  int num = 0;
  double sum = 0;
  cin>>N;
  cin>>M;
  int arr[N];
  for(int i = 0;i < N;i++){
    cin>>arr[i];
    sum += arr[i];
  }
  sort(arr,arr + (N),greater<int>());
  for(int i = 0;i < M;i++){
    if(arr[i] < (sum / (4*M))){
      cout<<"No"<<'\n';
      num = 1;
      break;
    }
  }
  if(num == 0){
    cout<<"Yes"<<'\n';
  }
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;

// tourist set
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << '\n'; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
// tourist set 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; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<'\n'
#define p2(s, t) cout << (s) << " " << (t) << '\n'
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << '\n'
#define p_yes() p("YES")
#define p_no() p("NO")
#define SZ(x) ((int)(x).size())
#define SORT(A) sort(ALL(A))
#define RSORT(A) sort(ALL(A), greater<ll>())

void no(){p_no(); exit(0);}
void yes(){p_yes(); exit(0);}

const ll mod = 1e9 + 7;
const ll inf = 1e18;
const double PI = acos(-1);

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

    // input
    ll M;
    cin >> M;

    ll D = 0; // 長さ
    ll S = 0; // 桁和
    rep(i, M){
      ll d, c;
      cin >> d >> c;
      D += c;
      S += d*c;
    }

    ll ans = (D-1) + (S-1)/9;
    p(ans);
    
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define PI 3.141592
int main()
{
  int N; cin >> N;
  map<int, int> list;
  REP(i, N) {
    list[i+1] = 0;
  }
  int tmp;
  REP(i, N-1) {
    cin >> tmp;
    list[tmp]++;
  }
  REP(i, N) {
    cout << list[i+1] << " ";
  }
}

Measured memory_bytes: 13004
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

int prime[101010];
bool is_prime[101010];

// n以下の素数の数を返す
int sieve(int n) {
	int p = 0;
	for (int i = 0; i <= n; i++) {
		is_prime[i] = true;
	}
	is_prime[0] = false;
	is_prime[1] = false;
	for (int i = 2; i <= n; i++) {
		if (is_prime[i]) {
			prime[p++] = i;
			for (int j = 2 * i; j <= n; j += i) {
				is_prime[j] = false;
			}
		}
	}
	return p;
}

int prime_count[101010];

int main() {
	int q;
	cin >> q;
	sieve(100001);
	for (int i = 1; i <= 100001; i += 2) {
		if (is_prime[i] && is_prime[(i + 1) / 2])prime_count[i]++;
	}
	for (int i = 1; i <= 100001; i++) {
		prime_count[i] += prime_count[i - 1];
	}
	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		cout << prime_count[r] - prime_count[l - 1] << endl;
	}

}

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

int main(){
    int N;
    char S[100];
    char T[100];
    cin >> N;
    rep(i,N){
        cin >> S[i];
    }
    rep(i,N){
        cin >> T[i];
    } 
    rep(i,N){
        cout << S[i] << T[i];
    }    
    cout << endl;
}



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

int main(){
  int a;
  cin >> a;
  cout << a + a*a + a*a*a << endl;
  return 0;
}


Measured memory_bytes: 3640
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n, p = map(int, input().split())
a = factorization(p)
ans = 1
for i in range(len(a)):
    if a[i][1]>=n:
        b = a[i][1]//n
        ans = ans*a[i][0]**b
    else:
        continue
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF = 1e11;
int main(){
    ll n,W,ans=0;
    cin >> n >> W;
    ll w[n],v[n],dp[100][100001];
    for(int i = 0;i < n;i ++){
        cin >> w[i] >> v[i];
    }
    fill(dp[0],dp[0]+100001,INF);
  	dp[0][0] = 0;
    for(int j = 0;j < 100001;j ++){
        if(v[0]==j) dp[0][j] = w[0];
        for(int i = 0;i < n-1;i ++){
            if(j>=v[i+1]) dp[i+1][j] = min(dp[i][j-v[i+1]]+w[i+1],dp[i][j]);
            else dp[i+1][j] = dp[i][j];
        }
    }
    for(int j = 0;j < 100001;j ++){
        if(dp[n-1][j]<=W) ans = j;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

string make(int id,int n)
{
	string s1="";
	while(id)
	{
		s1=char(id%10+'0')+s1;
		id/=10;
	}
	while(s1.length()<6) s1='0'+s1;
	string s2="";
	while(n)
	{
		s2=char(n%10+'0')+s2;
		n/=10;
	}
	while(s2.length()<6) s2='0'+s2;
	return s1+s2;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,m; cin>>n>>m;
	vector<vector<pii>> v(n);
	int id,y;
	REP(i,0,m-1)
	{
		cin>>id>>y;
		v[id-1].emplace_back(y,i);
	}
	string ans[m];
	REP(i,0,n-1)
	{
		sort(v[i].begin(),v[i].end());
		if(v[i].size()) REP(j,0,v[i].size()-1)
		{
			//cout<<v[i][j].S<<"\n";
			ans[v[i][j].S]=make(i+1,j+1);
		}
	}
	REP(i,0,m-1) cout<<ans[i]<<"\n";
	return 0;
}







Measured memory_bytes: 12416
#include <cstdio>
#include <cstring>

#include <algorithm>
#include <vector>
#include <queue>

#define PB push_back

using namespace std;

const int N = 5e5 + 500;
const int OFF = (1 << 19);

int n, k, P[N], Q[N], T[2 * OFF], sol[N];

inline int miin(int x, int y){
	if(Q[x] < Q[y])
		return x;
	return y;
}

void update(int i,int x){
	Q[i] = x; T[OFF + i] = i;
	for(i = (i + OFF) / 2; i ; i /= 2)
		T[i] = miin(T[2 * i], T[2 * i + 1]);
}

int query(int i,int a,int b,int lo,int hi){
	if(lo <= a && b <= hi) return T[i];
	if(a > hi || b < lo) return n;
	return miin(query(2 * i, a, (a + b) / 2, lo, hi), query(2 * i + 1, (a + b) / 2 + 1, b, lo, hi));
}

inline int lokal(int x){
	return x == query(1, 0, OFF - 1, max(0, x - k + 1), min(n - 1, x + k - 1));
}

priority_queue < pair < int, int > , vector < pair < int, int > >, less < pair < int, int > > > PQ;

inline void buket(int x){
	if(x < 0 || x * k >= n)
		return;
	int kan = query(1, 0, OFF - 1, x * k, min(x * k + k - 1, n - 1));
	if(Q[kan] == n)
		return;
	if(lokal(kan))
		PQ.push({kan, kan});
}

int main(){
	scanf("%d%d", &n, &k);
	for(int i = 0;i < n;i++){
		scanf("%d", P + i); P[i]--;
		update(i, n - P[i] - 1);
	}
	update(n, n);
	for(int i = 0;i * k < n;i++)
		buket(i);
	int trn = n - 1;
	for(;!PQ.empty();){
		int cur = PQ.top().second; PQ.pop();
		if(Q[cur] == n)
			continue;
		sol[cur] = trn--;
		update(cur, n);
		buket(cur / k);
		buket(cur / k - 1);
		buket(cur / k + 1);
	}
	for(int i = 0;i < n;i++)
		printf("%d\n", sol[i] + 1);
}






Measured memory_bytes: 17644
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long H, W;
	cin >> H >> W;
	if (H == 1 || W == 1) {
		cout << 1 << endl;
	} else {
		cout << (H * W + 1) / 2 << endl;
	}
}


Measured memory_bytes: 256