akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define N 100

int n, G[N][N];
int d[N];
void wfs(int a, int len)
{
  int i;
  len++;
    d[a] = len;
  for(i = 0; i < n; i ++)
    {
      if(G[a][i] == 1)
	{
	  if(d[i] <= len && d[i] >= 0)
	    {
	      continue;
	    }
	  wfs(i, len);
	}
    }
}

int main()
{
  int i, j, k, u, v;
  scanf("%d", &n);
  for(i = 0; i < n; i++)
    {
      for(j = 0; j < n; j++)
	{
	  G[i][j] = 0;
	}
    }

  for(i = 0; i < n; i++)
    {
      scanf("%d %d", &u, &k);
      u--;
      for(j = 0; j < k; j++)
	{
	  scanf("%d", &v);
	  v--;
	  G[u][v] = 1;
	}
    }
  for(i = 0; i < n; i++)
    {
      d[i] = -1;
    }
  wfs(0, -1);
  for(i = 0; i < n; i++)
    {
      printf("%d %d\n", i+1, d[i]);
    }
  return 0;
} 



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll a,b;
    cin>>a>>b;
    ll x=1,c=0;
    while(x<b){
        ++c;
        x+=(a-1);
    }
    cout<<c;
    
}


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

int main(){
    using namespace std;
    size_t N;
    cin >> N;
    deque<pair<size_t, size_t>> bef, aft;
    vector<size_t> ans(N * N), a(N);
    for(size_t i = !N, A; i < N;){
        cin >> A;
        if(i)for(size_t j = i ^ i; j < i; ++j)bef.emplace_back(A, -~i);
        if(++i != N)for(size_t j = i; j < N; ++j)aft.emplace_back(N * N - A, i);
        ans[--A] = i;
    }
    sort(bef.begin(), bef.end());
    sort(aft.begin(), aft.end());
    size_t cnt{};
    auto f = [&bef, &cnt](auto& i){
        ++cnt;
        if(i)return;
        if(bef.empty())return;
        if(bef.front().first < cnt)return;
        i = bef.front().second;
        bef.pop_front();
    };
    for_each(ans.begin(), ans.end(), f);
    if(!bef.empty())return !puts("No");
    cnt ^= cnt;
    swap(bef, aft);
    for_each(ans.rbegin(), ans.rend(), f);
    if(!bef.empty())return !puts("No");
    puts("Yes");
    copy(ans.cbegin(), ans.cend(), ostream_iterator<size_t>(cout, " "));
}

Measured memory_bytes: 7168
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    string hoge;
    cin>>hoge;
    
    int count=0;
    for(int i=0;i<n;i++){
        if(i!=0){
            if(hoge.at(i)==hoge.at(i-1))count++;
        }
    }
    cout<<n-count;
}

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

#ifdef LOCAL
    #define D(a) cerr << #a << " = " << a << endl
#else 
    #define D(a) 8 
#endif
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define all(a) (a).begin(),(a).end()
#define dforn(i,n) dforsn(i,0,n)
#define forn(i,n) forsn(i,0,n)
#define si(a) int((a).size())
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first
#define endl '\n'
using pii = pair<int,int>;
using vi = vector<int>;
using ll = long long;

int main() {
	fastio;
	
    string a,b; cin >> a >> b;
    int sa = si(a), sb = si(b);
    string ans;
    int ca = 0, cb = 0;
    forn(i, sa+sb) {
        if (i % 2 == 0 || cb == sb) ans += a[ca++]; 
        else ans += b[cb++];
    }
    cout << ans << endl;	
	return 0;
}


Measured memory_bytes: 3532
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**10
mod = 10**9 + 7


def f():
    s = input()
    t = ''
    r = -1
    for c in s:
        if t != c:
            r += 1
            t = c
    return r

print(f())


Measured memory_bytes: 5712
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

from collections import deque
N = ri()
a = deque(ri_())
i = 0
cnt = 0
if not 1 in a:
    print(-1)
    exit()
while i < N:
    if a[i] == i + 1:
        i += 1
    else:
        a.popleft()
        N -= 1
        cnt += 1
print(cnt)

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

typedef long long ll;
const ll mod=1e9+7;
const ll N=5e5+1;
const ll INF=1e10;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	ll n;
	cin>>n;
	string ans="";
	while(n){
		int rem=n%26;
		if(!rem) rem=26,n--;
		ans+='a'+rem-1;
		n/=26;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans;
}


Measured memory_bytes: 3644
// D - Walk and Teleport
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
	int n,a,b; cin>>n>>a>>b;
	vector<ll> dp(n);
	int xi,xj; cin>>xj;
	for(int i=0; i<n-1; i++){
		xi = xj; cin>>xj;
		dp[i+1] = dp[i] + min((ll)b, (ll)(xj-xi)*a);
	}
	cout<< dp[n-1] <<endl;
}

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

int main() {
	int a, b, c, d, e, f, g, h, s, t;
	cin >> a >> b >> c >> d >> e >> f >> g >> h;

	s = a + b + c + d;
	t = e + f + g + h;

	if (s > t) {
		cout << s << endl;
	}
	else {
		cout << t << endl;
	}

	return 0;
}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define MAXN 200005
#define INF 16843009
#define LL long long
using namespace std;

LL N,M,K;
LL r = 3;

map<LL,int> cnt;
map<LL,int>::iterator p;

LL ans[MAXN];

void work(LL x, LL y){	
	for(int i=max(x,r);i<=min(x+r-1,N);i++){
		for(int j=max(y,r);j<=min(y+r-1,M);j++){
			++cnt[M*i + j];
		}
	}
	
}

int main(){
	
	cin>>N>>M>>K;
	
	int x,y;
	for(int i=1;i<=K;i++){
		cin>>x>>y;
		work(x,y);
	}
	
	for(p=cnt.begin();p!=cnt.end();p++){
		ans[p->second]++;
		ans[0]--;
	}
	
	ans[0] += (N-r+1) * (M-r+1);
	
	for(int i=0;i<=r*r;i++){
		cout<<ans[i]<<endl;
	}
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

bool used[404][404];
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
int h, w;
string s[404];

pll bfs(int sx, int sy){
	queue<pair<pii, bool>> q;
	q.push(make_pair(pii(sx, sy), true));
	ll cnt1=0, cnt2=0;
	while(q.size()){
		pair<pii, bool> p=q.front();
		q.pop();
		REP(i, 4){
			int nx=p.first.first+dx[i];
			int ny=p.first.second+dy[i];
			if(nx>=0 && nx<h && ny>=0 && ny<w && !used[nx][ny]){
				if(p.second){
					if(s[nx][ny]=='.'){
						++cnt2;
						q.push(make_pair(pii(nx, ny), false));
						used[nx][ny]=true;
					}
				}
				else{
					if(s[nx][ny]=='#'){
						++cnt1;
						q.push(make_pair(pii(nx, ny), true));
						used[nx][ny]=true;
					}
				}
			}
		}
	}
	return pll(cnt1, cnt2);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>h>>w;
	REP(i, h){
		cin>>s[i];
	}
	ll ans=0;
	REP(i, h){
		REP(j, w){
			if(s[i][j]!='#'){
				continue;
			}
			pll cnt=bfs(i, j);
			ans+=cnt.first*cnt.second;
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
// greater<int>()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x%y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;
int main() {
	string s;
	int K;

	cin >> s >> K;
	vector<string> array;
	for (int i = 0; i < s.size(); i++)
	{
		for (int j = 1; j <= K; j++)
		{
			array.push_back(s.substr(i, j));
		}
	}
	
	sort(array.begin(), array.end());
	array.erase(unique(array.begin(), array.end()), array.end());

	cout << array[K - 1] << endl;

}

Measured memory_bytes: 1660
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	l := nextFloat64()

	ans := (l * l * l) / 27.0
	puts(ans)
}

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


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

int main() {
  int x;
  cin >> x;
  vector<bool> ok(x+1);
  ok[1] = true;
  for(int b = 2; b <= x; b++) {
    int v = b*b;
    while(v <= x) {
      ok[v] = true;
      v *= b;
    }
  }
  for(int i = x; i >= 1; i--) {
    if(ok[i]) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3604
#include <stdio.h>
#define N 100
#define INF 1000000
int min(int,int);

int main(){
  int a,i,j=0,l,k,q,A[N+1],B[N+1][N+1];
  scanf("%d",&a);
  
  for(i=0;i<a;i++)
    scanf("%d%d",&A[i],&A[i+1]);

  for(i=1;i<=a;i++)
    B[i][i]=0;

  for(l=2;l<=a;l++){
    for(i=1;i<=a-l+1;i++){
      j=i+l-1;
      B[i][j]=INF;
      for(k=i;k<=j-1;k++){
	q=B[i][k]+B[k+1][j]+A[i-1]*A[k]*A[j];
	B[i][j]=min(B[i][j],q);
      }
    }
  }
  printf("%d\n",B[1][a]);
  return 0;
}

int min(int x, int y){
  if(x>=y) return y;
  else return x;
}
  



Measured memory_bytes: 2112
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	ll x;
	cin >> n >> x;
	vector<ll> a(n);
	rep(i,n){
		cin >> a[i];
		a[i] = abs(a[i] - x);
	}
	ll ans = a[0];
	rep(i,n){
		ans = gcd(a[i], ans);
	}
	cout << ans << endl;
	return 0;
}

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

#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 pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define ALL(X)      (X).begin(),(X).end()

typedef long long LL;

using namespace std;

int main(void){
    LL A,B,C;
    cin>>A>>B>>C;
    REP(i,1000000){
        if(A%2==1 || B%2==1 || C%2==1){
            cout<<i<<endl;
            return 0;
        }
        LL a=(B+C)/2,b=(A+C)/2,c=(A+B)/2;
        A=a,B=b,C=c;
    }
    cout<<-1<<endl;
     return 0;
}

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

int main()
{
  int room[4][3][10]{0};
  int N;

  cin >> N;
  int b, f, r, v;
  for (int i = 0; i < N; ++i) {
    cin >> b >> f >> r >> v;
    room[b-1][f-1][r-1] += v;
    }

    for(int i=0; i<4; ++i){
        for(int j=0; j<3; ++j){
            for(int k=0; k<10; ++k){
                cout << ' ' << room[i][j][k];
            }
            cout << endl;
        }
        if( i!= 3){
            cout << "####################" << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

int A, B;

int main(void){
    
    scanf("%d %d", &A, &B);
    printf("%d\n", (A * B) - (A - 1 + B));
    
    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++)
typedef long long ll;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) {
    int num;
    cin >> num;
    --num;
    a[num]++; 
  }
  sort(a.begin(), a.end());
  vector<int> sums(n+1);
  rep(i, n) {
    sums[i+1] = sums[i] + a[i];  
  }

  int ans = n, i = n;
  for (int k = 1; k <= n; ++k) {
    while (ans) {
      while (i >= 1 && a[i-1] >= ans) --i;
      int sum = ans * (n-i) + sums[i];
      if (sum >= ans * k) break;
      --ans;
    }
    cout << ans << endl; 
  }
  return 0;
}


Measured memory_bytes: 3200
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int h[]=new int[n];
    for(int i=0;i<n;i++){
      h[i]=sc.nextInt();
    }
    sc.close();
    int counter=0;
    int max=0;
    for(int i=0;i<n-1;i++){
      if(h[i]>=h[i+1]){
        counter++;
        if(counter>max){
          max=counter;
        }
      }else{
        counter=0;
      }
    }
    System.out.print(max);
  }
}

Measured memory_bytes: 52688
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (h, w, k) = (v[0], v[1], v[2]);
    let mut grid = vec![vec![]; h];
    for i in 0..h {
        grid[i] = read::<String>().chars().collect::<Vec<_>>();
    }
    let grid = grid;

    let mut ans = 0i64;
    for hstate in 0..1 << h {
        for wstate in 0..1 << w {
            let mut grid_clone = grid.clone();
            for hi in 0..h {
                if (hstate >> hi) & 1 == 1 {
                    for wi in 0..w {
                        grid_clone[hi][wi] = '.';
                    }
                }
            }

            for wi in 0..w {
                if (wstate >> wi) & 1 == 1 {
                    for hi in 0..h {
                        grid_clone[hi][wi] = '.';
                    }
                }
            }

            let mut count = 0;
            for hi in 0..h {
                for wi in 0..w {
                    if grid_clone[hi][wi] == '#' {
                        count += 1;
                    }
                }
            }

            if count == k {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

const int MAX_N = 300;

int N;
int A[MAX_N][MAX_N];
bool necessary[MAX_N][MAX_N];

int main() {
    cin >> N;
    REP(i, N) {
        REP(j, N) cin >> A[i][j];
    }
    
    bool exist_structure = true;
    REP(i, N) {
        REP(j, N) necessary[i][j] = true;
    }

    REP(k, N) {
        REP(i, N) {
            REP(j, N) {
                if (A[i][j] > A[i][k] + A[k][j]) exist_structure = false;
                if (A[i][j] == A[i][k] + A[k][j] && i != k && k != j) necessary[i][j] = false;
            }
        }
    }

    if (!exist_structure) PRINT(-1);
    else {
        ll sum_len = 0;
        REP(i, N) {
            REP2(j, i+1, N) {
                if (necessary[i][j]) sum_len += A[i][j];
            }
        }
        PRINT(sum_len);
    }
    return 0;
}

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

using namespace std;

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

const ll N = 100005;
const ll INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-7;
const double PI = acos(-1.0);

ll n, h[N], dp[N];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> h[i];

	dp[1] = llabs(h[0] - h[1]);
	for(int i = 2; i < n; i++)
		dp[i] = min(dp[i - 1] + llabs(h[i] - h[i - 1]), dp[i - 2] + llabs(h[i] - h[i - 2]));
	cout << dp[n - 1] << endl;
}




Measured memory_bytes: 1792
N = int(input())
s = []
ans_dict = {}
for i in range(N):
    s.append(input())
M = int(input())
t = []
for i in range(M):
    t.append(input())
for s_i in s:
    if s_i in ans_dict.keys():
        ans_dict[s_i] += 1
    else:
        ans_dict[s_i] = 1
for t_i in t:
    if t_i in ans_dict.keys():
        ans_dict[t_i] -= 1
    else:
        ans_dict[t_i] = 1

ans = 0
for v in ans_dict.values():
    ans = max(ans, v)
print(ans)




Measured memory_bytes: 3064
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:

*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 200010;
const int MAXK = 110;
const int MAXQ = 200010;

string s;
int n;

struct HashModule {
    ll mod;
    vector<ll> pw, h;

    void init(string s, ll bas, ll p) {
        mod = p;
        pw.resize(s.length()+1);
        h.resize(s.length());
        pw[0] = 1;
        FOR(i,1,SZ(s)) pw[i] = (pw[i-1] * bas) % mod;
        h[0] = s[0]-'a';
        FOR(i,1,SZ(s)-1) h[i] = (h[i-1]*bas + s[i]-'a') % mod;
    }
    ll query(ll l, ll r) {
        if (!l) return h[r];
        return (h[r] - h[l-1] * pw[r-l+1] + mod*mod) % mod; 
    }
};

struct DoubleHash {
    HashModule hm1, hm2;
    void init(string s, ll base1, ll mod1, ll base2, ll mod2) {
        hm1.init(s, base1, mod1);
        hm2.init(s, base2, mod2);
    }
    II query(ll l, ll r) {
        return II(hm1.query(l,r), hm2.query(l,r));
    } 
};

map<II, int> ma;
DoubleHash dh;

bool check(int len) {
    ma.clear();
    FOR(l,0,n-1) {
        int r = l + len - 1;
        if (r >= n) break;
        II x = II(dh.query(l, r));
        if (!ma.count(x)) {
            ma[x] = r;
        }
        else {
            int R = ma[x];
            if (R < l) {
                return true;
            }
        }
    }
    return false;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    cin >> s;
    dh.init(s, 26, 1000000007, 26, 999999991);
    int dau = 1, cuoi = n/2, mid;
    while (dau <= cuoi) {
        mid = (dau + cuoi) / 2;
        if (check(mid)) dau = mid+1;
        else cuoi = mid-1;
    }
    cout << cuoi;
    return 0;
}


Measured memory_bytes: 768
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


void solve(string s,int dice[6]){
    int ans[6]={};
    rep(i,6)ans[i]=dice[i];
    if(s=="North"){
        ans[0]=dice[1];
        ans[1]=dice[5];
        ans[4]=dice[0];
        ans[5]=dice[4];
    }
    if(s=="East"){
        ans[0]=dice[3];
        ans[2]=dice[0];
        ans[3]=dice[5];
        ans[5]=dice[2];
    }
    if(s=="West"){
        ans[0]=dice[2];
        ans[2]=dice[5];
        ans[3]=dice[0];
        ans[5]=dice[3];
    }
    if(s=="South"){
        ans[0]=dice[4];
        ans[1]=dice[0];
        ans[4]=dice[5];
        ans[5]=dice[1];
    }
    if(s=="Right"){
        ans[1]=dice[2];
        ans[2]=dice[4];
        ans[3]=dice[1];
        ans[4]=dice[3];
    }
    if(s=="Left"){
        ans[1]=dice[3];
        ans[2]=dice[1];
        ans[3]=dice[4];
        ans[4]=dice[2];
    }
    
    rep(i,6){
        dice[i]=ans[i];
    }
}

int main() {
    int n;
    cin>>n;
    rep(i,n){
        int sum=0;
        
        int c,a,n;
        cin>>c>>a>>n;
        
        int mini=min(c,min(a,n));
        c-=mini;
        a-=mini;
        n-=mini;
        sum+=mini;
        
        while(c>=2 && a>=1){
            sum++;
            c-=2;
            a-=1;
        }
        
        while(c>=3){
            sum++;
            c-=3;
        }
        cout<<sum<<endl;
        
    }
    return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 998244353
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll a,b,c,d,dp[3005][3005];
ll f(ll p,ll q)
{
    if(p>c or q>d)
        return 0;
    if(p==c and q==d)
        return 1;
    if(dp[p][q]!=-1)
        return dp[p][q];
    dp[p][q]=(p*f(p,q+1)+q*f(p+1,q)-((p*q)%M*f(p+1,q+1))%M)%M;
    if(dp[p][q]<0)
        dp[p][q]+=M;
    return dp[p][q];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    memset(dp,-1,sizeof(dp));
    cin>>a>>b>>c>>d;
    cout<<f(a,b)<<"\n";
}


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

int main(){
    ll n, temp;
    vector<ll> an;
    cin >> n;
    for(auto i=0;i<n;i++){
        cin >> temp;
        an.push_back(temp);
    }
    ll xors = an.at(0);
    for(auto i=1;i<n;i++){
        xors = xors^an.at(i);
    }
    for(auto i=0;i<n;i++){
        ll ans = ~(xors ^ ~(an.at(i)));
        cout << ans <<" ";
    }
    cout << endl;
}

Measured memory_bytes: 5188
#set
n = gets.chomp.to_i
candy_arr = Array.new(2) {Array.new(n,0)}
max_sum = 0
temp_sum = 0

0.upto(1) do |i|
  candy_arr[i] = gets.chomp.split(" ").map(&:to_i)
end

#main
0.upto(n -1) do |i|
  sum_top_line = 0
  sum_under_line = 0
  0.upto(i) do |j|
    sum_top_line += candy_arr[0][j]
  end
  
  (n - 1).downto(i) do |k|
    sum_under_line += candy_arr[1][k]
  end

  temp_sum = sum_top_line + sum_under_line
  max_sum = temp_sum if max_sum < temp_sum

end

p max_sum

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

#define inf 0x3f3f3f3f
#define INF 1000111000111000111LL
#define mod 1000000007
#define endl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fi first
#define se second
#define all(cc) (cc).begin(),(cc).end()
using lli = long long int ;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vb = vector<bool> ;
using vvi = vector<vector<int>> ;
using vlli = vector<long long int> ;
using vpii = vector<pair<int, int>> ;

int main()
  {
    ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
    lli n, ans=-1 ;
    cin>> n ;
    vlli a(n) ;
    map<lli, int> cnt ;
    for(int i=0 ; i<n ; i++)
      {
        cin>> a[i] ;
        cnt[a[i]]++ ;
      }
    vector<pair<lli, lli>> sticks ;
    for(auto x:cnt)
      sticks.pb(mp(x.fi, x.se)) ;
    sort(all(sticks)) ;
    reverse(all(sticks)) ;
    for(auto x:sticks)
      {
        if(x.se>=4 && ans==-1)
          {
            cout<< x.fi*x.fi ;
            return 0 ;
          }
        else if(x.se>=2 && ans==-1)
          {
            ans=x.fi ;
          }
        else if(x.se>=2)
          {
            ans*=x.fi ;
            cout<< ans ;
            return 0 ;
          }
      }
    cout<< 0 ;
  }


Measured memory_bytes: 9464
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

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

set<ll> calc_divs_for(const ll N) {
    set<ll> ans;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ans.insert(i);
            ans.insert(N / i);
        }
    }
    return ans;
}

ll pow(const ll base, ll n) {
    ll ans = 1;
    while (n > 0) {
        ans *= base;
        n--;
    }
    return ans;
}

int main(void) {
    ll N;
    cin >> N;

    set<ll> ans;

    // for a = 0;
    {
        // printf("a = 0\n");
        set<ll> divs = calc_divs_for(N - 1);
        for (auto &div : divs) {
            // printf("%lld\n", div);
            ans.insert(div);
        }
    }

    // for a = 1;
    {
        // printf("a = 1\n");
        set<ll> divs = calc_divs_for(N);
        for (auto &div : divs) {
            ll x = N / div - 1;
            // printf("%lld\n", div);
            if (x % div == 0) {
                ans.insert(div);
            }
        }
    }

    // for a = n;
    for (ll i = 2; i <= 40; i++) {
        // printf("a = %lld\n", i);
        for (ll j = 1; pow(j, i) <= N; j++) {
            ll v = pow(j, i);
            if (N % v == 0) {
                ll x = N / v - 1;
                if (x % j == 0) {
                    // printf("%lld\n", j);
                    ans.insert(j);
                }
            }
        }
    }

    ans.erase(1);
    cout << ans.size() << endl;

    return 0;
}


Measured memory_bytes: 512
#define DEBUG 0

/**
 * File    : D2.cpp
 * Author  : Kazune Takahashi
 * Created : 5/23/2019, 11:22:03 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N, K;
string S;
vector<int> V;
vector<int> W;

int main()
{
  cin >> N >> K >> S;
  int now = 1;
  int cnt = 0;
  for (auto i = 0; i < N; i++)
  {
    if (S[i] == ('0' + now))
    {
      cnt++;
    }
    else
    {
      V.push_back(cnt);
      cnt = 1;
      now = 1 - now;
    }
  }
  if (cnt > 0)
  {
    V.push_back(cnt);
  }
  if (V.size() % 2 == 0)
  {
    V.push_back(0);
  }
  W = vector<int>(V.size() + 1, 0);
  for (auto i = 0; i < (int)V.size(); i++)
  {
    W[i + 1] = W[i] + V[i];
  }
  int ans = 0;
  for (auto i = 0; i < (int)W.size(); i += 2)
  {
    int start = i;
    int goal = min(i + 2 * K + 1, (int)W.size() - 1);
    ans = max(ans, W[goal] - W[start]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1272
a=input()
n=len(a)
if len(a)%2==0:
    a1=a[:n//2]
    a2=a[n//2:]
    a2=a2[::-1]
else:
    a1=a[:n//2]
    a2=a[n//2+1:]
    a2=a2[::-1]
cnt=0
for i in range(len(a1)):
    if a1[i]!=a2[i]:
        cnt+=1
print(cnt)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

// ----------------------------------------------------------------

func main() {
	var b int
	var h int
	fmt.Scan(&b, &h)

	var max = h
	var min = h

	if (min - b + 1) >= -1000000 {
		min = min - b + 1
	} else {
		min = -1000000
	}

	if (max + b - 1) <= 1000000 {
		max = max + b - 1
	} else {
		max = 1000000
	}

	for i := min; i <= max; i++ {
		fmt.Print(i)
		fmt.Print(" ")
	}
}

// ----------------------------------------------------------------

var dx = []int{0, 1, 0, -1, 0}
var dy = []int{1, 0, -1, 0, 0}
var inf = int(1e9)

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}

func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}

func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}

var nextReader func() []byte

func init() {
	nextReader = newScanner()
	log.SetFlags(log.Lshortfile)
}

func newScanner() func() []byte {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() []byte {
		r.Scan()
		return r.Bytes()
	}
}

func nextBytes() []byte {
	return nextReader()
}

func nextString() string {
	return string(nextReader())
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(string(nextReader()), 10, 64)
	return v
}

func nextInt() int {
	v, _ := strconv.Atoi(string(nextReader()))
	return v
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(string(nextReader()), 64)
	return f
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	int K;
	cin >> K;
	sort(a, a + 3);
	for (int i = 0; i < K; i++) {
		a[2] *= 2;
	}

	cout << a[0] + a[1] + a[2] << endl;
}

Measured memory_bytes: 256
public class Main {
  private static void solve() {
    int n = ni();
    char[] s = ns();
    int[] cnt = new int[256];
    for (char c : s) {
      cnt[c] ++;
    }
    
    System.out.println(cnt['R'] > cnt['B'] ? "Yes" : "No");
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 22868
#include <stdio.h>
int main(){
    int h[2],k[2],a,b,c,d,l=0,r=0;
    for(int i=0;i<2;i++)scanf("%d",&h[i]);
    for(int i=0;i<2;i++)scanf("%d",&k[i]);
    scanf("%d%d%d%d",&a,&b,&c,&d);
    l=h[0]*a+(h[0]/10)*c+h[1]*b+(h[1]/20)*d;
    for(int i=0;i<2;i++)h[i]=k[i];
    r=h[0]*a+(h[0]/10)*c+h[1]*b+(h[1]/20)*d;
    if(l==r)printf("even\n");
    else if(l>r)printf("hiroshi\n");
    else printf("kenjiro\n");
    
}


Measured memory_bytes: 2592
#include<stdio.h>
int card[1000000],num[1000000];
char mark[1000000];
 


int quicksort(int,int);
int partition(int,int);
 
int main(void)
{
    int m,k,flg=0;
 
    scanf("%d",&m);
    for(k=0;k<m;k++) num[k]=k;
    for(k=0;k<m;k++){
        scanf(" %c",&mark[k]);
        scanf("%d",&card[k]);
    }
    quicksort(0,m-1);
    for(k=1;k<m;k++){
        if(card[k]==card[k-1]){
            if(num[k]<num[k-1]){
                flg=1;
            }
        }
    }
    if(flg==1) printf("Not stable\n");
    else       printf("Stable\n");
    for(k=0;k<m;k++){
        printf("%c %d\n",mark[k],card[k]);
    }
    return 0;
}
 
int partition(int j,int n){
    int i,x,tmpi;
    char tmpc;
    x=card[n];
    for(i=j;i<n;i++){
        if(card[i]<=x){
            tmpi=card[i];
            card[i]=card[j];
            card[j]=tmpi;
            tmpc=mark[i];
            mark[i]=mark[j];
            mark[j]=tmpc;
            tmpi=num[i];
            num[i]=num[j];
            num[j]=tmpi;
            j++;
        }
    }
    tmpi=card[n];
    card[n]=card[j];
    card[j]=tmpi;
    tmpc=mark[n];
    mark[n]=mark[j];
    mark[j]=tmpc;
    tmpi=num[n];
    num[n]=num[j];
    num[j]=tmpi;
    return j;
}
 
int quicksort(int p,int r){
    int q;
    if(p<r){
        q=partition(p,r);
        quicksort(p,q-1);
        quicksort(q+1,r);
    }
    return 0;
}



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

int main() {
  double a,b,h,m;
  cin>>a>>b>>h>>m;
  double w,x,y;
  w=M_PI*(30*h-5.5*m)/180;
  x=a*a+b*b-2*a*b*cos(w);
  y=sqrt(x);
  cout << fixed << setprecision(20);
  cout<<y<<endl;
}
  

Measured memory_bytes: 4292
import java.util.*;
public class Main{
	static long Dan1(long[] d, long key){
		int pl = 0;
		int pr = d.length - 1;
		int pc = (pl + pr) / 2;
		while(pl<pr){
			if(d[pc]<key)pl = pc + 1;
			else {
				pr = pc;
			}
			pc = (pl + pr) / 2;
		}
		if(d[pl]==key)return pl;
		if(d[pc]>key)return pc;
		else return pc + 1;
	}

	static long Dan2(long[] d, long key){
		int pl = 0;
		int pr = d.length - 1;
		int pc = 0;
			pc = (pl + pr + 1) / 2;
		while(pl<pr){
			if(d[pc]>key)pr = pc - 1;
			else {
				pl = pc;
			}
			pc = (pl + pr + 1) / 2;
		}
		if(d[pr]==key)return d.length - 1 - pr;
		if(d[pc]>key)return d.length - pc;
		else return d.length - pc -1;
	}

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		long[] a = new long[n];
		long[] b = new long[n];
		long[] c = new long[n];
		for(int i=0; i<n; i++){
			a[i] = sc.nextLong();
		}
		for(int i=0; i<n; i++){
			b[i] = sc.nextLong();
		}
		for(int i=0; i<n; i++){
			c[i] = sc.nextLong();
		}
		Arrays.sort(a);
		Arrays.sort(c);
		long num = 0L;
		for(int i=0; i<n; i++){
			num += Dan1(a, b[i]) * Dan2(c, b[i]);
		}
		System.out.println(num);
	}
}

Measured memory_bytes: 99992
n, a, b = map(int, input().split())

if a == 0:
    print(0)
elif n >= a + b:
    if n % (a + b) <= a:
        print(a * (n // (a + b)) + (n % (a + b)))
    else:
        print(a * (n // (a + b)) + a)
        
else:
    if n < a:
        print(n)
    else:
        print(a)

Measured memory_bytes: 9136
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#include <boost/multiprecision/cpp_int.hpp>
namespace boost_multiprecision = boost::multiprecision;
#define LL long long
#define CINT boost_multiprecision::cpp_int
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while(true)

int main(){

	int N,M;
	cin >> N >> M;

	int A[1000];
	int vote[1000];
	for(int i=0; i<N; i++){
		cin >> A[i];
		vote[i] = 0;
	}

	for(int i=0; i<M; i++){
		int B;
		cin >> B;
		for(int j=0; j<N; j++){
			if(A[j] <= B){
				vote[j]++;
				break;
			}
		}
	}

	int ans;
	int tmp = 0;
	for(int i=0; i<N; i++){
		if(vote[i] > tmp){
			tmp = vote[i];
			ans = i;
		}
	}

	cout << ans + 1 << endl;
	
    return 0;
}


Measured memory_bytes: 3092
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int C = Integer.parseInt(sc.next());
		int D = Integer.parseInt(sc.next());
		sc.close();

		int left = A + B;
		int right = C + D;
		if(left > right) {
			System.out.println("Left");
		}else if(left < right) {
			System.out.println("Right");
		}else {
			System.out.println("Balanced");
		}

	}
}

Measured memory_bytes: 22608
#include<iostream>
using namespace std;
int main()
{
    int A,B;
    cin >> A >> B;
    if(A<=9 && B<=9)
    {
        int result = A*B;
        cout << result << endl;
    }
    else
    {
        cout << "-1" << endl;
    }
    return 0;


}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
ll dp[2300000];
const ll MOD=1e9+7;
int n;
bool can[25][25];
int cnt[2300000];
queue<int> q;
inline void Add(ll &x,ll y){
	x+=y;if (x<0) x+=MOD;if (x>=MOD) x-=MOD;return;
}
int main(){
	ios::sync_with_stdio(false);
	memset(dp,0,sizeof(dp));
	memset(cnt,0,sizeof(cnt));
	dp[0]=1;q.push(0);cnt[0]=0;
	cin>>n;
	for (int i=0;i<n;++i) for (int j=0;j<n;++j) cin>>can[i][j];
	while(!q.empty()){
		int state=q.front();q.pop();
		int cur=cnt[state];// consider this man
		for(int i=0;i<n;++i){// consider women
			if (state&(1<<i)) continue;// this woman is already chosen
			if (!can[cur][i]) continue;// not compatible
			int newstate=state|(1<<i);
			if (!cnt[newstate]){
				cnt[newstate]=cnt[state]+1;// one more man/woman chosen
				q.push(newstate);
			}
			Add(dp[newstate],dp[state]);
		}
	}
	cout<<dp[(1<<n)-1];
	return 0;
}

Measured memory_bytes: 28800
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<cmath>
#include<stack>
#include <algorithm>
#include <functional>
//#include<stdlib.h>
using namespace std;
int main() {
	int n,x,d=0,l,t=1;
	cin >> n >> x;
	for (int a = 0; a < n; a++)
	{
		cin >> l;
		d += l;
		if (x >= d) 
		{
			t++;
		} else 
		{
			break;
		} }
	cout << t;
	return 0;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=100100100;
const int mod=(int)1e9+7;

int main(){
    string s;
    cin>>s;
    if(s=="ABC")cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
return 0;
}

Measured memory_bytes: 3624
import sys
import os
import math
import bisect
import collections
import itertools
import heapq

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()
    print(math.floor(math.log(N, K))+1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9524
if __name__ == '__main__':
    A, B, C = map(int, input().split())

    max_value = max(A, B, C)
    diff_sum = sum([max_value - v for v in [A, B, C]])

    if diff_sum % 2 == 0:
        print(diff_sum // 2)
    else:
        print((diff_sum + 3) // 2)


Measured memory_bytes: 2940
n = gets.to_s.to_i
a = gets.to_s.split.map{|t| t.to_i }
b = gets.to_s.split.map{|t| t.to_i }

# 貪欲にそれぞれのa_i, b_iごとに判定してはダメか.これはダメそう。
# まず、aの方が大きい場合に、これを何とかしないといけなさそう。

c = 0
n.times do |i|
  t = a[i] - b[i]
  if t > 0
    c += t
    b[i] += t 
  elsif t < 0 && t.odd?
    c += 1
    b[i] += 1
  end
end

# p a
# p b
# p c

c *= 2

n.times do |i|
  t = b[i] - a[i]
  if t > 0
    k = [c, t].min
    a[i] += k
    c -= k
  end
end

puts c == 0 ? "Yes" : "No"

Measured memory_bytes: 4092
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;
 
int main() {
    int N, K, x[110000];

    cin >> N >> K;
    for(int i = 0; i < N; i++) cin >> x[i];

    long long int r, l, ans = INT_MAX;
    for(int i = 0; i < N - K + 1; i++){
        l = x[i]; r = x[i+K-1];

        long long int val = min(abs(l) + abs(r-l), abs(r) + abs(r-l));

        if(val < ans) ans = val;
    }

    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int h, w; cin >> h >> w;
  vector<string> s(h);
  rep(i,h) {
    cin >> s[i];
  }
  vvi u(h, vi(w, 0));
  vvi d(h, vi(w, 0));
  vvi l(h, vi(w, 0));
  vvi r(h, vi(w, 0));
  rep(i, h) {
    rep(j, w) {
      if (s[i][j] == '.') {
        u[i][j] = 1;
        l[i][j] = 1;
        if (i>0 && s[i-1][j] == '.') {
          u[i][j] += u[i-1][j];
        }
        if (j>0 && s[i][j-1] == '.') {
          l[i][j] += l[i][j-1];
        }
      }

      if (s[h-i-1][j] == '.') {
        d[h-i-1][j] = 1;
        if (i>0 && s[h-i][j] == '.') {
          d[h-i-1][j] += d[h-i][j];
        }
      }

      if (s[i][w-j-1] == '.') {
        r[i][w-j-1] = 1;
        if (j>0 && s[i][w-j] == '.') {
          r[i][w-j-1] += r[i][w-j];
        }
      }
    }
  }

  int ans = 0;
  rep(i, h) {
    rep(j, w) {
      if (s[i][j] == '#') continue;
      int val = u[i][j] + d[i][j] + l[i][j] + r[i][j] - 3;
      ans = max(ans, val);
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 129664
use std::process;
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}
fn main() {
    let (k,x) = get!(i32,i32);

    for i in x-k+1..x+k {
        print!("{} ",i);
    }
}


Measured memory_bytes: 4352