akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] card = new int[4][13];
        for(int i = 0; i < 4;i++){
            for(int j = 0; j < 13; j++){
                card[i][j] = j + 1;
                }
        }
        for(int i = 0; i < n; i++){
            String mark = sc.next();
            int num = sc.nextInt();
            if(mark.equals("S")){
                card[0][num-1] = -1;
            }
            if(mark.equals("H")){
                card[1][num-1] = -1;
            }
            if(mark.equals("C")){
                card[2][num-1] = -1;
            }
            if(mark.equals("D")){
                card[3][num-1] = -1;
            }
        }
        for(int a = 0; a < 4; a++){
            for(int b = 0; b < 13; b++){
                if(card[a][b] != -1){
                    if(a == 0){
                        System.out.println("S " + card[a][b]);
                    }
                    if(a == 1){
                        System.out.println("H " + card[a][b]);
                    }
                    if(a == 2){
                        System.out.println("C " + card[a][b]);
                    }
                    if(a == 3){
                        System.out.println("D " + card[a][b]);
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 26408
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;

static class MainClass
{
    public static void Main(string[] args)
    {
        var abc = Console.ReadLine().SplittedStringToInt32List();
        var a = abc[0];
        var b = abc[1];
        var c = abc[2];

        if (abc.Count(x => x == 5) == 2 && abc.Count(x => x == 7) == 1)
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }
        
    }


    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<long> SplittedStringToInt64List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    public const int INF = int.MaxValue / 2;
    public const long LONGINF = long.MaxValue / 2;

        // 素因数分解
    public static List<long> PrimeFactorize(long n)
    {
        var bases = n;
        var num = (long)Math.Pow(n, 0.5);
        var ls = new List<long>();
        for (int i = 2; i <= num; i++)
        {
            if (n % i == 0)
            {
                n = n / i;
                ls.Add(i);
                i--;
                continue;
            }
        }
        long nnn = 1;
        foreach (var item in ls)
        {
            nnn = nnn * item;
        }
        if (nnn != bases)
            ls.Add(n);
        return ls;
    }


    public static List<long> MakeDivisors(long n)
    {
        var ls = new List<long>();
        // ls.Add(1);
        for (int i = 1; i * i <= n; i++)
        {
            if (n % i == 0)
            {
                ls.Add(i);
                if (i != 1 && i * i != n)
                {
                    ls.Add(n / i);
                }
            }
        }
        return ls;
    }

    public static void PrintArray(int[,] array)
    {
        for (int i = 0; i < array.GetLength(0); i++)
        {
            var sb = new StringBuilder();
            for (int j = 0; j < array.GetLength(1); j++)
            {
                sb.Append(array[i, j]).Append(" ");
            }
            Console.WriteLine(sb.ToString());
        }
    }

    #endregion
}



Measured memory_bytes: 13396
import sys
input = sys.stdin.readline

N,K = map(int, input().split())
ITEM = []
for _ in range(N):
  a,b = map(int, input().split())
  ITEM.append((a,b))

# 桁DPのような形で、KをMAX数十パターン試す
# Kが1010101のとき
# K= 1010101, 1010011, 1001111, 0111111をためせばよい。
# 1を0に置き換えて、あとは1連発。
# 値は貪欲にとってよい。論理和をとって変化しなければOK
# 6 | 2 == 6 -> True, 6 | 3 == 6 -> False
def solve(X):
  res = 0
  for a,b in ITEM:
    if a | X == X:
      res += b
  #print(X,res)
  return res

wk = 1
ans = solve(K)
for i in range(1,32):
  if (K // wk) % 2 == 1:
    ans = max(ans, solve((K // (2*wk)) * 2* wk + wk-1))
  else:
    pass
  wk *= 2
  
print(ans)

Measured memory_bytes: 79364
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
const int MN = 1e5 + 5;
int n, k, q;
int arr[MN];
void update(int l, int r, int val) {
    arr[l] += val;
    arr[r+1] -= val;
}
int main() {
    cin >> n >> k >> q;
    for (int i = 0, z; i<q;i++) {
        cin >> z;
        z--;
        if (z == 0) {
            update(z+1, n-1, -1);
        }
        else if (z == n-1) {
            update(0, z-1, -1);
        }
        else {
            update(0, z-1, -1);
            update(z+1, n-1, -1);
        }
    }
    int ans = 0;
    for (int i = 0; i<n;i++) {
        if (i != 0) {
            arr[i] += arr[i-1];
        }
        if (arr[i] + k > 0) {
            cout << "Yes" << "\n";
        }
        else {
            cout << "No" << "\n";
        }
    }

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)

ll N, M, X;
ll c[12], b[12][12];
ll ans = INF;


void dfs(vector<ll> &A) {
    // 数列の長さが N に達したら打ち切り
    if (A.size() == N) {
        vector<ll> s(M);
        ll sum = 0;
        for (ll i=0; i<N; i++){
            if (A[i]==1){
                rep1(j, M){
                    s[j] += b[i][j];
                }
                sum += c[i];
            }
        }
        sort(s.begin(), s.end());
        if (s[0]>=X) ans = min(sum, ans);
        return;
    }
    for (int v = 0; v < 2; ++v) {
        A.push_back(v);
        dfs(A);
        A.pop_back();
    }
}


int main() {
    cin >> N >> M >> X;
    rep1(i, N){
        cin >> c[i];
        rep1(j, M) cin >> b[i][j];
    }
    vector<ll> A;
    dfs(A);
    if (ans != INF){
        cout << ans << endl;
    }
    else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 3648
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Map<String, Long> map = new HashMap<>();
        long count = 0L;
        for (int i = 0; i < N; i++) {
        	String s = sc.next();
        	char[] ar = s.toCharArray();
        	Arrays.sort(ar);
        	String key = new String(ar);
        	if (map.containsKey(key)) {
        		count += map.get(key);
        		map.put(key, map.get(key) + 1);
        	} else {
        		map.put(key, 1L);
        	}
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 52896
#[allow(dead_code)]
fn main() {
    let (sx, sy, tx, ty) = (i::i(), i::i(), i::i(), i::i());
    let dx = tx - sx;
    let dy = ty - sy;
    for _ in 0..dx {
        print!("R");
    }
    for _ in 0..dy {
        print!("U");
    }
    for _ in 0..dx {
        print!("L");
    }
    for _ in 0..dy + 1 {
        print!("D");
    }
    for _ in 0..dx + 1 {
        print!("R");
    }
    for _ in 0..dy + 1 {
        print!("U");
    }
    print!("L");
    print!("U");
    for _ in 0..dx + 1 {
        print!("L");
    }
    for _ in 0..dy + 1 {
        print!("D");
    }
    println!("R")
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n;
  cin >> n;
  vector<int> x(n);
  rep(i,n) cin >> x[i];
  ll ans = LLONG_MAX;
  rep(j,102){
    ll res=0;
    rep(i,n) res += (x[i]-j)*(x[i]-j);
    ans = min(res,ans);
  }
  cout << ans << endl;

  
  return 0;
    

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

int mn = INF, ans = -1;
int n, x, p[105];

int main(void) {
    cin >> x >> n;
    rep(i, 0, n) cin >> p[i];

    rep(i, -100, 102) {
        bool ok = true;
        rep(j, 0, n) {
            if (i==p[j]) ok = false;
        }
        if (ok) {
            if (abs(x-i)<mn) {
                mn = abs(x-i);
                ans = i;
            }
        }
    } 

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3624
/**
 * Combinatorial - Coin Changing Problem
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int n = parseInt(line.substring(0, line.indexOf(' ')));
			int m = parseInt(line.substring(line.indexOf(' ') + 1));

			int[] ns = new int[n + 1];
			int[] cs = new int[m];

			Arrays.fill(ns, Integer.MAX_VALUE);
			ns[0] = 0;

			StringTokenizer st = new StringTokenizer(br.readLine());
			for (int i = 0; i < m; i++) cs[i] = parseInt(st.nextToken());

			//solve
			for (int i = 0; i < m; i++) {
				for (int j = cs[i]; j < n + 1; j++) {
					ns[j] = Math.min(ns[j], ns[j - cs[i]] + 1);
				}
			}
			System.out.println(ns[n]);
		}//end while
	}//end main
}

Measured memory_bytes: 19892
#include <stdio.h>

//Compiler version gcc  6.3.0

int main()
{
  char a[110],n[1],b[4];
  int i,s,t;
  b[0]='Y';
  b[1]='e';
  b[2]='s';
  b[3]='\0';
  scanf("%s",&a);
  
  for(i=0;a[i];i++)
  {
    n[1]=a[i];
    for(t=0;a[t];t++)
    {
      if(n[1]==a[t])
      s++;
    }
    if(s%2!=0)
    {
    b[0]='N';
    b[1]='o';
    b[2]='\0';
    break;
    }
  }
  
  printf("%s",b);
  
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){
  int N;
  char S[500000];
  int W[500000],E[500000],w=0,e=0;
  int min=500000;
  
  scanf("%d",&N);
  scanf("%s",S);

  for(int i=0;i<N;i++)
    if(S[i]=='W')
      W[i]=w++;
    else
      W[i]=w;

  for(int i=N-1;i>=0;i--)
    if(S[i]=='E')
      E[i]=e++;
    else
      E[i]=e;

  for(int i=0;i<N;i++)
    if(min>W[i]+E[i])
      min = W[i]+E[i];

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

  return 0;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
int cnt[2019];
int main() {
	string s;
	cin >> s;
	int ans = 0, now = 0, p = 1;
	cnt[0] = 1;
	for (int i = s.size() - 1; i >= 0; i--){
		now = (now + (s[i] - '0') * p) % 2019;
		ans += cnt[now]++;
		p = p * 10 % 2019;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3668
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;
 
LL n,A,B;
LL a[N];
bool judge(LL x){
    LL temp=x*B;
    LL sub=A-B;
    LL sum=0;
    for(LL i=n;i>=1;i--){
        if(a[i]>temp){
            if((a[i]-temp)%sub)
                sum+=(a[i]-temp)/sub+1;
            else
                sum+=(a[i]-temp)/sub;
        }
    }
    if(sum<=x)
        return true;
    return false;
}
int main() {
    scanf("%lld%lld%lld",&n,&A,&B);
 
    LL right=0;
    for(LL i=1;i<=n;i++){
        scanf("%lld",&a[i]);
        right+=a[i]/B+1;
    }
    sort(a+1,a+1+n);
 
    LL left=1;
    while(left<right){
        LL mid=(left+right)>>1;
        if(judge(mid))
            right=mid;
        else
            left=mid+1;
    }
    printf("%lld\n",left);
 
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  
  int i, h1, h2, count = 0;
  h1 = 0;
  for (i = 0; i < N; i++){
    cin >> h2;
    if(h2 >= h1){
      count++;
      h1 = h2;
    }
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//---------------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
//--------------------------------------------------------------

void Main(){
  int n,k;
  cin>>n>>k;
  vi hor;
  int h = k-1;
  hor.pb(h);
  while(h>=1){
    h /= 2;
    hor.pb(h);
  }
  double w=1.0,win=0.0;
  while(hor[0]>n){hor.erase(hor.begin()); w/=2.0;}
  win+= w*(n-hor[0]);
  rep(i,hor.size()-1){
    w/=2.0;
    win+= w*(hor[i]-hor[i+1]);
  }
  win/=n;
  cout<<setprecision(12)<<fixed<<win<<endl;
} int main(int argc,char** argv)
{fastio; myio; Main();}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


vector<int> fac, finv, inv;

void comb_init(int n) {
  fac  = vector<int>(n);
  finv = vector<int>(n);
  inv  = vector<int>(n);
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < n; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
 
int comb(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

  comb_init(400010);

  int ans = 0;
  REP(i, min(N, K)+1){
    (ans += comb(N-1, i)*comb(N, i)) %= MOD;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int N;
    int A[300]={};
    int count[300]={};
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    
    for(int i=0;i<N;i++){
        while(A[i]%2==0){
            A[i]=A[i]/2;
            count[i]+=1;
        }
    }
    
    sort(count,count+N);
    
    printf("%d",count[0]);
    
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	int a, b, c, tmp;

	scanf("%d %d %d", &a, &b, &c);

	if (a > b){
		tmp = a;
		a = b;
		b = tmp;
	}
	if (b > c){
		tmp = b;
		b = c;
		c = tmp;
	}
	if (a > b){
		tmp = a;
		a = b;
		b = tmp;
	}

	printf("%d %d %d\n", a, b, c);

	return 0;
}

Measured memory_bytes: 596
# -*- coding: utf-8 -*-
# ローリングハッシュ
from collections import defaultdict
N=input()
s=raw_input()

str="abcdefghijklmnopqrstuvwxyz"
D={}
for i,str in enumerate(str):
	D[str]=i+1

base=27
mod=10**9+7
hash=[]

for i,x in enumerate(s):
	if i==0: hash.append(D[x])
	else: hash.append( hash[-1]*base+D[x] )

def get(l,r):
	if l==0: return hash[r-1]
	else: return hash[r-1]-hash[l-1]*pow(base,(r-l))

# 長さmを固定し、区間 [i, i + m) のハッシュ値を求めて、長さmの共通文字列があるかを判定
def check(m):
	C={}
	for i in range(N):
		if i+m<=N:
			hash_value=get(i,i+m)
			if hash_value in C:
				if m<=i-C[hash_value]:
					return True
			else:
				C[hash_value]=i
	else:
		return False

l=0
h=N

while 1<(h-l):
	m=(l+h)/2
	if check(m):
		l=m
	else:
		h=m

print l


Measured memory_bytes: 95268
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double n,k;cin>>n>>k;
    double tot=0.0;
    for(int i=1;i<=n;i++){
        double tmp=i;
        int cnt=0;
        while(tmp<k){
            tmp*=2;
            cnt++;
        }
        tot+=1.0/n*pow(0.5,cnt);
    }
    cout<<fixed<<setprecision(10)<<tot<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
typedef long long ll;
ll a[N],b[N];
int n;
ll sum1,sum2;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%lld",a+i);
    for(int i=1;i<=n;i++) scanf("%lld",b+i);
    for(int i=1;i<=n;i++) {
        if(a[i] > b[i]) sum1 += (a[i] - b[i]);
        if(a[i] < b[i]) sum2 += (b[i] - a[i])/2;
    }
    if(sum1 <= sum2) puts("Yes");
    else puts("No");
return 0;
}

Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;
using Ki = vector<vector<int>>;
using Vi = vector<int>;

int dfs(int v,int n,bool visit[8],bool G[8][8]){
    bool all=true;
    rep(i,n){
        if(!visit[i]) all=false;
    }
    if(all) return 1;
    int ret=0;
    rep(i,n){
        if(G[v][i]==false) continue;
        if(visit[i]) continue;

        visit[i]=true;
        ret+=dfs(i,n,visit,G);
        visit[i]=false;
    }
    return ret;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int n,m;
    cin>>n>>m;
    bool G[8][8];
    rep(i,n)rep(j,n) G[i][j]=false;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a][b]=true;
        G[b][a]=true;
    }
    bool visit[8];
    rep(i,8){
        visit[i]=false;
    }
    visit[0]=true;
    cout<<dfs(0,n,visit,G)<<endl;
}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int a, b;
  cin >> a >> b;
  cout << (a-1)*(b-1) << endl;
}

Measured memory_bytes: 3564
def base_10_to_n(x, n):
    ans = []
    while x > 0:
        x -= 1
        ans.append(str(x % n + 1))
        x //= n
    return ans[::-1]


a = base_10_to_n(int(input()), 26)
ans1 = ''
for i in a:
    ans1 += chr(ord('a') + int(i) - 1)

print(ans1)


Measured memory_bytes: 9184
s = list(input())
n = len(s) - 1
ans = 0
for i in range(2 ** n):
    op = [0] * n
    for j in range(n):
        op[j] = (i >> j) & 1
    val, idx = 0, 0
    for j in range(n):
        if op[j] == 0:
            pass
        else:
            mknum = ''
            for k in range(idx, j+1):
                mknum += s[k]
            val += int(mknum)
            idx = j+1
    mknum = ''
    for k in range(idx, n+1):
        mknum += s[k]
    val += int(mknum)
    ans += val
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#define INF 200000000000000
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define mk make_pair
#define en endl
#define RE return 0
#define int ll
#define P pair<int,int>
using namespace std;
int dx[5]={1,0,-1,0,0},dy[5]={0,1,0,-1,0};
int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}
int lcm(int a,int b){if(a==0){return b;} return a/gcd(a,b)*b;}

P mobi[105];
P pr[105];
int n;
int used[105];

int saiki(int m){
	// first
	int right=0,left=0;
	if(mobi[m].first){
		left=saiki(mobi[m].first);
	}
	if(mobi[m].second){
		right=saiki(mobi[m].second);
	}
	int ret=0;
	int s=pr[m].second+pr[m].first;
	if(left==0 && right==0){
		ret=s;
	}else if(right==0){
		int l=lcm(pr[m].second, left*pr[m].first);
		ret=l/pr[m].first+l/pr[m].second;
	}else if(left==0){
		int l=lcm(pr[m].second*right, pr[m].first);
		ret=l/pr[m].first+l/pr[m].second;
	}else{
		int l=lcm(right*pr[m].second, left*pr[m].first);
		ret=l/pr[m].first+l/pr[m].second;
	}
//	cout<<m<<"  "<<ret<<en;
	return ret;
}

signed main(){
	while(cin>>n&&n){
		memset(used, 0, sizeof(used));
		memset(mobi, 0, sizeof(mobi));
		memset(pr, 0, sizeof(pr));
		for(int i=1; i<=n; i++){
			cin>>pr[i].first>>pr[i].second;
			int g=gcd(pr[i].first, pr[i].second);
			pr[i].first/=g; pr[i].second/=g;
			cin>>mobi[i].first>>mobi[i].second;
			used[mobi[i].first]=used[mobi[i].second]=1; 
		}
		int root=0;
		for(int i=1; i<=n; i++){
			if(used[i]==0) root=i;
		}
//		sym
		cout<<saiki(root)<<en;
	}
}





Measured memory_bytes: 3104
#include <iostream>

using namespace std;

int main() {
  int x, y, ans{1<<30};
  cin >> x >> y;
  if (x <= y) ans = min(ans, y-x);
  if (-x <= y) ans = min(ans, x+y+1);
  if (x <= -y) ans = min(ans, -x-y+1);
  if (-x <= -y) ans = min(ans, x-y+2);
  cout << ans << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define CLEAR(a) memset(a,0,sizeof a)
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define fr freopen("input.txt", "r", stdin);
#define fw freopen("output.txt", "w", stdout);
typedef long long LL;
typedef pair<int,int> pii;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 5;
int prime[MAX];
vector<int> p;

void seive(int n)
{
  for(int i=0;i<n;i++) prime[i]=1;
  prime[0]=0;
  prime[1]=0;
     
     for(int i=2;i*i<n;i++)
     {
     if(prime[i])        
             {
                 for(int k=2;k*i<n;k++)
                 prime[k*i]=0;        
             }
     }
    REP(i, n) if(prime[i]) p.pb(i);
}

int main() {
    seive(1001);
    int n;
    cin >> n;
    LL ret = 1;
    REP(i, p.size()){
      if(p[i] > n) break;
      LL cnt = 0;
      int x = n;
      while(x){
        cnt += x/p[i];
        x /= p[i];
      }
      ret = (ret*(cnt+1))%MOD;
    }
    cout << ret;
    return 0;
}

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

int main()

{

    int a,b,c;

    map<string,int> MAP;
    map<string,int>::iterator it;
    scanf("%d ",&a);
    string s;

    for(int k=0;k<a;k++){
    scanf("%d",&b);
    if (b==0 ){

            cin >> s >> c;
	    MAP[s] = c;

            }
    else if (b==1){

            cin >> s;
	    printf("%d\n",MAP[s]);



    }
    }


    return 0;



}


Measured memory_bytes: 27944
def make(s):
    d=[]
    i=0
    ans=''
    while i<len(s):
        if s[len(s)-i-1] not in '+-[]':
            d.append(ord(s[len(s)-i-1]))
        else:
            if s[len(s)-i-1] == '+':
                if d[-1]!=ord('?'):
                    d[-1]=((d[-1]+1)-ord('A'))%26+ord('A')
            elif s[len(s)-i-1] == '-':
                if d[-1]!=ord('?'):
                    d[-1]=((d[-1]-1)-ord('A'))%26+ord('A')
            else:
                end=len(s)-i-1
                st=len(s)-i-2
                p=1
                while 1:
                    if s[st]==']':
                        p+=1
                    elif s[st]=='[':
                        p-=1
                    if p==0:
                        for j in range(len(d)):
                            ans+=chr(d[j])
                        ans+=make(s[st+1:end])
                        d=[]
                        i=len(s)-st-1
                        break
                    st-=1
        i+=1
    for j in range(len(d)):
        ans+=chr(d[j])
    return ans[::-1]

while 1:
    s=input()
    if s=='.':
        break
    for c in make(s):
        print('A' if c=='?' else c,end='')
    print()



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

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#define int128 __int128
#else
#define int128 long long
#endif

#define all(x) x.begin(), x.end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define mp make_pair
#define X first
#define Y second

using namespace std;

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

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

ll mod = 1e9 + 7;

namespace {
    ll mul(ll a, ll b) {
        ll val = a * b - (ll)((ld)a * b / mod) * mod;
        if (val < 0) val += mod;
        if (val >= mod) val -= mod;
        return val;
    }
    ll poww(ll a, ll b) {
        ll val = 1;
        a %= mod;
        while (b > 0) {
            if (b % 2) val = mul(a, val);
            a = mul(a, a);
            b >>= 1;
        }
        return val % mod;
    }
    ll inv(ll a) {
        return poww(a, mod - 2);
    }
    ll gcd(ll a, ll b) {
        return (a == 0 ? b : gcd(b % a, a));
    }
    ll gcdex(ll a, ll b, ll& x, ll& y) {
        if (a == 0) {
            x = 0; y = 1;
            return b;
        }
        ll x1, y1;
        ll d = gcdex(b % a, a, x1, y1);
        x = y1 - (b / a) * x1;
        y = x1;
        return d;
    }

    ll inv_eu(ll a, ll m) {
        ll x, y;
        ll g = gcdex(a, m, x, y);
        if (g != 1)
            assert(0);
        else {
            x = (x % m + m) % m;
            return x;
        }
    }
}

ll const maxn = 1e6 + 6;

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s; cin >> s;
    if (s.back() == 's') s += "es";
    else s += 's';
    cout << s << endl;

    return 0;
}

/*

*/

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
const int N = 25;
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};
int ans = 0;
int n, m;
vector < vector < int > > t(N + 5, vector < int > (N + 5, 0));
vector < vector < int > > a(N + 5, vector < int > (N + 5, 0));
bool ok(int x, int y, int x1, int y1, vector < vector < int > > &matrix) {
	if (x < 1 || y < 1 || x > n || y > m) return false;
	if (matrix[x][y] != 0) return false;
	if (x == x1 && y == y1) return false;
	return true;
}
int bfs(int x, int y) {
	queue < pair < int, int > > q;
	q.push({x, y});
	t = a;
	while(q.size()) {
		int a = q.front().first;
		int b = q.front().second;
		q.pop();
		for (int d = 0; d < 4; d++) {
			int new_a = a + dx[d];
			int new_b = b + dy[d];
			if (ok(new_a, new_b, x, y, t)) {
				q.push({new_a, new_b});
				t[new_a][new_b] = t[a][b] + 1;
				ans = max(ans, t[new_a][new_b]);
			}
		}
	}
}
int main() {
		cin >> n >> m;
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				char c; cin >> c; if (c == '#') a[i][j] = -1;
			}
		}
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				if (!a[i][j]) {
					bfs(i, j);
				}
			}
		}
		cout << ans << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        String k = s.substring(5, 7);
        int m = Integer.parseInt(k);
        if (m > 4) {
            System.out.println("TBD");
            return;
        }
        System.out.println("Heisei");
    }
}


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

using namespace std;
#define ll long long
#define ld long double

#define endl '\n'
#define FAST                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int MAXN = 1e5 + 5;
ll fastPow(ll x, ll b)
{
    if (b == 0)
        return 1;
    else if (!(b & 1))
    {
        return fastPow(x * x, b / 2);
    }
    else
        return x * fastPow(x * x, (b - 1) / 2);
}
//__builtin_popcount ();
struct def
{
    string h = ">";
};
int main()
{
    FAST 
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout << max((ll)(b * a),(ll)( d * c)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 2e5;
int n, k, a[N];
bool check(int b){
  int s = 0;
  FOR(i, 0, n) s += a[i]/b;
  return s <= k;
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  FOR(i, 0, n) cin >> a[i], a[i]--;
  int ng=0, ok=1e9, mid;
  while(ok-ng > 1){
    mid = (ok+ng)/2;
    (check(mid) ? ok : ng) = mid;
  }
  cout << ok << endl;
}

Measured memory_bytes: 4300
#include <bits/stdc++.h>
using namespace std;
#define elif else if
typedef long long ll;
typedef unsigned long long ull;
#define DEBUG(x) cout << (x) << endl
#define TGET(a, b) get<b>(a)

deque<char> ans;

int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++)
    {
        ans.push_back(s[i]);
    }
    int q;
    scanf("%d", &q);
    int par1, par2;
    char par3;
    bool is_reversed = false;
    while (q--)
    {
        scanf("%d", &par1);
        if (par1 == 1)
        {
            is_reversed = !is_reversed;
        }
        else
        {
            scanf("%d %c", &par2, &par3);
            if (par2 == 1 && is_reversed == false)
            {
                ans.push_front(par3);
            }
            elif (par2 == 1 && is_reversed == true)
            {
                ans.push_back(par3);
            }
            elif (par2 == 2 && is_reversed == true)
            {
                ans.push_front(par3);
            }
            elif (par2 == 2 && is_reversed == false)
            {
                ans.push_back(par3);
            }
        }
    }
    if (is_reversed)
    {
        for (int i = ans.size() - 1; i >= 0; i--)
        {
            printf("%c", ans[i]);
        }
    }
    else
    {
        for (int i = 0; i < ans.size(); i++)
        {
            printf("%c", ans[i]);
        }
    }
    printf("\n");
    return 0;
}


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

int main(){
  int N; cin >> N;
  int a;
  int count[100002]={};
  for(int i=0; i<N; i++){
    cin >> a;
    count[a]++; count[a+1]++; count[a+2]++;
  }
  int countmax=-1;
  for(int i=0; i<100002; i++){
    countmax=max(countmax,count[i]);
  }
  cout << countmax << endl;
}

Measured memory_bytes: 640
N, X, Y = [int(_) for _ in input().split()]

INF = 10 ** 9
dp = [[INF] * N for _ in range(N)]

for i in range(N - 1):
    for j in range(i + 1, N):
        dp[i][j] = j - i
        dp[j][i] = j - i

dp[X - 1][Y - 1] = 1
dp[Y - 1][X - 1] = 1

for k in [X - 1, Y - 1]:
    for i in range(N):
        for j in range(N):
            # k経由でiからjへ
            dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])

cnt = [0] * N
for i in range(N):
    for j in range(i + 1, N):
        v = dp[i][j]
        cnt[v] += 1
for i in range(1, N):
    print(cnt[i])


Measured memory_bytes: 105844
#include "bits/stdc++.h"
using namespace std;
const int MAXN = 100100;
int A[MAXN];

struct edge {
	int v;
	long long w;
	edge() {}
	edge(int v, long long w) : v(v), w(w) {};
};

vector<long long> dijkstra(int n, vector<vector<edge> >& G, int s) {
	vector<long long> d(n, 1e18);
	d[s] = 0;
	priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> que;
	que.push(make_pair((long long)0, s));
	while (!que.empty()) {
		auto p = que.top();
		que.pop();
		int u = p.second;
		long long dist = p.first;
		if (dist > d[u]) continue;
		for (edge e : G[u]) {
			if (d[e.v] > d[u] + e.w) {
				d[e.v] = d[u] + e.w;
				que.push(make_pair(d[e.v], e.v));
			}
		}
	}
	return d;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N, M, S, T;
	cin >> N >> M >> S >> T;
	S--;
	T--;
	vector<vector<edge> > G(N), rG(N);
	for (int i = 0; i < M; i++) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		a--; b--;
		G[a].emplace_back(b, c);
		G[b].emplace_back(a, c);
		rG[a].emplace_back(b, d);
		rG[b].emplace_back(a, d);
	}
	auto d = dijkstra(N, G, S);
	auto rd = dijkstra(N, rG, T);
	long long ans = 0;
	vector<long long>Ans(N);
	for (int i = 0; i < N; i++) {
		long long num = d[N - 1 - i] + rd[N - 1 - i];
		if (0 == i) {
			Ans[N - 1 - i] = num;
		}
		else {
			Ans[N - 1 - i] = min(num, Ans[N - i]);
		}
	}
	for (int i = 0; i < N; i++) {
		long long ans = 1e15;
		ans -= Ans[i];
		cout << ans << endl;
	}
	return 0;
}

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

typedef unsigned long long ll;

int main()
{
    int n;
    int i,j,k;
    cin >> n >> k;
    vector<int> d(11,0);
    for(i = 0;i < k;++i){
        cin >> j;
        d.at(j) = 1;
    }
    int ans = n;
    int number;
    while(true){
        bool flag = true;
        number = ans;
        while(number != 0){
            int digit = number%10;
            number /= 10;
            if(d.at(digit)){
                flag = false;
                break;
            }
        }
        if(flag){
            cout << ans << endl;
            return 0;
        }
        ++ans;
    }
    return 0;
}

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

int main()
{
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}

	for (int i = 0; i < w + 2; i++) {
		cout << '#';
	}
	cout << endl;
	for (int i = 0; i < h; i++) {
		cout << '#' << s[i] << '#' << endl;
	}
	for (int i = 0; i < w + 2; i++) {
		cout << '#';
	}
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define pb push_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define revv(V) reverse(allv(V))
using namespace std;
void fg(vector<int> G[], int a, int b) { G[a].pb(b); G[b].pb(a); }

const int MAXN = 100005;
const int MAXM = 100005;

vector<int> G[MAXN];

vector<int> Ans;

int A[MAXM], B[MAXM];
bitset<MAXN> chk;

int N, M;

void f(vector<int> &V, int i) {
	chk[i] = true;
	V.pb(i);
	for(int v : G[i]) if(!chk[v]) {
		f(V, v);
		return;
	}
}

int main() {
	ios::sync_with_stdio(false);

	cin >> N >> M;

	for(int i = 1; i <= M; i++) {
		cin >> A[i] >> B[i];
		fg(G, A[i], B[i]);
	}

	{
		vector<int> V;
		f(V, 1);
		Ans = V;
	}

	{
		bool flag = false;
		for(int v : G[1])
			flag |= (!chk[v]);
		if(!flag) {
			printf("%d\n", sz(Ans));
			for(int v : Ans)
				printf("%d ", v);
			puts("");
			return 0;
		}
	}

	revv(Ans);

	for(int i = 1;;) {
		int j = -1;
		for(int v : G[i]) if(!chk[v]) {
			j = v;
			break;
		}
		if(j < 0) break;
		chk[j] = true;
		Ans.pb(j);
		i = j;
	}

	printf("%d\n", sz(Ans));
	for(int v : Ans) printf("%d ", v);
	puts("");
	return 0;
}

Measured memory_bytes: 10408
#include<bits/stdc++.h>
#define fo(i, x, y) for(int i = x, _b = y; i <= _b; i ++)
#define ff(i, x, y) for(int i = x, _b = y; i <  _b; i ++)
#define fd(i, x, y) for(int i = x, _b = y; i >= _b; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
using namespace std;

const int N = 1e6 + 5;

int n;
char s[N], t[N];
int d[N], d0, p[N];

int main() {
	scanf("%d", &n);
	scanf("%s", s + 1);
	scanf("%s", t + 1);
	int ok = 1;
	fo(i, 1, n) if(s[i] != t[i]) ok = 0;
	if(ok) {
		pp("0\n"); return 0;
	}
	int w = n;
	fd(i, n, 1)	{
		if(i == 1 || t[i] != t[i - 1]) {
			while(w > 0 && (s[w] != t[i] || w > i)) w --;
			if(w == 0) {
				pp("-1\n");
				return 0;
			}
			d[++ d0] = w;
			p[d0] = i;
		}
	}
	reverse(d + 1, d + d0 + 1);
	reverse(p + 1, p + d0 + 1);
	fo(i, 2, d0) if(d[i - 1] > d[i]) {
		pp("-1\n");
		return 0;
	}
	int ans = 1;
	p[d0 + 1] = n + 1;
	d[d0 + 1] = 3 * n;
	fd(i, d0, 1) {
		int as;
		int v = p[i + 1] - 1;
		for(int l = i, r = d0 + 1; l <= r; ) {
			int m = l + r >> 1;
			if(d[m] - (m - i) >= v) as = m, r = m - 1; else l = m + 1;
		}
		ans = max(ans, as - i);
	}
	pp("%d\n", ans);
}

Measured memory_bytes: 10112
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        int n = s.Length;
        if (kaibun(s) && kaibun(s.Substring(0,(n-1)/2)) && kaibun(s.Substring((n + 3) / 2 - 1, n - (n + 3) / 2 + 1))){
            Console.WriteLine("Yes");
        } else
        {
            Console.WriteLine("No");
        }

    }

    static bool kaibun(string s)
    {
        string sRev = "";
        for(int i = s.Length - 1; i >= 0; i--)
        {
            sRev += s.Substring(i, 1);
        }
        if (s.Equals(sRev)) return true;
        return false;
    }



}





Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
int main() {

    int N;
    float D;
    cin >> N >> D;

    vector<int> X(N);
    vector<int> Y(N);

    int count = 0;

    for(int i = 0; i < N; i++){
        cin >> X.at(i) >> Y.at(i);
    
        if(pow(pow(X.at(i), 2.0) + pow(Y.at(i), 2.0), 0.5) <= D){
            count++;
        }
    }

    cout << count << endl;

}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n;
    cin >> n;
    
    if (n == 0)
    {
        cout << 0;
        return 0;
    }
    
    ll length = 0, count = 0, temp = 1;
    
    if (n > 0)
    {
        while (count < n)
        {
            count += temp;
            temp *= 4;
            
            length += 2;
        }
        
        ll arr[length] = {};
        count = 0;
        temp = 2;
        
        for (ll i = 2; i < length; i += 2)
        {
            arr[i] = arr[i + 1] = count += temp;
            temp  *= 4;
        }
        
        temp = pow(2, length - 2);
        for (ll i = length - 2; i >= 0; --i, temp /= 2)
            cout << ((n + arr[i]) / temp) % 2;
        
        return 0;
    }
    
    count = 0, temp = 2;
    while (count < abs(n))
    {
        count += temp;
        temp *= 4;
            
        length += 2;
    }
    
    ++length;
    
    ll arr[length] = {};
    count = 0;
    temp = 1;
        
    for (ll i = 1; i < length; i += 2)
    {
        arr[i] = arr[i + 1] = count += temp;
        temp  *= 4;
    }
        
    temp = pow(2, length - 2);
    for (ll i = length - 2; i >= 0; --i, temp /= 2)
        cout << ((arr[i] - n) / temp) % 2;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAX_n=1e5;
int n;
int d[MAX_n+10];
bool comp(int a,int b)
{
    return a<b;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>d[i];
    }
    sort(d+1,d+n+1,comp);
    if(d[n/2]==d[n/2+1])
    {
        cout<<"0";
        return 0;
    }
    cout<<d[n/2+1]-d[n/2];
    return 0;
}

Measured memory_bytes: 640
n=int(input())
ma,mb,mc=0,0,0
for _ in range(n):
  a,b,c=map(int,input().split())
  x,y,z=ma,mb,mc
  ma=a+max([y,z])
  mb=b+max([z,x])
  mc=c+max([x,y])
print(max([ma,mb,mc]))

Measured memory_bytes: 3064