akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

LL mod = 1000000007;

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

  LL A, B, Q;
  cin >> A >> B >> Q;
  vector<LL> s(A+2);
  vector<LL> t(B+2);

  s[0] = -200000000000LL;
  s[A+1] = 200000000000LL;
  t[0] = -200000000000LL;
  t[B+1] = 200000000000LL;

  REP(i,A){
    cin >> s[i+1];
  }
  REP(i,B){
    cin >> t[i+1];
  }

  REP(i,Q){
    LL x;
    cin >> x;

    int ngA = A+1;
    int okA = 0;

    while (abs(okA - ngA) > 1) {
        int mid = (okA + ngA) / 2;

        if (s[mid]<x) okA = mid;
        else ngA = mid;
    }

    int ngB = B+1;
    int okB = 0;

    while (abs(okB - ngB) > 1) {
        int mid = (okB + ngB) / 2;

        if (t[mid]<x) okB = mid;
        else ngB = mid;
    }

    cout << min({
                max(abs(x - s[okA]), abs(x - t[okB])),
                max(abs(x - s[okA + 1]), abs(x - t[okB + 1])),
                abs(x - s[okA])+2*abs(x - t[okB + 1]),
                abs(x - s[okA])*2+abs(x - t[okB + 1]),
                abs(x - t[okB])+2*abs(x - s[okA + 1]),
                abs(x - t[okB])*2+abs(x - s[okA + 1])})
        << endl;
  }
}


Measured memory_bytes: 2944
function main(input: string) {
  let ans = 0
  let temp = 0
  for (let i = 0; i < input.length; i++) {
    if (input[i] === 'A' || input[i] === 'C' || input[i] === 'G' || input[i] === 'T') {
      temp++
    } else {
      temp = 0
    }

    if (temp > ans) {
      ans = temp
    }
  }

  console.log(ans)
}

main(require("fs").readFileSync("/dev/stdin", "utf8").trim())

Measured memory_bytes: 7372
#include<stdio.h>
int b[8];
int main()
{
    int n,m,sum=0,i,cnt=0;
    scanf("%d",&n);
    int a[n];
    while(n--)
    {
        scanf("%d",&m);
        if(m>0&&m<400)b[0]=1;
        else if(m>399&&m<800)b[1]=1;
        else if(m>799&&m<1200)b[2]=1;
        else if(m>1199&&m<1600)b[3]=1;
        else if(m>1599&&m<2000)b[4]=1;
        else if(m>1999&&m<2400)b[5]=1;
        else if(m>2399&&m<2800)b[6]=1;
        else if(m>2799&&m<3200)b[7]=1;
        else cnt++;
    }
    for(i=0;i<8;i++)
        if(b[i])sum++;
    if(sum)printf("%d ",sum);
    else printf("1 ");
    printf("%d",cnt+sum);
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int rabbit = sc.nextInt();
    int[] list = new int[rabbit];
    for(int i = 0; i < rabbit; ++i){
      list[i] = sc.nextInt();
    }
    
   int count = 0;
    
    for(int i = 0 ; i < rabbit; ++i){
      int love = list[i];
      
        if(list[love - 1] == (i + 1)){
          count++;
        }
    }
    
    System.out.println(count/2);
    
  }
}

Measured memory_bytes: 59036
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] nos = new int[n];
		long sum = 0;
		for (int i = 0; i < n; i++) {
			nos[i] = sc.nextInt();
			sum += nos[i];
		}
		sc.close();
		Arrays.sort(nos);
		int min = nos[0];
		int max = nos[n-1];
		System.out.println(min + " " + max + " " + sum);
	}
}


Measured memory_bytes: 41460
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=10e9+7;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}

ll par[100100];
ll ranker[100100];
ll incon[100100];

void init(){
    rep(i,100100){
        par[i]=i;
        ranker[i]=0;
        incon[i]=1;
    }
}

ll find(ll x){
    if(par[x]==x) return x;
    else return par[x]=find(par[x]);
}

void unite(ll x,ll y){
    x=find(x);
    y=find(y);
    if(x==y) return;
    
    if(ranker[x]<ranker[y]) {
        par[x]=y;
        incon[y]+=incon[x];
    }
    else {
        par[y]=x;
        incon[x]+=incon[y];
    }
    if(ranker[x]==ranker[y]) ranker[x]++;
}

bool same(ll x,ll y) {
  return find(x)==find(y);
}

ll kosu(ll x) {
  return incon[find(x)];
}


int main(void){
    ll N,M;
    cin>>N>>M;
    vector<ll> A(M),B(M);
    vector<ll> ans(M,0);
    ans.at(M-1)=N*(N-1)/2;
    rep(i,M) cin>>A.at(i)>>B.at(i);
    init();
    
    for(ll i=M-2;i>=0;i--){
        ll a=A.at(i+1),b=B.at(i+1);
        if(same(a,b)) ans.at(i)=ans.at(i+1);
        else ans.at(i)=ans.at(i+1)-kosu(a)*kosu(b);
        if(ans.at(i)==0) break;
        unite(a,b);
    }
    rep(i,M) cout<<ans.at(i)<<endl;
    return 0;
}


Measured memory_bytes: 6016
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){int b=0;for(auto itr :a){if(b++!=0)cout << " "; cout << itr;} }
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
#define int ll
signed main(){
    int a,b;
    while(cin >> a >> b, a + b){
        vector<int>h,w;
        h.push_back(1);
        w.push_back(1);
        map<int,int>v,u;
        rep(i,a){
            int t; cin >> t;
            int temp = h.back();
            h.push_back(temp+t);
            v[temp+t] = 1;
        }
        v[1] = u[1] = 0;
        rep(i,b){
            int t; cin >> t;
            int temp = w.back();
            w.push_back(temp+t);
            u[temp+t] = 1;
        }
        map<int,int>mp;
        for(int i = 0; i< w.size();i++){
            for(int j = i+1; j<w.size();j++){
                mp[w[j]-w[i]]++;
            }
        }
        int ans = 0;
        for(int i = 0; i< h.size();i++){
            for(int j = i+1; j<h.size();j++){
                ans += mp[h[j]-h[i]];
            }
        }
        cout << ans << endl;
    }
}




Measured memory_bytes: 26964
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ft first
#define sd second
#define pb push_back
using namespace std;
const ll mod = 1e9+7;
const ll inf = 1e9+9;
 
ll power(ll a, ll b, ll m = mod) {
    ll x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
 
mt19937_64 gen (random_device{}());
ll rint(ll a, ll b) { // generate rand int in [a, b]
    return a + gen() % (b - a + 1);
}

const int N = 2e5+9;
const int B = 30;
bool oc[B];
int a[N];
signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int n, k; cin >> n >> k;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    vector<long long> p(n+1);
    long long ans = 0;
    for(int i = 1; i <= n; i++) {
        p[i] = p[i-1] + (a[i]+1);
        if(i >= k) {
            ans = max(ans, p[i]-p[i-k]);
        }
    }
    cout << fixed << setprecision(15) << ans / 2.l << endl;







    return 0;
    
}

Measured memory_bytes: 2560
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let w = read::<i64>();
    let mut a = read::<i64>();
    let mut b = read::<i64>();
    if a > b {
        std::mem::swap(&mut a, &mut b);
    }
    let ans = std::cmp::max(0, b - (a + w));
    println!("{}", ans);
}


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

using namespace std;

const int MAX = 1001;

int n, k, p[MAX], i, res = 0;

int main()
{
  cin >> n >> k;

  for(i = 0; i < n; i++)
  {
    cin >> p[i];
  }

  sort(p, p+n);

  for(i = 0; i < k; i++)
  {
    res += p[i];
  }

  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 3640
# -*- coding: utf-8 -*-
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
write = sys.stdout.write
def ii(): return int(readline())
def mi(): return map(int, readline().rstrip().split())
def li(): return list(readline().rstrip())
def lmi(): return list(map(int, readline().rstrip().split()))
def end(*arg): print(*arg); sys.exit()
# template


def main():
    N = ii()
    S, T = input().rstrip().split()
    ans = ""
    for i in range(N):
        ans += S[i] + T[i]
    print(ans)
    return


if __name__ == '__main__':
    main()


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

int main(void){
    int a,b;
    cin >> a >> b;
    int A = a+b;
    int B = a-b;
    int C = a*b;
    int max = A;
    if(max<B) max = B;
    if(max<C) max = C;
    cout << max << endl;

    
    return 0;
}


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

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

    int n, m;
    cin >> n >> m;
    int cnt[n], ans = 0;
    bool red[n] = {};

    red[0] = 1;
    for (int &x : cnt)
        x = 1;

    while (m--) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        red[y] = max(red[y], red[x]);
        cnt[y]++;
        cnt[x]--;
        red[x] = min(red[x], (bool)cnt[x]);
    }

    for (bool x : red)
        if (x)
            ans++;
    cout << ans << '\n';
}

Measured memory_bytes: 4088
import java.util.*;
import java.util.stream.*;

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

        int N=sc.nextInt();
        int M=sc.nextInt();
        int Q=sc.nextInt();
    
        int[][] map=new int[N+1][N+1];
        for(int i=0;i<M;i++){
            map[sc.nextInt()][sc.nextInt()]++;
        }

   
        for(int i=0;i<=N;i++){
            for(int j=1;j<=N;j++){
                map[i][j]+=map[i][j-1];
            }
        }
        for(int i=0;i<Q;i++){
            int p=sc.nextInt();
            int q=sc.nextInt();
            if(q<p){
                int tmp=p;
                p=q;
                q=tmp;
            }
            int ans=0;
            for(int k=p;k<=q;k++){
                ans+=map[k][q]-map[k][p-1];
            }
            System.out.println(""+ans);
        }
    }
}

Measured memory_bytes: 155692
#include "bits/stdc++.h"
using namespace std;

int main() {
    string s, ans;
    cin >> s;
    for (char c : s) {
        if (c == 'B') {
            if(!ans.empty()) ans.pop_back();
        }
        else
            ans.push_back(c);
    }

    cout << ans << endl;
}

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

W = []
for _ in range(n):
    w = int(input())
    W.append(w)
    
Baggages = W[:]
        
def _check(tmp_P):
    num_track = 1
    tmp_sum = 0
    for b in Baggages:
        if tmp_sum+b <= tmp_P:
            tmp_sum += b
        else:
            num_track += 1
            tmp_sum = b
            if num_track > k:
                return False
    return True
    

def check(P):
    i = 0
    for _ in range(k):
        s = 0
        while s+Baggages[i] <= P:
            s += Baggages[i]
            i += 1
            if i >= n:
                return True
    if i == n:
        return True
    else:
        return False

    
def binary_search(max_r):
    left = 0
    right = max_r
    
    while right-left > 1:
        mid = (left+right)//2
        if check(mid) == True:
            right = mid
        else:
            left = mid
    return right
            
max_p = sum(Baggages)+1
ans = binary_search(max_p)
print(ans)

#print(check(4))
#print(check(5))
#print(check(6))
#print(check(7))
    
    

    

    



Measured memory_bytes: 10304
#include <iostream>
using namespace std;
int main()
{
  int n;
  
  int sum=0;
  cin>>n;
  int a[n+1],b[n+1],c[n+1];
  for(int i=1;i<=n;i++)
  {
    cin>>a[i];
  }
  for(int i=1;i<=n;i++)
  {
    cin>>b[i];
    sum+=b[i];
  }
  for(int i=1;i<=n;i++)
  {
    cin>>c[i];
  }
  for(int i=1;i<n;i++)
  {
    if(a[i+1]-a[i]==1)
      sum+=c[a[i]];
  }
  cout<<sum;
  return 0;
}
  

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

int main(){
  int L,N,W,H,ans;
  int u=0;
  cin>>H>>W;
  int a[H][W];
  vector<int>b(W*H),c(W*H),d(H*W),e(H*W);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
    cin>>a[i][j];
  }
  }
    for(int i=0;i<H;i++){
    for(int j=0;j<W-1;j++){
    if(a[i][j]%2==1){
      a[i][j+1]+=1;
      ans++;
      b[u]=i+1;
      c[u]=j+1;
      d[u]=i+1;
      e[u]=j+2;
      u++;
  }
  }
    }
      for(int i=0;i<H-1;i++){
    if(a[i][W-1]%2==1){
      a[i+1][W-1]+=1;
      ans++;
      b[u]=i+1;
      c[u]=W;
      d[u]=i+2;
      e[u]=W;
      u++;
  }
      }
 cout<<ans<<endl;
    for(int i=0;i<ans;i++){
    cout<<b[i]<<" "<<c[i]<<" "<<d[i]<<" "<<e[i]<<endl;
  }
}

Measured memory_bytes: 7040
#include<iostream>
using namespace std;
int main(void){
  
  int N, K, i, sum = 1;
  
  cin >> N >> K;
  
  for(i = 0; i < N; i++){
    if(sum < K){
      sum *= 2;
    }else{
      sum += K;
    }
  }
  
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 256
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

X,Y,Z,K = II()
A = III()
B = III()
C = III()

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

a = []
if X*Y*Z <= 10**6:
    for i in range(X):
        for j in range(Y):
            for k in range(Z):
                a.append(A[i]+B[j]+C[k])
    a.sort(reverse=True)
    for i in range(K):
        print(a[i])
else:
    for i in range(X):
        if i==0: jmax = Y
        else: jmax = min(Y,math.ceil(5000/i))
        for j in range(jmax):
            if i*j==0: kmax = Z
            else: kmax = min(Z,math.ceil(5000/i/j))
            for k in range(kmax):
                a.append(A[i]+B[j]+C[k])
    a.sort(reverse=True)   
    for i in range(K):
        print(a[i])

Measured memory_bytes: 121276
#include <bits/stdc++.h>
        using namespace std;
        #define ll long long int
        #define pb push_back
        #define mk make_pair
        #define ft first
        #define sc second
        #define ppb pop_back
        #define sz size
        #define forn(i,a,n) for(i=a;i<n;i++)
        #define M 1000000007
        #define inf 2e18

        int main() {
 

        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
            
        ll h,a;
        cin>>h>>a;
        if(h - a*(h/a)==0)
            cout<<h/a;
        else
            cout<<h/a+1;

        return 0;
        }

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

#define MOD 1000000007LL
ll memo[100005];

ll go(ll n) {
	if (n == 1LL)
		return 1;
	if (memo[n] != 0)
		return memo[n];

	return memo[n] = n * go(n - 1) % MOD;
}

int main(){
	ll a, b;
	cin >> a >> b;
	if (abs(a - b) >= 2)
		cout << "0" << endl;
	else if (abs(a - b) == 1) {
		cout << go(a)*go(b) % MOD << endl;
	}
	else {
		cout << 2 * go(a)*go(b) % MOD << endl;
	}

	return 0;
}


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

#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(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

struct UnionFind{
    vector<int> data;
    //data[i] = -x ... iが根であり、サイズがx
    //data[i] = x ... iの親がx

    //最初は全員根
    UnionFind(int size): data(size,-1){}

    bool union_set(int x, int y){//サイズがx>yになるようにしてから、xにyをつなげる
        x=root(x);
        y=root(y);
        if(x != y){
            if(data[y] < data[x]) swap(x,y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool find_set(int x, int y){//ルートが一致するかどうかを返す
        return root(x) == root(y);
    }
    int root(int x){//根を見つける。ついでに深さ2にしちゃう
        return data[x]<0 ? x : data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};


int main() {
    ll N,M; cin >> N >> M;
    vector<pair<ll,ll>> AB(M);
    REP(i,M){
        cin >> AB[i].first >> AB[i].second;
        AB[i].first--;
        AB[i].second--;
    }

    UnionFind uf(N);

    vector<ll> ans(M+1);
    ans[M] = N*(N-1)/2;


    REPR(i,M-1){
        if(!uf.find_set(AB[i].first, AB[i].second)){
            ans[i] = ans[i+1] - uf.size(AB[i].first) * uf.size(AB[i].second);       
        }else{
            ans[i] = ans[i+1];
        }
        uf.union_set(AB[i].first, AB[i].second);
    }

    FOR(i,1,M+1){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 5832
use std::io::{BufRead, Write};
use std::cmp;

fn main() {
    let stdin = std::io::stdin();
    let stdout = std::io::stdout();
    let mut reader = std::io::BufReader::new(stdin.lock());
    let mut writer = std::io::BufWriter::new(stdout.lock());

    let n: usize = {
        let mut buf = String::new();
        reader.read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };
    let mut x: Vec<i64> = vec![0; n];
    let mut y: Vec<i64> = vec![0; n];
    let mut p: Vec<i64> = vec![0; n];
    for i in 0..n {
        let mut buf = String::new();
        reader.read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        x[i] = iter.next().unwrap().parse().unwrap();
        y[i] = iter.next().unwrap().parse().unwrap();
        p[i] = iter.next().unwrap().parse().unwrap();
    }

    let mut a: Vec<Vec<i64>> = vec![vec![std::i64::MAX; n]; 1 << n];
    let mut b: Vec<Vec<i64>> = vec![vec![std::i64::MAX; n]; 1 << n];
    for i in 0..(1 << n) {
        for j in 0..n {
            a[i][j] = cmp::min(a[i][j], x[j].abs());
            b[i][j] = cmp::min(b[i][j], y[j].abs());
            if i & 1 << j == 0 { continue; }
            for k in 0..n {
                a[i][k] = cmp::min(a[i][k], (x[j] - x[k]).abs());
                b[i][k] = cmp::min(b[i][k], (y[j] - y[k]).abs());
            }
        }
    }

    let pow = |mut a: usize, mut n: usize| {
        let mut res = 1;
        while n > 0 {
            if n & 1 > 0 { res *= a; }
            a *= a;
            n >>= 1;
        }
        res
    };

    let mut ans = vec![std::i64::MAX; n + 1];
    for i in 0..pow(3, n) {
        let mut c = 0;
        let mut x = i;
        let mut s = 0;
        let mut t = 0;
        for j in 0..n {
            let y = x % 3;
            if y == 1 {
                s += 1 << j;
                c += 1;
            }
            else if y == 2 {
                t += 1 << j;
                c += 1;
            }
            x /= 3;
        }

        let mut d = vec![std::i64::MAX; n];
        for i in 0..n {
            d[i] = cmp::min(a[s][i], b[t][i]);
        }
        let res = {
            d.iter()
                .enumerate()
                .fold(0, |acc, (i, k)| acc + p[i] * k)
        };
        ans[c] = cmp::min(ans[c], res);
    }

    for i in 0..=n {
        writeln!(writer, "{}", ans[i]).unwrap();
    }
}

Measured memory_bytes: 11748
import java.util.Scanner;

public class Main {
  public static char[] getInvert(char[] array) {
    char[] res = new char[array.length];
    res = array;
    for (int i = 0; i < array.length/2; i++) {
      char temp = res[i];
      res[i]= res[array.length - 1 - i];
      res[array.length - 1 - i]= temp;
    }
    return res;
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int c = sc.nextInt();

    String s = sc.next();

    char[] sa = s.toCharArray();

    // i回目の最速の勤務日
    int[] l = new int[k+1];
    l[0] = 0;

    int count = 0;
    for (int i = 0; i < n && count < k;) {
      if (sa[i] == 'o') {
        count++;
        l[count] = i + 1;
        i += c + 1;
      } else {
        i++;
      }
    }


    char[] saRev = getInvert(sa);
    int[] r = new int[k+1];
    r[0] = 0;
    count = 0;
    for (int i = 0; i < n && count < k;) {
      if (saRev[i] == 'o') {
        count++;
        r[k + 1 - count] = n - i;
        i += c + 1;
      } else {
        i++;
      }
    }
    for (int i = 1; i <= k; i++) {
      if (l[i] == r[i]) System.out.println(l[i]);
    }
  }
}


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

int main(){
    int n;
    cin >>n;
    int a[n];
    rep(i,n) cin >>a[i];
    int num=0;
    rep(i,n){
        int minij=i;
        for(int j=i;j<n;j++){
            if(a[j]<a[minij])
            minij=j;
        }
        if(a[i]>a[minij]){
            swap(a[i],a[minij]);
            num++;
        }
    }
    rep(i,n){
        cout << a[i];
        if(i<n-1) cout << " ";
    }
    cout <<endl<<num<<endl;

    return 0;
}


Measured memory_bytes: 3112
#include <iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	int a=0;
	for(int i=1;i<n-1;i++)
	{
		if(arr[i]>arr[i-1]&&arr[i+1]>arr[i]||arr[i]<arr[i-1]&&arr[i+1]<arr[i])
		{
			a++;
		}
	}

	cout<<a<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cctype>
#include<cstdio>
using namespace std;
int main(){
    string num;
    int sum = 0;
    while(1){
        cin >> num;
        if(num=="0"){
            break;
        }
        for(int i=0;i<(int)num.size();i++){
            sum = sum + (int)num[i] -48 ;
        }
        cout << sum << endl;
        sum = 0;
        
    }
    return 0;
}


Measured memory_bytes: 3212
package main

import "fmt"

const mod = 1000000007

func main() {
	var n int
	fmt.Scan(&n)

	as := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&as[i])
	}

	cs := []int{0, 0, 0}
	ans := 1
	for i := 0; i < n; i++ {
		a := as[i]
		c := 0
		idx := -1
		for k, v := range cs {
			if a == v {
				c++
				idx = k
			}
		}
		if idx == -1 {
			fmt.Println(0)
			return
		}
		cs[idx]++

		ans *= c
		ans %= mod
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504
# -*- coding: utf-8 -*-
str_S = input()
len_S = len(str_S)
num_S = int(str_S, 2)
mask = 0B0

for i in range(len_S):
    mask = mask << 1
    if i % 2 == 0:
        mask += 1

cnt_one = bin(mask ^ num_S).count("1")

print(min(cnt_one, len_S - cnt_one))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(){
  int D; cin >> D;
  if(D==25) cout << "Christmas" << endl;
  else if(D==24) cout << "Christmas Eve" << endl;
  else if(D==23) cout << "Christmas Eve Eve" << endl;
  else  cout << "Christmas Eve Eve Eve" << endl;
  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;

typedef pair<int, int> P;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int H, W, sx, sy, gx, gy;
    cin >> H >> W;
    --sx;
    --sy;
    --gx;
    --gy;
    sx = 0, sy = 0;
    gx = H-1, gy = W-1;
    vector<string> s(H);
    for(int i = 0; i < H; ++i){
        cin >> s[i];
    }

    int cou1 = 0;
    rep(i,H){
      rep(j,W){
        if(s[i][j] == '.') cou1++;
      }
    }
    int dist[51][51];
    fill(dist[0], dist[H], INF);
    queue<P> que;
    dist[sx][sy] = 0;
    que.push(P(sx, sy));
    while(!que.empty()){
        P p = que.front();
        que.pop();
        int x = p.first;
        int y = p.second;
        
        for(int i = 0; i < 4; ++i){
            int nx = x + dx[i], ny = y + dy[i];
            if(nx < 0 || nx >= H || ny < 0 || ny >= W)  continue;
            if(s[nx][ny] == '#')    continue;
            
            if(dist[nx][ny] > dist[x][y] + 1){
                dist[nx][ny] = dist[x][y] + 1;
                que.push(P(nx, ny));
            }
        }
    }
    if(dist[gx][gy] == INF) cout << -1 << endl;
    else cout << cou1 - dist[gx][gy] - 1 << endl;
}

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

int N, M;
vector<vector<int>> D;
vector<int> S;

void bfs() {
  queue<int> que;
  que.push(0);
  for (int i = 0; i < N; i++) S.at(i) = -1;
  
  while (!(que.empty())) {
    int now = que.front();
    que.pop();
    for (int i = 0; i < D.at(now).size(); i++) {
      if (S.at(D.at(now).at(i)) == -1) {
        S.at(D.at(now).at(i)) = now;
        que.push(D.at(now).at(i));
      }
    }
  }
  
}

int main() {
  cin >> N >> M;
  D.resize(N);
  S.resize(N);
  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    A--;
    B--;
    D.at(A).push_back(B);
    D.at(B).push_back(A);
  }
  
  bfs();
  cout << "Yes" << endl;
  for (int i = 1; i < N; i++) {
    cout << S.at(i) + 1 << endl;
  }
}

Measured memory_bytes: 10280
inline = list(map(int,input().split()))
N = inline[0]
x = inline[1]
inline = list(map(int,input().split()))
two = []
cost = 0;
for i in range(N-1):
    two.append(inline[i]+inline[i+1])

for i in range(N-2):
    if two[i] > x:
        cost += (two[i]-x)
        two[i+1] -= min((two[i]-x),inline[i+1])

if two[-1]>x:
    cost += (two[-1]-x)

print(cost)


Measured memory_bytes: 14060
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <map>
#include <queue>
#include <bitset>
#include <sstream>
using namespace std;
typedef long long ll;

bool Check(ll i){
        for(int k=2;k*k <= i; k++){
                if(i%k==0){
                        return false;
                }
        }
        if(i%5==1)
        return true;
        else return false;
}


int main(){
        ll N;
        cin >> N;
        vector<ll> A;
        for(ll i=2; i<=55555; i++){
                if(Check(i)) A.push_back(i);
        }
//      for(int i; i<A.size(); i++){
//              cout << A[i] << endl;
//      }
        for(int i; i<N; i++){
                cout << A[i] << " ";
        }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define BeatMeScanf ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
const int mod=1e9+7;

ll solve(vector<ll>v){
    ll sum=0,cnt0,cnt1;

    for(int i=0;i<=60;i++){
        cnt0=0,cnt1=0;
        for(int j=0;j<v.size();j++){
            ll x=v[j]%2;
            v[j]/=2;
            if(x%2==0) cnt0++;
            else cnt1++;
        }
        sum=(sum+((cnt0*cnt1)%mod)*((1LL<<i)%mod))%mod;
    }
    return sum;
}

int main(){
    BeatMeScanf;
    int n;
    while(cin>>n){
        vector<ll>v(n);
        for(int i=0;i<n;i++) cin>>v[i];
        ll ans=solve(v);
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 4992
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int ans = 0;
        int tmp = 0;
        for (int i = 0; i < s.length(); i++) {
            if(s.charAt(i) == 'A' ||s.charAt(i) == 'T' ||s.charAt(i) == 'C' ||s.charAt(i) == 'G'){
                tmp++;
            }else if(ans < tmp){
                ans = tmp;
                tmp = 0;
            }
        }
        if(ans < tmp) ans = tmp;
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define rep(i, z, n) for(ll i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n;
  ll R=0,G=0,B=0;
  ll res=0;
  string s;
  cin >> n;
  cin >> s;
  rep(i,0,n){
    if(s[i]=='R'){
      R++;
    }else if(s[i]=='G'){
      G++;
    }else{
      B++;
    }
  }
  ll rgb=R*G*B;
  rep(i,0,n){
    rep(j,i+1,n){
      if(2*j-i>=n) continue;
      res+=s[i]!=s[j] && s[j]!=s[2*j-i] && s[i]!=s[2*j-i];
    }
  }
  cout << rgb-res <<endl;
  return 0;
}


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

#define ll long long
#define pb push_back

const int maxn = 1e5 + 20;

int a[maxn] , b[maxn];

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

	int n;
	cin >> n;

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

	sort(b , b + n);

	int res = 0;
	for(int i = 0; i < n; i++)
	{
		int k = lower_bound(b , b + n , a[i]) - b;
		res += (k & 1) && ((i & 1) == 0);
	}
	cout << res << endl;
}
















Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

const int N = 10;

int cnt[N][N];

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

    int n;
    cin >> n;
    for (int i = 0; i <= n; i++) {
        string s = to_string(i);
        if (s.back() == '0' || s.front() == '0') continue;
        cnt[s.front() - '0'][s.back() - '0']++;
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            ans += cnt[i][j] * cnt[j][i];
        }
    }
    cout << ans << endl;
}   


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

int main()
{
    string s;
    cin >> s;
    string t;
    cin >> t;
    int ans = 0;

    string str = s+s;

    ans = (int)str.find(t);
    
    if (ans != -1) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;



}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
#define INF 1e9 //10^9
#define MOD 1000000007
#define INFL 100000000000000000//10^18 = 2^60


int main(void){
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cin >> B[i];
    int ans = 0;
    for(int i = 0; i < N; i++){
        int res = 0;
        for(int j = 0; j <= i; j++){
            res += A[j];
        }
        for(int j = i; j < N; j++){
            res += B[j];
        }
        ans = max(ans, res);
    }
    cout << ans << endl;
}



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

m = []
for i in range(N):
    m.append(int(input()))
    
komugi = sum(m)
dona = N

while True:
    komugi += min(m)
    if komugi>X:
        break
    else:
        dona += 1
        
    
print(dona)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define fst first

string s;
int id;
void eat(char c){
  assert(s[id] == c);
  id++;
}
char peek(){
  return s[id];
}
char pop(){
  return s[id++];
}
bool left(){
  return id < (int)s.size();
}
int number(){
  int res = 0;
  while (isdigit(peek())) {
    res = res * 10 + pop() - '0';
  }
  return res;
}
int solve(){
  eat('[');
  int res = 0;
  vi vec;
  if (isdigit(peek())) {
    res = number() / 2 + 1;
    eat(']');
  } else {
    while (peek() != ']') {
      vec.pb(solve());
    }
    sort(ALL(vec));
    eat(']');
    REP(i,(int)vec.size() / 2 + 1){
      res += vec[i];
    }
  }
  return res;
}


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  REP(i,n){
    id = 0;
    cin >> s;
    cout << solve() << endl;
  }
  return 0;
}


Measured memory_bytes: 3264
main::IO()
main = do
    _ <- getLine
    n <- map read . words <$> getLine
    let evenlist = filter even n
    putStrLn $ if check evenlist then "APPROVED" else "DENIED"

check :: [Int] -> Bool
check (x:xs) = if (mod x 3 ==0) || (mod x 5 ==0)
	then check xs
    else False
check [] = True

Measured memory_bytes: 4316
// AOJ Volume 0 Problem 0047

#include <stdio.h>

int main(void)
{
    char str[4];
    int cup[3];
	int tmp;
	
	cup[0] = 1;
	cup[1] = cup[2] = 0;
	
    while (scanf("%s", str) != EOF){
		tmp = cup[str[0] - 'A'];
		cup[str[0] - 'A'] = cup[str[2] - 'A'];
		cup[str[2] - 'A'] = tmp;
    }
	
	if (cup[0] == 1){
		printf("A\n");
	}
	if (cup[1] == 1){
		printf("B\n");
	}
	if (cup[2] == 1){
		printf("C\n");
	}
		
	return (0);
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
    ll n;
    cin >> n;
    ll ans = 0;
    REP(i,n+1) {
        int keta = 0;
        ll temp = i;
        while (temp != 0)
        {
            keta++;
            temp/=10;
        }
        if (keta  % 2 == 1) ans++;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> x(n);
    for(int i = 0; i < n; i++)
    {
        cin >> x[i];
    }

    ll ans = 0;
    for(int i = 0; i < n-1; i++)
    {
        ll d = x[i+1] - x[i];
        ans += min(d * a, b);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
        
        System.out.println(a.substring(0,1) + b.substring(1,2) + c.substring(2));
    } 
}


Measured memory_bytes: 39072
solve :: [Float] -> String
solve [a,b,c,d,e,f,g,h] 
  | (d-b)/(c-a) == (h-f)/(g-e) = "YES"
  | otherwise = "NO"
 
main = getContents >>= mapM_ putStrLn . map solve . tail . map (map read . words) . lines

Measured memory_bytes: 4332
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
ll from, to, cost;
bool operator<(const E &b) const { return cost < b.cost; }
bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
template<typename T>
void print_vec(vector<T>a) {
	for (int i = 0; i < a.size(); i++) {
		cout << (i == 0 ? "" : " ") << a[i];
	}
	cout << endl;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
int a[4000];
bool used[3000][3000];
int dp[3000][3000];
//先頭がi、末尾がjの時のX-Yの値
//先頭-末尾でいまどちらの手番化を求められる。
int solve(int x, int y) {
	int res;
	if (x > y) return 0;
	if (used[x][y]) return dp[x][y];
	if (!((n - (y - x + 1)) % 2)) {
		//太朗, maximam
		res = max(solve(x + 1, y) + a[x], solve(x, y - 1) + a[y]);
	}
	else {
		res = min(solve(x + 1, y) - a[x], solve(x, y - 1) - a[y]);
	}
	used[x][y] = 1;
	return dp[x][y] = res;
}
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	cout << solve(0, n - 1) << endl;
}

Measured memory_bytes: 79488
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int mx = max({a, b, c});
	cout << a+b+c+9*mx;
	return 0;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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 dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

Vi p_list(ll n){
   //n以下の素数のリスト
   Vi a(n + 1, 0);
   Vi p;
   FOR(i, 2, n + 1){
      if(a[i] == 0){
         p.push_back(i);
         for(ll j = 2 * i ; j <= n; j += i) a[j]++;
      }
   }
   return p;
}

ll greater_than(ll n, const Vi& v){
   //vの要素のうちn以上のものの個数
   Vi w = v;
   SORT(w);
   return (w.end() - lower_bound(w.begin(), w.end(), n));
}
int main(){
   ll n; cin >> n;
   Vi p = p_list(n);
   Vi a(p.size(), 0);
   REP(i, p.size()){
      ll temp = n / p[i];
      while(temp > 0){
         a[i] += temp;
         temp /= p[i];
      }
   }
//   REP(i, p.size()) printf("p = %lld, ord_p (N!) = %lld\n", p[i], a[i]);
   ll ans = 0;
   ans += greater_than(74, a);
   ans += greater_than(24, a) * (greater_than(2, a) - 1);
   ans += greater_than(14, a) * (greater_than(4, a) - 1);
   ans += greater_than(4, a) * (greater_than(4, a) - 1) * (greater_than(2, a) - 2) / 2;
   cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

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

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

const int MOD = 1000000007;

struct Pony
{
    long a, b;
 
    Pony(long a_, long b_)
    {
        a = a_;
        b = b_;
    }
 
    bool operator<(const Pony &another) const
    {
        return b < another.b;
    };
};

int fac(int k){
    int sum = 0;
    for (int i = 1; i <= k; ++i)
    {
        sum += i;
    }
    return sum;
}

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

  int n;

  cin >> n;

  int cnt = 0;

  for(int i=1;i<=n; i++) {
        if(i >= 1 && i <= 9) cnt++; 
    if (i >= 100 && i <= 999) cnt++;
    if(i >= 10000 && i <= 99999)cnt++;
  }
  
  cout << cnt << endl;
}


Measured memory_bytes: 888
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, sX, mod = mapint()

X = sX
s = set()
s.add(X)
s_loop = set()
ans = X
loop = 0
loops = []
i = -1
for i in range(min(10**5*2+10, N-1)):
    X = pow(X, 2, mod)
    if X in s:
        if X in s_loop:
            loops.append(X)
            break
        loop += X
        s_loop.add(X)
        loops.append(X)
    s.add(X)
    ans += X

rest = N-i-2
if rest:
    ans += (rest//len(s_loop))*loop
    amari = rest%len(s_loop)+1
    for i in range(amari):
        ans += loops[i]
    print(ans)
else:
    print(ans)

Measured memory_bytes: 86032
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int n;
	cin >> n;
	vector<int> a(n);
	REP(i, n) cin >> a[i];
	bool ch = true;
	REP(i, n) if(a[i] % 2 == 0 && a[i] % 6 != 0 && a[i] % 10 != 0) ch = false;
	if (ch) cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;
	
	//cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  string s;
  cin>>s;
  map<char,ll> m;
  for(int i=0;i<s.size();i++){
    m[s[i]]++;
  }
  ll c=0;
  for(int i=0;i<26;i++){
    ll j=m[(char)('a'+i)];
    c+=j*(j+1)/2;
  }
  ll j=(ll)s.size();
  cout<<j*(j+1)/2+1-c;
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>>
using namespace std;
#define rep(i,n) for(auto i=0; i<(n); i++)
#define mem(x,val) memset((x),(val),sizeof(x));
#define rite(x) freopen(x,"w",stdout);
#define read(x) freopen(x,"r",stdin);
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define pb push_back
#define clr clear()
#define inf (1<<30)
#define ins insert
#define fi first
#define se second
#define eps 1e-9
typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
typedef map<int, int> mii;
typedef map<st, int> msi;
typedef set<int> si;
typedef set<st> ss;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
int main() {
	//freopen("in.txt", "r", stdin);
	int a, b;
	cin >> a >> b;
	int s1 = a + a - 1;
	int s2 = b + b - 1;
	int s3 = a + b;
	cout << max(s1, max(s2, s3)) << endl;
	//cout << "Hello" << endl;
	return 0;
}

Measured memory_bytes: 256