akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define rrep(i, n) for(ll i = 0; i <= (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

struct UnionFind {
    //iを頂点として、d[i] := iが子ならば親のID(非負)、iが親ならば-サイズ(負)
    vector<int> d;
    //初期化子リストによる初期化、n=0としているのはデフォルト引数
    //n個の頂点をすべて親として初期化(サイズは全て1なので-1)
    UnionFind(int n=0) : d(n, -1) {}
    //親を見つける
    int find(int x){
        if(d[x] < 0) return x; //親ならばそれ自体を返す
        return d[x] = find(d[x]); //メモ化して経路縮約
    }
    //連結する
    bool unite(int x, int y){
        x = find(x); y = find(y); //親同士を連結する
        if(x == y) return false;
        if(d[x] > d[y]) swap(x, y); //yの方がサイズが大きい場合入れ替え
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    //親が同じならtrue
    bool same(int x, int y) { return find(x) == find(y); }
    //連結成分のサイズ
    int size(int x){ return -d[find(x)]; }
};

int main() {
    ll N,M;
    cin >> N >> M;
    vl A(M), B(M);
    UnionFind uf(N);
    rep(i, M){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
        uf.unite(A[i], B[i]);
    }
    int ans;
    rep(i, N){
        if(i == 0){
            ans = uf.size(i);
        }else{
            ans = max(ans, uf.size(i));
        }
    }

    cout << ans;
}

Measured memory_bytes: 7212
n = int(input())
vlist = [int(x) for x in input().split(" ")]
clist = [int(x) for x in input().split(" ")]

result = 0

for i in range(n):
	diff = vlist[i] - clist[i]
	result += diff if diff > 0 else 0
	
print(result)


Measured memory_bytes: 2940
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int gcd(int a, int b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	int a[n];
	ll sum = 0LL;
	int neg = 0;
	int mn = 1e9;
	rep(i, n){
		cin >> a[i];
		sum += abs(a[i]);
		if(a[i] < 0){
			a[i] = abs(a[i]);
			neg++;
		}
		mn = min(a[i], mn);
	}
	if(neg % 2 == 0) cout << sum << endl;
	else cout << sum - 2 * mn << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 640
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	s := getNextString(scanner)
	ans := 0
	for i := 0; i < 4; i++ {
		if s[i] == '2' {
			ans++
		}
	}
	fmt.Fprintln(writer, ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln =  '\n';

const int mx=100010;
const ll mod=1e9+7;


int main(){
  string h,w;
  cin >> h >> w;
  int n=h.size();
  int ans = 0;
  rep(i,n){
    if(h[i]==w[i])ans++;
  }
  cout << ans << ln;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int p[100];
char s[100][11];

int cmp(const void *a, const void *b)
{
	int c=*(int*)a,d=*(int*)b,m=strcmp(s[c],s[d]);
	return m ? m : p[d]-p[c];
}
int main()
{
	int n,a[100],i;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s%d",s[i],&p[i]);
		a[i]=i;
	}
	qsort(a,n,sizeof(int),cmp);
	for(i=0;i<n;i++)
		printf("%d\n",a[i]+1);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h1,m1,h2,m2,k ;
  int time = 0;
  cin >> h1>>m1>>h2>>m2>>k;
  if(m1<=m2){
      time=(h2-h1)*60+(m2-m1)-k;
  }else{
      time=(h2-h1-1)*60+(m2+60-m1)-k;
  }
  if(time>=0){
  cout << time << endl;
  }else{
  cout << "0" << endl;
  }
} 

Measured memory_bytes: 3636
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    string s;
    cin >> s;

    int ans = 700;
    for (int i = 0; i < 3; i++) {
        if (s[i] == 'o') {
            ans += 100;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<stdlib.h>
void merge(int*, int, int, int,int*);
void mergeSort(int*, int, int,int*);
int main() {
	int *S, n, i,cnt=0;
	scanf("%d", &n);
	S = (int*)calloc(n+1, sizeof(int));
	for (i = 0; i < n; i++)scanf("%d", S + i);
	mergeSort(S, 0, n,&cnt);
	for (i = 0; i < n; i++)printf("%d%c", *(S + i), i < n - 1 ? ' ' : '\n');
	printf("%d\n", cnt);
	free(S);
	return 0;
}

void merge(int *A, int l, int m, int r,int* cnt) {
	int n1 = m - l, n2 = r - m, *L, *R, i, j, k;
	L = (int*)malloc(sizeof(int)*n1+1);
	R = (int*)malloc(sizeof(int)*n2+1);
	for (i = 0; i < n1; i++) *(L + i) = *(A + l + i);
	for (i = 0; i < n2; i++) *(R + i) = *(A + m + i);
	*(L + n1) = 2147483647;
	*(R + n2) = 2147483647;
	for (k = l, i = j = 0; k < r; k++) {
		++*(cnt);
		if (*(L + i) <= *(R + j)) { *(A + k) = *(L + i); ++i; }
		else { *(A + k) = *(R + j); ++j; }
		
	}
	//free(L); free(R);
}

void mergeSort(int *A, int l, int r,int *cnt) {
	int m;
	if (l + 1 < r) {
		m = (l + r) / 2;
		mergeSort(A, l, m,cnt);
		mergeSort(A, m, r,cnt);
		merge(A, l, m, r,cnt);
	}
}

Measured memory_bytes: 63192
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n, k;
	string s;
	cin >> n >> s >> k;

	char c = s[k - 1];
	for (auto &v : s) {
		if (v != c) {
			v = '*';
		}
	}

	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
S=input()
S_rev=S[::-1]

import numpy as np

arr_rev=[]
cnt=0
for s_rev in S_rev:
    if s_rev==">":
        cnt+=1
    else:
        cnt=0
    arr_rev.append(cnt)

A=np.array(arr_rev[::-1]+[0])

arr=[]
cnt=0
for s in S:
    if s=="<":
        cnt+=1
    else:
        cnt=0
    arr.append(cnt)

B=np.array([0]+arr)

print(sum(np.maximum(A,B)))

Measured memory_bytes: 48500
if __name__ == '__main__':
    s = input()
    t = input()

    min = len(t)

    for i in range(len(s)-len(t)+1):
        now = len(t)
        for j in range(len(t)):
            if s[i:][j] ==t[j]:
                now-=1
        if min > now:
            min = now
    print(min)


Measured memory_bytes: 9056
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

type Weight = i32;
#[allow(dead_code)]
#[derive(Clone, Debug, Eq, PartialEq)]
struct Edge {
    index: usize,
    src: usize,
    dest: usize,
    weight: Weight,
}
#[allow(dead_code)]
impl Edge {
    fn new(index: usize, src: usize, dest: usize, weight: Weight) -> Edge {
        Edge {
            index: index,
            src: src,
            dest: dest,
            weight: weight,
        }
    }
}
impl std::cmp::Ord for Edge {
    fn cmp(&self, other: &Self) -> std::cmp::Ordering {
        (self.weight, self.src, self.dest).cmp(&(other.weight, other.src, other.dest))
    }
}
impl std::cmp::PartialOrd for Edge {
    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
        Some(self.cmp(other))
    }
}
type Edges = Vec<Edge>;
type Graph = Vec<Edges>;
#[allow(dead_code)]
fn graph_new(n: usize) -> Graph {
    vec![vec![]; n]
}
#[allow(dead_code)]
fn add_bi_edge(graph: &mut Graph, index: &mut usize, src: usize, dest: usize, weight: Weight) {
    graph[src].push(Edge::new(*index, src, dest, weight));
    graph[dest].push(Edge::new(*index, dest, src, weight));
    *index += 1;
}
#[allow(dead_code)]
fn add_uni_edge(graph: &mut Graph, index: &mut usize, src: usize, dest: usize, weight: Weight) {
    graph[src].push(Edge::new(*index, src, dest, weight));
    *index += 1;
}

fn dfs(
    from: usize,
    parent: usize,
    parent_color: usize,
    g: &Graph,
    colors: &mut Vec<usize>,
) -> usize {
    let mut ret = g[from].len();
    let mut c = 0;
    for edge in g[from].iter() {
        if edge.dest == parent {
            continue;
        }
        if parent_color == c {
            c += 1;
        }
        colors[edge.index] = c;
        let nret = dfs(edge.dest, from, c, g, colors);
        ret = std::cmp::max(ret, nret);
        c += 1;
    }
    return ret;
}

fn main() {
    let n = read::<usize>();
    let mut g = graph_new(n);
    let mut e = 0;
    for _i in 0..n - 1 {
        let a = read::<usize>() - 1;
        let b = read::<usize>() - 1;
        add_bi_edge(&mut g, &mut e, a, b, 1);
    }
    let mut colors = vec![0; n - 1];
    let ans = dfs(0, 0, n, &g, &mut colors);
    println!("{}", ans);
    for i in 0..n - 1 {
        println!("{}", colors[i] + 1);
    }
}


Measured memory_bytes: 13820
#include <bits/stdc++.h>
using namespace std;
const int MAXN=200010;
int n,k,c,tot,l[MAXN],r[MAXN];
char s[MAXN];
int main () {
	scanf("%d%d%d%s",&n,&k,&c,s+1);
	int las=-c;
	for (int i=1;i<=n;i++) {
		if (s[i]=='x'||i-las<c+1) {continue;}
		l[++tot]=las=i;
	}
	if (tot!=k) {return 0;}
	tot=k+1;
	las=n+c+1;
	for (int i=n;i>=1;i--) {
		if (s[i]=='x'||las-i<c+1) {continue;}
		r[--tot]=las=i;
	}
	for (int i=1;i<=k;i++) {
		if (l[i]==r[i]) {printf("%d\n",l[i]);}
	}
	return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <queue>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1LL<<60
#define pb push_back
#define mp make_pair

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

int w, h, k;
vector<P> X[200005], Y[200005];
vector<P> xy;
ll d[200005][2];

// PI f(int a, int b, int c) {
// 	return mp(mp(a, b), c);
// }

void dijkstra() {
	rep(i, 200005) {
		d[i][0] = INF;
		d[i][1] = INF;
	}

	// cost id (0 or 1)
	priority_queue<PI, vector<PI>, greater<PI> > que;

	rep(i, X[1].size()) {
		int y = X[1][i].first;
		int to = X[1][i].second;

		d[to][1] = y;
		// que.push(f(y, to, 1));
		que.push(mp(mp(y, to), 1));
	}

	while(que.size()) {
		PI p = que.top(); 
		que.pop();

		int c = p.first.first;
		int v = p.first.second;
		int state = p.second;

		if(d[v][state] < c) continue;

		int y = xy[v].first;
		int x = xy[v].second;

		if(state == 0) {
			rep(i, X[x].size()) {
				int ny = X[x][i].first;
				int to = X[x][i].second;

				if(ny == y) continue;

				if(d[to][1] > d[v][state] + abs(ny - y) + 1) {
					d[to][1] = d[v][state] + abs(ny- y) + 1;
					// que.push(f(d[to][1], to, 1));
					que.push(mp(mp(d[to][1], to), 1));
				}
			}
		} else {
			rep(i, Y[y].size()) {
				int nx = Y[y][i].first;
				int to = Y[y][i].second;

				if(nx == x) continue;

				if(d[to][0] > d[v][state] + abs(nx - x) + 1) {
					d[to][0] = d[v][state] + abs(nx - x) + 1;
					// que.push(f(d[to][0], to, 0));
					que.push(mp(mp(d[to][0], to), 0));
				}
			}
		}
	}
}

int main() {
	cin >> w >> h >> k;

	xy.resize(k);
	rep(i, k) {
		int x, y;
		cin >> x >> y;

		xy[i] = mp(y, x);
		X[x].push_back(mp(y, i));
		Y[y].push_back(mp(x, i));
	}

	dijkstra();

	ll ans = INF;
	rep(i, k) {
		int y = xy[i].first;
		int x = xy[i].second;

		if(y == h) {
			ans = min(ans, d[i][1] + abs(w - x));
		}

		if(x == w) {
			ans = min(ans, d[i][0] + abs(h - y));
		}
	}

	if(ans == INF) cout << -1 << endl;
	else cout << ans << endl;


	return 0;
}

Measured memory_bytes: 27252
def main(l,r)
  min = 2020
  (l..r-1).each do |i|
    ((i+1)..r).each do |j|
      mod = (i*j)%2019
      min = mod if min >= mod
      break if min == 0
    end
    break  if min == 0
  end
  return min
end

L, R = gets.chomp.split.map(&:to_i)
p main(L, R)

Measured memory_bytes: 1788
#!/usr/bin/env python3
import sys
import itertools
import collections
import functools
import math
import operator
from queue import Queue
INF = float("inf")


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


def solve(N: int, M: int, a: "List[int]", b: "List[int]"):

    ab = [[x, y] for x, y in zip(a, b)]
    ab.sort(key=operator.itemgetter(1))
    # print(ab)

    cut = [0]                   # i番目とi+1番目をカット
    for a, b in ab:
        if a <= cut[-1]:         # OK
            continue
        cut.append(b-1)
    print(len(cut)-1)


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int()] * (M)  # type: "List[int]"
    b = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, M, a, b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 23960
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  int i = 0;
  while (true) {
    if (i % 2 == 0) {
      C -= B;
    } else {
      A -= D;
    }
    ++i;
    if (A <= 0 || C <= 0)
      break;
  }

  if (A <= 0)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll l;
  cin >> l;
  cout << fixed << setprecision(8) << l * l * l / 27.0 << endl;
}

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

bool check(unordered_set<int> dislikes, int n) {
  while(n) {
    if(dislikes.find(n%10) != dislikes.end()) {
      return false;
    }
    n /= 10;
  }
  return true;
}
/* 
 * g++ -std=c++17 main.cpp -o main
 */
int main() {
  ios::sync_with_stdio(false);
  int n, k;
  cin>>n>>k;
  unordered_set<int> dislikes;
  for(int i = 0; i < k; i++) {
    int s;
    cin>>s;
    dislikes.insert(s);
  }
  while (!check(dislikes, n)) {
    n++;
  }
  cout << n << endl;
}


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

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll n, a, b, c, d, ans=0, tmp=0;
vector<ll> A, negp, posp;

signed main(){
    cin >> n >> a >> b >> c >> d;
    b -= a;
    for(int i=0;i<n;i++) {
        negp.push_back(-n+1+i);
        posp.push_back(i);
    }
    for(int i=0;i<n;i++) {
        ll num1 = negp[i]*c+posp[i]*d;
        ll num2 = negp[i]*d+posp[i]*c;
        if(num2<=b&&num1>=b) tmp++;
        //cout << num1 << " <= " << b << " <= " << num2 << endl;
    }
    if(tmp>0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

signed main(){
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    sort(ALL(a));
    auto isOK = [&](ll x){
        ll cnt = 0;
        if(x >= 0){
            rep(i,n){
                if(a[i] == 0){
                    cnt += n - 1;
                }else if(a[i] > 0){
                    cnt += n - (a.end() - upper_bound(ALL(a), x / a[i])) - (a[i] <= x / a[i] ? 1 : 0);
                }else{
                    cnt += a.end() - lower_bound(ALL(a), x / a[i]) - (a[i] >= x / a[i] ? 1 : 0);
                }
            }
            cnt /= 2;
        }else{
            rep(i,n){
                if(a[i] < 0){
                    cnt += a.end() - lower_bound(ALL(a), (abs(x) + abs(a[i]) - 1) / abs(a[i]));
                }
            }
        }
        return k <= cnt;
    };
    ll ng = -LINF, ok = LINF;
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if(isOK(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second


void solve(){
    string s;cin>>s;
    ll acc=0,ans=0;
    REP(i,s.size()){
        if(s[i]=='A')acc++;
        else if(s[i]=='B'&&s[i+1]=='C'){ans+=acc;i++;}
        else acc=0;
    }
    cout<<ans<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 720
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double price = n / 1.08;
		if((int)((int)price * 1.08) == n) {
			System.out.println((int)price);
		}else if((int)(((int)price + 1) * 1.08) == n) {
			System.out.println((int)price + 1);
		}else {
			System.out.println(":(");
		}

		sc.close();
	}
}


Measured memory_bytes: 23124
import numpy as np
n,m  = [int(k) for k in input().split()]
h = [int(k) for k in input().split()]
j = []
for i in range(n):
    j.append([-1])
r = 0
for i in range(m):
    a,b = [int(k) - 1 for k in input().split()]
    j[a].append(b)
    j[b].append(a)
for i in range(n):
    
    j[i] = list(set(j[i][1:]))
    is_good = False if not len(j) >= 1 else True
    for l in j[i]:
        if h[i] > h[l]:
            is_good = True
        else:
            is_good = False
            break
    if is_good:
        r += 1
print(r)

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

int main(){
    int n;
    cin >> n;
    int i = 1;
    while(++i <= n){
        int x = i;
        if(x%3 == 0){
            cout << " " << i;
            continue;
        }
        while(x){
            if(x%10 == 3){
                cout << " " << i;
                break;
            }
            x /= 10; 
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
using namespace std;
int main() {
    int H, W, ans = 0;
    cin >> H >> W;
    vector<string> S(H);
    for (auto& i : S) cin >> i;
    const int dh[] = {1, -1, 0, 0}, dw[] = {0, 0, 1, -1};
    vector<vector<bool>> visited(H, vector<bool>(W, false));
    queue<tuple<int, int, int>> q;
    for (int sh = 0; sh < H; sh++) {
        for (int sw = 0; sw < W; sw++) {
            if (S[sh][sw] == '#') continue;
            visited[sh][sw] = true;
            q.push(make_tuple(sh, sw, 0));
            while (!q.empty()) {
                int ch = get<0>(q.front()), cw = get<1>(q.front()), cc = get<2>(q.front());
                if (cc > ans) ans = cc;
                q.pop();
                for (int i = 0; i < 4; i++) {
                    int nh = ch + dh[i], nw = cw + dw[i];
                    if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
                    if (S[nh][nw] == '#' || visited[nh][nw] == true) continue;
                    visited[nh][nw] = true;
                    q.push(make_tuple(nh, nw, cc + 1));
                }
            }
            for (size_t i = 0; i < visited.size(); i++) for (size_t j = 0; j < visited[i].size(); j++) visited[i][j] = false;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n]; //数列
        long count[] = new long[n]; //各値の出現回数
        long sum=0; //Nから選ぶときのパターン

        for(int i=0;i<n;i++)count[i]=0;

        for(int i=0;i<n;i++){
            a[i]=sc.nextInt()-1;
            count[a[i]]++;
        }

        for(int i=0;i<n;i++){
            if(count[i]>1){
                sum += (count[i]*(count[i]-1))/2;
            }
        }

        for(int i=0;i<n;i++){
            int num = a[i]; //numのボールが一個減る
            long dif = 0;
            if(count[num]>1){
                dif = count[num]-1;
            }
            System.out.println(sum-dif);
        }

    }
}


Measured memory_bytes: 94432
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
#define ull unsigned long long
const int maxn=1e5+5;
const ull maxx=1e18;
const int maxlg=log2(maxx)+1;
ull a[maxn];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++)
        if(a[i]==0)
        {
            cout<<0<<'\n';
            return 0;
        }
    ull ans=1;
    for(int i=1;i<=n;i++)
    {
        if(log2(ans)+log2(a[i])>maxlg)
        {
            cout<<-1<<'\n';
            return 0;
        }
        ans*=a[i];
    }
    if(ans>maxx)
        cout<<-1<<'\n';
    else cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 4568
import heapq

def main():
    K, T = map(int, input().split())
    a = list(map(int, input().split()))
    if T == 1:
        print(K-1)
        return
    b = [-x for x in a]
    heapq.heapify(b)
    tmp = heapq.heappop(b)
    for i in range(K):
        tmp2 = heapq.heappop(b)
        if tmp2 == 0:
            break
        heapq.heappush(b, tmp+1)
        tmp = tmp2
    print(K-1-i)
    
if __name__ == "__main__":
    main()


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

template<class T> inline T pop_element(stack<T> &sta) {
	const T res = sta.top();
	sta.pop();
	return res;
}

string solve() {
	string value;
	cin >> value;

	stack<int> sta;
	for(const auto &e : value) sta.push(e - '0');

	for(int i = 0;; ++i) {
		if(sta.size() == 1) return (i & 1) ? "Fabre wins." : "Audrey wins.";
		int sum = pop_element(sta) + pop_element(sta);
		if(sum >= 10) {
			sta.push(1);
			sum -= 10;
		}
		sta.push(sum);
	}
}

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

	int t;
	cin >> t;
	while(t--) cout << solve() << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1232
import std.algorithm;
import std.conv;
import std.math;
import std.stdio;
import std.string;

void solve(int N, long[] A){
	long[] left = new long[](N), right = new long[](N);
	for(int i = 0;i < N;i++){
		if(i == 0)left[i] = abs(A[0]);
		else left[i] = left[i - 1] + abs(A[i - 1] - A[i]);
	}
	for(int i = N - 1; i >= 0;i--){
		if(i == N - 1)right[i] = abs(A[N - 1]);
		else right[i] = abs(right[i + 1] + abs(A[i] - A[i + 1]));
	}
	for(int i = 0;i < N;i++){
		if(i == 0)writeln(abs(A[1]) + right[1]);
		else if(i == N - 1)writeln(left[N - 2] + abs(A[N - 2]));
		else writeln(left[i - 1] + abs(A[i - 1] - A[i + 1]) + right[i + 1]);
	}
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
	auto input = stdin.byLine.map!split.joiner;

	int N;
	N = input.front.to!int;
	input.popFront;

	long[] A = new long[](cast(size_t) (N));
	foreach (i; 0 .. cast(size_t) (N)) {
		A[i] = input.front.to!long;
		input.popFront;
	}

	solve(N, A);
	return 0;
}


Measured memory_bytes: 9336
#include<bits/stdc++.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 rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAXHW 1000

int dp[MAXHW][MAXHW];

int main(){
  int h,w; cin>>h>>w;
  vector<string> a(h);
  rep(i, h)cin>>a[i];

  dp[0][0]=1;
  rep(i, h)rep(j, w){
    if(i<h-1 && a[i+1][j]=='.')dp[i+1][j] = (dp[i+1][j] + dp[i][j])%MOD;
    if(j<w-1 && a[i][j+1]=='.')dp[i][j+1] = (dp[i][j+1]+dp[i][j])%MOD;
  }

  cout<<dp[h-1][w-1]<<endl;

  return 0;

  rep(i, h){
    rep(j, w)cout<<dp[i][j]<<' ';
    cout<<endl;
  }

  return 0;
}

Measured memory_bytes: 9388
io = STDIN
n=io.gets.to_i
l=io.gets.split.map(&:to_i).sort
cnt=0
#a+b>c
#b+c>a  c>a-b
#c+a>b  c>b-a
(0...n-2).each do |i|
   (i+1...n-1).each do |j|
      apb=l[i]+l[j]
      k=l[j+1,n-j-1].bsearch_index{|c|c>=apb}
      cnt+=k||n-1-j
   end
end
p cnt


Measured memory_bytes: 1912
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;

int main(){
    double n,d,x,ans=0;
    cin>>n>>d>>x;
    for(;n>0;n--){
	ans+=d+(n-0.5)*x;
	d=(d*(n+1)+x*2.5)/n;
	x*=(2/n+1);
    }
    printf("%.9lf\n",ans);
    return 0;
}


Measured memory_bytes: 256
n,m = list(map(int, input().split())) 

a = list(map(str, input().split()))

#a[0][m]=a[0][m-1].lower()
c=a[0][m-1]
d=a[0][0:m-1]
e=a[0][m:n]

a[0]=d+c.lower()+e

print(a[0])

Measured memory_bytes: 3060
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,popcnt")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
const int maxn = 1<<19, mod = 1e9 + 7, i2 = (mod+1)/2;
ll n, k, f[maxn];
#include<bits/extc++.h>
using namespace __gnu_pbds;
using oset = tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update>;
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> k;
	ll p = 0, ans = 0;
	oset x;
	x.insert({0, -1});
	for(int t, i = 0; i < n; i++) {
		cin >> t; t -= k;
		p += t;
		ans += x.order_of_key({p+1, -1});
		x.insert({p, i});
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 16144
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(int i=j;i<k;i+=in)
#define DF(i,j,k,in) for(int i=j;i>=k;i-=in)
#define feach(it,l) for (auto it = l.begin(); it != l.end(); ++it)
#define fitr(it,it1,itr2) for(auto it=itr1;it!=itr2;++it)
#define fall(a) a.begin(),a.end()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define eq equal_range
#define fs first
#define ss second
#define ins insert
#define mkp make_pair
#define endl "\n"
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vin;
typedef vector<char> vch;
typedef vector<string> vst;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int,int>> vvin;
typedef vector<pair<ll,ll>> vpll;
typedef vector<pair<int,int>> vpin;
typedef set<ll> sll;
typedef set<int> sint;
typedef set<char> sch;
typedef set<string> sst;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef queue<int> qin;
typedef priority_queue<int> pqin;
typedef map<ll,ll> mpll;
typedef map<int,int> mpin;
typedef pair<ll,ll> pll;
typedef pair<int,int> pin;
const ll MOD=1000000007;
const long double PI=3.1415926535897932384626433832795;
ll pwr(ll b,ll p){ll res=1;while(p){if(p&1) {res*=b; p--;}else{b*=b; p>>=1;}}return res;}
int main()
{
ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);
int h,w;
cin>>h>>w;
char A[1000][1000];
F (i,0,h,1) {
  F (j,0,w,1) cin>>A[i][j];
}
ll ways[1000][1000];
ways[0][0]=1;
F (i,1,w,1) { 
  if (A[0][i]=='.') ways[0][i]=ways[0][i-1];
  else ways[0][i]=0;
}
F (i,1,h,1)  { 
  if (A[i][0]=='.') ways[i][0]=ways[i-1][0];
  else ways[i][0]=0;
}
F (i,1,h,1) {
  F (j,1,w,1) {
    if (A[i][j]=='.') ways[i][j]=((ways[i-1][j]%MOD)+(ways[i][j-1]%MOD))%MOD;
    else ways[i][j] =0 ;
  }
}
cout<<ways[h-1][w-1]<<endl;
return 0;
}



Measured memory_bytes: 12276
#include <cstdio>
#include <algorithm>
using namespace std;

void chmin(int &a, int b) {
     a = min(a, b);
}

const int INF = 1 << 25;
int N, M, R;
int dl[210][210], ds[210][210], dist[1010][210], op[1010];

int main() {
    while(scanf("%d%d", &N, &M)) {
        if(N == M && M == 0) break;
        for(int i=0; i<N; i++) {
            fill(dl[i], dl[i] + N, INF);
            fill(ds[i], ds[i] + N, INF);
            dl[i][i] = ds[i][i] = 0;
        }

        for(int i=0; i<M; i++) {
            int x, y, t; char s;
            scanf(" %d%d%d %c", &x, &y, &t, &s);
            x--; y--;
            if(s == 'L') {
                chmin(dl[x][y], t);
                chmin(dl[y][x], t);
            }
            else {
                chmin(ds[x][y], t);
                chmin(ds[y][x], t);
            }
        }

        for(int k=0; k<N; k++) {
            for(int i=0; i<N; i++) {
                for(int j=0; j<N; j++) {
                    chmin(dl[i][j], dl[i][k] + dl[k][j]);
                    chmin(ds[i][j], ds[i][k] + ds[k][j]);
                }
            }
        }

        scanf("%d", &R);
        for(int i=0; i<R; i++) {
            scanf("%d", &op[i]); op[i]--;
            fill(dist[i], dist[i] + N, INF);
        }

        dist[0][op[0]] = 0;
        for(int i=0; i<R-1; i++) {
            for(int j=0; j<N; j++) {
                if(dist[i][j] == INF) continue;
                int cur = op[i], nxt = op[i+1];

                // land only
                chmin(dist[i+1][j], dist[i][j] + dl[cur][nxt]);

                // land + sea
                for(int k=0; k<N; k++) {
                    chmin(dist[i+1][k], dist[i][j] + dl[cur][j] + ds[j][k] + dl[k][nxt]);
                }
            }
        }

        printf("%d\n", *min_element(dist[R-1], dist[R-1] + N));
    }
    return 0;
}


Measured memory_bytes: 3736
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

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

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  string s, t;
  cin >> s >> t;

  vector<vector<int>> as(26);
  F0R(i, s.size()) {
    as[s[i] - 'a'].push_back(i);
  }

  int srep = 0;
  int si = 0;
  F0R(ti, t.size()) {

    auto v = as[t[ti] - 'a'];
    if (!v.size()) {
      cout << -1;
      return 0;
    }

    auto it = lower_bound(v.begin(), v.end(), si);
    if (it == v.end()) {
      srep++;
      si = v[0] + 1;
    }
    else {
      si = *it + 1;
    }
  }

  i64 result = (i64)srep * s.size() + si;
  cout << result;
}
#endif


Measured memory_bytes: 4396
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;
const int mod = 1000000007;
const int MAX = 1000010;

int main(){
    int N;
    cin >> N;
    vector<int> D(MAX, 0);
    //エラトステネスの篩もどき
    D[0] = 0;
    D[1] = 0;
    for(int i = 2; i <= MAX; i++){
        if(D[i] != 0)continue;
        for(int j = 2; i*j <= MAX; j++){
            D[i*j] = i;
        }
    }
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    unordered_map<int, int> m;
    bool pairwise = true;
    rep(i, N){
        int tmp = A[i];
        while(D[tmp] != 0){
            int a = D[tmp];
            while(tmp%a == 0){
                tmp /= a;
            }
            m[a]++;
        }
        if(tmp != 1)m[tmp]++;
    }
    for(auto x:m)if(x.second != 1) pairwise = false;
    if(pairwise){
        cout << "pairwise coprime" << endl;
        return 0;
    }

    int tmp = A[0];
    rep(i, N - 1){
        tmp = __gcd(tmp, A[i + 1]);
    }
    if(tmp == 1){
        cout << "setwise coprime" << endl;
        return 0;
    }
    cout << "not coprime" << endl;
}

Measured memory_bytes: 14276
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <math.h>

#define mp                  make_pair
#define F                   first
#define S                   second
#define pb                  push_back
#define FOR(i,j,n)          for(int i=j;i<n;i++)
#define F0R(i,j,n)          for(int i=j;i<=n;i++)
#define RFOR(i,j,n)         for(int i=n-1;i>=j;i--)
#define RF0R(i,j,n)         for(int i=n;i>=j;i--)
#define FOREACH(x,v)        for(auto x:v)
#define ITFOR(it,v)         for(__typeof(v.begin()) it =v.begin();it!=v.end();++it)
#define __in_arr__(a,j,n)   FOR(i,j,n)cin >> a[i];
#define __out_arr__(a,j,n)  FOR(i,j,n)cout << a[i];
#define LOG                 cout << "[ !" << __LINE__ << "L ] " << endl;
#define PLOG(x)             cout << "[ !" << __LINE__ << "L ] " \<<x<<endl;

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int a,b,c;
    cin >> a >> b >> c;
    if( a== b) {
        cout << c;
    } else if( b== c) {
        cout << a;
    } else 
        cout << b;
    cout << endl;
    return 0;
}


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

using namespace std;

int n;
string s;
vector<char> tmp(111111);

bool check(){
    bool f=true;
    for(int i=1;i<n-1;i++){
        if(tmp[i]=='S'){
            if(s[i]=='o') tmp[(i+1)%n]=tmp[i-1];
            else{
                if(tmp[i-1]=='S') tmp[(i+1)%n]='W';
                else tmp[(i+1)%n]='S';
            }
        }
        else{
            if(s[i]=='x') tmp[(i+1)%n]=tmp[i-1];
            else{
                if(tmp[i-1]=='S') tmp[(i+1)%n]='W';
                else tmp[(i+1)%n]='S';
            }
        }
    }
    if(s[0]=='o'){
        if(tmp[0]=='S' && tmp[1]!=tmp[n-1]) f=false;
        if(tmp[0]=='W' && tmp[1]==tmp[n-1]) f=false;
    }
    if(s[0]=='x'){
        if(tmp[0]=='S' && tmp[1]==tmp[n-1]) f=false;
        if(tmp[0]=='W' && tmp[1]!=tmp[n-1]) f=false;
    }

    if(s[n-1]=='o'){
        if(tmp[n-1]=='S' && tmp[n-2]!=tmp[0]) f=false;
        if(tmp[n-1]=='W' && tmp[n-2]==tmp[0]) f=false;
    }
    if(s[n-1]=='x'){
        if(tmp[n-1]=='S' && tmp[n-2]==tmp[0]) f=false;
        if(tmp[n-1]=='W' && tmp[n-2]!=tmp[0]) f=false;
    }

    return f;
}

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

    cin>>n;
    cin>>s;
    bool f=false;
    vector<char> res(n);
    tmp[0]='S'; tmp[1]='S';
    if(check()){
        f=true;
        for(int i=0;i<n;i++) res[i]=tmp[i];
    }
    tmp[0]='S'; tmp[1]='W';
    if(check()){
        f=true;
        for(int i=0;i<n;i++) res[i]=tmp[i];
    }
    tmp[0]='W'; tmp[1]='S';
    if(check()){
        f=true;
        for(int i=0;i<n;i++) res[i]=tmp[i];
    }
    tmp[0]='W'; tmp[1]='W';
    if(check()){
        f=true;
        for(int i=0;i<n;i++) res[i]=tmp[i];
    }
    if(!f) cout<<-1<<endl;
    else{
        for(int i=0;i<n;i++) cout<<res[i];
        cout<<endl;
    }
    return 0;
}


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

int main(){
  long N,A,B,i,j=0;
  string S;
  cin >> N >> A >> B;
  cin >> S;
  bool can = false;
  for(i=0;i<N;i++){
    if(S[i]=='b'){
      j++;
    }
    if(S[i]!='c' && i+1<=A+B){
      if(S[i]=='a'){
        can = true;
      }else if(j<=B){
        can = true;
      }else{
        A++;
      }
    }else{
      A++;
    }
    if(can){
    	cout << "Yes" << endl;
  	}else{
    	cout << "No" << endl;
  	}
    can = false;
  }
  return 0;
}

Measured memory_bytes: 896
#include<cstdio>
#include<cstring>
#define in inline
#define re register
using namespace std;
in int read() {
	re int t=0;
	re char v=getchar();	
	while(v<'0'||v>'9'){
	v=getchar();
	}	
	while(v>='0'&&v<='9'){		
	t=(t<<3)+(t<<1)+(v^48);		
	v=getchar();	}
	return t;
}
int a,b,c,d;
int main(){
a=read();
b=read();
c=read();
d=read();
if(a!=c)puts("1");
else puts("0");
}


Measured memory_bytes: 128
require 'prime'

# util functions
def gcd(arr) # arr: Array of non-negative integers
  if arr.size < 2
    raise "array (#{arr}) size is less than 2."
  end
  
  def gcd_two(a, b) # assume b <= a
    return a if b % a == 0
    return gcd_two(b % a, a)
  end

  g = arr[0]
  for i in 1..arr.size - 1 do
    g = gcd_two([g, arr[i]].min, [g, arr[i]].max)
  end
  return g
end


# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if true
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

str = inputs[0][0]

# body
if $debugFlag
end

cnt = 0
if str.size >= 2
  for i in 0..str.size-2
    cnt += 1 if str[i] != str[i+1]
  end
end

puts cnt


Measured memory_bytes: 2428
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)

	i := 0
	for ; i < len(S); i++ {
		if S[i:i+1] == "R" {
			if i%2 != 0 {
				break
			}
		} else if S[i:i+1] == "L" {
			if i%2 == 0 {
				break
			}
		}
	}
	if i == len(S) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <cassert>
#include <iostream>
#include <vector>
#include <utility>
using namespace std;


struct LCA {
private:
  vector<vector<int>> G;
  size_t n, m;
  vector<vector<int>> A;
  vector<int> D;
  void dfs(int v, int p){
    for(auto v_ : G[v]){
      if(v_ == p) continue;
      A[v_][0] = v;
      D[v_] = D[v]+1;
      dfs(v_,v);
    }
  }
  void build(int r){
    dfs(r,-1);
    A[r][0] = r;
    for(size_t i = 1; i < m; ++i){
      for(size_t j = 0; j < n; ++j){
        A[j][i] = A[A[j][i-1]][i-1];
      }
    }
  }
public:
  LCA(const vector<vector<int>>& Tree, int r) : G(Tree), n(Tree.size()), m(1), D(n,0) {
    size_t t = 1;
    while(t < n) ++m, t *= 2;
    A = vector<vector<int>>(n,vector<int>(m,-1));
    build(r);
  }
  size_t query(int u, int v){
    if(D[u] < D[v]) swap(u,v);

    for(size_t i = m-1; i < m; --i){
      size_t u_ = A[u][i];
      if(D[u_] < D[v]) continue;
      u = u_;
    }

    if(u == v) return u;
    assert(D[u] == D[v]);
    for(size_t i = m-1; i < m; --i){
      if(A[u][i] != A[v][i])
        u = A[u][i], v = A[v][i];
    }
    return A[u][0];
  }
};

int main(){
  int n;
  cin >> n;
  vector<vector<int>> G(n);
  for(int i = 0; i < n; ++i){
    int k;
    cin >> k;
    for(int j = 0; j < k; ++j){
      int c;
      cin >> c;
      G[i].push_back(c);
      G[c].push_back(i);
    }
  }
  LCA lca(G,0);
  int q;
  cin >> q;
  while(q--){
    int u, v;
    cin >> u >> v;
    cout << lca.query(u,v) << endl;
  }
}



Measured memory_bytes: 27684
using System;
using System.Collections.Generic;
using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            Console.WriteLine(abc[1]/abc[0]>=abc[2]?abc[2]:abc[1]/abc[0]);


        }
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 27488
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int a,b;
    cin >> a >> b;
    if((a%3)!=0 && (a%3)==(b%3)){
      cout << "Impossible";
    }else{
      cout << "Possible";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(), v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 1;
vector<int> g[N];
void solve(){
    string s;
    cin >> s;
    string s1 = "s", s2 = "es";
    cout << (s[(int)s.size() - 1] == 's' ? s + s2 : s + s1) << '\n';
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        solve();
    }
}

Measured memory_bytes: 27024
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var x int
	scanner.Scan()
	fmt.Sscan(scanner.Text(), &x)

	for i := x; i <= 100003; i++ {
		if isPrime(i) {
			fmt.Println(i)
			return
		}
	}
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}


Measured memory_bytes: 1844
"""
# 標準入力取得
## 文字列
     = sys.stdin.readline().rstrip()
     = list(sys.stdin.readline().rstrip())

## 数値
     = int(sys.stdin.readline())
     = map(int, sys.stdin.readline().split())
     = list(map(int, sys.stdin.readline().split()))
     = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 2019

if __name__ == "__main__":
     L, R = map(int, sys.stdin.readline().split())
     if R - L > 2019:
          print(0)
          exit()
     mod_min = 2020
     for i in range(L, R + 1):
          for j in range(i + 1, R + 1):
               m_tmp = (i * j) % mod
               #print("i {}, j {}, m_tmp {}".format(i, j, m_tmp))
               if m_tmp < mod_min:
                    mod_min = m_tmp
     print(mod_min)


Measured memory_bytes: 5612
n = int(input())
alphabet = "abcdefghijklmnopqrstuvwxyz"

l = []

for _ in range(20):
  rem = n % 26
  l.append(rem - 1 if rem else 25)
  n = (n - 1) // 26
  if n == 0:
    break;

l.reverse()
print("".join([alphabet[i] for i in l]))

Measured memory_bytes: 9120
#include <stdio.h>
int main(){
	int a,b,ans;
	char op;
	while(1){
                scanf("%d %c %d",&a,&op,&b);
		
		if(op =='?'){
			break;
		}
		else if(op == '+'){
			ans=a+b;
		}
		else if(op == '-'){
			ans=a-b;
		}
		else if(op == '*'){
			ans=a*b;
		}
		else {
			ans=a/b;
		}

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

	}
	return 0;
}



Measured memory_bytes: 2044
import math

n=int(input())
count = 0
sum_count = 0

while n > 0:
    if n == 1:
        n = n - 1
        sum_count = sum_count + 2**(count)
    else:
        n = math.floor(n / 2)
        count += 1
        sum_count = sum_count + 2**(count-1)

print(sum_count)

Measured memory_bytes: 3060