akhauriyash/Code-Regression huggingface dataset:
from collections import deque
import numpy as np
h, w = map(int, input().split())
S = [input() for _ in range(h)]
dy = [1, 0, -1, 0]
dx = [0, 1, 0, -1]
def search(sy, sx):
  if S[sy][sx] == "#":
    return -1
  dist = [[-1]*w for _ in range(h)]
  dist[sy][sx] = 0
  dq = deque()
  dq.append((sy, sx))
  while dq:
    y, x = dq.popleft()
    for i in range(4):
      ny = y+dy[i]
      nx = x+dx[i]
      if 0<=ny<h and 0<=nx<w:
        if S[ny][nx] == "#":
          continue
        if dist[ny][nx] != -1:
          continue
        dist[ny][nx] = dist[y][x] + 1
        dq.append((ny, nx))
  A = np.array(dist)
  return A.max()
ans = 0
for i in range(h):
  for j in range(w):
    ans = max(ans, search(i, j))
print(ans)

Measured memory_bytes: 20700
/*
1. I'm the Future Red Coder :)
2. Hopefully, I'll be Yellow Soon.
*/
#include<bits/stdc++.h>
#define mod 998244353 //1000000007
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
ll power(ll a,ll b,ll m=mod) {
    if (b==0) return 1;
    ll c = power(a,b>>1,m);
    c = (c*c)%m;
    if (b&1) return (c*a)%m;
    return c;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}
/*struct node {
    int l,r,nq;
};
bool compare(const node& a,const node& b) {
    if (a.r != b.r) return a.r<b.r;
    return a.l<b.l;
}*/
/* ******* DSU START ****** */
/*
const int dsusize = (int)1e5+5;
struct node {
    int data;
    int rk,pn;
}dsu[dsusize];
//ll fans;
void initialize(int n) {
    REP(i,1,n) {
        dsu[i].data = 1;
        dsu[i].rk = 0;
        dsu[i].pn = i;
    }
}
int fnd(int i) {
    if (dsu[i].pn != i) dsu[i].pn = fnd(dsu[i].pn);
    return dsu[i].pn;
}
void unn(int i,int j) {
    i = fnd(i);
    j = fnd(j);
    if (i!=j) {
        //fans -= dsu[i].data*dsu[j].data;
        if (dsu[i].rk>dsu[j].rk) {
            dsu[j].pn = i;
            dsu[i].data += dsu[j].data;
        }
        else {
            dsu[i].pn = j;
            dsu[j].data += dsu[i].data;
            if (dsu[i].rk==dsu[j].rk) {
                dsu[j].rk++;
            }
        }
    }
}
*/
/* ******* DSU END****** */

const int N = (int)2e5+5;
const int Q = 250;
pi a[N];
void solve() {
    int n;
    cin>>n;
    REP(i,1,n) {
        cin>>a[i].first;
        a[i].second = i;
    }
    sort(a+1,a+n+1);
    REP(i,1,n) {
        if (i!=a[n].second) cout<<a[n].first;
        else cout<<a[n-1].first;
        cout<<"\n";
    }
}
int main() {
    //freopen("class_treasurer.txt","r",stdin);
    //freopen("output.txt","w",stdout);

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

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 3200
n = int(input())

if n < 10:
    print(n)
elif 10<= n <100:
    print(9)
elif 100<= n <1000:
    print(n-90)
elif 1000<= n <10000:
    print(909)
elif 10000<= n <100000:
    print(n-9090)
else:
    print(90909)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
const int mod=998244353;
using namespace std;
int n,a[100010],ans=1;
int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=0;i<n;i++){
		ans=1ll*ans*gcd(a[i+1],i)%mod;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

vvpll G;
vl visited;
vl d(MAX_N);
bool ok = true;

void dfs(ll v, ll dist) {
    if(visited[v]) {
        if(d[v] != dist) {
            ok = false;
        }
        return;
    }
    visited[v] = 1;
    d[v] = dist;
    for(auto p : G[v]) {
        ll u = p.first;
        ll cost = p.second;
        dfs(u, d[v] + cost);
    }
}

int main() {
    ll n, m;
    cin >> n >> m;    

    G.resize(n);
    rep(i, m) {
        ll L, R, D;
        cin >> L >> R >> D;
        L--;  R--;
        G[L].pb(make_pair(R, D));
        G[R].pb(make_pair(L, -D));
    }

    visited.resize(n);
    rep(v, n) {
        if(!visited[v]) {
            dfs(v, 0);
        }
    }

    if(ok) {
        out("Yes");
    }
    else {
        out("No");
    }
    
    re0;
}

Measured memory_bytes: 16384
n = int(input())

s = input()

result = 0
for i in range(1, len(s)):
    f_s = s[:i]
    b_s = s[i:]
#    print(f_s)
#    print(b_s)
    
    f_s_set = set(f_s)
    b_s_set = set(b_s)
    
    matched_s = list(f_s_set & b_s_set)
    if(len(matched_s) > result):
        result = len(matched_s)

print(result)

Measured memory_bytes: 3064
dic = {}
for _ in range(int(input())):
    s = input()
    if s in dic:
        dic[s] +=1
    else:
        dic[s] = 1
for _ in range(int(input())):
    t = input()
    if t in dic and 1 < dic[t]:
        dic[t] -=1
    else:
        dic[t] = 0
print(max(dic.values()))

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> p(N);
  for(int &pi: p) cin >> pi;
  vector<int> q(p);
  sort(q.begin(), q.end());
  int d=0;
  for(int i=0; i<N; i++) if(p[i]!=q[i]) d++;
  cout << (d==0||d==2 ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    S=list(ST())
    if S==list("abcdefghijklmnopqrstuvwxyz"):
        print("abcdefghijklmnopqrstuvwxz")
        return 
    exist = defaultdict(int)
    N=len(S)
    for s in S:
        exist[s]+=1
    if len(S)==26:
        flag = False
        for i in range(N)[::-1]:
            s = chr(ord("a")+i)
            if S[i]==s:
                flag = True
                continue
            if flag:
                exist_s = set(S[:i+1])
                for j in range(26):
                    t = chr(ord("a")+j)
                    if t not in exist_s and t>S[i]:
                        S[i]=t
                        break
            else:
                done = False
                for i in range(N-1)[::-1]:
                    if S[i]<S[i+1]:
                        for j in range(N)[::-1]:
                            if S[i]<S[j]:
                                S[i],S[j] = S[j],S[i]
                                # S[i+1:] = S[i+1:][::-1]
                                S=S[:i+1]
                                done = True
                                break
                    if done:
                        break
                if done:
                    print(*S,sep="")
                else:
                    print(-1)
                return
            break
        print(*S,sep="")
    else:
        for i in range(26):
            s = chr(i+ord("a"))
            if exist[s]==0:
                S+=s
                break
        print(*S,sep="")
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 63596
<?php

fscanf(STDIN, '%d %d %d', $N, $M, $C);
$bArray = explode(' ', trim(fgets(STDIN)));

$a = [];
for ($i = 0; $i < $N; $i++) {
    $aArray = explode(' ', trim(fgets(STDIN)));
    $a[] = $aArray;
}

$ans = 0;
foreach ($a as $array) {
    $sum = 0;
    for ($i = 0; $i < $M; $i++) {
        $sum += $array[$i] * $bArray[$i];
    }
    $sum += $C;
    if ($sum > 0) {
        $ans++;
    }
}

echo $ans;

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

int main() {
  int k,a,b;
  cin >> k >> a >> b;
  
  for(int i = a; i <= b;i++) {
    if(i % k == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}


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

A = [0 for _ in range(N)]
B = [0 for _ in range(N)]
X = [0 for _ in range(N)]
S = N
A[0] = 1
for i in range(N - 1):
  S += abs(p[i] - p[i-1])
for i in range(N):
  X[p[i]-1] = S + i
B[0] = X[0] - 1
for i in range(1, N):
  s = max(A[i-1] + 1, X[i] - B[i-1] + 1)
  A[i] = s
  B[i] = X[i] - s
if min(min(A), min(B)) <= 0:
  m = -min(min(A), min(B)) + 1
  for i in range(N):
    A[i] += m
    B[i] += m
for i in range(N):
  if i != N - 1:
    print(A[i], end = ' ')
  else:
    print(A[i])
for i in range(N):
  if i != N - 1:
    print(B[i], end = ' ')
  else:
    print(B[i])

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

int main() {
    double a, b, x;
    cin >> a >> b >> x;
    double pi = acos(-1);
    double l = 0, r = pi/2;
    while(r - l > 1e-8) {
        double mid = (l + r) / 2;
        double bot = tan(pi/2 - mid) * b;
        double res = 0;
        if(bot > a) {
            double xie = a / tan(pi/2 - mid);
            res += a*a*(b - xie) + a*xie*a/2;
        } else {
            res = bot * a * b / 2;
        }
        if(res >= x) {
            l = mid;
        } else {
            r = mid;
        }
    }
    printf("%.10f\n", l/(2*pi)*360);
    return 0;
}

Measured memory_bytes: 768
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		char [][] arr=new char[n][m];
		long[][] dp=new long[n][m];
		for(int i=0;i<n;i++){
		    arr[i]=sc.next().toCharArray();
		    Arrays.fill(dp[i],-1);
		  //  for(int j=0;j<m;j++){
		  //      arr[i][j]=sc.next().charAt(j);
		  //      if(arr[i][j]=='#')dp[i][j]=Integer.MIN_VALUE+2;
		  //  }
		}
	    for(int i=1;i<n;i++){
	        if(arr[i][0]=='#') break;
	        dp[i][0]=1;
	    }
	        
	    for(int i=1;i<m;i++){
	        if(arr[0][i]=='#') break;
	        dp[0][i]=1;
	    }
		for(int i=1;i<n;i++){
		    for(int j=1;j<m;j++){
		        if(arr[i][j]=='.')
		            dp[i][j]=(dp[i-1][j]<=0? 0 : dp[i-1][j])+(dp[i][j-1]<=0?0:dp[i][j-1]);
		        else 
		            dp[i][j]=-100;
		        dp[i][j]%=1000000007;
		    }
		}
		System.out.println(dp[n-1][m-1]);
		
	}
}


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

typedef long long ll;

int main() {
  string s;
  cin >> s;

  int a = s[0] - '0';
  int b = s[1] - '0';
  int c = s[2] - '0';
  int d = s[3] - '0';

  if (a + b + c + d == 7)
    cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
  else if (a + b + c - d == 7)
    cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
  else if (a + b - c + d == 7)
    cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
  else if (a - b + c + d == 7)
    cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
  else if (a + b - c - d == 7)
    cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
  else if (a - b + c - d == 7)
    cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
  else if (a - b - c + d == 7)
    cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
  else if (a - b - c - d == 7)
    cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<ll>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int64_t gcd(int64_t a, int64_t b) {return b?gcd(b, a%b):a;}
int64_t lcm(int64_t a, int64_t b) {return a/gcd(a,b)*b;}
int64_t extgcd(int64_t a, int64_t b, int64_t &x, int64_t &y) { // ax+by=gcd(a, b)の解を与える
    int64_t d = a;
    if(b) {
        d = extgcd(b, a%b, y, x);
        y -= (a/b)*x;
    } else {
        x = 1; y = 0;
    }
    return d;
}

//Range Minimum Query
struct segment {
    int n;
    vector<int64_t> dat;
    // n_は範囲
    segment(int n_) { // nはn_以上の2^?
        n = 1<<(32-__builtin_clz(n_));
        if(n == 2*n_) n >>= 1;
        dat.assign(2*n-1, 0);
    }
    //更新の手順
    inline int64_t theorem(int i) {
        int64_t chld = dat[i*2+1];
        int64_t chrd = dat[i*2+2];
        return gcd(chld, chrd);
    }
    //初期化(初期状態はINT64_MAX)
    void init(const vector<int64_t> &vec) {
        int num = vec.size();
        rep(i, num) {
            dat[i+n-1] = vec[i];
        }
        rep(i, n-1) {
            dat[n-2-i] = theorem(n-2-i);
        }
    }
    // k番目の値をaに変更
    void update(int k, int64_t a) {
        // 葉の節点
        k += n-1;
        dat[k] = a;
        // 登りながら更新
        while(k>0) {
            k = (k-1)/2;
            dat[k] = theorem(k);
        }
    }
    // [a, b)の最小値
    int64_t query(int a, int b) {
        assert(a<b);
        return query_(a, b, 0, 0, n);
    }
    //kは節点の番号, [l, r)に節点が対応
    // (a, b, 0, 0, .n)で呼ぶ
    int64_t query_(int a, int b, int k, int l, int r) {
        if(a>=r || l>=b) return 0;
        if(a<=l && r<=b) return dat[k];
        else {
            int chl = k*2+1;
            int chr = k*2+2;
            int64_t vl = query_(a, b, chl, l, (l+r)/2);
            int64_t vr = query_(a, b, chr, (l+r)/2, r);
            return gcd(vr, vl);
        }
    }
};

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) {
        cin >> a[i];
    }

    segment seg(n);
    seg.init(a);
    ll ans = 0;
    rep(i, n) {
        seg.update(i, 0);
        ans = max(ans, seg.query(0, n+1));
        seg.update(i, a[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define N 200009
using namespace std;
typedef long long ll;
int main()
{
//    freopen("in.txt", "r", stdin);

    int s,w;
    cin>>s>>w;
    if(w>=s) puts("unsafe");
    else puts("safe");

    return 0;
}


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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define all(c) begin(c),end(c)

template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


const int INF = 1 << 29;

auto solve() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (a + b < c) {
        ll rem = c - a - b;
        if(rem > 0) {
            return b * 2 + a + 1;
        } else {
            return b * 2 + a;
        }

    } else {
        return b + c;
    }
}


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

    cout << solve() << endl;
//    solve();
    return 0;
}


Measured memory_bytes: 256
use std::cmp::{max, min};

use std::io::*;
use std::str::FromStr;

pub 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 n = read::<i32>();
  let mut a = vec![];

  for _ in 0..n {
    let v = read::<i32>();
    a.push(v);
  }
  let mut m = 0;
  let mut counter = 0;

  for i in a {
    if (m <= i) {
      m = i;
      counter += 1;
    }
  }

  println!("{}", counter);
}



Measured memory_bytes: 4352
n = int(input())
h = list(map(int, input().split()))

ans = 0
def solve(li_h):
    l = 0
    for i in li_h:
        if(i==0):
            l += 1
        else:
            break
    r = l + 1
    for i in li_h[l+1:]:
        if(i==0):
            break
        r += 1
    
    for i in range(l, r):
        li_h[i] -= 1
    
    return li_h

while(sum(h)!=0):
    h = solve(h)
    ans += 1

print(ans)

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

#define REP(i,n) for(int i=1;i<(n);i++)

int main() {
    string word1, word2, word3;
    cin >> word1 >> word2 >> word3;
    cout << (char)toupper(word1[0]) << (char)toupper(word2[0]) <<(char)toupper(word3[0]);
}


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

int main(){
	/*input*/
	char s[3];
	for(int i = 0; i < 3; i++)cin >> s[i];
	/*calculation*/
	bool flaga = false;
	bool flagb = false;
	bool flagc = false;
	for(int i = 0; i < 3; i++){
		switch(s[i]){
			case 'a':
			flaga = true;
			break;
			case 'b':
			flagb = true;
			break;
			case 'c':
			flagc = true;
			break;
		}
	}
	/*output*/
	if(flaga && flagb && flagc){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;;
	}
}


Measured memory_bytes: 256
#import numpy as np
import math
#from fractions import gcd

def main():

    ##get int
    first_input = list(map(lambda x:int(x), input().split(" ")))
    #second_input = list(map(lambda x:int(x), input().split(" ")))

    ##get float
    #first_input = list(map(lambda x:float(x), input().split(" ")))
    #second_input = list(map(lambda x:float(x), input().split(" ")))

    ##get string
    #first_input = input().split(" ")

    N = first_input[0]

    keihin = []
    for i in range(N):
        string_i = input()
        keihin.append(string_i)

    print(len(set(keihin)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 107724
N, T = map(int, input().split())
A = [int(x) for x in input().split()]

M = [0]*N
D = [0]*N
M[0] = A[0]
D[0] = 0

for i in range(1, N):
    M[i] = min(M[i-1], A[i])
    D[i] = A[i] - M[i]

D = sorted(D,reverse=True)
m = D[0]
cnt = 0
for i in range(N):
    if D[i] == m:
        cnt += 1
    else:
        break
print(cnt) 




Measured memory_bytes: 14244
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class B
{
	public static void Main()	
	{
		long a = GetLong();
		long b = GetLong();
		long x = GetLong();
		Console.WriteLine(b/x - (a + x - 1)/x + 1);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 13140
n = int(input())
s = [str(input()) for i in range(n)]
m = int(input())
t = [str(input()) for h in range(m)]

from collections import Counter
s = Counter(s).most_common()
t = Counter(t).most_common()
l = []
for x in range(len(s)):
    z = 'Y'
    for y in range(len(t)):
        if s[x][0] == t[y][0]:
            l.append((s[x][1]-t[y][1],s[x][0]))
            z = 'N'
            break
    if z == 'Y':
        l.append((s[x][1],s[x][0]))
l.sort()
if l[-1][0] < 0:
    print(0)
else:
    print(l[-1][0])

Measured memory_bytes: 9376
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int n;cin>>n;
    vector<ll> A(n), B(n), C(n);
    REP(i,n) cin >> A[i];
    REP(i,n) cin >> B[i];
    REP(i,n) cin >> C[i];
    sort(ALL(A)), sort(ALL(B)), sort(ALL(C));

    ll ans = 0;
    REP(i,n){
        if(B[i] > A[0] && B[i] < C[n-1]){
            ll itr_a = lower_bound(ALL(A),B[i])-A.begin();
            ll itr_c = C.end() - upper_bound(ALL(C),B[i]);
            ans += itr_a * itr_c;
        }
    }
    cout << ans << endl;
}

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

int main(int argc, char *argv[])
{
  int n, t_sc = 0, h_sc = 0;
  string taro, hanako;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> taro >> hanako;
    if(taro == hanako){
      t_sc++;
      h_sc++;
    }
    else if (taro > hanako) {
      t_sc+=3;
    } else if (hanako > taro) {
      h_sc+=3;
    }
  }
  cout << t_sc << " " << h_sc << endl;
  return 0;
}


Measured memory_bytes: 3172
n = int(input())
job = [list(map(int,input().split())) for i in range(n)]


job.sort(key = lambda x: x[1])
time = 0
ans = 0
for i in range(n):
    time += job[i][0]
    if time > job[i][1]:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 53600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	static final int N = 100;
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int[][] M = new int[N][N];
		int n = Integer.parseInt(br.readLine());
		
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				M[i][j] = 0;
		
		for(int i=0;i<n;i++){
			String[] next = br.readLine().split(" ");
			for(int j=0;j<Integer.parseInt(next[1]);j++){
				M[i][Integer.parseInt(next[j+2])-1] = 1;
			}
		}
		for(int i=0;i<n;i++){
			StringBuilder sb = new StringBuilder();
			for(int j=0;j<n;j++){
				if(M[i][j]==0)
					sb.append("0 ");
				else
					sb.append("1 ");
			}
			System.out.println(sb.toString().trim());
		}
	}
}

Measured memory_bytes: 26780
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007
#define INF 1000000001
vector<vector<int>> g;

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs( vector<int> &dist, int sv)
{
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}
	
int rec(vector<int> &dp, int sv)
{
	if(dp[sv]!=-1) return dp[sv];
	if(g[sv].empty()) return dp[sv]=0;

	int ret=-1;
	for(int v : g[sv]) ret = max(ret,rec(dp,v)+1);
	return dp[sv]=ret;

}

int main(void) {
	int n,m; cin >> n >> m;
	g.assign(n,vector<int>());
	vector<int> dp(n,-1);
	rep(i,m){
		int x,y; cin >> x >> y;
		x--;y--;
		g[x].push_back(y);
	}
	int ans = -1;
	rep(i,n) ans = max(ans,rec(dp,i));
	out(ans);
}




Measured memory_bytes: 8192
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int top=0, S[1000];
void push(int x){
    S[++top] = x;
}
int pop(void){
    top--;
    return S[top+1];
}
int main(void){
    int a,b;
    top = 0;
    char s[100];
    while(scanf("%s", s) != EOF){
        if(s[0] == '+'){
            a = pop();
            b = pop();
            push(a+b);
        }else if(s[0] == '-'){
            b = pop();
            a = pop();
            push(a-b);
        }else if(s[0] == '*'){
            a = pop();
            b = pop();
            push(a*b);
        }else{
            push(atoi(s));
        }
    }
    printf("%d\n", pop());
    return 0;
}


Measured memory_bytes: 2148
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    getLine
    as <- getIntList
    print . sum . map ((\x -> x * (x-1) `div` 2) . length) . group . sort $ scanl (+) 0 as

Measured memory_bytes: 37244
func main() {
  let n = Int(readLine()!)!
  let a = readLine()!.split(separator: " ").map { Int($0)! }

  var cEven = 0
  var dp = [Int: Int]()
  dp[-1] = 0

  for i in 0..<n {
    if i == 0 {
      cEven += a[i]
      dp[i] = 0
      continue
    }
    if i % 2 == 0 {
      cEven += a[i]
      dp[i] = max(dp[i-1]!, dp[i-2]! + a[i])
    }
    else {
      dp[i] = max(dp[i-2]! + a[i], cEven)
    }
  }

  print(dp[n-1]!)
}

main()


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/22  Problem: ABC 053 C / Link: http://abc053.contest.atcoder.jp/tasks/abc053_c  ----- */


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

	LL N; cin >> N;

	LL ans = (N / 11)*2 + (N%11?1+(N%11>6):0);


	cout << (ans) << "\n";

	return 0;
}


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

int main() {
    int N;
    cin >> N;
    double xy[N][2];
    rep(i, N) cin >> xy[i][0] >> xy[i][1];

    double dist[N][N];
    rep(i, N) rep(j, N) {
        dist[i][j] = sqrt(
            (xy[i][0] - xy[j][0]) * (xy[i][0] - xy[j][0])
            + (xy[i][1] - xy[j][1]) *(xy[i][1] - xy[j][1]));
    }

    vector<int> order;
    rep(i, N) order.push_back(i);
    int comb_num = 0;
    double all_dist_sum = 0;

    do {
        double dist_sum = 0;
        for (int i=0; i<order.size()-1; i++) dist_sum += dist[order[i]][order[i+1]];
        all_dist_sum += dist_sum;
        comb_num++;
    } while (next_permutation(order.begin(), order.end()));

    cout << fixed << setprecision(8) << all_dist_sum / comb_num << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#include<ext/rope>
//using namespace __gnu_cxx
//#include<ext/pb_ds/priority_queue.hpp>
//using namespace __gnu_pbds;
#define lowbit(x) (x&-x)
#define pb push_back
#define empb emplace_back
#define all(x) (x).begin(),(x).end()
#define clr(a,b) memset(a,b,sizeof(a))
#define caze(T) for(cin>>T;T;T--)
#define inf (1<<29)
#define Endl ('\n')
#define fi first
#define se second
#define db double
#define ldb long double
#define ll long long
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define ull unsigned long long
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
inline char nc() {
	#define SZ 1000000
	static char buf[SZ], *p1, *p2;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,SZ,stdin),p1==p2)?EOF:*p1++;
}
template<typename T>
inline int scan(T &x) {
	char c, sign=1; 
	while(!isdigit(c=nc())&&c!=EOF)if(c=='-')sign*=-1;
	if(c==EOF) return EOF;
	for(x = 0; isdigit(c); c = nc())
		x = (x<<1) + (x<<3) + (c&15);
	return x *= sign, 1;
}
template<typename T, typename...Args>
inline int scan(T &x, Args&...args) {
	return scan(x), scan(args...);
}
int main()
{
	int n;cin>>n;
	cout<<(n/2)*((n+1)/2)<<Endl;
}

Measured memory_bytes: 256
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimize("02")
using namespace std;
using ll =long long ;
const ll maxn=1e5+5,inf=1e18+5;
ll n,m,t,d,x,a[maxn],ans;
vector <ll> v;
bool mark[maxn];
string s;
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>d;
		while(d--){
			cin>>x;
			mark[x]=1;
		}
	}
	for(int i=1;i<=n;i++){
		if(!mark[i])ans++;
	}
	cout<<ans;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;

long long mod = 1000000007;

long long inv(long long x) {
    long long res = 1;
    long long k = mod - 2;
    long long y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}

int main() {
    long long X,Y;
    cin >> X >> Y;
    long long sum = X + Y;
    long long diff = X - Y;
    if(sum % 3 != 0){
        cout << 0 << endl;
    }else{
        long long moveCount = sum / 3;
        long long moveA = (moveCount - diff) / 2;
        long long moveB = (moveCount + diff) / 2;
        if(moveA < 0 || moveB < 0){
            cout << 0 << endl;
            return 0;
        }
        long long sumAB = 1;
        for(long long i = moveA + moveB; i > 0; i--){
            sumAB = (sumAB * i) % mod;
        }
        long long sumA = 1;
        for(long long i = moveA; i > 0; i--){
            sumA = (sumA * i) % mod;
        }
        long long sumB = 1;
        for(long long i = moveB; i > 0; i--){
            sumB = (sumB * i) % mod;
        }
        long long tmp = (sumA * sumB) % mod;
        tmp = inv(tmp)  % mod;
        long long result = (long long)(sumAB * tmp) % mod;
        cout << result << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define watch(x) cout<<"->"<<#x<<" : "<<x<<endl;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c)) 
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef unsigned long long llu;
const double PI = 2*acos(0.0);

signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	int res = 0;
	for(int i=0;i<n;i++)
	{
		int cnt1=0,cnt2=0;
		int j1 = i;
		int j2 = i;
		while(a[j1]>=a[j1+1]&&j1<n)++cnt1,++j1;
		while(a[j2]<=a[j2+1]&&j2<n)++cnt2,++j2;
		if(cnt1>cnt2)++res,i=j1;
		else ++res,i=j2;
	}	
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include <stdio.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: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n, ans=0, cnt=0;
    cin>>n;
 
    vector<int> h(n);
    cin>>h.at(0);
    for(int i=1; i<n; i++){
        cin>>h.at(i);
        if(h.at(i-1)>=h.at(i)) cnt++;
        else cnt=0;
        ans=max(cnt, ans);
    }
 
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/rope>
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;
//
//template<class T> using Tree = tree<T, null_type, less<T>, rb_t_tag,t_order_statistics_node_update>;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______      
 * |\  \|\  \  |\  ___ \  |\  ___ \     
 * \ \  \/  /|_\ \   __/| \ \   __/|    
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
const long long mod = 1000000007;
//const long long mod = 998244353;

// watch this
//using ll = long long;
//typedef long long LL;
#define ll long long
#undef ll

const int mxN = 610;

long long solve(multiset<pair<int, int> > L, multiset<pair<int, int> > R) {
	long long at = 0, res = 0;
	bool f = true;
	while (!R.empty()) {
		auto p = (f ? *R.begin() : *L.rbegin());
		if (p.second < p.first) {
			swap(p.first, p.second);
		}
//		cerr << p.first << ' ' << p.second << ' ' << at << ' ' << R.size()
//				<< ' ' << L.size() << '\n';
		R.erase(R.find(make_pair(p.second, p.first)));
		L.erase(L.find(p));
		if (at < p.first)
			res += p.first - at, at = p.first;
		else if (at > p.second)
			res += at - p.second, at = p.second;
		f = !f;
	}
	res += abs(at);
	return res;
}

int main(int argc, char** argv) {
	//#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	//#endif

	int N;
	cin >> N;
	vector<pair<int, int> > a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i].first >> a[i].second;
	}
	long long res = 0;
	for (int f = 0; f < 2; f++) {
		multiset<pair<int, int> > L, R;
		for (auto p : a)
			L.insert(p), R.insert( { p.second, p.first });
		res = max(res, solve(L, R));
		for (int i = 0; i < N; i++)
			a[i].first *= -1, a[i].second *= -1, swap(a[i].first, a[i].second);
	}
	cout << res << '\n';
	return 0;
}


Measured memory_bytes: 19840
#include <bits/stdc++.h>
using namespace std;
const int N=2005,mod=1e9+7;
int n,k;
int Fac[N*N],Inv[N*N],dp[N][N];
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=1LL*x*x%mod)
		if (y&1)
			ans=1LL*ans*x%mod;
	return ans;
}
int C(int n,int m){
	if (m<0||m>n)
		return 0;
	return 1LL*Fac[n]*Inv[m]%mod*Inv[n-m]%mod;
}
int main(){
	scanf("%d%d",&n,&k);
	if (k==1){
		puts("1");
		return 0;
	}
	for (int i=Fac[0]=1;i<=n*k;i++)
		Fac[i]=1LL*Fac[i-1]*i%mod;
	Inv[n*k]=Pow(Fac[n*k],mod-2);
	for (int i=n*k-1;i>=0;i--)
		Inv[i]=1LL*Inv[i+1]*(i+1)%mod;
	dp[0][0]=1;
	for (int i=0;i<=n;i++)
		for (int j=i;j<=n;j++){
			dp[i][j+1]=(dp[i][j+1]+dp[i][j])%mod;
			dp[i+1][j]=(1LL*dp[i][j]*C(k*(n-i)-(j-i)-1,k-2)+dp[i+1][j])%mod;
		}
	printf("%lld",1LL*dp[n][n]*Fac[n]%mod);
	return 0;
}

Measured memory_bytes: 47360
#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>;

int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int ans;
	if(c >= b) ans = 0;
	if(c >= a && d > b) ans = b-c;
	if(c >= a && d <= b) ans = d-c;
	if(d <= a) ans = 0;
	if(c <= a && d >= b) ans = b-a;
	if(c <= a && d < b && d >= a) ans = d-a;
    if(ans < 0) ans = 0;
	cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include<time.h>
#include<stdlib.h>
#define pb push_back
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define clr(x) x.clear()
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define mp make_pair
#define hell 1000000007

using namespace std;

int main()
{
   	IOS
	int a,b;
	cin>>a>>b;
	if(a<=5)
        cout<<"0\n";
    else if(a>=6&&a<=12)
        cout<<b/2<<"\n";
    else
        cout<<b<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#include <bitset>
#include <complex>
#include <cassert>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define GI(i) (scanf("%d",&i))
#define GLL(i) (scanf("%lld",&i))
#define GD(i)  (scanf("%lf",&i))
#define PB          push_back
#define MP          make_pair
#define MT          make_tuple
#define GET0(x)     (get<0>(x))
#define GET1(x)     (get<1>(x))
#define GET2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       (1LL<<60)
#define LLMIN       -(1LL<<60)
#define IMAX        (1<<30)
#define IMIN        -(1<<30)
typedef long long LL;
using namespace std;

int H,W,D;
int Q;

int main(void){
    GI(H);GI(W);GI(D);
    vector<pair<int, int> > numToPos(H*W);
    REP(i,H)REP(j,W){
        int a;
        GI(a);
        a--;
        numToPos[a] = MP(i,j);
    }
    vector<vector<int> > sumCost(D);
    for(int i=0;i<D;i++)
        for(int j=0;i+j*D<H*W;j++){
            if(j==0)
                sumCost[i].PB(0);
            else{
                int xd = numToPos[i+j*D].first - numToPos[i+(j-1)*D].first;
                int yd = numToPos[i+j*D].second - numToPos[i+(j-1)*D].second;
                sumCost[i].PB(abs(xd) + abs(yd) + sumCost[i][j-1]);
            }
        }
    int Q;
    GI(Q);
    REP(i,Q){
        int L,R;
        GI(L);GI(R);
        L--;R--;
        int res = sumCost[R%D][R/D] - sumCost[L%D][L/D];
        printf("%d\n",res);
    }
    return 0;
}


Measured memory_bytes: 6016
s = str(input())
list_s = list(s)
list_comma = [0]*(len(list_s)-1)
list_memo = []
ans = 0
for i in range(2**(len(s)-1)):
    list_memo = []
    bib = bin(i)[2:]
    bib = str(bib).zfill(len(s)-1)
    list_bib = list(bib)
    for j in range(len(list_bib)):
        if list_bib[j] == "0":
            list_bib[j] = ""
        else:
            list_bib[j] = ","
    for l in range(len(list_s)-1):
        list_memo.append(list_s[l])
        list_memo.append(list_bib[l])
    list_memo.append(list_s[-1])
    calc = "".join(list_memo)
    calc_list = list(calc.split(","))
    for number in calc_list:
        ans += int(number)
print(ans)


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


int N;
int a[1000000]={};
int O_num=0;
int T_num=0;
int Z_num=0;
void input(){
cin>>N;
for(int i=0;i<N;i++){
	cin>>a[i];
	a[i]=a[i]%3;
	if(a[i]==0){
		Z_num++;
	}else if(a[i]==1){
		O_num++;
	}else if(a[i]==2){
		T_num++;
	}	
  }
}


int main(){
	input();
	int x=abs(T_num-O_num);
	if(Z_num==N){
		cout<<1;	
	}else if(x<=3){
		cout<<N;
	}else{
	cout<<(Z_num+3+min(T_num,O_num)*2);
	}
	cout<<endl;
	return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N; cin >> N;
    string S; cin >> S;
    using P = pair<char, i64>;
    vector<P> A;
    A.emplace_back(S[0], 1);
    REP(i, N - 1) {
        if (A[A.size() - 1].first == S[i + 1]) A[A.size() - 1].second++;
        else A.emplace_back(S[i + 1], 1);
    }

    i64 prep = 0;
    i64 append = 0;
    i64 C = 0;
    REP(i, A.size()) {
        C += (A[i].first == '(' ? 1 : -1) * A[i].second;
        if (C < 0) {
            prep += -1 * C;
            C = 0;
        }
    }
    if (C > 0) append = C;

    REP(i, prep) S = '(' + S;
    REP(i, append) S += ')';

    cout << S << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(), (a).end()

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

    long N, M;
    cin >> N >> M;

    vector<long> A(N);
    for (long n = 0; n < N; n++)
    {
        cin >> A[n];
    }

    vector<pair<long, long>> CB(M);
    for (long m = 0; m < M; m++)
    {
        cin >> CB[m].second >> CB[m].first;
    }

    sort(A.begin(), A.end());
    sort(CB.begin(), CB.end());

    long A_idx = 0;
    for (int m = M - 1; m >= 0; m--)
    {
        long b = CB[m].second, c = CB[m].first;
        while (A[A_idx] < c && b > 0)
        {
            A[A_idx] = c;
            A_idx++;
            b--;
        }
    }

    long answer = 0;
    for (long n = 0; n < N; n++)
    {
        answer += A[n];
    }

    cout << answer << '\n';

    return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>

void trace (int a[], int n) {
  int i;
  
  for (i = 0; i < n; i++) {
    if (i >= 1) printf(" ");
    printf("%d", a[i]);
  }
  printf("\n");
  
}

int main () {
  int *a, i, j, k, n, key;
  
  scanf("%d", &n);
  a = (int *)malloc(sizeof(int) * n);
  
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  
  trace(a, n);
    
  for (i = 1; i < n; i++) {
    key = a[i];
    j = i - 1;
    
    while (j >= 0 && a[j] > key) {
      a[j + 1] = a[j];
      j--;
    }
    
    a[j + 1] = key;
    
    trace(a, n);
  }
  
  free(a);
  
  return 0;
}

Measured memory_bytes: 604
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int a[3], b[3];
  int cnt[4];
  REP(i,4){
    cnt[i] = 0;
  }
  REP(i,3){
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    cnt[a[i]]++;
    cnt[b[i]]++;
  }
  REP(i,4){
    if(cnt[i] == 3){
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if ((c-a+b)<0)
	{
		printf("0\n");
		return 0;
	}
	else
	{
		printf("%d\n",c-a+b);
		return 0;
	}
	printf("%d\n",c-a+b);
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 1 << 30
#define LLINF LLONG_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;FOR(i,1,a)b*=i;return b;}
ll power(ll x,ll n){ll a=1;REP(i,n)a*=x;return a;}

int n,x,y;

int main()
{
  while(1)
  {
    scanf("%d",&n);
    if(n==0) return 0;
    int A = 0;
    int B = 0;
    REP(i,n)
    {
      scanf("%d %d",&x,&y);
      if(x>y) A+=(x+y);
      else if(x<y) B+=(x+y);
      else
      {
        A+=x;
        B+=y;
      }
    }
    printf("%d %d\n",A,B);
  }
}

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

int check(int n){
	int ans=n%10;
	while(n/10!=0){
		n/=10;
		ans+=n%10;
	}
	return ans;
}

int main(void) {
	long long x,y;
	int ans=1;
	cin >> x >> y;
	while(x*2<=y){
		ans++;
		x*=2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
// 参考元 #2877332

#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int N,M;
int main (){
    cin >> N >> M;
    pair<int,int> v[M];
    for(int i=0; i<M; i++){
        cin >> v[i].second >> v[i].first;
    }
    sort(v, v+M);
    int cnt = 0;
    int pos = -1;
    for(int i=0; i<M; i++){
        if( v[i].second >= pos){
            cnt++;
            pos = v[i].first;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1024