akhauriyash/Code-Regression huggingface dataset:
import sys
from collections import deque

def main():
    N, A, B, C = map(int, input().split())
    s_list = [input() for i in range(N)]

    select_list = deque()
    select_list.append('Yes')
    for i, i_s in enumerate(s_list):
        if i_s == 'AB':
            if A == 0 and B == 0:
                select_list = ['No']
                break
            elif A == 1 and B == 1:
                if i+1 >= N:
                    A -= 1
                    B += 1
                    select_list.append('B')
                    continue
                if s_list[i+1] == 'AC':
                    A += 1
                    B -= 1
                    select_list.append('A')
                else:
                    A -= 1
                    B += 1
                    select_list.append('B')
            elif A > B:
                A -= 1
                B += 1
                select_list.append('B')
            else:
                A += 1
                B -= 1
                select_list.append('A')
        elif i_s == 'AC':
            if A == 0 and C == 0:
                select_list = ['No']
                break
            elif A == 1 and C == 1:
                if i+1 >= N:
                    A -= 1
                    C += 1
                    select_list.append('C')
                    continue
                if s_list[i+1] == 'AB':
                    A += 1
                    C -= 1
                    select_list.append('A')
                else:
                    A -= 1
                    C += 1
                    select_list.append('C')
            elif A > C:
                A -= 1
                C += 1
                select_list.append('C')
            else:
                A += 1
                C -= 1
                select_list.append('A')
        else:
            if B == 0 and C == 0:
                select_list = ['No']
                break
            elif B == 1 and C == 1:
                if i+1 >= N:
                    B -= 1
                    C += 1
                    select_list.append('C')
                    continue
                if s_list[i+1] == 'AB':
                    B += 1
                    C -= 1
                    select_list.append('B')
                else:
                    B -= 1
                    C += 1
                    select_list.append('C')
            elif B > C:
                B -= 1
                C += 1
                select_list.append('C')
            else:
                B += 1
                C -= 1
                select_list.append('B')

    for i in select_list:
        print(i)

    return

if __name__ == '__main__':
    main()
    sys.exit(0)

Measured memory_bytes: 81528
require"zlib"
ans=[]
[?m,?a,?p,?u,?t,?s].permutation(6){|a,b,c,d,e,f|
t="#{a}=0..59;puts 9394,#{b}=?+,0,1,#{c}=8,?<,2,8,3,[0,1].map{|#{d}|[#{b},3,#{d},#{d}]+#{a}.map{[#{b},#{e}=#{d}+4,#{e},#{e},#{b},3,#{e},6,[#{b},6,6,6]*(59-_1),?<,6,#{d},#{c}+=1,#{b},#{c},#{e},#{e}]}},#{a}.map{|#{f}|[#{b},2,2,2]+(1..#{f}).map{[#{b},39+#{f}-_1,98+_1,5,?<,3,5,5,#{b},5,2,2]}}"
s=Zlib.deflate t
ans<<"#!ruby -Krzlib
eval Zlib.inflate'#{s}'" unless s=~/\x1A/||s=~/'/
}
eval ans[0]

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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int H,W;
int dist[410][410];
int dx[4]={-1,1,0,0};
int dy[4]={0,0,-1,1};
char s[410][410];
bool used[410][410]={};

long long bfs(int x,int y){
    long long w=0;long long b=0;
    queue<P> que;
    que.push({x,y});
    used[x][y]=true;
    while(!que.empty()){
        P q=que.front(); que.pop();
        if(s[q.first][q.second]=='.') w++;
        else b++;
        for(int i=0;i<4;i++){
            int nx=q.first+dx[i]; int ny=q.second+dy[i];
            if(nx>=0&ny>=0&&nx<H&&ny<W){
                if(used[nx][ny]==true) continue;
                if(s[q.first][q.second]==s[nx][ny]) continue;
                used[nx][ny]=true;
                que.push({nx,ny});
            }
        }
    }
    return w*b;
}

int main(){
    cin >> H >> W;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> s[i][j];
        }
    }
    long long ans=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(s[i][j]=='.') continue;
            if(used[i][j]) continue;
            ans+=bfs(i,j);
        }
    }
    cout << ans << endl;
}


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

int main() {
    long long a, b, x, y, count=1;
    cin >> a >> b;
    x=__gcd(a, b);
    y=sqrt(x);
    for(int i=2; i<=y; i++) {
        if(x%i==0) {
            count++;
            while(x%i==0) {
                x /= i;
            }
        }
    }
    if(x != 1) count++;
    cout << count;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
a = list(map(int,input().split()))
c = [0]
x = 0
for i in a:
    x += i
    c.append(x)

data = []
for i in range(n+1):
    for j in range(i+1,n+1):
        data.append(c[j]-c[i])

data.sort()
ans = 0
for bit in range(45,-1,-1):
    new_data = []
    for d in data:
        if d>>bit&1:
            new_data.append(d)
    if len(new_data) >=k:
        data = new_data
        ans += 2**bit

print(ans)

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

int bitlen(int n) {
  int cnt = 0;
  while (n > 0) {
    ++cnt;
    n /= 2;
  }
  return cnt;
}

int main() {
  int l;
  cin >> l;
  
  int n = bitlen(l);
  vector<tuple<int, int, int>> edges;
  for (int i = n - 2, j = 0; i >= 0; --i, ++j) {
    edges.emplace_back(i, i + 1, 0);
    edges.emplace_back(i, i + 1, 1 << j);
  }
  for (int i = 0; i < n - 1; ++i) {
    if (l & (1 << i)) {
      edges.emplace_back(0, n - i - 1, (l >> (i + 1)) << (i + 1));
    }
  }
  
  cout << n << ' ' << edges.size() << '\n';
  for (auto& edge: edges) {
    int from, to, len;
    tie(from, to, len) = edge;
    cout << from + 1 << ' ' << to + 1 << ' ' << len << '\n';
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//







int main(void) {

    ll x; cin >> x;
    ll ans = x / 11 * 2;
    if (x % 11 != 0) {
        if (x % 11 <= 6) {
        ans += 1;
        }
        else {
            ans += 2;
        }
    }
    out(ans);
    

    return 0;
}











Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

int main(){
    long long n, m;
    cin >> n >> m;
    vector<vector<long long> > path(n);

    for(long long i = 0; i < m; i++){
        long long a, b;
        cin >> a >> b;
        path[a-1].push_back(b-1);
        path[b-1].push_back(a-1);
    }

    queue<long long> q;
    vector<long long> distance(n, -1);
    vector<long long> result(n);
    distance[0] = 0;
    q.push(0);

    while(!q.empty()){
        long long top = q.front();
        q.pop();

        for(long long next = 0; next < path[top].size(); next++){
            if(distance[path[top][next]] == -1){
                q.push(path[top][next]);
                result[path[top][next]] = top;
                distance[path[top][next]] = distance[top] + 1;
            }
        }
    }

    printf("Yes\n");

    for(long long i = 1; i < n; i++){
        printf("%lld\n", result[i]+1);
    }

    return 0;

}

Measured memory_bytes: 13572
fn main() {
    let _n: usize = read();
    let s: Vec<char> = read::<String>().chars().collect();

    let mut ans = 0;
    for i in 0..1000 {
        let pass: Vec<char> = format!("{:0>3}", i).chars().collect();

        let mut start = 0;
        let mut flag = true;
        for c in pass.iter() {
            match find_from(&s, start, *c) {
                Some(index) => start = index + 1,
                None => {
                    flag = false;
                    break;
                },
            }
        }

        ans += flag as i64;
    }

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

fn find_from(seq: &Vec<char>, from: usize, key: char) -> Option<usize> {
    for i in from..(seq.len()) {
        if seq[i] == key {
            return Some(i)
        }
    }
    None
} 

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()
}


Measured memory_bytes: 4352
#include<iostream>

using namespace std;

int main(){
  double in;
  while(cin >> in){
    if(in == -1) break;

    double dec;
    dec = in - (int)in;
    in = (int)in;

    int data[12];
    int div = 128;
    for(int i = 0; i < 8; i++){
      if(in >= div){
	data[i] = 1;
	in -= div;
      }else data[i] = 0;
      div /= 2;
    }
    double divd = 0.5;
    for(int i = 8; i < 12; i++){
      if(dec >= divd){
	data[i] = 1;
	dec -= divd;
      }else data[i] = 0;
      divd /= 2;
    }

     if(in || dec){
      cout << "NA" << endl;
      continue;
      }

    for(int i = 0; i < 8; i++) cout << data[i];
    cout << ".";
    for(int i = 8; i < 12; i++) cout << data[i];
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;





int main(int argc, const char * argv[]) {
    
   
    cin.tie(0);
    ios::sync_with_stdio(false);
   
    
    int H,W; cin >> H >> W;
    vector<string> field(H);
    rep(i,H) cin >> field[i];
    
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            
            int nowH = i;
            int nowW = j;
            
            if(field[nowH][nowW]=='#') {
                cout << '#';
                continue;
            }
            
            int bomb = 0;
            
            for (int k = 0; k < 8; k++) {
                int newH = nowH + dx8[k];
                int newW = nowW + dy8[k];
                
                
                if( !(0<=newH&&newH<H && 0<=newW&&newW<W) ) continue;
                if( field[newH][newW] == '#' ) bomb++;
            }
            
            cout << bomb;
            bomb = 0;
        
        }
        
        cout << endl;
        
    }
    cout << endl;
    
    
    
}


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

using ll = long long;

const int N = 200005;
const ll INF = ll(1e18);

struct E{ int s, e; ll x; };

int n, q, c, p[N];
ll v[N], w[N], r;
E e[2 * N];

int f(int x){ return p[x] = (x == p[x] ? x : f(p[x])); }

int main(){
    scanf("%d%d", &n, &q);
    fill(v, v + n, INF);
    fill(w, w + n, INF);
    for(int x, y, z; q--; ){
        scanf("%d%d%d", &x, &y, &z);
        v[x] = min(v[x], z + 1LL);
        v[y] = min(v[y], z + 2LL);
        e[c++] = {x, y, ll(z)};
    }
    ll m = INF;
    for(int i = 0; i < 2 * n; i++){
        m = min(m + 2, v[i % n]);
        w[i % n] = min(w[i % n], m);
    }
    for(int i = 0; i < n; i++) e[c++] = {i, (i + 1) % n, w[i]};
    sort(e, e + c, [](E x, E y){ return x.x < y.x; });
    iota(p, p + n, 0);
    for(int i = 0; i < c; i++){
        int x = f(e[i].s), y = f(e[i].e);
        if(x == y) continue;
        r += e[i].x;
        p[y] = x;
    }
    printf("%lld\n", r);
}

Measured memory_bytes: 10368
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

s = I()
def f(n):
    if n % 2 == 0:
        return int(n/2)
    else:
        return int(3*n+1)
use = {s}
a = s
for i in range(1, 10**6+1):
    na = f(a)
    if na in use:
        print(i+1)
        exit()
    use.add(na)
    a = na


Measured memory_bytes: 72496
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#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 fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
bool func(int x){
  int cnt=0;
  while(x>0){
    x/=10;
    cnt++;
  }
  if(cnt%2!=0)return true;
  else return false;
}
int main(){
  int n;
  cin>>n;
  int ans=0;
  for(int i=1;i<=n;i++){
    if(func(i))ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.Math;

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

        int n = sc.nextInt();
        double t = sc.nextInt();
        double a = sc.nextInt();

        int cand = 0;
        double min = Integer.MAX_VALUE;

        for (int i = 0; i < n; i++) {
            double dif = Math.abs(t - (sc.nextDouble() * 0.006) - a);
            if (dif < min) {
                cand = i;
                min = dif;
            }
        }
        System.out.println(cand + 1);
    }
}


Measured memory_bytes: 27244
fn main() {
    let mode = "b";
    if mode == "a" {
        a::solve();
    } else if mode == "b" {
        b::solve();
    }
}

mod b {
    use std;
    use std::io::Read;

    pub fn solve() {
        let mut buf = String::new();
        std::io::stdin().read_to_string(&mut buf).unwrap();
        let n = buf.split_whitespace().next().unwrap().parse().unwrap();
        let res = calc(n);
        println!("{}", res);
    }

    fn calc(num: i32) -> i32 {
        let mut base = 10;
        let mut res = 0;
        loop {
            if num >= base {
                res += base - base / 10;
                base *= 100;
            } else {
                break;
            }
        }

        let amari = match num - (base / 10) >= 0 {
            true => num - (base / 10) + 1,
            false => 0,
        };

        res + amari
    }
}

mod a {
    use std;
    use std::io::Read;

    pub fn solve() {
        let mut buf = String::new();
        std::io::stdin().read_to_string(&mut buf).unwrap();
        let mut text = buf.split_whitespace();
        let a = text.next().unwrap().parse().unwrap();
        let b = text.next().unwrap().parse().unwrap();
        let c = text.next().unwrap().parse().unwrap();

        let res = calc(a, b, c);
        println!("{}", res);
    }

    fn calc(a: i32, b: i32, c: i32) -> i32 {
        let used = std::cmp::min(a - b, c);
        c - used
    }

    #[cfg(test)]
    mod tests {
        #[test]
        fn test1() {}
    }

}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int N;
long long W, w[110], v[110];

ll dp[110][100010];

int main(){
  cin >> N >> W;
  rep(i, N) cin >> w[i] >> v[i];

  rep(i, N){
    rep(wj, W+1){
      if(wj + w[i] <= W){
        chmax(dp[i+1][wj + w[i]], dp[i][wj] + v[i]);
      }
      chmax(dp[i+1][wj], dp[i][wj]);
    }
  }

  cout << dp[N][W] << endl;

  return 0;
}


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

using namespace std;

typedef pair<int,int> P;
typedef long long ll; 

#define int ll

const ll mod = 1e9 + 7;


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

	for(int i=0;i<s.length();i++){
		if(s[i]!=t[i]) ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3884
#include <bits/stdc++.h>
using namespace std;
int n,m,a,b,g[200002][2],is_del[200002];
vector<int> v[200002],u;
string s;

int main (){
    cin >> n >> m;
    cin >> s;
    for (int i = 0; i < m ; i++ ){
        cin >> a >> b ;
        v[a].push_back(b);
        v[b].push_back(a);
        g[a][s[b - 1] == 'A' ] ++;
        g[b][s[a - 1] == 'A' ] ++;
    }
    for(int i=1;i<=n;i++) {
        if(!g[i][0] || !g[i][1]){
            is_del[i] = 1;
            u.push_back(i);
        }
    }
    for (int i=0;i<u.size();i++){
        for(auto j:v[u[i]]){
            g[j][ s[ u[i] - 1 ] == 'A' ] -- ;
            if(!(g[j][ s[ u[i] - 1 ] == 'A' ]) && !is_del[j]){
                u.push_back(j);
                is_del[j] = 1;
            }
        }
    }
    if (u.size() != n){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 13824
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>

enum Color { red,
             blue };

Color query(const std::vector<int>& v) {
    std::cout << '?';
    for (auto& x : v) {
        std::cout << ' ' << x + 1;
    }
    std::cout << std::endl;

    std::string s;
    std::cin >> s;
    if (s == "Red") return red;
    if (s == "Blue") return blue;
    std::exit(0);
}

void answer(const std::string& s) {
    std::cout << '!' << ' ' << s << std::endl;
    std::exit(0);
}

int main() {
    int n;
    std::cin >> n;

    std::vector<int> idx(n * 2);
    std::iota(idx.begin(), idx.end(), 0);

    auto rquery = [&](int l) {
        // l < n
        std::vector<int> v;
        for (int i = 0; i < n; ++i) {
            v.push_back(idx[l + i]);
        }
        return query(v);
    };

    Color c = rquery(0);
    if (c == blue) {
        std::rotate(idx.begin(), idx.begin() + n, idx.end());
    }

    // [0, n): red, [n, 2n): blue
    int ok = 0, ng = n;
    while (ng - ok > 1) {
        int mid = (ok + ng) / 2;
        c = rquery(mid);
        (c == red ? ok : ng) = mid;
    }

    // [ok, ok + n): red, [ok + n, ok + 2n): blue
    std::rotate(idx.begin(), idx.begin() + ok, idx.end());
    // [0, n): red, [1, n]: blue

    std::string preans(n * 2, '*');
    preans[0] = 'R';
    preans[n] = 'B';

    for (int i = 1; i < n; ++i) {
        std::vector<int> v{idx[0], idx[n]};
        for (int j = 1; j < n; ++j) {
            if (j == i) continue;
            v.push_back(idx[j]);
        }
        c = query(v);
        preans[i] = (c == red ? 'B' : 'R');
    }

    for (int i = 1; i < n; ++i) {
        std::vector<int> v{idx[0], idx[n]};
        for (int j = 1; j < n; ++j) {
            if (j == i) continue;
            v.push_back(idx[n + j]);
        }
        c = query(v);
        preans[n + i] = (c == red ? 'B' : 'R');
    }

    std::string ans(n * 2, '*');
    for (int i = 0; i < n * 2; ++i) {
        ans[idx[i]] = preans[i];
    }

    answer(ans);
    return 0;
}


Measured memory_bytes: 724
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
//#include <intrin.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 300005
#define inf 2000000000
#define EPS 1e-7
#define MOD 999377ll
#define __builtin_popcount(x) __popcnt(x)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pr;
typedef pair<pair<ll, ll>, pair<ll, ll>> tup;

inline void solve()
{
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	fore(i, 0, n)
		cin >> v[i];
	sort(v.begin(), v.end());
	ll sum = 0;
	fore(i, 0, max(0, n - k))
		sum += v[i];
	cout << sum;
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include<string.h>
#include <algorithm>
#include<math.h>
#include<vector>
#include <queue>
#include <deque> 
#define ll long long
#define M 1000000007 
#define MM 998244353
using namespace std;
 
int main()
{
    int a;

    cin >> a;

    cout << a + a*a + a*a*a;

    return 0;
}

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

int main(){
    string s;
    cin >> s;
    int N = s.length() + 1;
    int a[N];
    for(int i=0; i<N; i++){
        a[i] = 0;
    }

    for(int i=0 ; i<N-1; i++){
        //a[i] = 0;
        if(s[i] == '<'){
            a[i+1] = max(a[i+1], a[i]+1);
        }
        //cout << a[i]; 
    }
    //cout << a[N-1] << endl;
    
    for(int i=N-2; i>=0; i--){
        if(s[i] == '>'){
            a[i] = max(a[i], a[i+1]+1);
        }
    }
    long long int sum = 0;
    for(int i=0; i<N; i++){
        sum += a[i];
    }
    cout << sum << endl;
    return 0;

}

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

int main(){
  int n;
  int top=0;
  int sec = 0;
  int top_num=0;
  cin >> n;
  vector<int> a(n);
  for (int i=0; i<n; i++){
    cin >> a[i];
    if(a[i] > top){
      sec = top;
      top = a[i];
      top_num = i;
    }
    else if(a[i] > sec){
      sec = a[i];
    }
  }
  for(int i=0; i<n; i++){
    if(top_num != i){
      cout << top << endl;
    }
    else{
      cout << sec << endl;
    }
  }
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N, Z, W; cin >> N >> Z >> W;
	int A[N];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	if (N == 1) {
		cout << abs(A[0] - W) << endl;
	}
	else {
		cout << max(abs(A[N - 1] - W), abs(A[N - 1] - A[N - 2])) << endl;
	}
	return 0;
}

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

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

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

int main() {
    int ans = 0;
    int tmp;
    int x, a, b;
    cin >> x >>a >> b;
    if (b-a<=0) cout << "delicious" << endl;
    else if(b-a<=x) cout << "safe" << endl;
    else cout << "dangerous" << endl;
    
    //cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n,c=0,m=0;
    cin>>n;
    long long a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n-1;i++)
    {
        if(a[i]>=a[i+1])
        {
            c++;
            if(c>m)
            {
                m = c;
            }
        }
        else
        {
            c=0;
        }
    }
    cout<<m;
}



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

int main()
{
    int n,k;
    int d[100];
    cin>>n>>k;
    
   vector<int>A(n,0);
   int nu[100][100];
   
  for(int i=0;i<k;i++)
  {
      cin>>d[i];
    
       for(int j=0;j<d[i];j++)
       {
           cin>>nu[i][j];
       }
    
  }
  
  for(int i=0;i<k;i++)
  {
      for(int j=0;j<d[i];j++)
      {
         A.at(nu[i][j]-1)++;
      }

  }
  
  int sum=0;
  for(int i=0;i<n;i++)
  {
      if(A.at(i)==0)
        sum++;
  
  }
  
   cout<<sum<<endl;
  
  return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string &s)
{
    return '"' + s + '"';
}

string to_string(const char *s)
{
    return to_string((string)s);
}

string to_string(bool b)
{
    return (b ? "true" : "false");
}

string to_string(vector<bool> v)
{
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v)
{
    string res = "";
    for (size_t i = 0; i < N; i++)
    {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v)
{
    bool first = true;
    string res = "{";
    for (const auto &x : v)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
#define fst first
#define snd second
#define fr(i, a, b) for(int i=a; i<b; i++)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    double pi = 4 * atan(1.0);
    int a, b, h , m; cin >> a >> b>> h >> m;
    double j1 = (h*60.0 +(double) m)/(12.0*60) * 2 * pi;
    double j2 = (double)m/60.0 *2*pi;
    double d = abs(j1-j2);
    d= min(d, 2*pi - d);
    cout << setprecision(11) << sqrt(a*a + b*b - 2 * a* b * cos(d)) << endl;
}


Measured memory_bytes: 4180
#include <bits/stdc++.h>
using namespace std;
using pi = pair<int, int>;

int chk[11];

bool bad(int x){
	while(x){
		if(chk[x % 10]) return 1;
		x /= 10;
	}
	return 0;
}

int main(){
	int n, k;
	cin >> n >> k;
	while(k--){
		int x; cin >> x;
		chk[x] = 1;
	}
	while(bad(n)) n++;
	cout << n << endl;
}


Measured memory_bytes: 256
s = input()
K = int(s)

if ((K & 1 == 0) or (s[-1] == "5")):
  print(-1)
else:
  if K % 7 == 0:
    L = 9 * K / 7
  else:
    L = 9 * K

  i = 1
  r = 10
  while True:
    r = r % L
    if r == 1:
      print(i)
      break
    r *= 10
    i += 1

Measured memory_bytes: 9200
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  int n;
  cin>>n;
  while(n --> 0){
    int x1,x2,y1,y2;
    cin>>x1>>y1>>x2>>y2;
    x2 += x1; y2 += y1;
    int m;
    cin>>m;
    int ans = 0;
    while(m --> 0){
      int x,y;
      cin>>x>>y;
      if(x >= x1 && x <= x2 && y >= y1 && y <= y2)
        ans++;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	private static Scanner sc = new Scanner(System.in);
	private static int[] p = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997 };
	private static long INF = 1000000007;
	public static void main(String[] args) {
		int[] a = new int[1010];
		for (int i = 1;i <= 1000;i++) {
			a[i] = -1;
		}
		for (int i = 0;i < p.length;i++) {
			a[p[i]] = 0;
		}
		int n = sc.nextInt();
		if (n==1) {
			System.out.println(1);
			return;
		} else if (n==2) {
			System.out.println(2);
			return;
		}

		for (int i = 2;i <= n;i++) {
			int s = i;
			for (int j = 0;j < p.length;j++) {
				int t = p[j];
				while (true) {
					if (s%t==0) {
						a[t]++;
						s /= t;
					} else {
						break;
					}
				}
			}
		}

		long ret = 1;
		for (int i = 1;i <= n;i++) {
			if (a[i]>0) {
				ret *= (a[i]+1);
			}
			ret %= INF;
		}
		System.out.println(ret);
	}
}


Measured memory_bytes: 9684
#include <bits/stdc++.h>
#include <math.h>
#define ll long long
using namespace std;

int main() {
  int H,W,N,ans;
  cin>>H>>W>>N;
  if(N%max(H,W)==0) ans=N/max(H,W);
  else ans=N/max(H,W)+1;
  cout<<ans<<endl;
}	


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<string> vs;
const ll mod = 1e9+7;
const ll inf = 1e17;
const int INF = 1e9;
const double PI = acos(-1);
#define fo(i, a, b) for(int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  int n;
  cin >> n;
  int l, r;
  int s = 0;
  re(i, n) {
    cin >> l >> r;
    s += r - l + 1;
  }
  cout << s << endl;

  return 0;
}


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

using namespace std;

#define PB push_back
#define f first
#define s second

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

const int MOD = 1000000007;
const int INF = 1000000007;
const int MAXN = (int)3e5+1;

void setIO(string name)
{
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //setIO("");
    int n, m;
    cin >> n >> m;
    int arr[n];
    int sum = 0;
    for(int i=0; i<n; i++)
    {
        cin >> arr[i];
        sum += arr[i];
    }
    sort(arr, arr+n);
    if(arr[n-m] * m * 4 < sum)
    {
        cout << "No";
    }
    else
    {
        cout << "Yes";
    }


    return 0;
}


Measured memory_bytes: 256
(let* ((n (read))
    (ans (make-array (+ n 1) :initial-element 0)))
    (loop for x from 1 to 100 do
        (loop for y from 1 to 100 do
            (loop for z from 1 to 100 do
                (if (<= (+ (* x x) (* y y) (* z z) (* x y) (* y z) (* z x)) n)
                    (incf (aref ans (+ (* x x) (* y y) (* z z) (* x y) (* y z) (* z x))))
                ))))
    (loop for i from 1 to n do
        (format t "~D~%" (aref ans i))
    )
)

Measured memory_bytes: 24404
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
int X,Y,A,B,C;
int p[1<<17],q[1<<17],r[1<<17];
main()
{
	cin>>X>>Y>>A>>B>>C;
	for(int i=0;i<A;i++)cin>>p[i];
	for(int i=0;i<B;i++)cin>>q[i];
	for(int i=0;i<C;i++)cin>>r[i];
	sort(p,p+A);
	sort(q,q+B);
	sort(r,r+C);
	long now=0;
	long ans=0;
	for(int i=0;i<X-C;i++)now+=p[A-i-1];
	for(int i=0;i<min(X,C);i++)now+=r[C-i-1];
	priority_queue<int>P;
	long Ps=0;
	for(int i=0;i<B;i++)
	{
		Ps+=q[i];
		P.push(-q[i]);
	}
	for(int i=0;i<C-X;i++)
	{
		Ps+=r[i];
		P.push(-r[i]);
	}
	while(P.size()>Y)
	{
		Ps+=P.top();
		P.pop();
	}
	ans=now+Ps;
	int id=min(X,C);
	for(int i=max(0,X-C);i<X;i++)
	{
		now+=p[A-i-1];
		--id;
		now-=r[C-id-1];
		Ps+=r[C-id-1];
		P.push(-r[C-id-1]);
		if(P.size()>Y)
		{
			Ps+=P.top();
			P.pop();
		}
		ans=max(ans,now+Ps);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 2552
#include <stdio.h>
#include <string.h>

void print(char str[], int a, int b);
void reverse(char str[], int a, int b);
void replace(char str[], int a, int b, char p[]);

int main(void)
{
    int i;

    char str[1001];
    scanf("%s", str);

    int op_num;
    scanf("%d", &op_num);

    char op[8];
    int a, b;
    for (i = 1; i <= op_num; i++) {
        scanf("%s", op);
        scanf("%d %d", &a, &b);

        if (strcmp(op, "print") == 0) {
            print(str, a, b);
        } else if (strcmp(op, "reverse") == 0) {
            reverse(str, a, b);
        } else {
            char p[1001];
            scanf("%s", p);
            replace(str, a, b, p);
        }
    }

    return 0;
}

void print(char str[], int a, int b)
{
    int i;
    for (i = a; i <= b; i++) {
        printf("%c", str[i]);
    }
    printf("\n");
}

void reverse(char str[], int a, int b)
{
    char tmp[1001];
    int i;
    for (i = a; i <= b; i++) {
        tmp[i] = str[b + a - i];
    }
    for (i = a; i <= b; i++) {
        str[i] = tmp[i];
    }
}

void replace(char str[], int a, int b, char p[])
{
    int i;
    for (i = 0; i < b - a + 1; i++) {
        str[a + i] = p[i];
    }
}

Measured memory_bytes: 576
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n, k;
    cin >> n >> k;

    vector<int> a(n + 1);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    vector<int> b(n + 1);

    while (k--) {
        for (int i = 0; i <= n; i++) {
            b[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            b[max(i - a[i], 0)]++;
            b[min(i + a[i] + 1, n)]--;
        }
        for (int i = 0; i < n; i++) {
            b[i + 1] += b[i];
        }
        swap(a, b);

        int t = 1;
        for (int i = 0; i < n; i++) {
            if (a[i] < n) t = 0;
        }

        if (t) break;
    }

    for (int i = 0; i < n; i++) {
        cout << a[i] << " \n"[i == n - 1];
    }

    //自分自身は照らしてる 隣に1以上があれば照らされてる
    //自分の今の明るさは他人にしか関係ないんだなあ いや関係あるのか 0以上なだけで

    return 0;
}

Measured memory_bytes: 4792
#include <iostream>
#include <vector>

using namespace std;

int main()
{
  int N;
  bool isFour = false;
  cin >> N;
  vector<char> s(N);
  for (int i = 0; i < N; i++) {
    cin >> s[i];
  }  
  for (int i = 0; i < N; i++) {
    if (s[i] == 'Y') {
      isFour = true;
      break;
    }
  }
  if (isFour) {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

bool u[1<<20] = {};

int main(){
	int k; scanf("%d", &k);
	for(int i = 7%k, j = 1; !u[i]; i = (i * 10 + 7) % k, j++){
		u[i] = true;
		if(i == 0){
			printf("%d\n", j);
			return 0;
			return 0;
		}
	}
	printf("-1\n");
}


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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int n;
char c;
vector<int> v;

main() {
    cin >> n;
    rep(i,n) {
        cin >> c;
        v.pb((int)c)
    }
    sort(all(v));
    vdelete(v)
    if (v.size() == 3) ct("Three")
    else ct("Four")
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <string>
#define SIZE 100005
#define INF 100000000000000000LL

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

vector <P> vec[SIZE];
ll dp[SIZE];

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++)
	{
		int l,r,d;
		scanf("%d %d %d",&l,&r,&d);l--,r--;
		vec[l].push_back(P(r,d));
		vec[r].push_back(P(l,-d));
	}
	for(int i=0;i<n;i++) dp[i]=INF;
	for(int i=0;i<n;i++)
	{
		if(dp[i]==INF)
		{
			queue <int> que;
			que.push(i);
			dp[i]=0;
			while(!que.empty())
			{
				int v=que.front();que.pop();
				for(int j=0;j<vec[v].size();j++)
				{
					P p=vec[v][j];
					int to=p.first,c=p.second;
					if(dp[to]==INF)
					{
						dp[to]=dp[v]+(ll) c;
						que.push(to);
					}
					else if(dp[to]!=dp[v]+(ll) c)
					{
						puts("No");
						return 0;
					}
				}
			}
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 9728
using namespace std;

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <numeric>
typedef long long ll;
typedef pair<int,int> p;

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)


int main()
{
  string s;
  cin >> s;
  int begin, end;
  for (int i = 0; i < int(s.size()); i++)
  {
    if (s[i] == 'A')
    {
      begin = i;
      break;
    }
  }
  for (int i = begin; i < int(s.size()); i++)
  {
    if (s[i] == 'Z')
    {
      end = i;
    }
  }
  cout << end - begin + 1 << endl;
}


Measured memory_bytes: 640
Q,H,S,D = map(int, input().split())
N = int(input())

q = Q * 8
h = H * 4
s = S * 2
d = D

rlt = 0

lst1 = [Q, H, S, D]
lst2 = [q, h, s, d]
lst3 = [q, h, s]

while N > 0:
  if N >= 2:
    a = lst2.index(min(lst2))
  else:
    a = lst3.index(min(lst3))
  if a == 0:
    rlt += lst1[0] * N * 4
    N = 0
  elif a == 1:
    rlt += lst1[1] * N * 2
    N = 0
  elif a == 2:
    rlt += lst1[2] *N
    N = 0
  else:
    rlt += lst1[3] * (N // 2)
    N = N % 2

print(rlt)


Measured memory_bytes: 38256
package main

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

func main() {
	var n, q int
	var t string
	s := wordScanner(100001)
	scanInts(s, &n, &q)
	scanStrings(s, &t)

	l, r := make([]int, q), make([]int, q)
	for i := 0; i < q; i++ {
		scanInts(s, &l[i], &r[i])
	}

	count := make([]int, n)
	for i := 1; i < n; i++ {
		count[i] = count[i-1]
		if t[i-1:i+1] == "AC" {
			count[i]++
		}
	}

	ans := make([]string, q)
	for i := 0; i < q; i++ {
		ans[i] = strconv.Itoa(count[r[i]-1] - count[l[i]-1])
	}

	fmt.Println(strings.Join(ans, "\n"))
}

func wordScanner(n int) *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	b := make([]byte, n)
	s.Buffer(b, n)
	return s
}

func scanInts(s *bufio.Scanner, vals ...*int) {
	for i := range vals {
		s.Scan()
		n, _ := strconv.Atoi(s.Text())
		*vals[i] = n
	}
}

func scanStrings(s *bufio.Scanner, vals ...*string) {
	for i := range vals {
		s.Scan()
		*vals[i] = s.Text()
	}
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
 
int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    
    if(a+b > c+d){
        cout << "Left" << endl;
    }else if(a+b == c+d){
        cout << "Balanced" << endl;
    }else{
        cout << "Right" << endl;
    }

}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL)
    {
      y=x;
      if(z->key<x->key)
	x=x->left;
      else
	x=x->right;
    }
  z->parent=y;
  if(y==NIL)
    root=z;
  else if(z->key<y->key)
    y->left=z;
  else
    y->right=z;
}

void inorder(Node u){
  if(u!=NIL)
    {
      inorder(u->left);
      printf(" %d",u->key);
      inorder(u->right);
    }

}
void preorder(Node u){
  if(u!=NIL)
    {
      printf(" %d",u->key);
      preorder(u->left);
      preorder(u->right);
    }

}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



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

typedef long long ll;
#define pi acos(-1)
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    double r;
    cin>>r;
    double ans=2*pi*r;
    printf("%0.6lf\n",ans);
    return 0;
}


Measured memory_bytes: 3776
#include <iostream>
#include <sstream>
#include <stdio.h>
//#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;


int main(void)
{
	lli N; cin >> N;
	vector<int> digits;
	int ans = 0;
	while (N > 0) {
		ans += (N % 10);
		digits.push_back(N % 10);
		N /= 10;
	}
	ans = more(ans, (digits[digits.size() - 1] - 1 + (digits.size() - 1) * 9));
	/*
	for (int i = digits.size() - 1; i >= 1;i--) {
		if (digits[i] > digits[i - 1]) {
			ans = digits[i] - 1;
			ans += (digits.size() - 1) * 9;
			break;
		}
	}
	*/
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N; LLONG K; cin >> N >> K;
    vector<vector<int>> adList(N);
    for (int i = 0; i < N - 1; ++i)
    {
        int a, b; cin >> a >> b; --a; --b;
        adList[a].push_back(b);
        adList[b].push_back(a);
    }
    vector<bool> notColored(N, true);
    LLONG ans = K;
    notColored[0] = false;
    deque<int> Q;
    for (LLONG i = 0, n = adList[0].size(); i < n; ++i)
    {
        notColored[adList[0][i]] = false;
        Q.push_back(adList[0][i]);
        ans *= K - 1 - i;
        ans %= MOD;
    }
    while (!Q.empty())
    {
        int v = Q.front(); Q.pop_front();
        LLONG num = 0;
        for (const int n : adList[v])
        {
            if (notColored[n])
            {
                notColored[n] = false;
                Q.push_back(n);
                ++num;
            }
        }
        for (LLONG i = 0; i < num; ++i)
        {
            ans *= K - 2 - i;
            ans %= MOD;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 9584
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = INT_MAX;
const ll LLINF = INT64_MAX;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b;
  char c;
  cin>>a>>c>>b;
  cout<<(c=='+'?a+b:a-b)<<endl;
}

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

using namespace std;
typedef long long ll;
ll n;
int a[1000000];
int b[1000000];
int c[1000000];
int main(){
    ll cnt=0;
    cin >> n;
    for(int i=1; i<=n; i++) cin >> a[i];
    for(int i=1; i<=n; i++) b[i] = 0;
    //cerr << " end in" << endl;
    for(ll i=n; i>0; i--){
        ll sum = 0;
        for( ll j=i; j<=n; j+=i) sum+=b[j];
        //for( ll j=0; j<cnt; j++) if( c[j]%i == 0) sum++;
        if( a[i] != (sum%2) ) {
            b[i] = 1;
            c[cnt] = i;
            cnt++;
        }
        else b[i] = 0;
    }
    /* 
    for(ll i=1; i<=n; i++){
        cout << b[i] << endl;
    }
    */
   //cerr << "end calc" << endl;
   cout << cnt << endl;
   for( ll i=0; i<cnt; i++){
       cout << c[i] << " ";
   }
   if( cnt!= 0) cout << endl;
   return 0;
}


Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define TEST int t = 1; while(t--) solve()
 
void solve(){
    int n, ans = 0; cin>>n;
    string s; cin>>s;
    vector<vector<int>> a(n, vector<int>(3));
    map<char, int> mp;
    mp['R'] = 0;
    mp['G'] = 1;
    mp['B'] = 2;
    a[n-1][mp[s[n-1]]]++;
    for(int i=n-2;i>=0;i--){
        a[i][mp[s[i]]]++;
        for(int j=0;j<3;j++)
            a[i][j] += a[i+1][j];
    }

    for(int i=0;i<n-1;i++){
        int temp = 1;
        for(int j=0;j<3;j++){
            if(mp[s[i]] == j)
                continue;
            temp *= a[i+1][j];
        }
        ans += temp;
        for(int j=i+1;j<n;j++){
            if(mp[s[i]] != mp[s[j]] && (j+(j-i) < n) && mp[s[j]] != mp[s[j+(j-i)]] && mp[s[i]] != mp[s[j+(j-i)]]){
                ans--;
            }
        }
    }
    cout<<ans<<endl;
}   
 
signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); TEST; return 0;
}

Measured memory_bytes: 3844