akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
struct edge{ll to, cap, rev;}; //to, capacity, 反対エッジ
struct graph{
    ll N;
    vector<vector<edge> > G;
    vector<bool> used;

    graph(ll n): N(n), G(N), used(N,false) {}

    void add_edge(ll s, ll t, ll cap){
        G[s].emplace_back((edge){t, cap, (ll)G[t].size()});
        G[t].emplace_back((edge){s, cap, (ll)G[s].size()-1}); // 無向ならcap
    }

    ll dfs(ll v, ll goal, ll water){
        if(v == goal) return water;
        used[v]=true;
        for(auto& E : G[v]){
            if(!used[E.to] and E.cap > 0){
                ll o_flow = dfs(E.to, goal, min(water, E.cap));
                if(o_flow > 0){
                    E.cap -= o_flow;
                    G[E.to][E.rev].cap += o_flow;
                    return o_flow;
                }
            }
        }
        return 0;
    }

    ll max_flow(ll s, ll g){
        ll flow = 0;
        while(1){
            rep(i,N) used[i] = false;
            ll o_flow = dfs(s, g, INF);
            if (o_flow==0) return flow; //更新がなかったら終了
            flow += o_flow;
        }
    }
};
//--MAIN-----------------------------------
void Main(){
    ll H,W; cin>>H>>W;
    graph g(H+W+2);
    rep(i,H){
        rep(j,W){
            char c; cin>>c;
            if(c=='.') continue;
            if(c=='o'){
                g.add_edge(2+i,2+H+j,1);
            }
            if(c=='S'){
                g.add_edge(0,2+i,INF);
                g.add_edge(0,2+H+j,INF);
            }
            if(c=='T'){
                g.add_edge(1,2+i,INF);
                g.add_edge(1,2+H+j,INF);
            }
        }
    }
    ll ans=g.max_flow(0,1);
    cout<< ( ans>=INF ? -1 : ans )<<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 896
import math
import sys
#k
k=int(input())
#a,b
a,b = (int(x) for x in input().split())

ans = math.floor(a/k)*k
if ans == a:
    print("OK")
    sys.exit()

ans += k

if ans <= b:
    print("OK")
else:
    print("NG")

Measured memory_bytes: 9116
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(void) {
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    for(int i=0; i<N; i++) {
        cin >> p[i];
    }

    sort(p.begin(), p.end());
    cout << accumulate(p.begin(), p.begin()+K, 0) << endl;
    return 0;
}


Measured memory_bytes: 3632
#![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 calc_cost(lwi: usize, lh: usize, rh: usize, h: usize, grid: &Vec<Vec<char>>) -> i64 {
    let mut ret = 0;
    if lh >= rh {
        for ri in 0..rh {
            let li = ri + (lh - rh);
            if grid[li][lwi] == grid[ri][lwi + 1] {
                ret += 1;
            }
        }
    } else {
        for li in 0..lh {
            let ri = li + (rh - lh);
            if grid[li][lwi] == grid[ri][lwi + 1] {
                ret += 1;
            }
        }
    }
    ret
}

fn solve(lwi: usize, h: usize, grid: &Vec<Vec<char>>) -> i64 {
    let mut l_largers = vec![vec![0; h + 1]; h + 1];
    for offset in 0..h {
        for rhi in 0..h - offset {
            if grid[rhi + offset][lwi] == grid[rhi][lwi + 1] {
                l_largers[offset][rhi + 1] = 1;
            }
            if rhi > 0 {
                l_largers[offset][rhi + 1] += l_largers[offset][rhi];
            }
        }
    }
    let mut r_largers = vec![vec![0; h + 1]; h + 1];
    for offset in 0..h {
        for lhi in 0..h - offset {
            if grid[lhi][lwi] == grid[lhi + offset][lwi + 1] {
                r_largers[offset][lhi + 1] = 1;
            }
            if lhi > 0 {
                r_largers[offset][lhi + 1] += r_largers[offset][lhi];
            }
        }
    }

    let mut dp = vec![vec![std::i64::MAX; h + 1]; h + 1];
    dp[h][h] = 0;
    for lhi in (0..h + 1).rev() {
        for rhi in (0..h + 1).rev() {
            let cost;
            if lhi >= rhi {
                cost = l_largers[lhi - rhi][rhi];
            } else {
                cost = r_largers[rhi - lhi][lhi];
            }
            if lhi > 0 {
                dp[lhi - 1][rhi] = min(dp[lhi - 1][rhi], dp[lhi][rhi] + cost);
            }
            if rhi > 0 {
                dp[lhi][rhi - 1] = min(dp[lhi][rhi - 1], dp[lhi][rhi] + cost);
            }
        }
    }
    dp[0][0]
}

fn main() {
    let v = read_vec::<usize>();
    let (h, w) = (v[0], v[1]);

    let mut grid = vec![vec![]; h];
    for i in 0..h {
        grid[i] = read::<String>().chars().collect::<Vec<_>>();
    }

    let mut ans = 0;
    for i in 0..w - 1 {
        ans += solve(i, h, &grid);
    }
    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: 4680
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<ll>
#define vvint vector<vint>
#define P pair<ll,ll>
#define INT_MAX 2147483647
#define MOD 998244353
#define PI 3.14159265358979323846
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;

#define MAX 1000000000000

int main(void) {
	ll x, k, d; cin >> x >> k >> d;
	if (x < 0) {
		x = -x;
	}
	if (x / k > d) {
		cout << x - d * k << endl;
	}
	else {
		ll p = x % d, m = x % d - d;
		ll time = k - ((x - p) / d);

		if (time < 0) {
			cout << x - d * k << endl;
		}else if (time % 2 == 0) {
			cout << p << endl;
		}
		else {
			cout << -m << endl;
		}

	}

	return 0;
}

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

int main(){
  while(1){
    int t, N, i;
    scanf("%d%d", &t, &N);
    if(t == 0 && N == 0){
      return 0;
    }
    vector<vector<int>> B(161, vector<int>(161, -1));
    int sx, sy;
    int x, y, d, v, ans = 0;
    for(i = 0; i < N; i++){
      scanf("%d%d", &x, &y);
      B[x + 80][y + 80] = -2;
    }
    scanf("%d%d", &sx, &sy);
    sx += 80;
    sy += 80;
    int dx[6] = {0, 1, 1, 0, -1, -1};
    int dy[6] = {1, 1, 0, -1, -1, 0};
    queue<pair<pair<int, int>, int>> q;
    q.push(pair<pair<int, int>, int>(pair<int, int>(sx, sy), 0));
    while(q.size() > 0){
      x = q.front().first.first;
      y = q.front().first.second;
      v = q.front().second;
      q.pop();
      if(v > t){
        break;
      }
      if(B[x][y] == -1){
        B[x][y] = v;
        ans++;
        for(d = 0; d < 6; d++){
          q.push(pair<pair<int, int>, int>(pair<int, int>(x + dx[d], y + dy[d]), v + 1));
        }
      }
    }
    printf("%d\n", ans);
  }
}



Measured memory_bytes: 3396
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

void solve()
{
    string s;
    cin >> s;
    int n = (int) s.length();
    int ans = n / 2;
    for(int i = (n - 1) / 2, k = n / 2; i < n && k >= 0; i--, k++)
    {
        if(s[i] != s[n / 2] || s[k] != s[n / 2])
        {
            break;
        }
        ans++;
    }
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    //freopen("file.in", "r", stdin);freopen("file.out", "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<ll> A(N+1);
    rep(i,N+1) cin >> A[i];
    ll sum = 0;
    rep(i,N){
        ll b; cin >> b;
        ll X = min(A[i],b);
        ll Y = b - X;
        ll Z = min(Y,A[i+1]);
        sum += (X + Z);
        A[i+1] -= Z;
    }
    cout << sum << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

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

        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();

            if (H == 0 && W == 0)
                break;

            if (H % 2 == 0) {
                if (W % 2 == 0) {
                    for (int i = 0; i < H / 2; i++) {
                        for (int j = 0; j < W / 2; j++)
                            System.out.print("#.");
                        System.out.println();
                        for (int j = 0; j < W / 2; j++)
                            System.out.print(".#");
                        System.out.println();
                    }
                } else {
                    for (int i = 0; i < H / 2; i++) {
                        for (int j = 0; j < W / 2; j++)
                            System.out.print("#.");
                        System.out.println("#");
                        for (int j = 0; j < W / 2; j++)
                            System.out.print(".#");
                        System.out.println(".");
                    }
                }
            } else {
                if (W % 2 == 0) {
                    for (int i = 0; i < H / 2; i++) {
                        for (int j = 0; j < W / 2; j++)
                            System.out.print("#.");
                        System.out.println();
                        for (int j = 0; j < W / 2; j++)
                            System.out.print(".#");
                        System.out.println();
                    }
                    for (int j = 0; j < W / 2; j++)
                        System.out.print("#.");
                    System.out.println();
                } else {
                    for (int i = 0; i < H / 2; i++) {
                        for (int j = 0; j < W / 2; j++)
                            System.out.print("#.");
                        System.out.println("#");
                        for (int j = 0; j < W / 2; j++)
                            System.out.print(".#");
                        System.out.println(".");
                    }
                    for (int j = 0; j < W / 2; j++)
                        System.out.print("#.");
                    System.out.println("#");
                }
            }
            System.out.println();
        }
    }
}



Measured memory_bytes: 35632
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

struct BIT {
    int n;
    vector<int> bit; // 1-indexd

    BIT(int sz) {
        bit.resize(sz + 1);
        n = sz;
    }

    int sum(int i) {
        int s = 0;
        while (i > 0) {
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }

    void add(int i, int x) {
        while (i <= n) {
            bit[i] += x;
            i += i & -i;
        }
    }
};

bool check(const vector<int>& a, int x) {
    vector<int> sum(a.size() + 1);
    REP(i, a.size()) {
        int val = a[i] >= x ? 1 : -1;
        sum[i + 1] = sum[i] + val;
    }

    BIT bit(sum.size() * 2 + 2);

    int num = 0;
    int offset = sum.size() + 1;
    REP(i, sum.size()) {
        num += bit.sum(sum[i] + offset);
        bit.add(sum[i] + offset, 1);
    }

    int total = (int) a.size() * ((int) a.size() + 1) / 2LL;
    int val = (total + 1) / 2;
    return num >= val;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n;
    cin >> n;

    vector<int> v(n);
    REP(i, n) cin >> v[i];

    int l = 1;
    int r = 1e9 + 7;
    while (r - l > 1) {
        int m = (r + l) / 2;
        if (check(v, m)) {
            l = m;
        } else {
            r = m;
        }
    }

    cout << l << endl;

    return 0;
}



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

int main(){
	char ball = 'A';
	string c;
	
	while(cin >> c){
		if(c[0] == ball){
			ball = c[2];
		}
		else if(c[2] == ball){
			ball = c[0];
		}
	}
	
	cout << ball << endl;
	return 0;
}

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


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

    int min = x[0];
    ll ans=-30000000000;

    for(int j=1;j<n;j++){
        if(min>x[j-1]) min=x[j-1];
        if(x[j]-min>ans) ans=x[j]-min;
    }


    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 3896
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k;
  cin >> n >> k;
  vector<int> v(n,0);
  int d,a;
  for(int i = 0; i<k; i++){
    cin >> d;
    for(int j=0; j<d; j++){
      cin >> a;
      v.at(a-1) = 1;
    }
  }
  int count = 0;
  for(int x: v){
    if(x == 0){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int n,m,i,j,d,k,a,b,c,h;
string s,t;
int main()
{
  for(cin>>s;i<s.size()/2;i++)if(s[i]!=s[s.size()-1-i])c++;
  cout<<c;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 998244353;

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int n, K, C;
	string s;
	vector<int> con1, con2, sum;
	vector<int> hoge1, hoge2;
	
	cin>>n>>K>>C;
	cin>>s;
	
	con1.resize(n+1);
	con2.resize(n+2);
	sum.resize(n+1);
	hoge1.resize(n+2,-1);
	hoge2.resize(n+2,-1);
	
	for(int i = 0; i < n; i++){
		sum[i+1] = sum[i] + (s[i] == 'o');
	}
	
	for(int i = 1; i <= n; i++){
		int b = i - C - 1;
		int c = 0;
		
		if(b >= 0) c = con1[b];
		
		con1[i] = max(con1[i-1], (int)c + (s[i-1] == 'o'));
		if(hoge1[con1[i]] == -1) hoge1[con1[i]] = i-1;
	}
	
	
	if(con1[n] > K) {
		return 0;
	}

	for(int i = n; i >= 1; i--){
		int b = i + C + 1;
		int c = 0;
		
		if(b <= n+1) c = con2[b];

		con2[i] = max(con2[i+1], (int)c + (s[i-1] == 'o'));
		if(hoge2[K - con2[i]] == -1) hoge2[K - con2[i]] = i-1;
	}
	
	// cout<<"con1 n = "<<con1[n]<<endl;
	
	for(int i = 1, x = 0; i <= K; i++){
		// cout<<"i = "<<i<<" hoge "<<hoge1[i] <<" "<<hoge2[i-1]<<endl;
		if(hoge1[i] == hoge2[i-1] && hoge1[i] != -1) {
			cout<<hoge1[i]+1<<endl;
		}
	}
	
	
	return 0;
}


Measured memory_bytes: 9620
import itertools
N = int(input())
nums = set([7,5,3])
n = 0
for i in range(8):
    li = list(nums)
    for youso in li:
        nums.add(youso * 10 + 3)
        nums.add(youso * 10 + 5)
        nums.add(youso * 10 + 7)
li753 = list()
for i in nums:
    s = str(i)
    if '3' in s and '5' in s and '7' in s:
        li753.append(i)
ans = 0
for i in li753:
    if N >= i: ans += 1
print(ans)

Measured memory_bytes: 6384
import java.util.*

fun main(args: Array<String>) {
    val (N) = readLine()!!.split(" ").map { it.toInt() }
    val L =readLine()!!.split(" ").map { it.toInt() }.toIntArray()
    L.sortDescending()
    var ans = 0
    for (a in 0 until N - 2){
        for (b in (a+1) until N - 1) {
            var c = bsearch(L, L[a] - L[b] + 1, b + 1, N-1) - 1

            if (L[a] + L[b] > L[c]) {
                //println("a=$a(${L[a]}) b=$b(${L[b]}) c=$c(${L[c]}) ${c - b}")
                ans += c - b
            } else {
                //println("NG a=$a(${L[a]}) b=$b(${L[b]}) c=$c(${L[c]}) ${c - b}")
            }
        }
    }
    println(ans)
}

// arrayの中でvの値を探し、そのIndexを返す
fun bsearch(array: IntArray, v: Int, min: Int, max: Int) : Int {
    if (min > max) return min
    val mid = min + (max - min) / 2
    return when {
        array[mid] < v -> bsearch(array, v, min, mid-1)
        array[mid] >= v -> bsearch(array, v, mid + 1, max)
        else -> Integer.MAX_VALUE
    }
}

Measured memory_bytes: 38576
from math import sqrt

n, d = map(int, input().split())
x_s = [list(map(int, input().split())) for _ in range(n)]

def calc_dist(y_s, z_s):
    yz_s = [[y_s[i], z_s[i]] for i in range(d)]

    distance = 0
    for y, z in yz_s:
        distance += abs(y - z) ** 2
    distance = sqrt(distance)
    return distance

cnt = 0
for i in range(n):
    for j in range(i+1, n):
        dist = calc_dist(x_s[i], x_s[j])
        if dist % 1 == 0:
            cnt += 1

print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


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

  for (double i = 1; i <= n; i++) {
    if(int(i * 1.08) == n){
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" <<endl;
}


Measured memory_bytes: 256
n=int(input())
if n<4:
  print(2,5,63)
  exit()
a,b=[],[]
i=j=k=0
while i<n:
  if not b or a and a[-1]>b[-1]:
    b+=3*-~k,
    k+=1
    i+=1
  else:
    t=2*-~j
    if t%3:
      a+=t,
      i+=1
    j+=1
c=sum(a+b)
if c%6:
  if c%2:
    b[-1]+=3
    c+=3
  while c%6:
    a[-1]+=2
    c+=2
    if a[-1]%3<1and a[-1]==b[-1]:
      a[-1]+=2
      c+=2
print(*a+b)

Measured memory_bytes: 45296
w, h, n = map(int, input().split())
ll_x, ll_y, tr_x, tr_y = 0, 0, w, h
for q in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        ll_x = max(ll_x, x)
    elif a == 2:
        tr_x = min(tr_x, x)
    elif a == 3:
        ll_y = max(ll_y, y)
    elif a == 4:
        tr_y = min(tr_y, y)
ans = (tr_x - ll_x) * (tr_y - ll_y)
if (ll_x > tr_x) or (ll_y > tr_y):
    ans = 0
print(ans if ans > 0 else 0)

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

#define int long long
#define endl "\n"

signed main ()
{

//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	string a;
	cin >> n >> a;
	pair <int, int> prefix[n+1];
	prefix[0].first = 0;
	int white = 0;
	for (int i=0; i<n; i++){
		if (a[i] == 'W') white++;
		prefix[i+1].first = white;
	}	
	
	int red = 0;
	for (int i=n-1; i>=0; i--){
		if (a[i] == 'R') red++;
		prefix[i].second = red;
	}
	prefix[n].second = 0;
//	for (int i=0; i<=n; i++){
//		cerr << "position " << i << " " << prefix[i].first << " " << prefix[i].second << endl;
//	}
	
	int ans = INT_MAX;
	for (int red = 0; red <= n; red++){
		int now_ans = prefix[red].first + prefix[red].second - min(prefix[red].first, prefix[red].second);
		ans = min(ans, now_ans);
	}
	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 6908
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N ;
  cin >> N;
   //cout << setprecision(15) << (double)1/3 << endl;
  //cout << (double)1/3 << endl;
  if (N%2==1) {
    cout << fixed << setprecision(12);
    cout << (N+1.0)*0.5/N << endl;
  }
  else {
  cout << 1.0/2.0 << endl;
  }
}

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

int N;
static const int maxN = 100005;
ll C;
ll x[maxN], v[maxN];
ll fa[maxN], fb[maxN], ga[maxN], gb[maxN];

int main() {
	cin >> N >> C;
	x[0] = 0; v[0] = 0;
	for (int i = 1; i <= N; i++) {
		cin >> x[i] >> v[i];
	}

	fa[1] = v[1] - x[1];
	fb[N] = v[N] - (C - x[N]);
	ga[1] = fa[1];
	gb[N] = fb[N];
	for (int i = 1; i < N; i++) {
		fa[i + 1] = fa[i] + v[i + 1] + x[i] - x[i + 1];
		ga[i + 1] = max(ga[i], fa[i + 1]);
	}
	for (int i = N - 1; i >= 1; i--) {
		fb[i] = fb[i + 1] + v[i] + x[i] - x[i + 1];
		gb[i] = max(gb[i + 1], fb[i]);
	}

	ll ans = max((ll) 0, max(gb[1], ga[N]));
	for (int i = N ; i >= 2; i--) {
		ans = max(ans, ga[i - 1] + fb[i] - (C - x[i]));
	}

	for (int i = 1; i < N; i++) {
		ans = max(ans, gb[i + 1] + fa[i] - x[i]);
	}

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

Measured memory_bytes: 4992
#from collections import *
#from itertools import *
#from bisect import *
from heapq import *
#import copy
#N=int(input())
#X,Y=map(int,input().split())
#S=list(map(int,input().split()))
#S=[list(map(int,input().split())) for i in range(N)]

N,M=map(int,input().split())
A=sorted(list(map(int,input().split())),reverse=True)
"""
lst=[]
for i in range(N):
    for m in range(N):
        lst.append(A[i]+A[m])
lst=sorted(lst,reverse=True)
#print(sum(lst[:M]))
print(lst)
"""
ng=-1
ok=max(A)*2+1
while ok>ng+1:
    mid=(ok+ng)//2
    K=0
    idx=0
    for i in range(N-1,-1,-1):
        X=mid-A[i]
        while idx<N and A[idx]>=X:
            idx+=1
        K+=idx
    if K>M:
        ng=mid
    else:
        ok=mid
idx=0
lst=[0 for i in range(N)]
for i in range(N-1,-1,-1):
    X=ng-A[i]
    while idx<N and A[idx]>=X:
        idx+=1
    lst[i]=idx*2
value=0
for a,i in zip(A,lst):
    value+=a*i
value-=ng*(sum(lst)//2-M)
print(value)


Measured memory_bytes: 14268
#include <bits/stdc++.h>
 
#define int long long
 
#define Vanya Unstoppable
 
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    
    string a;
    cin >> a;
    
    int n = a.size();
    
    for (int i = 2; i < n; ++i) {
        set<char> s;
        for (int j = i - 2; j <= i; ++j) {
            s.insert(a[j]);
        }
        if (s.size() < 3) {
            return cout << i - 2 + 1 << ' ' << i + 1, 0;
        }
    }
    
    for (int i = 1; i < n; ++i) {
        set<char> s;
        for (int j = i - 1; j <= i; ++j) {
            s.insert(a[j]);
        }
        if (s.size() < 2) {
            return cout << i - 1 + 1 << ' ' << i + 1, 0;
        }
    }
    
    cout << "-1 -1";
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0 ,-1};
signed main() {
    int N,M;
    cin >> N >> M;
    vector<int>X(N);
    vector<int>Y(M);
    vector<int>Z(100005);
    for(int i = 0; i < N; i++) {
        cin >> X[i];
        Y[X[i]%M]++;
        Z[X[i]]++;
    }
    int ans = 0;
    for(int i = 0; i < M; i++) {
        if(i == 0) {
            ans+=Y[i]/2;
            Y[i] = Y[i]%2;
        }
        else if(M%2 == 0 && i == M/2) {
            ans+=Y[i]/2;
            Y[i] = Y[i]%2;
        }
        else {
            ans+=min(Y[i],Y[M-i]);
            int cnt = Y[i];
            Y[i]-=min(cnt,Y[M-i]);
            Y[M-i]-=min(cnt,Y[M-i]);
        }
    }
    for(int i = 0; i <= 100000; i++) {
        if(Z[i] >= 2) {
            if(Y[i%M]) {
                ans+=min(Z[i]/2,Y[i%M]/2);
                Y[i%M]-=min(Z[i]/2*2,Y[i%M]/2*2);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5540
# frozen_string_literal: true

n = gets.to_i
a = []
while n.positive? do
  r = n % 26
  if r.zero?
    n -= 26
    r = 26
  end
  a.push (('a'.ord - 1) + r).chr
  n /= 26
end

puts a.reverse.join


Measured memory_bytes: 14328
//  __      __       .__           .____________                   __________        __ ________   __                 
// /  \    /  \ ____ |_________  __| _\______   \__ __  ____  _____\______   \__ ___/  |\_____  \ |  | ______  ___.__.
// \   \/\/   _/ __ \|  \_  __ \/ __ | |    |  _|  |  \/ ___\/  ___/|    |  _|  |  \   __/   |   \|  |/ \__  \<   |  |
//  \        /\  ___/|  ||  | \/ /_/ | |    |   |  |  / /_/  \___ \ |    |   |  |  /|  |/    |    |    < / __ \\___  |
//   \__/\  /  \___  |__||__|  \____ | |______  |____/\___  /____  >|______  |____/ |__|\_______  |__|_ (____  / ____|
//        \/       \/               \/        \/     /_____/     \/        \/                   \/     \/    \/\/     

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define ff first
#define ss second
#define PI 3.14159265358979323846
#define endl '\n'

using namespace std;

void solve()
{
    ll n;
    cin >> n;
    ll ans = 0;
    n--;
    for(ll i = 1; i * i <= n; i++)
        if(n % i == 0)
        {
            ans++;
            //cout << i << " ";
            if(i * i < n)
            {
                ans++;
                //cout << n / i << " ";
            }
        }
    //cout << endl;
    //cout << ans << endl;
    n++;
    for(ll i = 2; i * i <= n; i++)
    {
        if(n % i == 0)
        {
            ll t = n;
            while(t % i == 0)
                t /= i;
            if(t % i == 1)
            {
                ans++;
                //cout << i << " ";
            }
            if(i * i < n)
            {
                ll t = n;
                ll u = n / i;
                while(t % u == 0)
                    t /= u;
                if(t % u == 1)
                {
                    ans++;
                    //cout << u << " ";
                }
            }
            //cout << endl;
        }
    }
    cout << ans << endl;
}

int main()
{
	int q = 1;
	//scanf("%d", &q);
	for(int i = 1; i <= q; i++)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3568
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int rank[110];
int main()
{
	int a,b;
	while(cin >> a >> b)
	{
		if(a==0&&b==0)
		{
			if(rank[1]%2==1&&rank[2]%2==1)
			{
				bool flag=true;
				for(int i=3;i<=100;i++)
				{
					if(rank[i]%2==1)
					{
						flag=false;
						break;
					}
				}
				if(flag)cout << "OK" << endl;
				else cout << "NG" << endl;
			}
			else cout << "NG" << endl;
			memset(rank,0,sizeof(rank));
		}
		else
		{
			rank[a]++;
			rank[b]++;
		}
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
#define inf 0x3f3f3f3f
vector<ll>a;
stack<char>b;
//std::ios::sync_with_stdio(0); std::cin.tie(0);
int main() {
	ll n, t = 0;
	cin >> n;
	while (n > 0) {
		a.push_back(n % 26);
		n /= 26;
	}
	int i;
	for (i = 0; i < a.size(); ++i) {
		if (i == a.size()-1 && a[i] <= 0)break;
		if (a[i] > 0)b.push(a[i] + 'a' - 1);
		else {
			a[i] += 26;
			a[i + 1] -= 1;
			b.push(a[i] + 'a' - 1);
		}
	}
	while (!b.empty()) {
		cout << b.top();
		b.pop();
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define all(v) v.begin(), v.end()
typedef int64_t lint;

int main() {
	int N;
	cin >> N;
	vector<lint> v(N);
	rep(i, N) {
		cin >> v.at(i);
	}

	lint a=0, b=0, c=0, x, y, z;
	bool f = true;
	sort(all(v));
	reverse(all(v));
	rep(i, N-1) {
		a += v.at(b);
		if (f) b++;
		f = !f;
	}
	std::cout << a << '\n';
}


Measured memory_bytes: 4812
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
using ll = long long;
int N,M;
using P = pair<ll,ll>;
vector<vector<P>> G;
ll memo[100010][2];
bool vis[100010][2];
void dfs(int v,int t,ll a){
	if(vis[v][t]){
		if(memo[v][t] != a){
			puts("0");
			exit(0);
		}
		return;
	}
	vis[v][t] = 1;
	memo[v][t] = a;
	for(P p:G[v]){
		int u = p.fs;
		ll c = p.sc;
		dfs(u,t^1,c-a);
	}
}
int main(){
	cin>>N>>M;
	G.resize(N);
	rep(i,M){
		int u,v,s;
		cin>>u>>v>>s;
		u--,v--;
		G[u].pb(P(v,s));
		G[v].pb(P(u,s));
	}
	dfs(0,0,0);
	if(vis[0][1]){
		if(memo[0][1]%2!=0){
			puts("0");
			return 0;
		}
		ll X = memo[0][1]/2;
		bool ok = 1;
		rep(i,N){
			ll a = memo[i][0], b = memo[i][1];
			if((b-a)%2!=0) ok = 0;
			if((b-a)/2 != X) ok = 0;
			if(X+a<=0) ok = 0;
			if(-X+b<=0) ok = 0;
		}
		if(ok) puts("1");
		else puts("0");
	}else{
		ll lb = 1, ub = 1e10;
		rep(i,N){
			if(vis[i][0]){
				chmax(lb,1-memo[i][0]);
			}else{
				chmin(ub,memo[i][1]-1);
			}
		}
		ll ans = ub-lb+1;
		if(ans<0) ans = 0;
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 16000
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a*b;
        int length = 2*a + 2*b;
        System.out.println(area + " " + length);
        sc.close();
    }
}


Measured memory_bytes: 26096
N, M = gets.chomp.split(" ").map(&:to_i)
P = gets.chomp.split(" ").map(&:to_i)
R = Hash.new{|h, k| h[k] = []}
M.times{|i|
  x, y = gets.chomp.split(" ").map(&:to_i)
  R[x] << y
  R[y] << x
}

ans = 0
lst = (1..N).to_a
until lst.empty? do
  s = lst.shift
  bef = [s]
  pos = [s]
  num = [P[s-1]]
  until bef.empty? do
    nxt = []
    bef.each{|b|
      R[b].each{|r|
        nxt << r
        pos << r
        num << P[r-1]
      }
      R.delete(b)
    }
    bef = nxt.uniq
  end
  pos.each{|n|
    idx = lst.bsearch_index{|x| x >= n}
    next if idx.nil?
    lst.delete_at(idx) if lst[idx] == n
  }
  ans += (pos & num).size
  pos.clear
  num.clear
end

puts ans


Measured memory_bytes: 28116
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int main()
 {
   string str;
   string su;
   cin>>str>>su;
   string str2=str+str;
   if(str2.find(su)!=string::npos) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   //while(1);
   return 0;
 }

 
 

Measured memory_bytes: 3212
#include <iostream>
#include <string>
#include <string.h>
using namespace std;

int main()
{
    int stu[101][101];
    //bool flag[101][101];
    //int get[101][2];
    int n;
    while(cin>>n && n!=0)
    {
             int i,j;
             int min=200000;
             int max=0;
             int min_num=0,minmin_num=0,max_num=0;
             bool flag=true;
             for(i=0;i<n;i++)
             {   for(j=0;j<n;j++)
                 {
                     cin>>stu[i][j];
                     if(min>stu[i][j]){min=stu[i][j];min_num=j;}
                 }
                 if(max<min){max=min;max_num=i;minmin_num=min_num;}
                 min=200000;
             }
             for(i=0;i<n;i++){
                              if(stu[i][minmin_num]>max){ flag=false;break;cout<<234<<endl;}
                              }
             if(flag)
                     cout<<max<<endl;
             else
                     cout<<0<<endl;                 
    }
    return 0;
}

Measured memory_bytes: 0
# ABC136.py

SELECT = "ABC"[1]

if SELECT == "A":  # Transfer

    a, b, c = map(int, input().split())
    ans = c - (a - b)
    if ans < 0:
        print(0)
    else:
        print(ans)

if SELECT == "B":  # UnevenNumbers

    n = int(input())

    length = len(str(n))
    if length % 2 == 0:
        ans = 0
        for i in range(0, length-1, 2):
            ans += 9 * 10 ** i
    else:
        ans = n
        for i in range(1, length, 2):
            ans -= 9 * 10 ** i
    print(ans)

    """
    if n == 100000:
        print(90909)
    elif (9999 < n) and (n < 100000):
        print(909 + n - 9999)
    elif (999 < n) and (n < 10000):
        print(909)
    elif (99 < n) and (n < 1000):
        print(9 + n - 99)
    elif (9 < n) and (n < 100):
        print(9)
    else:
        print(n)
    """

if SELECT == "C":  # BuildStairs

    n = int(input())
    s = list(map(int, input().split()))
    bar = 0
    for i in range(n):
        if bar < s[i]:
            bar = s[i]
        elif s[i] + 1 < bar:
            print("No")
            exit()

    print("Yes")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

bool f(string s){
    int n = s.size();
    rep(i, n / 2) {
        if(s[i] != s[n - 1 - i]){
            return false;
        }
    }
    return true;
}

signed main() {
    string s;
    cin >> s;
    int n = s.size();
    if (f(s) && f(s.substr(0, n / 2)) && f(s.substr((n + 1) / 2, n / 2))){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*
_____________________$$o____________________o$$$$$o__
___________________o$o_$$o____oo$$$$$$$oo______o$$$$o
______________$o________o$$$$$o___oo$$$$$$$o______$$$
______________$$$ooo________o$$$$o______o$$$$$o_____o
____________oo_____oo_____oo___o$$$$$______$$$$$$____
_________ooooo___$$o_$___oooooo___o$$$$o__o__o$$$$___
_______ooo__ooo$$$$o_$$ooooooooooo__o$$$o__oo_oo$$$o_
______oo_o$$o_$$_o$o_o$o__oooooooooo__o$$$o_oo__o$$$o
____oooooo$$$$o___oo__$$o_ooo_oooooooo__o$$o_ooo_o$$$
___ooooooo__o___oooo__$$ooooo$_oooooooo__o$$__ooo_$$$
_$$o_ooooo___o$$$$$o__o$o__o_$o__oooooooo_o$$o_oo__$$
_$$$o_ooo_________o$$_$$o____$$o_ooooooooo_$$$o_oo_$$
__oo________o$$o____o_$$o____o$ooooooooooo_o$$o_oo_o$
___o$$$$$$$$$$$$$o___$$$o____$$o_oooooooooo_$$$o_o_o$
________o__oo$$$$$o__$$$o____$$o____oooooo__$$$o_o_o$
_________$$$$$$$$$o__$$_____$$$o___________$$$oooooo_
__________o$$$$$$$o_________$$___________o$o___oooooo
___________o$$$$o_______________ooooo__oo$__ooo__oooo
________________________________ooo_$$oo___oooo$o____
________________________________oooo_$$$$$o___oo$$$o_
________________________________ooooo_o$$$$$o_____$$$
________________________________oooooo_o$$$$$$ooo___o
________________________________ooooooo__o$$$$$o_____
*/
#include<bits/stdc++.h>
#define ll long long
#define ft first
#define sd second
#define HageBaIO_KPOCCbI int LOL;scanf("%d", &LOL);for(int i = 0; i < LOL; i++)
using namespace std;
//BY |3 |<
const int dx[] = {1, 0, -1,  0};
const int dy[] = {0, 1,  0, -1};
//Where I am?
const ll N = 1e5 + 5;
const ll MOD = (1e9 + 7);
const ll MOD1 = 998244353;
const double PI = 3.14159265;
const int INF32 = 2e9;
const ll INF64 = 2e18;
//Don`t believe!!!//
ll x, k;
void KEK(){
	cin>>x>>k;
	x %= k;
	cout<<min(x, k - x);
}
int main(){
	//HageBaIO_KPOCCbI
	KEK();
}
//TAUMAC, 9| BbIWEJI 3A TObOU!!!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 



Measured memory_bytes: 256
S = [int(c) for c in input()]
N = len(S)
ans = S[-1]
for i in range(2,N + 1):
    num = S[-i]
    ans = 2 * ans + num * (10 ** (i - 1))
    for j in range(i - 1):
        ans += num * (10 ** j) * (2 ** (i - j - 2))
print(ans)

Measured memory_bytes: 3060
n=int(input())
x=list(map(int,input().split()))
x.sort()
v=x[0]
y=True
for i in range(1,len(x)):
  if v==x[i]:
    y=False
    break
  else:
    v=x[i]
    
if y==True:
  print("YES")
else:
  print("NO")


Measured memory_bytes: 25936
n=int(input())
a=[0,1,3,3,7,7,7,14,22,22,22,33,33,46,60]
b=[0,1,2,2,3,3,3,4,5,5,5,6,6,7,8]
print(60*((n//15)**2)+b[n%15]*(15*(n//15))+a[n%15])

Measured memory_bytes: 9032
#include<bits/stdc++.h>
#include <math.h>
#include <cmath>
#include <limits>
#include <iostream>
#include <assert.h>

#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=10000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	int x,y,cost;
};
int x[51];
ll dp[2501][51][51]={};
int main(){

	int n,a;
	cin>>n>>a;

	rep(i,n){
		cin>>x[i+1];
		dp[0][0][i]=1;
	}
	for(int i=1; i<n+1; i++){
		for(int j=1; j<=i; j++){
			for(int k=1; k<2501; k++){
				if(x[i]<=k)dp[k][j][i]+=dp[k-x[i]][j-1][i-1];
				dp[k][j][i]+=dp[k][j][i-1];
			}
		}
	}
	ll total=0;
	for(int j=1; j<n+1; j++){
		for(int k=1; k<2501; k++){
			if(k%j==0&&k/j==a)total+=dp[k][j][n];
		}
	}
	cout<<total<<endl;
	return 0;

}



Measured memory_bytes: 51072
#include<stdio.h>

typedef struct{
  int parent;
  int left;
  int right;
} tree;
tree t[1000000];

int main(){
  int a,b,c,id,k,m,depth = 0;
  int h[100000];
  scanf("%d",&a);


  for(b = 0; b < a; b++){
    t[b].parent = -1;
    t[b].left = -1;
    t[b].right = -1;
  }

  for(b = 0; b < a; b++){
    scanf("%d%d",&id,&k);
    for(c = 0; c < k; c++){
      scanf("%d",&h[c]);
      if(c == 0){
	t[h[0]].parent = id;
	t[id].left = h[0];
      }else{
	t[h[c]].parent = id;
	t[h[c-1]].right = h[c];
      }
    }
  }
  
  for(b = 0; b < a; b++){
    printf("node %d: parent = %d,",b,t[b].parent);
    m = b;
    while(t[m].parent != -1){
      depth++;
      m = t[m].parent;
    }
    printf(" depth = %d,",depth);
    depth = 0;
    if(t[b].parent == -1 && t[b].left == -1){
      printf(" root, []\n");
    }
    else if(t[b].parent == -1 && t[b].left != -1){
      printf(" root, [%d",t[b].left);
      for(c = t[t[b].left].right;c!=-1;c = t[c].right){
	printf(", %d",c);
      }
      printf("]\n");
    }

    else if(t[b].left!=-1){
      printf(" internal node, [%d",t[b].left);
      for(c = t[t[b].left].right;c!=-1;c=t[c].right){
	printf(", %d",c);
      }
      printf("]\n");
    }


    else{
      printf(" leaf, []\n");
    }
  }

  return 0;
}



Measured memory_bytes: 3252
S=input()

first=int(S[0:2])
second=int(S[2:4])

if (first>12 or first==0)and (second>12 or second==0):
    print('NA')
    
elif first<=12 and (second>12 or second==0):
    print('MMYY')
    
elif (first>12 or first==0) and second<=12:
    print('YYMM')
    
else:
    print('AMBIGUOUS')

Measured memory_bytes: 3064
////jsjks

#include<stdio.h>
int main()
{
    double l,e;
   scanf("%lf",&l);
        
        e=(l/3.0)*(l/3.0)*(l/3.0);
        
        
   printf("%lf",e);
        
        
        
        
    
    
    return 0;
}

Measured memory_bytes: 1716
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define pb push_back
#define __ ios_base::sync_with_stdio(false); cin.tie(NULL);

void scan(ll &n) { scanf("%lld",&n) ; }
void scan(ll &n, ll &m) { scanf("%lld%lld",&n,&m) ; }
void scan(vector<ll> &v) { ll n = v.size() ; for(ll i=0 ;i<n;i++) scanf("%lld",&v[i]) ; }


void solve() {

    ll n , x ,t ;
    cin >> n >> x >> t ;
    n = (n+x-1)/x ;
    cout << n*t << endl ;
}

int main() {

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

	ll t = 1 ;
	//cin >> t ;
	for (ll cz = 1 ;cz <= t ; cz++) {
       // cout << "Case " <<cz <<": " ;
        solve() ;
	}
    return 0 ;
}







Measured memory_bytes: 3636
A,B,C,D = input()

for i in range(2**3):
    op = ['+']*3
    for j in range(3):
        if((i>>j) & 1):
            op[j] = '-'
    
    if eval(A+op[0]+B+op[1]+C+op[2]+D) == 7:
        print(A+op[0]+B+op[1]+C+op[2]+D+'=7')
        break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,t;
  	ci(n>>t);
  ll now=0;
  ll ans=0;
  FOR(i,0,n){
    ll a;
    	ci(a);
    if(a<=now){
      ans+=(a+t-now);
    }
    else{
      ans+=t;
    }
    now=a+t;
  }
  co(ans)
}

Measured memory_bytes: 256
//============================================================================
// Name        : c.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	int n;cin>>n;
	int m;cin>>m;
	vector<int> p(m),y(m),f(m);
//	vector<int> pk(n+1,0);
	vector<vector<pair<int,int>>> pv(n+1);

	for(int i=0;i<m;i++){
		cin>>p[i]>>y[i];
//		pk[p[i]]++;
		pv[p[i]].push_back(make_pair(y[i],i));
	}

	for(int i=1;i<=n;i++){
		sort(pv[i].begin(),pv[i].end());
//		for(int j=0;j<pv[i].size();j++){
//			cout<<pv[i][j].first<<' '<<pv[i][j].second<<endl;
//		}
//		cout<<endl;
		for(int j=0;j<pv[i].size();j++){
			f[pv[i][j].second]=j+1;
		}
	}

	for(int i=0;i<m;i++){
			int tp=p[i];
			int d=0;
			while(tp){
				tp/=10;
				d++;
			}
			for(int k=1;k<=6-d;k++){
				cout<<0;
			}
			cout<<p[i];
			int tj=f[i];
			d=0;
			while(tj){
				tj/=10;
				d++;
			}
			for(int k=1;k<=6-d;k++){
				cout<<0;
			}
			cout<<f[i]<<endl;;

	}

	return 0;
}

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

int main(void)
{
	string str;
	int count[26] = {};
	//getline(cin, str);
	while (getline(cin, str))
	{
		for (int i = 0; i < str.size(); i++)
		{
			if ('a' <= str[i] && str[i] <= 'z') count[str[i] - 'a']++;
			else if ('A' <= str[i] && str[i] <= 'Z') count[str[i] - 'A']++;
		}
		if (str.size() == 0) break;
	}
	for (int i = 0; i < 26; i++)
	{
		cout << (char)('a' + i) << " : " << count[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3216
from collections import defaultdict
import re
import sys

def count_char(inp):

    dic = { chr(c) : 0 for c in range(97, 123)}

    inp = re.sub("[,.]", "", inp)
    inp = inp.replace("\n", "")
    inp = inp.lower()

    for c in inp:
        if c in dic.keys():
            dic[c] += 1

    for n, (k, v) in enumerate(dic.items()):
        print(str(k) + " : " + str(v), end = "")

        if n != len(dic) - 1:
            print("\n", end = "")
        else:
            print("\n", end = "")

if __name__ == "__main__":

    # str = ""
    #
    # while(True):
    #     param = input().split("\n", "")
    #
    #     if param != "":
    #         str += param
    #     else:
    #         break
    #
    #
    # str = "".join(s)

    stri = ""

    for e in sys.stdin:
        stri += e
    
    count_char(stri)



Measured memory_bytes: 6532
#include "bits/stdc++.h"
using namespace std;
struct ${$(){ios_base::sync_with_stdio(0);cin.tie(0);}}$;

const int N = 200005;

int main() {
   int a, b, c, d;
   cin >> a >> b >> c >> d;
   if(a + b == c + d) {
      cout << "Balanced" << endl;
   } else if(a + b > c + d) {
      cout << "Left" << endl;
   } else {
      cout << "Right" << endl;
   }
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int count = 0;
    string s, t;
    cin>>s>>t;

    int s_length = s.length();

    for(int i = 0 ; i < s_length ; i++)
    {
        if(s[i] == t[i])
        {
            count++;
        }
    }
    if(s_length == count )
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }

    return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
int main(void)
{
    int i,j,a;
    for(i=1;i<=9;i++){
        for(j=1;j<=9;j++){
            a = i*j;
            printf("%dx%d=%d\n",i,j,a);
        }
    }
    return 0;
}



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

using namespace std;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.in" , "r" , stdin);
#endif
    int n;
    cin >> n;

    vector<int> a(n);
    for (int &x : a)
        cin >> x;

    sort(a.rbegin() , a.rend());

    long long ans = a.front();
    for (int i = 1 , j = 2 ;j < n ;j += 2 , i++) {
        if (j + 1 < n)
            ans += 2 * a[i];
        else
            ans += a[i];
    }

    cout << ans;
}

Measured memory_bytes: 3980