akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> x = new ArrayList<Integer>();
        //int x[] = new int[100];
        int count = 0;
        while(true){
            x.add(count,sc.nextInt());
            if(x.get(count)==0)
                break;
            count += 1;
        }
        for(int i = 0; i < count; i++){
            if(!(i==count))
            System.out.println("Case "+(i+1)+": "+x.get(i));
        }
    }
}

Measured memory_bytes: 43748
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;

int main(){

  int n;
  ll a[100000] = {}, cur = 0, res1 = 0, res2 = 0;
  cin >> n;
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n; i++){
    cur += a[i];
    if(i % 2){
      if(cur < 0) continue;
      else res1 += 1 + cur, cur = -1;
    }else{
      if(cur > 0) continue;
      else res1 += 1 - cur, cur = 1;
    }
  }
  cur = 0;
  for(int i = 0; i < n; i++){
    cur += a[i];
    if(i % 2){
      if(cur > 0) continue;
      else res2 += 1 - cur, cur = 1;
    }else{
      if(cur < 0) continue;
      else res2 += 1 + cur, cur = -1;
    }
  }
  cout << min(res1, res2) << endl;
  return 0;
}


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

using namespace std;
//FILE *fi=freopen("1.txt","r",stdin);
int n;
string s;
int a[4001];
int d[5];
long long ans;
int main()
{
    cin>>n>>s;
    for(int i=1;i<=n;i++)
    {
        if(s[i-1]=='R')
            a[i]=1;
        else if(s[i-1]=='G')
            a[i]=2;
        else
            a[i]=3;
    }
    for(int i=3;i<=n;i++)
    {
        memset(d,0,sizeof d);
        d[a[1]]=1;
        for(int j=2;j<i;j++)
        {
            if(a[i]==a[j])
            {
                ans+=1LL*(j-1);
                d[a[j]]++;
                continue;
            }
            ans+=d[a[j]];
            ans+=d[a[i]];
            d[a[j]]++;
            int k = 2*j-i;
            if(k>=1&&a[k]!=a[i]&&a[k]!=a[j])
                ans++;
        }
    }
    ans = 1LL*n*(n-1)*(n-2)/6 - ans;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3680
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int n,m,a,b;
long long lst;
const long long md=1e9+7;
long long p[200010];
long long qmul(long long x,int p)
{
	if(p==0)return 1LL;
	if(p==1)return x;
	long long res=qmul(x,p/2);
	res=res*res%md;
	if(p&1)res=res*x%md;
	return res;
}
long long C(int x,int y)
{
	if(x<y)return 0LL;
	return p[x]*qmul(p[x-y]*p[y]%md,md-2)%md;
}
long long gtans(int x,int y)
{
	return C(x+y-2,y-1);
}
int main()
{
	scanf("%d%d%d%d",&n,&m,&a,&b);
	p[0]=1LL;
	for(int i=1;i<=n+m-2;i++)p[i]=p[i-1]*i%md;
	a=n-a;
	b++;
	long long ans=0LL; 
	while(a>0 && b<=m)
	{
		ans=ans+gtans(a,b)*gtans(n+1-a,m+1-b)%md;
		if(ans>=md)ans-=md;
		a--;
		b++;
	}
	printf("%lld",ans);
	return 0;
}

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

#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define PI acos(-1.0)
const int N=1e5 + 5;
const int M=1e5 + 5;


int main()
{
	ios_base::sync_with_stdio(false);
	int n,i;
	ll s[N];
	cin>>n;
	ll gd=0;
	for(i=0;i<n;i++){
		cin>>s[i];
		gd = __gcd(gd,s[i]);
	}
	cout << gd << endl;
		
	
		
	return 0;
}

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

using namespace std;

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

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

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;

ll modx(ll a)
{
    return (a%MOD+MOD)%MOD;
}

ll times(ll a, ll b)
{
    return modx(modx(a)*modx(b));
}

ll add(ll a, ll b)
{
    return modx(modx(a)+modx(b));
}

ll sub(ll a, ll b)
{
    return modx(MOD+modx(a)-modx(b));
}

ll fastExp(ll base, ll exp)
{
    if(exp == 0LL)
    {
        return 1LL;
    }

    if(exp%2==0)
    {
        return fastExp(times(base, base), exp/2);
    }
    else
    {
        return times(exp, fastExp(times(base, base), exp/2));
    }
}


const int MAXN = (int)1e5+1;
int N;


int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int A, B;
    cin >> A >> B;
    if(B==1)
    {
        cout << 0;
    }
    else if(A>=B)
    {
        cout << 1;
    }
    else
    {
        B-=A;
        int ct = 1;
        int a = 0;
        while(a < B)
        {
            ct ++;
            a += (A-1);
        }
        cout << ct;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    N,K=mis()
    s = set()
    for _ in range(K):
        input()
        s |= set(lmis())
    print(N-len(s))

main()



Measured memory_bytes: 10048
#include<stdio.h>
int main(){
  int a,b,i,min,max;
  scanf("%d%d",&a,&b);
  if(a%2==0){
    min=a/2*25;
    max=min+13;
  }
  else{
    min=(a-1)/2*25+13;
    max=min+12;
  }
  for(i=10*b;i<10*b+10;i++)
    if(min<=i && i<max){
      printf("%d\n",i);
      return 0;
    }
  printf("-1\n");
  return 0;
}


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

int main(){
    string s;
    cin >> s;
    int n;
    n = s.size();
    int mid;
    mid = n/2;
    int ans = 0;
    rep(i,mid){
        if(s[i]!=s[n-1-i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	N := nextInt()
	M := nextInt()
	var pq priorityQueue
	heap.Init(&pq)
	for i := 0; i < N; i++ {
		heap.Push(&pq, &pair{first: nextInt(), second: 1})
	}
	for i := 0; i < M; i++ {
		heap.Push(&pq, &pair{second: nextInt(), first: nextInt()})
	}

	var ans int
	for i := 0; i < N; i++ {
		p := heap.Pop(&pq).(*pair)
		ans += p.first
		if p.second > 1 {
			p.second--
			heap.Push(&pq, p)
		}
	}

	fmt.Println(ans)
}

type pair struct {
	first, second int

	index int
}

type priorityQueue []*pair

func (pq priorityQueue) Len() int { return len(pq) }

func (pq priorityQueue) Less(i, j int) bool {
	if pq[i].first == pq[j].first {
		return pq[i].second > pq[j].second
	}

	return pq[i].first > pq[j].first
}

func (pq priorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *priorityQueue) Push(x interface{}) {
	n := len(*pq)
	p := x.(*pair)
	p.index = n
	*pq = append(*pq, p)
}

func (pq *priorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	p := old[n-1]
	p.index = -1
	*pq = old[0 : n-1]
	return p
}

func (pq *priorityQueue) update(p *pair, first, second int) {
	p.first = first
	p.second = second
	heap.Fix(pq, p.index)
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextFloat() float64 {
	sc.Scan()
	f64, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}

	return f64
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 13824
#include <iostream>
#include <map>
#include <cmath>
using namespace std;

int main()
{
  uint64_t n, p;
  cin >> n >> p;
  map<uint64_t, uint64_t> m;
  for (uint64_t i = 2; i * i <= p; i++) {
    while (p % i == 0) {
      m[i]++;
      p /= i;
    }
  }
  m[p] = 1;
  uint64_t ans = 1;
  for (const auto& e : m) {
    ans *= pow(e.first, e.second / n);
  }
  cout << ans << endl;
}


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


int main()
{
 	int s, count;
	cin >> s;
	count=0;
	if (s==1){
		cout << 4 << endl;
		return 0;
	}
	if (s==2){
		cout << 4 << endl;
		return 0;
	}
	
	for (int i=0;i<1000000;i++){
		count+=1;
		if (s == 4) break;
		if (s %2 == 0){
			s=s/2;
		continue;
		}
		if (s %2 == 1)s=3*s+1;
		//cout << s << endl;
	}
	cout << count+3 << endl;

	
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
as = gets.split.map(&:to_i)
position = Array.new(n + 1)

MOD = 10**9 + 7

left = nil
right = nil

(n+1).times do |i|
    if position[as[i]]
        left = position[as[i]]
        right = n - i
        break
    end
    position[as[i]] = i
end

sides = left + right

fact_mod = Array.new(n+2)
fact_inv = Array.new(n+2)
fact_mod[0] = 1
fact_inv[0] = 1

def power_mod(num, power, mod)
    prod = 1
    num %= mod
    while power > 0 do
        if power & 1 == 1
            prod = (prod * num) % mod
        end
        num = (num * num) % mod
        power >>= 1
    end
    return prod
end

POWER = MOD - 2

(1..(n+1)).each do |i|
    fact_mod[i] = (fact_mod[i - 1] * i) % MOD
    fact_inv[i] = (fact_inv[i - 1] * power_mod(i, POWER, MOD)) % MOD
end

(1..(n+1)).each do |k|
    comb_all = fact_mod[n + 1] * fact_inv[n + 1 - k] * fact_inv[k]
    if k - 1 <= sides
        comb_sides = fact_mod[sides] * fact_inv[sides - (k - 1)] * fact_inv[k - 1]
    else
        comb_sides = 0
    end
    puts (comb_all - comb_sides) % MOD
end

Measured memory_bytes: 14092
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


N, M = map(int, input().split())
G = [[] for _ in [0]*N]
for _ in [0]*(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

add = [0]*N
for _ in [0]*M:
    p, x = map(int, input().split())
    p -= 1
    add[p] += x
counter = [0]*N


def dfs(v, p, x):
    counter[v] = x
    for u in G[v]:
        if u == p:
            continue
        dfs(u, v, x+add[u])


dfs(0, -1, add[0])

print(*counter)


Measured memory_bytes: 237740
s = input()
S = len(s)
Words = {}
for i in range(len(s)):
    if s[i] not in Words:
        Words[s[i]] = [j for j, x in enumerate(s) if x == s[i]]
Ans = float("inf")
for w in Words:
    Indexes = Words[w]
    change = Indexes[0]
    for i in range(1, len(Indexes)):
        change = max(change, Indexes[i] - Indexes[i-1] - 1)
    change = max(change, S - Indexes[-1] - 1)
    Ans = min(Ans, change)
print(Ans)

Measured memory_bytes: 3064
N = int(input())

#print(int((N**0.5)//1))
for i in range(min(int((N**0.5)//1)+1, 10**5), 0, -1):
    if N % i == 0:
        #print(i)
        print(max(len(str(i)), len(str(N//i))))
        exit()

Measured memory_bytes: 3060
# ALDS_1_C: Prime Numbers
import sys
from math import sqrt
n = int(input())


def is_prime(x):
    if x == 1:
        return False
    if x % 2 == 0:
        if x == 2:
            return True
        else:
            return False
    for i in range(3, int(sqrt(x)) + 1):
        if x % i == 0:
            return False

    return True


ans = 0
for i in range(n):
    if is_prime(int(input())):
        ans += 1
print(ans)







Measured memory_bytes: 5676
from collections import deque

N, K = map(int, input().split())
S = [int(x) for x in input()]

count = 0
flag = True

la = deque([])
for c in S:
    if int(flag) == c:
        count += 1
    else:
        la.append(count)
        count = 1
        flag = not flag

la.append(count)

if K >= (len(la) / 2):
    print(N)
    exit()

ltmp = deque([])
sum_la = 0
for _ in range((K-1)*2 + 1):
    tmp = la.popleft()
    sum_la += tmp
    ltmp.append(tmp)

last_a = [sum_la]
while len(la) > 0 :
    tmp = la.popleft()
    sum_la += tmp
    ltmp.append(tmp)
    if len(la) > 0:
        tmp = la.popleft()
        sum_la += tmp
        ltmp.append(tmp)

    last_a.append(sum_la)

    if len(ltmp) > 0:
        tmp = ltmp.popleft()
        sum_la -= tmp
    if len(ltmp) > 0:
        tmp = ltmp.popleft()
        sum_la -= tmp
    last_a.append(sum_la)

print(max(last_a))


Measured memory_bytes: 8216
h, w = map(int, input().split())

s = [input() for _ in range(h)]

padded = []

for i in range(h + 2):
    if i == 0 or i == h + 1:
        padded.append("." * (w + 2))
    else:
        padded.append("." + s[i - 1] + ".")
# print(padded)

out = [[0] * w for _ in range(h)]

for i in range(1, h + 1):
    for j in range(1, w + 1):
        c = 0
        if padded[i][j] == "#":
            out[i - 1][j - 1] = "#"
        else:
            for k in range(8):
                dx = [-1, 0, 1, -1, 1, -1, 0, 1]
                dy = [-1, -1, -1, 0, 0, 1, 1, 1]
                c += padded[i + dx[k]][j + dy[k]] == "#"
            out[i - 1][j - 1] = c
        # print(i, j, out)
# print(out)
for i in range(h):
    print(*out[i], sep="")



Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
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;}

int main(){
    std::cout<<std::fixed<<std::setprecision(10);
    int n, k; cin>>n>>k;
    double ans = 0.0;
    for(int i=1; i<=n; i++){
        double t = 1.0;
        int x = i;
        while(x < k){
            t = t/2;
            x*=2;
        }
        ans += (t/n);
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
aa, bb = map(int,input().split())
aa -= 1
ans = 0
a1=0
b1=0
if 1<=aa%4<=2 :
    a1=1
if 1<=bb%4<=2 :
    b1=1
ans += (b1-a1)%2
#print(ans)

mod = 2
mod2 = 4

for i in range(1,45) :
    bketa = 0
    b = bb % mod2
    if b >= mod :
        bketa = (b - mod + 1) % 2
        #print("b"+str(i)+" "+str(bketa))

    aketa = 0
    a = aa % mod2
    if a >= mod :
        aketa = (a - mod + 1) % 2
        #print("a"+str(i)+" "+str(aketa))

    ans += (bketa-aketa)%2 * mod

    mod *= 2
    mod2 *= 2

print(ans)


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

using namespace std;

const int N = 100005;

int main() {
	int x, y;
	cin >> x >> y;

	if(x > y) return printf("No\n"), 0;
	if(y < 2 * x) return printf("No\n"), 0;
	if(y > 4 * x) return printf("No\n"), 0;
	while(y > 2 * x) {
		y -= 4;
		x--;
	}
	printf("%s\n", y == 2 * x ? "Yes" : "No");
}


Measured memory_bytes: 3588
#include<iostream>

using namespace std;

typedef long long ll;
int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    ll r, m;
    r = N / (A + B);
    m = N % (A + B);
    ll ans = r * A + (A < m ? A : m);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define N 1010
#define M 2
int num, s0, s1, num0, num1, n, m;
ll k;
char s[N][N];
ll Qpow(ll x, ll n) {
    n %= (mod - 1);
    ll s = 1;
    while (n) {
        if (n & 1) s = s * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return s;
}
struct Matrix {
    ll a[M][M];
    Matrix() { memset(a, 0, sizeof a); };
    Matrix operator*(Matrix &x) {
        Matrix s;
        for (int i = 0; i < M; i++)
            for (int j = 0; j < M; j++)
                for (int k = 0; k < M; k++)
                    s.a[i][j] = (s.a[i][j] + a[i][k] * x.a[k][j] % mod) % mod;
        return s;
    }
};
int main() {
    scanf("%d%d%lld", &n, &m, &k);
    for (int i = 1; i <= n; i++) {
        scanf("%s", s[i] + 1);
        for (int j = 1; j <= m; j++)
            if (s[i][j] == '#')
                num++, s0 += (s[i - 1][j] == '#'), s1 += (s[i][j - 1] == '#');
        if (s[i][1] == '#' && s[i][m] == '#') num1++;
        if (i == n)
            for (int j = 1; j <= m; j++)
                if (s[1][j] == '#' && s[n][j] == '#') num0++;
    }
    if ((num0 && num1) || k == 0) {
        printf("1\n");
        return 0;
    } else if (num0 == 0 && num1 == 0) {
        printf("%lld\n", Qpow(num, k - 1));
        return 0;
    }
    if (num0 == 0) {
        swap(num0, num1);
        swap(s0, s1);
    }
    Matrix A, ans;
    A.a[0][0] = num, A.a[1][0] = s0, A.a[1][1] = num0;
    ans.a[0][0] = ans.a[1][1] = 1;
    k--;
    while (k) {
        if (k & 1) ans = ans * A;
        A = A * A;
        k >>= 1;
    }
    printf("%lld\n", (ans.a[0][0] - ans.a[1][0] + mod) % mod);
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

long long n, fn;

int main() {
	cin >> n;

	fn = 1;

	for (int i = 0; n > 1; n--) {
		fn *= n;
	}

	cout << fn << endl;

	return 0;
}

/*@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@                       @*/
/*@ debug output erased ? @*/
/*@                       @*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@*/

Measured memory_bytes: 1156
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=lin(n)+[0]
cnt=0
for i in range(n):
    if arr[i]//2 >=1:
        cnt+=arr[i]//2
        if arr[i]%2==1 and arr[i+1]>0:
            cnt+=1
            arr[i+1]-=1
print(cnt)




Measured memory_bytes: 74584
import sys
readline = sys.stdin.readline
from collections import defaultdict
from bisect import bisect_left, bisect, insort_left, insort
INF = 10000
def lcs(s1, s2):
    c = defaultdict(list)
    for i, s in enumerate(s1):
        c[s].append(i)
    for s in set(s2):
        c[s].append(INF)
    dp = []
    for s2_k in s2:
        bgn_idx = 0
        for i, cur_idx in enumerate(dp):
            chr_idx = c[s2_k][bisect_left(c[s2_k], bgn_idx)]
            if chr_idx == INF:
                break
            dp[i] = min(cur_idx, chr_idx + 1)
            bgn_idx = cur_idx
        else:
            chr_idx = c[s2_k][bisect_left(c[s2_k], bgn_idx)]
            if chr_idx != INF:
                dp.append(chr_idx + 1)
    return len(dp)
def solve():
    N = int(input())
    for _ in range(N):
        x = readline().strip()
        y = readline().strip()
        print(lcs(x, y) if len(x) > len(y) else lcs(y, x))
solve()



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_e() {
	ll n;
	cin >> n;
	V a(n);
	rep(i, n) {
		cin >> a[i];
	}

	V b(n), c(n);
	unordered_map<ll, V> m;
	rep(i, n) {
		b[i] = a[i] - i;
		c[i] = -a[i] - i;
		m[c[i]].push_back(i);
	}

	ll ans = 0;
	rep(i, n) {
		if (m.find(b[i]) != m.end()) {
			auto itr = lower_bound(ALL(m[b[i]]), i);
			ans += (ll)(itr - m[b[i]].begin());
		}
	}

	cout << ans << endl;
}

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

	solve_abc_e();

	return 0;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
using ll = long long;
using str = string;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}

main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);

  ll n;
  cin>>n;
  vector<ll> a(n);
  cin>>a;

  ll ans=0;
  rep(i,n){
    for(int j=i+1;j<n;++j){
      ans += a[i]*a[j];
    }
  }
  cout<<(ans)<<endl;


}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main{
	public static void main(String[] args)throws IOException{
		Scanner sc = new Scanner(System.in);
		int size = sc.nextInt();
		String s = sc.next();
		char[] arr = s.toCharArray();
 
		int x = 0;
		int max = 0;
 
		for(int i = 0; i < size; i++){
			char c = arr[i];
			if(c =='I'){
				x += 1;
			}else{
				x--;
			}
			max = Math.max(max,x);
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios		ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
	ios
	int h,w;
	cin>>h>>w;
	char a[100][100];

	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		cin>>a[i][j];
	}
	for(int i=0;i<=h+1;i++)
	{
		a[i][0]='.';
		a[i][w+1]='.';
	}
	for(int j=0;j<=w+1;j++)
	{
		a[0][j]='.';
		a[h+1][j]='.';
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(a[i][j]=='#')
			{
				if(a[i][j-1]=='#'||a[i][j+1]=='#'||a[i+1][j]=='#'||a[i-1][j]=='#')
				continue;
				else
				{
					cout<<"No";
					return 0;
				}	
			}
		}
	}
	cout<<"Yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main(){
int a,b;
  cin>>a>>b;
double ret=0;
for(int i=1;i<=a;i++){
double tmp=1.0/a;
int now=i;
while(now<b){
now*=2;
tmp/=2;
}
ret+=tmp;
}
  cout<<fixed<<setprecision(12)<<ret;
}

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

int n,pos;
vector<int> pre,in,post;

void rec(int l,int r)
{
  if(l>=r) return ;
  int root = pre[pos++];
  int m = distance(in.begin(),find(in.begin(),in.end(),root));
  rec(l,m);
  rec(m+1,r);
  post.push_back(root);
}

void solve()
{
  pos = 0;
  rec(0,pre.size());
  for(int i=0;i<n;i++)
    {
      if(i) cout << " ";
      cout << post[i];
    }
  cout << endl;
}

int main ()
{
  int k;
  cin >> n;

  for (int i=0;i<n;i++)
    {
      cin >> k;
      pre.push_back(k);
    }

  for(int i=0;i<n;i++)
    {
      cin >> k;
      in.push_back(k);
    }

  solve();

  return 0;
}



Measured memory_bytes: 3160
def ShiftCharacter(str):
    plaintext=""

    for ch in list(str):
        if 'a' <= ch <= 'z':
            plaintext += chr((ord(ch)-ord('a') + 1) % 26 + ord('a'))
        else:
            plaintext +=ch
    return plaintext

def Match(str):
    fg = 0
    if (str=="the") or (str=="this") or (str=="that"):
        fg = 1
    return fg


while True:
    try:
        flag =0
        word=raw_input().split()
        if len(word)==0:
            break
        while (flag==0):
    #try:
        #print "aaaaa"
            for i in range(0,len(word)):
                word[i]=ShiftCharacter(word[i])
                #print word[i]
            for j in range(0,len(word)):
                if Match(word[j]) == 1:
                    flag = 1
                    break
                else:
                    continue
            if flag==1:
                for k in range(0,len(word)-1):
                    print word[k],
                print word[len(word)-1]
    except:
        break


Measured memory_bytes: 4688
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N;
  cin >> N;
  vector<int> p(N + 1);
  REP1(i, N)
  cin >> p[i];
  int ans = 0;
  REP1(i, N)
  {
    if (p[i] == i)
    {
      ans++;
      if (i == N)
        swap(p[i - 1], p[i]);
      else
        swap(p[i], p[i + 1]);
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
	ios_base::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int ans = 1;
	for (int i = 0; i < n; ++i) {
		ans = 1LL * ans * __gcd(a[i], i) % 998244353;
	}
	cout << ans << '\n';
}

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

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

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

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

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 ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<p> v(m);
  rep(i, m){
    int from, to;
    cin >> from >> to;
    from--;to--;
    v[i] = {to, from};
  }
  sort(ALL(v));

  int res = 0;
  int right = -1;
  for (int i = 0; i < m; ++i) {
    int l = v[i].second;
    int r = v[i].first;
    if(right <= l){
      res++;
      right = r;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 1792
#include <cstdio>

using namespace std;

int main()
{
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n,t,x;
    scanf("%d%d",&n,&t);
    long long first=0,last=0,sol=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        if(x<=last) last=x+t;
        else
        {
            sol+=last-first;
            first=x;
            last=x+t;
        }
    }
    sol+=last-first;
    printf("%lld",sol);
    return 0;
}


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

using namespace std;

int main()
{
    string s;
    cin >> s;
       
    int ans = 0;
    for(int i = 0; i < s.size(); i++){
	if(s.at(i) == '+'){
	    ans++;
	}else{
	    ans--;
	}
    }

    cout << ans << endl;
    
}


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

// マクロ //
#define rep(i,N) for(int i = 0; i < (int)(N); i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)
#define db(i) cout << #i << " = " << i;

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvli = vector<vli>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vvs = vector<vs>;
using mii = map<int, int>;
using mili = map<int, lint>;
using mci = map<char, int>;
using mcli = map<char, lint>;
using msi = map<string, int>;
using msli = map<string, lint>;


// 関数 //
template<class T, class Q> lint gcd_(T a, Q b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T, class Q> lint lcm_(T a, Q b) {
    return a * b / gcd(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

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

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

// 定数 //
const double pi = acos(-1);
const int mod = 1000000007;
const int MOD = 998244353;
const int inf = 1045141919;
const lint linf = ((1LL << 62) - 1);


// キーワード //
#define elif else if

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
        
    int N;
    cin >> N;

    for (int i = -500; i < 500; i++) {
        for (int j = -500; j < 500; j++) {
            if (pow(i, 5) - pow(j, 5) == N) {
                cou(i << " " << j);
                goto end;
            }
        }
    }
end:{}

}

Measured memory_bytes: 4112
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
using namespace std;
int n,m;
int main()
{
	scanf("%d%d",&n,&m);
	cout<<((pow(n,2))-m);
	putchar(10);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=1;i<=N;i++)

signed main(){
  string A,B;
  cin>>A>>B;
  string C=A+B,ans="No";
  int num=atoi(C.c_str());
  rep(i,1000){
    if(i*i==num){
      ans="Yes";
      break;
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    int c = 0;
    for (int i = 0; i < n; i++) {
        c += a[i] % 2;
    }
    if (c % 2 == 0) {
        cout << "YES" << "\n";
    } else {
        cout << "NO" << "\n";
    }
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <iterator>
#include <stack>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cstring>
#include <bitset>

#include <random>
#define all(x) (x).begin(), (x).end()


using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl

using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

//#define solvsh
//#define multi
#ifdef solvsh

const int MAXN = 3e2 + 1e2;

const int M = 54;

vector<int> g;

bool bit(int num, int i){
    return (num >> i) & 1;
}

void add_row(int row){

    g.push_back(row);


    for (int i = 20; i >= 0; --i){
        if (bit(row, i)){

        }
    }


    sort(all(g));
    while (g.back() == 0)
        g.pop_back();
}

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> v;
    for (int i = 0; i < n; ++ i){
        int curr;
        cin >> curr;
        v.push_back(curr);
    }

}

#else

void solve(){
    ld r;
    cin >> r;
    ld pi = acos(-1.);
    cout << pi * 2 * r;
}

#endif

void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
        cout << "Case #" << (i++) << ": ";
        solve();
        cout << endl;
    }
}


#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);


#ifdef multi
    multisolve();
#else
    solve();
//    gen();
#endif

}

Measured memory_bytes: 3812
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	List<Long> constraints = new ArrayList<>();
	long N;
	long result;

	Main() throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		this.N = Long.parseLong(in.readLine());
		for (int i = 0; i < 5; ++i) {
			this.constraints.add(Long.parseLong(in.readLine()));
		}
		in.close();

		this.calc();
	}

	void calc() {
		long min = Long.MAX_VALUE;
		for (Long c : this.constraints) {
			min = Math.min(min, c);
		}
		long time = this.N / min;
		if (this.N % min != 0) {
			++time;
		}
		time += 4;
		this.result = time;
	}

	public static void main(String[] args) throws IOException {
		Main ins = new Main();
		System.out.println(ins.result);

	}

}


Measured memory_bytes: 21332
var n,a,b,s,i,x,m:Longint;
begin
	read(n,a,b);
	for i:=1 to n do begin
		x:=1;
		m:=0;
		while x<=i do begin
			m:=m+i div x mod 10;
			x:=x*10;
		end;
		if (a<=m)and(m<=b)then s:=s+i;
	end;
	writeln(s);
end.


Measured memory_bytes: 128
/* long long or int */
/* inline & usighed & sighned main */
/* xx 396 */

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

const int MAX_N=1e5+10;

int dist[MAX_N],N,M,ans=0;
vector <int> G[MAX_N];

inline int dfs(int x){
	if(dist[x]!=-1) return dist[x];
	dist[x]=0;
	for(int i=0;i<G[x].size();i++){
		int to=G[x][i];
		dist[x]=max(dist[x],dfs(to)+1);
	}
	return dist[x];
}

signed main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	for(int i=0;i<MAX_N;i++) dist[i]=-1;
	cin>>N>>M;
	for(int i=0;i<M;i++){
		int X,Y; cin>>X>>Y; 
		X--; Y--;  G[X].push_back(Y);
	}
	for(int i=0;i<N;i++) ans=max(ans,dfs(i));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7680
#include <iostream>
#include <stdio.h>
#include <math.h>
#define PI 3.141592653589
using namespace std;
 
double x[3],y[3],rx,ry,r;
 
int trgin() {
    int i,k;
    double a,b,c,d=0;
    for (i=0; i<3; i++) {
     k=(i+1) % 3;
     a=sqrt((x[i]-x[k])*(x[i]-x[k])+(y[i]-y[k])*(y[i]-y[k]));
     b=sqrt((x[i]-rx)*(x[i]-rx)+(y[i]-ry)*(y[i]-ry));
     c=sqrt((x[k]-rx)*(x[k]-rx)+(y[k]-ry)*(y[k]-ry));
     d=d+acos((b*b+c*c-a*a)/(2*b*c));
    }
    if ((d-PI*2)<0.000001 && (d-PI*2)>-0.000001) return 1;
    return 0;
}
int line(double x1,double y1,double x2,double y2) {
    double x,y,m,d;
    if (y1==y2) { x=rx;y=y1;} else if (x1==x2) { x=x1;y=ry;}
    else {
    m=(y2-y1)/(x2-x1);
    x=(ry-y1+m*x1+rx/m)/(m+1/m);
    y=y1+m*(x-x1);
    }
    if (((x>=x1 && x<=x2) || (x>=x2 && x<=x1)) && ((y>=y1 && y<=y2) || (y>=y2 && y<=y1))){
    d=(rx-x)*(rx-x)+(ry-y)*(ry-y);
    if (d==r*r) return 1; else if (d<r*r) return 2;
    }
    return 0;
}
int main() {
    int i,j,k,f;
    while(true) {
        for (i=0;i<3;i++) {
        cin >> x[i] >> y[i];
        if (x[i]==0) break;
    }
    if (i!=3) break;
    cin >> rx >> ry >> r;
    for (i=0,f=0;i<3;i++) if ((x[i]-rx)*(x[i]-rx)+(y[i]-ry)*(y[i]-ry)<=r*r) f++;
    if (f==3) { cout << 'b' << endl; continue;} else if (f>0) { cout << 'c' << endl; continue;} 
    for (i=0,f=0,k=0;i<3;i++) {
        j=line(x[i],y[i],x[(i+1) % 3],y[(i+1) % 3]); k+=j;
        if (j>1) break;
    }
    if (i==3) if (trgin()==1) { cout << 'a' << endl; continue;} else if (k==0) {cout << 'd' << endl; continue;}
    cout << 'c' << endl;
    }
return 0;
 }

Measured memory_bytes: 3256
/* Author : Harshit Jain a.k.a. iharshit009 */
#include <bits/stdc++.h>
#define vi               vector<int>
#define pb(x)            push_back(x)
#define all(x)           x.begin(), x.end()
#define sortall(x)       sort(all(x))
#define sortrev(x)       sort(all(x), greater<int>())
#define debug(x)         cout << '>' << #x << ':' << x << endl;
#define int              long long
#define ld               long double
#define endl 			 "\n";
#define mp 				 make_pair
#define pii 			 <int, int>
#define lb 				 lower_bound
#define ub				 upper_bound
#define len(a)           int((a).size())
#define prec(n)          fixed<<setprecision(n)
#define cnt(n)           __builtin_popcountll(n)
#define pi               pair<int, int>
const int mod = 1000000007;
using namespace std;
using namespace std::chrono;
// const int N = 1e5 + 5; 
// int n;
// int a[N];



int32_t main(){
auto start = high_resolution_clock::now(); // starting clock
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t;
t = 1;
// cin >>t;
while(t--){


int count = 0;
int n,d;
cin >> n >>d;
for(int i = 0; i<n; i++){
	int a,b;

	cin >>a>>b;
	if(pow((a*a + b*b), 0.5) <= d){
		count++;
	}
}

cout << count << endl;




}
auto stop = high_resolution_clock::now(); // stop clock
auto duration = duration_cast<microseconds>(stop - start);  // printing duration
cerr << "Time taken by function: " << duration.count() << " milliseconds" << endl; 
return 0;
}

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

int main(){
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < s.size()-1; i++){
        if(s[i] == s[i+1]){
            if(s[i+1] == '0') s[i+1] = '1';
            else s[i+1] = '0';
            ans ++;
        }
    }
    cout << ans << endl;
}

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

const int N = 1e5 + 5;
const int inf = 1e9;

ll dp[N];

int main () {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  int n, k = 2;
  cin >> n;
  vector<int> a(n);
  a[0] = dp[0] = inf;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    dp[i] = inf;
  }
  dp[1] = 0;
  for (int i = 2; i <= n; i++) {
    for (int j = 1; j <= k; j++) {
      if (i-j >= 1) {
        dp[i] = min(dp[i-j] + abs(a[i] - a[i-j]), dp[i]);
      }
    }
  }
  cout << dp[n] << '\n';
  return 0;
}

Measured memory_bytes: 1408
#include<cstdio>

int a[200000];
int b[200000];

int pa[200000];
long long int sz[200000];
long long int res[200000];

int root(int x) {
    if(pa[x] == x) return x;
    return pa[x] = root(pa[x]);
}

void uni(int x, int y) {
    x = root(x);
    y = root(y);
    pa[x] = y;
    sz[y] += sz[x];
}

int main(void) {
    long long int n,m;
    scanf("%lld%lld",&n,&m);
    for(int i=0; i<m; i++)
        scanf("%d%d",&a[i],&b[i]), a[i]--, b[i]--;

    for(int i=0; i<n; i++)
        pa[i] = i, sz[i] = 1;

    long long int r = n*(n-1)/2;
    for(int j=m-1; j>=0; j--) {
        res[j] = r;

        int aa = root(a[j]), bb = root(b[j]);
        if(aa == bb) continue;
        r -= sz[aa] * sz[bb];
        uni(aa, bb);
    }

    for(int i=0; i<m; i++)
        printf("%lld\n", res[i]);
}

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

signed main(void)
{
	int h, w, n, p, ans;
	cin >> h >> w >> n;
	p = max(h, w);
	ans = n / p;
	if (n % p != 0)
		ans++;
	cout << ans << endl;
	return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:

int main(void) {
	int n;
	cin >> n;

	vector<int> p(n);
	rep(i, n) cin >> p[i];

	vector<int> op;

	auto query = [&](int k) {
		op.push_back(k);
		for (int i = k; i < n; ++i) {
			swap(p[i], p[i - k]);
		}
		return;
	};

	while (1) {
		if (p[0] == 0 or p[n - 1] == 0 or p[n - 1] < p[0])
			query(1);
		else
			query(n - 1);

		bool ok = true;
		rep(i, n) if (p[i] != i) ok = false;
		if (ok) break;
	}

	cout << op.size() << endl;
	for (auto &elem : op) cout << elem << endl;

	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <queue>
using namespace std;

string S;

int main() {
	cin >> S;
	if (S == "AAA" || S == "BBB") cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

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

int main()
{
    int n,i,indx,sum=0;
    cin>>n;
    int arr1[n+2],arr2[n+2],arr3[n+2];
    arr1[0]=200000;
    for(i=1; i<=n; i++)
    {
        cin>>arr1[i];
    }
    for(i=1; i<=n; i++)
    {
        cin>>arr2[i];
    }
    for(i=1; i<n; i++)
    {
        cin>>arr3[i];
    }
    for(i=1; i<=n; i++)
    {
        indx=arr1[i];
        sum+=arr2[indx];
        if(arr1[i]-arr1[i-1]==1)sum+=arr3[indx-1];

    }
    cout<<sum<<endl;



    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
int main()
{
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    ll suf[n];
    for(int i=0;i<n;i++)
        suf[i]=0;
    suf[n-1]=a[n-1];
    for(int i=n-2;i>=0;i--)
    {
        suf[i]=(a[i]+suf[i+1])%mod;
    }
    ll ans=0;
    for(int i=0;i<n-1;i++)
    {
        ans=(ans%mod+(a[i]%mod*suf[i+1]%mod)%mod)%mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6732
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    int n;
    ll ans = 1;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);
    sort(a.begin(), a.end());
    if (n % 2 == 1) {
        if (a.at(0) != 0) goto last;
        for (int i = 2; i < n; i += 2) {
            if (a.at(i - 1) != i) goto last;
            if (a.at(i) != i) goto last;
        }
        rep(i, n / 2) {
            ans *= 2;
            if (ans > 1000000007) ans %= 1000000007;
        }
        cout << ans << endl;
    }
    else {
        for (int i = 1; i < n; i += 2) {
            if (a.at(i - 1) != i) goto last;
            if (a.at(i) != i) goto last;
        }
        rep(i, n / 2) {
            ans *= 2;
            if (ans > 1000000007) ans %= 1000000007;
        }
        cout << ans << endl;
    }
    return 0;
    last:
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 640
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def MI() : return map(int, input().split())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

S, T = input().split()

print(T + S)


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

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

  string s;
  cin >> s;

  if(s == "ARC") cout << "ABC" << endl;
  else cout << "ARC" << endl;
}

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

int main() {
	int l[10], v1, v2;
	while (scanf("%d,", &l[0]) == 1) {
		for (int i = 1; i < 10; i++)
			scanf("%d,", &l[i]);
		scanf("%d,%d", &v1, &v2);
		int x = 0;
		for (int i = 0; i < 10; i++) {
			x += l[i];
			l[i] *= v1+v2;
		}
		x *= v1;
		for (int i = 0; i < 10; i++) {
			x -= l[i];
			if (x <= 0) {
				cout << i+1 << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
N = int(input())
if N >= 2:
    n = list(map(int,input().split()))
    a = sorted(n)
    if (a[N-1]-a[0])%2 ==0:
        y =int((a[N-1]-a[0])//2)
        print(y)
    else:
        y = int((a[N-1]-a[0]+1)//2)
        print(y)
elif N == 1 :
    print(0)


Measured memory_bytes: 5620
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
double heron(double a,double b,double c){
  double s = (a+b+c)/2;
  return sqrt(s*(s - a)*(s - b)*(s - c));
}
int main(){
  double a,l,x;
  while( cin >> a >> l >> x ){
    double m,s;
    m = (x+l)/2;
  
    s = 2*heron(m,m,l) + heron(a,l,l);
    printf("%.7f\n",s);
} 
}

Measured memory_bytes: 1240