akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	w := bufio.NewWriter(os.Stdout)
	bh := NewBinaryHeap()

	for {
		sc.Scan()
		command := sc.Text()

		if command == "insert" {
			sc.Scan()
			x, _ := strconv.Atoi(sc.Text())
			//insert
			bh.Add(x)

		} else if command == "extract" {
			//remove
			x := bh.Remove()
			w.Write([]byte(fmt.Sprintf("%d\n", x)))

		} else if command == "end" {
			break
		}
	}

	w.Flush()
}

type BinaryHeap struct {
	n int
	a []int
}

func NewBinaryHeap() *BinaryHeap {
	return &BinaryHeap{}
}
func (bh *BinaryHeap) left(i int) int {
	return 2*i + 1
}

func (bh *BinaryHeap) right(i int) int {
	return 2*i + 2
}

func (bh *BinaryHeap) parent(i int) int {
	return (i - 1) / 2
}

func (bh *BinaryHeap) Add(x int) bool {
	if bh.n+1 > len(bh.a) {
		bh.resize()
	}

	bh.a[bh.n] = x
	bh.n++
	bh.bubbleUp(bh.n - 1)

	return true
}

func (bh *BinaryHeap) resize() {
	capNew := 1
	if 2*bh.n > 1 {
		capNew = 2 * bh.n
	}
	newArray := make([]int, capNew)
	copy(newArray, bh.a)
	bh.a = newArray
}

func (bh *BinaryHeap) bubbleUp(i int) {
	p := bh.parent(i)
	for i > 0 && bh.a[i]-bh.a[p] > 0 {
		tmp := bh.a[i]
		bh.a[i] = bh.a[p]
		bh.a[p] = tmp

		i = p
		p = bh.parent(i)
	}
}

func (bh *BinaryHeap) Remove() int {
	x := bh.a[0]
	bh.n--
	bh.a[0] = bh.a[bh.n]
	bh.trickleDown(0)
	if 3*bh.n < len(bh.a) {
		bh.resize()
	}

	return x
}

func (bh *BinaryHeap) trickleDown(i int) {
	for {
		j := -1

		r := bh.right(i)
		if r < bh.n && bh.a[r]-bh.a[i] > 0 {
			l := bh.left(i)
			if bh.a[l]-bh.a[r] > 0 {
				j = l
			} else {
				j = r
			}
		} else {
			l := bh.left(i)
			if l < bh.n && bh.a[l]-bh.a[i] > 0 {
				j = l
			}
		}

		if j >= 0 {
			tmp := bh.a[i]
			bh.a[i] = bh.a[j]
			bh.a[j] = tmp

			i = j
		}

		if j < 0 {
			break
		}
	}
}



Measured memory_bytes: 20104
#include<stdio.h>
int main(){
  int a;
  scanf("%d",&a);
  float b[a];
  for(int i=0;i<a;i++)
    scanf("%f",&b[i]);
  float k;
  k=0;
  for(int i=0;i<a;i++){
    k+=1/b[i];
  }
  k=1/k;
  printf("%f",k);
}

Measured memory_bytes: 1696
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
ll MOD = 1000000007;
#define INF (1e9)

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


int main()
{
    string N;
    cin >> N;
    cout << "ABC" + N << endl;
    return 0;
}


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

int  main() {
string s;
int n,q;
cin>>n>>q;
cin>>s;

int arr[n+1]={0};
int length=0;
for(int i=1;i<n;i++)
{
    if(s[i]=='C'&&s[i-1]=='A')
    arr[i]=1;
    arr[i]+=arr[i-1];

}

int l,r;
while(q--)
{
    cin>>l>>r;
    cout<<arr[r-1]-arr[l-1]<<endl;
}
return 0;
}


Measured memory_bytes: 1536
import java.io.*;
import java.util.*;
class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		long n = Long.parseLong(reader.readLine());
		long res = 0;
		for(long i = 1;i<=n;i++){
			long p = n/i;
			res += ((p*(p+1))*i)/2;
		}
			System.out.println(res);
		}
}

Measured memory_bytes: 32560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<ll,P> pip;
typedef vector<pip> vip;
const ll INF=1ll<<60;

class Union_Find_Tree{
	public:
	vi p,r;
	Union_Find_Tree(int n){
		p=r=vi(n);
		for(int i=0;i<n;i++) p[i]=i;
	}
	int Par(int x){
		if(p[x]==x) return x;
		return p[x]=Par(p[x]);
	}
	bool Unite(int x,int y){
		x=Par(x);
		y=Par(y);
		if(x==y) return 0;
		if(r[x]<r[y]) p[x]=y;
		else{
			p[y]=x;
			if(r[x]==r[y]) r[x]++;
		}
		return 1;
	}
};

const P Inf={INF,INF};
ll n;
vl a,b;
vp dp[2];
vvp g;
vvi G;

void dfs(int v,int pre){
	vp c;
	c.push_back(Inf);
	c.push_back(Inf);
	for(auto p:g[v]){
		ll u=p.first,w=p.second;
		if(u!=pre){
			dfs(u,v);
			P p1=dp[0][u],p2=dp[1][u];
			c.push_back({p1.first+w,p1.second});
			c.push_back({p2.first+w,p2.second});
			c.push_back({a[u]+w,b[u]});
		}
	}
	sort(c.begin(),c.end());
	ll t=INF,I=0;
	for(auto p:c){
		ll tmp=p.second;
		if(tmp!=t||tmp==INF){
			t=tmp;
			dp[I++][v]=p;
		}
		if(I==2) break;
	}
}

void DFS(int v,int pre,ll d){
	if(pre>=0){
		vp c;
		c.push_back(dp[0][v]);
		c.push_back(dp[1][v]);
		c.push_back({dp[0][pre].first+d,dp[0][pre].second});
		c.push_back({dp[1][pre].first+d,dp[1][pre].second});
		c.push_back({d+a[pre],b[pre]});
		sort(c.begin(),c.end());
		ll t=INF,I=0;
		for(auto p:c){
			ll tmp=p.second;
			if(tmp!=t||tmp==INF){
				t=tmp;
				dp[I++][v]=p;
			}
			if(I==2) break;
		}
	}
	for(auto p:g[v]){
		ll u=p.first,w=p.second;
		if(u!=pre) DFS(u,v,w);
	}
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	a=b=vl(n);
	g=vvp(n);
	G=vvi(n);
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n-1;i++){
		int u,v,w;
		cin>>u>>v>>w;
		u--;v--;
		g[u].push_back({v,w});
		g[v].push_back({u,w});
	}
	Union_Find_Tree uft(n);
	ll cnt=0,res=0;
	while(1){
		dp[0]=dp[1]=vp(n,Inf);
		vl c(n);
		for(int i=0;i<n;i++){
			b[i]=uft.Par(i);
			c[b[i]]=i;
		}
		dfs(0,-1);
		DFS(0,-1,0);
		map<ll,P> mp;
		for(int v=0;v<n;v++){
			P p=dp[0][v];
			if(p.second==b[v]) p=dp[1][v];
			if(mp.find(b[v])==mp.end()) mp[b[v]]=Inf;
			P pre=mp[b[v]];
			mp[b[v]]=min(pre,{p.first+a[v],p.second});
		}
		for(auto i=mp.begin();i!=mp.end();i++){
			P p=i->second;
			ll u=c[i->first],v=c[p.second];
			if(uft.Unite(u,v)) res+=p.first,cnt++;
		}
		if(cnt==n-1) break;
	}
	cout<<res<<endl;
}

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

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
long long dp[100100];

int main() {
    string S; cin >> S;

    int cnt0 = 0;
    int cnt1 = 0;
    for(int i = 0; i < S.length(); i++) {
        if(S[i] == '0') cnt0++;
        else cnt1++;
    }
    
    cout << min(cnt0, cnt1) * 2 << endl;


    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
	public static void main(String[] args) throws java.io.IOException{
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		sc.close();
		double x = Double.valueOf(num).doubleValue();
		x = Math.pow(x,3);
		int result = (int)x;
		System.out.println(result);
	}
}

Measured memory_bytes: 17184
#include<iostream>
#include<vector>
#include<string>

int main(){
    std::string S;
    std::cin >> S;
    if(S[0] == 'R' && S[1] == 'R' && S[2] == 'R'){
        std::cout << 3 << std::endl;
    }else if((S[0] == 'R' && S[1] == 'R') || (S[1] == 'R' && S[2] == 'R')){
        std::cout << 2 << std::endl;
    }else if(S[0] == 'S' && S[1] == 'S' && S[2] == 'S'){
        std::cout << 0 << std::endl;
    }else{
        std::cout << 1 << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3620
#標準入力からソートまで
N, M = map(int, input().split())
A = list(map(lambda x : int(x) * (-1), input().split()))
#Aの中で一番でかいのをdiscountしてまた並び替え
#優先度付きqueuemを使う
import heapq
heapq.heapify(A)
for i in range(M):
    tmp = (-1) * heapq.heappop(A) // 2
    heapq.heappush(A, tmp * (-1))
print(-sum(A))

Measured memory_bytes: 14228
#include<iostream>
using namespace std;
int n, a[2];
int dp[2000000];
int main() {
	while (true) {
		cin >> n >> a[0] >> a[1];
		if (n == 0) { break; }
		for (int i = 0; i < 2000000; i++)dp[i] = 0;
		dp[0] = 1;
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < 1000000; j++) {
				if (dp[j] == 0) { continue; }
				dp[j + a[i]] = 1;
			}
		}
		int sum = 0;
		for (int i = 1; i <= n; i++) {
			if (dp[i] == 0)sum += 1;
		}
		cout << sum << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
 
  int n, k, q;
  cin >> n >> k >> q;
 
  vector<int> players(n+1, k-q);
  for (int i = 0; i < q; i++) {
    int p;
    cin >> p;	
    players[p]+=1;
  }
  
  for (int i = 1; i <= n;i++) {
   	if (players[i] > 0) cout << "Yes\n";
    else cout << "No\n";
  }  
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
  int N,X;
  int L[100];
	int S=0;
	int num=0;
  scanf("%d %d",&N,&X);
	for(int i=0;i<N;i++)scanf("%d",&L[i]);
	if(X==0)
	{
		printf("%d\n",1);
	}else
	{
		for(int i=0;i<=1000;i++)
		{
			S += L[i];
			if(S>X)printf("%d\n",i+1);
			if(S>X)break;
			if(S==X)printf("%d\n",i+2);
			if(S==X)break;
		}
	}
  return 0;
}

Measured memory_bytes: 128
# by the authority of GOD     author: manhar singh sachdev #

import os,sys
from io import BytesIO, IOBase

def main():
    n = int(input())
    x = [tuple(list(map(int,input().split())))for _ in range(n)]
    for i in range(n-2):
        if x[i][0]==x[i][1] and x[i+1][0]==x[i+1][1] and x[i+2][0]==x[i+2][1]:
            print('Yes')
            exit()
    print('No')
    
#Fast IO Region
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == '__main__':
    main()

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

#define int long long

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

signed main()
{
    int i=0, j=0, k=0, ans=0;
    int K;
    cin>>K;

    for(i=1;i<=K;i++){
        for(j=1;j<=K;j++){
            for(k=1;k<=K;k++){
                ans+=gcd(gcd(i,j),k);
            }
        }
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
double eps=1e-7;
bool eq(double a,double b){return (b-a<eps&&a-b<eps);}
double cross(P a,P b){return imag(b*conj(a));}
double dot(P a,P b){return real(b*conj(a));}
P project(P a,P b,P c){b-=a;c-=a;return a+b*real(c/b);}
P reflect(P a,P b,P c){b-=a;c-=a;return a+conj(c/b)*b;}
int ccw(P a,P b,P c){
  b-=a,c-=a,a=c*conj(b);
  if(a.imag()>eps)return 1;//ccw
  if(a.imag()<-eps)return -1;//cw
  if(a.real()<-eps)return 2;//ob
  if(abs(b)+eps<abs(c))return -2;//of
  return 0;//os
}
 
//segment ab , point c
double dist(P a,P b,P c){
  if(dot(b-a,c-a)<0)return abs(c-a);
  if(dot(a-b,c-b)<0)return abs(c-b);
  return abs(cross(b-a,c-a))/abs(b-a);
}
 
bool isintersect(P a,P b,P c,P d){
  return ((ccw(a,b,c)*ccw(a,b,d)<=0)&&(ccw(c,d,a)*ccw(c,d,b)<=0));
}
 
//segment ab , segment cd
P intersect(P a,P b,P c,P d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}
 
double dist(P a,P b,P c,P d){
  if(isintersect(a,b,c,d))return 0;
  double ab=min(dist(a,b,c),dist(a,b,d));
  double cd=min(dist(c,d,a),dist(c,d,b));
  return min(ab,cd);
}
 
int main(){
  int T;
  cin>>T;
  while(T--){
    double ax,ay,bx,by,cx,cy,dx,dy;
    cin>>ax>>ay>>bx>>by>>cx>>cy>>dx>>dy;  
    printf("%.12f\n",dist( P(ax,ay) , P(bx,by) , P(cx,cy) , P(dx,dy) ) );
  }
}

Measured memory_bytes: 3344
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int t[2200][3];
map<LL,int> m1[2];
bool used[6200][6200];
LL sq[6200][6200];
vector<LL> v[2];
const int N=6100;
queue<P> q1;

int main(){
	int n,m;
	int i,j,k;
	LL a,b,c,d;
	cin>>n>>m;
	m1[0][0]=1,m1[1][0]=1;
	for(i=0;i<n+m;i++){
		for(j=0;j<3;j++){
			cin>>t[i][j];
			if(i<n){
				if(j<2)a=0;
				else a=1;
			}else{
				if(j<1)a=0;
				else a=1;
			}
			m1[a][t[i][j]]=1;
		}
	}
	for(i=0;i<2;i++){
		j=0;
		for(auto& node:m1[i]){
			node.second=j++;
			v[i].push_back(node.first);
		}
	}
	for(i=0;i<n+m;i++){
		if(i<n){
			a=m1[0][t[i][0]]*2,b=m1[1][t[i][2]]*2;
			c=m1[0][t[i][1]]*2,d=m1[1][t[i][2]]*2;
		}else{
			a=m1[0][t[i][0]]*2,b=m1[1][t[i][1]]*2;
			c=m1[0][t[i][0]]*2,d=m1[1][t[i][2]]*2;
		}
		while(a<=c && b<=d){
			used[a][b]=true;
			if(i<n)a++;
			else b++;
		}
	}
	for(i=0;i+1<v[0].size();i++){
		for(j=0;j+1<v[1].size();j++){
			sq[2*i+1][2*j+1]=(v[0][i+1]-v[0][i])*(v[1][j+1]-v[1][j]);
		}
	}
	a=m1[0][0],b=m1[1][0];
	q1.push(make_pair(a*2,b*2));
	LL s=0;
	while(!q1.empty()){
		a=q1.front().first,b=q1.front().second;q1.pop();
		if(a<0 || a>N || b<0 || b>N){
			s=-1;
			break;
		}
		if(used[a][b])continue;
		used[a][b]=true;
		s+=sq[a][b];
		q1.push(make_pair(a+1,b));
		q1.push(make_pair(a-1,b));
		q1.push(make_pair(a,b-1));
		q1.push(make_pair(a,b+1));
	}
	if(s==-1)cout<<"INF"<<endl;
	else cout<<s<<endl;
}

Measured memory_bytes: 193404
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
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; }

int main(){
  ll N,index=0,sum=0;
  cin>>N;
  ll A[N];
  for(ll i=0;i<N;i++) cin>>A[i];
  sort(A,A+N);
  for(ll i=0;i<N-1;i++){
      sum+=A[i];
      if(A[i+1]>sum*2){
          index=i+1;
      }
  }
  cout<<N-index<<endl;
}

Measured memory_bytes: 1024
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// }}}

int N;
vector<ll> a;
vector<ll> b;

void solve()
{
    ll ans1 = 0, ans2 = 0;
    vector<ll> a1(a), a2(a), b1(b), b2(b);
    REP(i, N){
        ll x = min(a1[i], b1[i]);
        ans1 += x;
        if(b1[i] > x){
            b1[i] -= x;
            ll y = min(b1[i], a1[i+1]);
            a1[i+1] -= y;
            ans1 += y;
        }
    }
    REPR(i, N-1){
        ll x = min(a2[i+1], b2[i]);
        ans2 += x;
        if(b2[i] > x){
            b2[i] -= x;
            ll y = min(b2[i], a2[i]);
            a2[i] -= y;
            ans2 += y;
        }
    }
    cout << max(ans1, ans2) << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    a.resize(N+1);
    b.resize(N);
    REP(i, N+1) cin >> a[i];
    REP(i, N) cin >> b[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 4992
''''atcoder beginner contest-170'''

import math
from collections import defaultdict
def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

'''A'''
a=rl()
b=defaultdict(int)
for i in a:
    b[i]=1
for i in range(1,len(a)+1):
    if b[i]==0:
        print(i)
        break


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

int main() {
    int n,k;
    cin>>n>>k;
    int x[101];
    int cnt=0;
    for(int i=1;i<=n;i++){
        cin>>x[i];
        if(x[i]<abs(k-x[i])) cnt+=2*x[i];
        else cnt+=2*abs(k-x[i]);
    }

    cout<<cnt<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
map<string,int>sad;
int main()
{
    _SAD()
    int a,b;
    cin>>a>>b;
    cout<<max(0,a-b)<<NL;
    return 0;
}


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

string s;
int ans,x;
bool flag[3];
bool foot; //t = left, f = right
int a[100001];

int check(){
	int res = 0;
	for(int i = 1;i < s.size();i++){
		if(foot){
			if(a[i-1] == 1 && (a[i] == 2 || a[i] == 0)){
				res++;
			}
			else if(a[i-1] == 2 && a[i] == 0){
				res++;
			}
			else foot = false;
		}
		else{
			if(a[i-1] == 0 && (a[i] == 1 || a[i] == 2)){
				res++;
			}
			else if(a[i-1] == 2 && a[i] == 1){
				res++;
			}
			else foot = true;
		}
	}
	return res;
}

int main(){
	while(1){
		ans = 0;
		cin >> s;
		if(s[0] == '#')break;
		for(int i = 0;i < s.size();i++){
			stringstream ss;
			ss << s[i];
			ss >> a[i];
			a[i] %= 3;
		}
		foot = true;
		ans = check();
		foot = false;
		ans = min(ans,check());
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3676
X, Y = map(int, input().split())
ans = 10**18
for i in [True, False]:
    for j in [True, False]:
        x, y = X, Y
        tot = 0
        if i: x = -x; tot += 1
        if j: y = -y; tot += 1
        if x <= y:
            ans = min(ans, tot+(y-x))
print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
int main()
{
  int A,B,ans;
  scanf("%d %d",&A,&B);
  if(A>B){
    ans=A+(A-1);
  }
  else if(A<B){
    ans=B+(B-1);
  }
  else{
    ans=A+B;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] order = new int[N+1];
        for (int i = 1; i <= N; i++) {
        	order[sc.nextInt()] = i;
        }
        for (int i = 1; i <= N; i++) {
        	System.out.print(order[i] + " ");
        }
    }
}

Measured memory_bytes: 57140
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;

int M(int x) { return x >= mod ? x - mod : x; }
int n, k, res;
int fsp(long long bs, int p) {
    if (p <= 0) return 1;
    int rt = 1;
    while (p) {
        if (p & 1) rt = bs * rt % mod;
        bs = bs * bs % mod, p >>= 1;
    }
    return rt;
}

int f[2003];
int main() {
    scanf("%d%d", &n, &k);
    if (k == 1) return printf("%d\n", fsp(2, n - k - 1)), 0;
    for (int i = 1; i < n; ++i) f[i] = 1;
    for (int i = 2; i < k; ++i)
        for (int j = i; j < n; ++j) f[j] = M(f[j - 1] + f[j]);

    for (int j = k - 1; j < n; ++j) res = M(res + f[j]);
    printf("%d\n", 1ll * res * fsp(2, n - k - 1) % mod);
    return 0;
}


Measured memory_bytes: 3824
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
//#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <vector>
#define INF 0x3f3f3f
typedef long long ll;
const int maxn = 1e3 + 5;
const ll mod = 1e9 + 7;
const double pi = acos(-1.0);
int n, m;
int dis[maxn][maxn];
std::vector<int> v[maxn];

void GetDistance(int u) {
  std::queue<int> q;
  q.push(u);
  dis[u][u] = 0;

  while (!q.empty()) {
    int cur = q.front();
    q.pop();
  
    for (int i=0; i < v[cur].size(); i++) {
      if (dis[u][cur] + 1 < dis[u][v[cur][i]]) {
        dis[u][v[cur][i]] = dis[u][cur] + 1;
        q.push(v[cur][i]);
      }
    }
  }
}

void FindPath(int s, int t, std::set<int> &S) {
  int pre[maxn];
  memset(pre, 0, sizeof(pre));
  S.insert(s);
  std::queue<int> q;
  q.push(s);
  pre[s] = s;

  while (!q.empty()) {
    int cur = q.front();
    q.pop();
    if (cur == t) {
      int u = cur;
      while (pre[u] != s) {
        u = pre[u];
        S.insert(u);
      }
      return;
    }
    
    for (int i=0; i < v[cur].size(); i++) {
      if (!pre[v[cur][i]]) {
        pre[v[cur][i]] = cur;
        q.push(v[cur][i]);
      }
    } 
  }
}

int main(int argc, char **argv){
  std::cin >> n >> m;
  int x, y;
  for (int i=1; i <= m; i++) {
    std::cin >> x >> y;
    v[x].push_back(y);
  }

  memset(dis, INF, sizeof(dis));
  for (int i=1; i <= n; i++) {
    GetDistance(i);
  }
  
  int ans = n+2;
  int s = -1, t = -1;
  for (int i=1; i <= n; i++) {
    for (int j=i+1; j <= n; j++) {
      if (dis[i][j] + dis[j][i] < ans) {
        ans = dis[i][j] + dis[j][i];
        s = i;
        t = j;
      }
    }
  }
  
  // std::cout << s << " " << t << " " << ans << std::endl;
  if (s != -1 && t != -1) {
    std::cout << ans << std::endl;
    std::set<int> S;
    FindPath(s, t, S);
    FindPath(t, s, S);
    for (auto& it: S) {
       std::cout << it << std::endl;
    }
  } else {
    std::cout << "-1" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 7256
import Data.List                                                                                                                                      
                                                                                                                                                      
main :: IO ()                                                                                                                                         
main = do                                                                                                                                             
  _ <- getLine                                                                                                                                        
  as <-  map read . words <$> getLine :: IO [Int]                                                                                                     
  let gcdr = scanr gcd 0 as                                                                                                                           
      gcdl = scanl' gcd 0 as                                                                                                                          
  print $ maximum $ zipWith gcd gcdl (tail gcdr)

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

int main(){
  int num, K;
  cin>>num>>K;
  int *heights=new int[num];
  for(int index=0; index<num; index++) cin>>heights[index];
  
  int *minCost = new int[num];
  minCost[0]=0;
  for(int i=1; i<num; i++){
  	int tempMin=INT_MAX;
  	for(int j=1; j<=K; j++){
  		if(i-j >= 0){
  			int temp = abs(heights[i]-heights[i-j])+minCost[i-j];
  			if(tempMin>temp) tempMin=temp;
 		}else break;
  	}
  	minCost[i]=tempMin;
}
  cout<<minCost[num-1]<<endl;
  return 0;
}

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

#define int long long
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int N, C;
int D[555][555];
int c[555][555];
map<int, int> mp0, mp1, mp2; // map<色, 個数>
int X[5][50];

// mod0の色、mod1の色、mod2の色を決め打った時の合計コスト
int solve(int zero, int one, int two) {
	int ret = 0;
	for (int ci = 1; ci <= C; ci++) {
		ret += D[ci-1][zero-1] * X[0][ci];
	}
	for (int ci = 1; ci <= C; ci++) {
		ret += D[ci-1][one-1] * X[1][ci];
	}
	for (int ci = 1; ci <= C; ci++) {
		ret += D[ci-1][two-1] * X[2][ci];
	}

	return ret;
}

signed main() {
	cin >> N >> C;
	for (int i = 0; i < C; i++) {
		for (int j = 0; j < C; j++) {
			cin >> D[i][j];
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> c[i][j];
			int I = i+1, J = j+1;
			// mod0, mod1, mod2ごとにその色が何個あるかを求める
			X[(I+J)%3][c[i][j]]++;
		}
	}

	int ans = 1e18;
	for (int c0 = 1; c0 <= C; c0++) { // mod0の色
		for (int c1 = 1; c1 <= C; c1++) { // mod1の色
			for (int c2 = 1; c2 <= C; c2++) { // mod2の色
				if (c0 == c1) continue;
				if (c0 == c2) continue;
				if (c1 == c2) continue;

				int t = solve(c0, c1, c2);
				chmin(ans, t);
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main{
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(); //yousoの中身に一つ目の入力を保存
		int[] a = new int[n];//arrayって名前の配列を作成。要素数はretu
		for(int i=0; i< n; i++)a[i] = sc.nextInt(); //ｎの数だけ繰り返す。aを生成
		for(int j=a.length-1 ; j>=0; j--) {
			if(j!=0) {
			System.out.print(a[j] + " ");
		}else {
			System.out.print(a[j]);
		}
		}
		System.out.println();

}
}


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

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
    ifstream t("/proc/self/status");
    cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;

const int MAXN = (int) 2e5;

int n;

int A[MAXN + 5];

inline void input()
{
	n = read<int>();
	for(int i = 1; i <= n; ++i) A[i] = read<int>();
}

inline void solve()
{
	LL ans = 0;
	int xor_sum = A[1], add_sum = A[1];
	for(int l = 1, r = 1; r <= n; ++r)
	{
		while(l < r && xor_sum != add_sum) xor_sum ^= A[l], add_sum -= A[l++];
		xor_sum ^= A[r + 1];
		add_sum += A[r + 1];
		ans += r - l + 1;
	}
	printf("%lld\n", ans);
}

int main()
{
//	freopen("D.in", "r", stdin);
//	freopen("D.out", "w", stdout);

	input();
	solve();

	return 0;
}



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

using namespace std;
#define int long long

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w, m;
  cin >> h >> w >> m;
  vector<int> row(h), col(w);
  vector<pair<int, int>> pts(m);
  for(int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    row[x]++; col[y]++;
    pts[i] = make_pair(x, y);
  }
  int maxr = -1, maxc = -1;
  for(int x : row) {
    maxr = max(maxr, x);
  }
  for(int x : col) {
    maxc = max(maxc, x);
  }
  int r = 0, c = 0, should = 0;
  for(int x : row) {
    if(x==maxr) r++;
  }
  for(int x : col) {
    if(x==maxc) c++;
  }
  for(pair<int, int> p : pts) {
    int x = p.first;
    int y = p.second;
    if(row[x]==maxr && col[y]==maxc) {
      should++;
    }
  }
  if(r*c > should) {
    cout << maxr + maxc << '\n';
  } else {
    cout << maxr + maxc - 1 << '\n';
  }
  return 0;
}


Measured memory_bytes: 12684
#include <iostream> 
#include <vector> 
#include <algorithm> 
#include <bits/stdc++.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <functional> 
#include<math.h> 

using namespace std;
int main(void){
    // Your code here!
    long int s;
    cin >> s;
    vector<int> vec(1000010);
    vec.at(s) = 1;
    
    for(long int i = 0; i < 1000000 ; i++){
        if(s % 2 == 0){
            s /= 2;
        }
        else{
            s = s * 3 + 1;
        }
        
        if(vec.at(s) == 0){
            vec.at(s)++;
        }
        else{
            cout << i + 2 << endl;
            break;
        }
        
    }
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#include <cstring>
#include <ctype.h>
#include<stdlib.h>

#define pi 2 * acos(0.00)
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl '\n'
#define nll '\0'
#define mx 1000007
#define bdyptb return 0;
#define testcase ll t,tt; cin>>tt; for(t=1;t<=tt;t++)
   
#define mod 142857

using namespace std;


struct level
{
    int a;
    int b;
};

bool acp(level lhs,level rhs)
{return lhs.a<rhs.a;}

int main()
{
    fastio;
    
    int x,y;

    cin>>x>>y;
    if(y%2==1)cout<<"No"<<nl;
    else
    {
        int n1,n2;
        n1=floor((y-2*x)/2);
        n2=ceil((y-2*x)/2);
        if(n1==n2 and n1<=x and n1>=0)cout<<"Yes"<<nl;
        else cout<<"No"<<nl;
    }
    
    
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>

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

using namespace std;

typedef int Data;

struct Treap {
  Data value;
  int pri;
  Treap *left;
  Treap *right;
  int cnt;
  int minv;
  Treap(Data v)
      : value(v), pri(rand()),
      left(nullptr), right(nullptr),
      cnt(1), minv(v) {}
};

int count(Treap *t) { return !t ? 0 : t->cnt; }
int minv(Treap *t) { return !t ? 1000000000 : t->minv; }

Treap *update(Treap *t) {
  t->cnt = count(t->left) + count(t->right) + 1;
  t->minv = min(min(minv(t->left),minv(t->right)),t->value);
  return t;
}

Treap *merge(Treap *l, Treap *r){
  if(!l || !r) return !l ? r : l;

  if(l->pri > r->pri){
    l->right = merge(l->right, r);
    return update(l);
  } else {
    r->left = merge(l, r->left);
    return update(r);
  }
}

pair<Treap*, Treap*> split(Treap *t, int k) {
  if(!t) return make_pair(nullptr, nullptr);

  if(k <= count(t->left)) {
    auto s = split(t->left, k);
    t->left = s.second;
    return make_pair(s.first, update(t));
  } else {
    auto s = split(t->right, k - count(t->left) - 1);
    t->right = s.first;
    return make_pair(update(t), s.second);
  }
}

Treap *insert(Treap *t, int k, Data v) {
  auto s = split(t, k);
  return merge(s.first, merge(new Treap(v), s.second));
}

Treap *erase(Treap *t, int k) {
  auto s1 = split(t, k);
  auto s2 = split(s1.second, 1);
  delete s2.first;
  return merge(s1.first, s2.second);
}

int main() {
  srand(0);
  Treap *root = nullptr;
  int n,q;
  cin>>n>>q;
  REP(i,n){
    int a;
    cin>>a;
    root = insert(root, i, a);
  }
  REP(i,q){
    int x,y,z;
    cin>>x>>y>>z;
    switch(x){
      case 0: {
        auto b = split(root, z+1);
        auto f = split(b.first, y);
        auto s = split(f.second, z-y);
        Treap *ns = merge(s.second, s.first);
        Treap *nf = merge(f.first, ns);
        root = merge(nf, b.second);
      } break;
      case 1: {
        auto b = split(root, z+1);
        auto f = split(b.first, y);
        cout << f.second->minv << endl;
        Treap *nf = merge(f.first, f.second);
        root = merge(nf, b.second);
      } break;
      case 2: {
        root = erase(root, y);
        root = insert(root, y, z);
      } break;
    }
  }
  return 0;
}

Measured memory_bytes: 10576
N = int(input())
A = [int(input())-1 for _ in range(N)]

visited = {0}

G = 1
t = 0
for i in range(N):
    n = A[t]
    if n in visited:
        print(-1)
        break
    elif n == G:
        print(i+1)
        break
    else:
        visited.add(n)
        t = n
else:
    print(-1)


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

void bubble(int *a,char *b,int n){
	int x,flag=1;
	char y;
	while(flag!=0){
		flag=0;
		for(int i=n-1;i>0;i--){
			if(a[i]<a[i-1]){
				x=a[i];
				y=b[i];
				a[i]=a[i-1];
				b[i]=b[i-1];
				a[i-1]=x;
				b[i-1]=y;
				flag=1;
			}
		}
	}
	//出力
	for(int i=0;i<n;i++){
			printf("%c%d",b[i],a[i]);
			if(i!=n-1){
				printf(" ");
		}else{
			printf("\n");
		}
	}
}

void ssort(int* a,char* b,int n){
	
	int minj,x,flag=0;
	char y;
	
	for(int i=0;i<n;i++){
		minj=i;
		for(int j=i;j<n;j++){
			if(a[j]<a[minj]){
				minj=j;
				flag=1;
			}
		}
		x=a[i];
		y=b[i];
		a[i]=a[minj];
		b[i]=b[minj];
		a[minj]=x;
		b[minj]=y;
		flag=0;
	}
	for(int i=0;i<n;i++){
		printf("%c%d",b[i],a[i]);
		if(i!=n-1) printf(" ");
	}
	printf("\n");
}

void isStable(int n,char* b,char* d){
	
	int c=0;
	
	for(int i=0;i<n;i++){
		if(b[i]!=d[i]){
			c++;
		}
	}
	if(c!=0){
		printf("Not stable\n");
	}else{
		printf("Stable\n");
	}
}

int main(void){
	
	int n;
	
	scanf("%d",&n);
	
	int* a=(int*)malloc(sizeof(int)*n);
	char* b=(char*)malloc(sizeof(char)*n);
	int* c=(int*)malloc(sizeof(int)*n);
	char* d=(char*)malloc(sizeof(char)*n);
	
	for(int i=0;i<n;i++){
		scanf(" %c",&b[i]);
		scanf("%d",&a[i]);
		c[i]=a[i];
		d[i]=b[i];
	}
	
	bubble(a,b,n);
	printf("Stable\n");
	ssort(c,d,n);
	isStable(n,b,d);
}



Measured memory_bytes: 2036
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int,int> ii;
int n,m,res=0;
string a[10005];
vector<ii> row[10005],col[10005];
int main()
{
    //freopen("D.INP","r",stdin);
    ios_base::sync_with_stdio(false);
    cin >> n >> m;
    for (int i=1;i<=n;i++)
    {
        cin >> a[i];
        a[i]="0"+a[i];
    }
    for (int i=1;i<=n;i++)
        for (int j=1;j<=m;j++)
        {
            if (a[i][j]=='.')
            {
                int j1=j;
                while (a[i][j+1]=='.'&&j!=m) j++;
                row[i].push_back(ii(j1-1,j+1));
                //cout << "left: " << j1-1 << ". right: " << j+1 << "\n";
            }
        }
    for (int j=1;j<=m;j++)
        for (int i=1;i<=n;i++)
        {
            if (a[i][j]=='.')
            {
                int i1=i;
                while (a[i+1][j]=='.'&&i!=n) i++;
                col[j].push_back(ii(i1-1,i+1));
                //cout << "up: " << i1-1 << ". down: " << i+1 << "\n";
            }
        }
    for (int i=1;i<=n;i++)
    {
        for (ii v:row[i])
        {
            for (int j=v.F+1;j<v.S;j++)
            {
                //vector<ii>::iterator t;
                for (ii t:col[j])
                    if (t.F < i && i < t.S) res=max(res,(t.S-t.F+v.S-v.F-3));
            }
        }
    }

    cout << res;

}


Measured memory_bytes: 22912
use std::io::*;
use std::str::FromStr;
use std::collections::VecDeque;

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

fn solve(n: u64) -> u64 {
    if n < 10 {
        return n;
    }

    let mut cnt = 0;
    let mut queue: VecDeque<u64> = VecDeque::new();
    for i in 1..10 {
        queue.push_back(i as u64);
        cnt += 1;
    }

    let mut ans = 0;
    loop {
        let num = queue.pop_front().unwrap();
        let n2 = num % 10;

        if n2 != 0 {
            ans = num * 10 + n2 - 1;
            queue.push_back(ans);
            cnt += 1;
        }
        if n == cnt {
            break
        }

        ans = num * 10 + n2;
        queue.push_back(ans);
        cnt += 1;
        if n == cnt {
            break
        }

        if n2 != 9 {
            ans = num * 10 + n2 + 1;
            queue.push_back(ans);
            cnt += 1;
        }
        if n == cnt {
            break
        }
    }

    return ans;
}

fn main() {
    let n: u64 = read();

    println!("{}", solve(n));
}


Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <array>
#include <deque>
#include <bitset>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;
 
int main() {
    int n, w;
    scanf("%d", &n);
    scanf("%d", &w);
    int weight[n + 1];
    int value[n + 1];
    for (int i = 1; i <= n; i++) {
        scanf("%d", &weight[i]);
        scanf("%d", &value[i]);
    }
    vector<ll> dp(w + 1, 0);
    for (int i = 1; i <= n; i++) {
        for (int j = w; j >= 0; j--) {
            if (j >= weight[i]) {
                dp[j] = max(dp[j - weight[i]] + value[i], dp[j]);
            }
        }
    }
    cout << dp[w] <<endl;
    return 0;
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(V),v.end()));
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

typedef long long ll;
using namespace std;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, h;
	cin >> a >> b >> h;
	cout << (a + b)*h / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int MAXN=10000010;
bool prime[MAXN];
long long Prime[MAXN];
int num=0,ans;
void make_prime()
{
	memset(prime,true,sizeof(prime));
	prime[0]=prime[1]=false;
	for(int i=2; i<=MAXN; i++)
	{
		if(prime[i])
		{
			Prime[num++]=i;
		}
		for(int j=0; j<num&&i*Prime[j]<MAXN; j++)
		{
			prime[i*Prime[j]]=false;
			if(!(i%Prime[j]))
				break;
		}
	}
	return;
}
bool check(long long x)
{
	int flag=0;
	for(int i=0; Prime[i]<=x; i++)
	{
		if(x%Prime[i]==0)
			flag=1;
	}
	if(flag)
		return 0;
	else
		return 1;
}
int main()
{
	make_prime();
	long long a,b;
	cin>>a>>b;
	long long gcd=__gcd(a,b);
	for(int i=0; i<num; i++)
	{
		int flag=0;
		while(gcd%Prime[i]==0)
			gcd/=Prime[i],flag=1;
		if(flag)
			ans++;
	}
	if(gcd==1)
	{
		cout<<ans+1;
		return 0;
	}
	else 
	{
		cout<<ans+2;
		return 0;
	}
}

Measured memory_bytes: 16640
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
using namespace std;

class Node{
    public:
    int location;
    int p,l,r;
    Node(){}
};

class Point{
    public:
    int id,x,y;
    Point(){}
    Point(int id,int x,int y):id(id),x(x),y(y){}
    bool operator <(const Point &p) const{
        return id<p.id;
    }

    void print(){
        printf("%d\n",id);
    }
};

#define MAX 1000000
#define NIL -1
int n;
Point P[MAX];
Node T[MAX];
int np;

bool lessX(const Point &p1,const Point &p2){return p1.x<p2.x;}
bool lessY(const Point &p1,const Point &p2){return p1.y<p2.y;}

int makeKDTree(int l,int r,int depth){
    if(!(l<r)) return NIL;
    int mid=(l+r)/2;
    int t=np++;
    if(depth%2==0)  sort(P+l,P+r,lessX);
    else    sort(P+l,P+r,lessY);
    T[t].location=mid;
    T[t].l=makeKDTree(l,mid,depth+1);
    T[t].r=makeKDTree(mid+1,r,depth+1);
    return t;
}
void find(int v,int sx,int tx,int sy,int ty,int depth,vector<Point> &ans){
    int x=P[T[v].location].x;
    int y=P[T[v].location].y;

    if(sx<=x&&x<=tx&& sy<=y&&y<=ty) ans.push_back(P[T[v].location]);

    if(depth%2==0){
        if(T[v].l!=NIL && sx<=x) find(T[v].l,sx,tx,sy,ty,depth+1,ans);
        if(T[v].r!=NIL && x<=tx) find(T[v].r,sx,tx,sy,ty,depth+1,ans);
    }
    else{
        if(T[v].l!=NIL && sy<=y) find(T[v].l,sx,tx,sy,ty,depth+1,ans);
        if(T[v].r!=NIL && y<=ty) find(T[v].r,sx,tx,sy,ty,depth+1,ans);
    }
}
int main(){
    int x,y;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d %d",&x,&y);
        P[i]=Point(i,x,y);
        T[i].l=T[i].r=T[i].p=NIL;
    }
    np=0;
    int root=makeKDTree(0,n,0);
    int q;
    scanf("%d",&q);
    int sx,tx,sy,ty;
    vector<Point> ans;
    for(int i=0;i<q;i++){
        scanf("%d %d %d %d",&sx,&tx,&sy,&ty);
        ans.clear();
        find(root,sx,tx,sy,ty,0,ans);
        sort(ans.begin(),ans.end());
        for(int j=0;j<ans.size();j++) ans[j].print();
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 16472
def calc_num2(num):
  total = 0
  while num % 2 == 0:
    total += 1
    num = num / 2
  
  return total

num_count = input()
num_list = [int(i) for i in input().split(' ')]
ans_list = []
for num in num_list:
  ans_list.append(calc_num2(num))

print(min(ans_list))

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
using namespace std;

int n, MX = 100005;
int dp[100005];
vector<int> heights;

int solve(int curr){
    if(curr == n) return 0;
    if(curr > n) return INT_MAX;
    if(dp[curr] != -1) return dp[curr];
    int ans = INT_MAX;
    ans = min(ans, solve(curr+1) + abs(heights[curr] - heights[curr + 1]) );
    ans = min(ans, solve(curr+2) + abs(heights[curr] - heights[curr + 2]) );
    return dp[curr] = ans;
}

int32_t main()
{
    cin>>n;
    heights.resize(n+1);
    memset(dp, -1, sizeof dp);
    for(int i = 1 ; i <= n ; i++) cin>>heights[i];
    cout<<solve(1);
    return 0;
}


Measured memory_bytes: 9512
#include <bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;

struct point {
    int x,y;
}p[maxn];

map<int,int> xcnt,ycnt;

int main(){
    int H,W,M;cin>>H>>W>>M;
    int maxh=0,maxw=0;
    for(int i=0;i<M;i++){
        int h,w;cin>>h>>w;
        p[i]={h,w};
        xcnt[h]++,ycnt[w]++;
        maxh=max(maxh,xcnt[h]),maxw=max(maxw,ycnt[w]);
    }
    int cnt=0;
    for(int i=0;i<M;i++){
        int h=p[i].x,w=p[i].y;
        if(xcnt[h]==maxh&&ycnt[w]==maxw)
            cnt++;
    }
    //cout<<cnt<<endl;
    int num1=0,num2=0;
    for(auto tmp:xcnt)
        if(tmp.second==maxh)
            num1++;
    for(auto tmp:ycnt)
        if(tmp.second==maxw)
            num2++;
        //cout<<ycnt[i]<<endl;
    //cout<<num1<<' '<<num2<<endl;
    if(num1*num2==cnt) cout<<maxh+maxw-1<<endl;
    else cout<<maxh+maxw<<endl;
    return 0;
}




Measured memory_bytes: 33948
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,x,y,z,l,n,m,a,r,f,c;
  long long min,max,sum;
  string s;

    cin >> n >> m >> l;
    vector<vector<int>> A(n, vector<int>(m, 0));
    vector<vector<int>> B(m, vector<int>(l, 0));
      
    for(int i=0;i<n;i++){
		for(int j=0;j<m;j++) cin >> A.at(i).at(j);
    }
    for(int i=0;i<m;i++){
		for(int j=0;j<l;j++) cin >> B.at(i).at(j);
    }
  
	for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
          sum = 0;
    		for(int k=0;k<m;k++){
    			sum +=A.at(i).at(k) * B.at(k).at(j);
    		}
          cout << sum; 
          if(j != l-1) cout << " ";
    	} 
      cout << endl;
    }  
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;

template<typename T> struct segtree {
    
    T merge(T x, T y) {
	return max(x,y);
    }
    int n;
    vector<T> t;
    void init(int n) {
	n += 10;
	this->n = n;
	t.assign(n*4, 0);
    }

    void upd(int v, int tl, int tr, int i, T dx) {
	if (tl == tr) {
	    t[v] = merge(t[v], dx);
	} else {
	    int tm = (tl+tr)/2;
	    if (i<=tm) {
		upd(2*v,tl,tm,i,dx);
	    } else {
		upd(2*v+1,tm+1,tr,i,dx);
	    }
	    t[v] = merge(t[2*v], t[2*v+1]);
	}
    }

    T qry(int v, int tl, int tr, int l, int r) {
	if (l>tr || r<tl) {
	    return 0;
	}
	if (l <= tl && tr <= r) {
	    return t[v];
	}
	int tm = (tl+tr)/2;
	return merge(qry(2*v,tl,tm,l,r), qry(2*v+1,tm+1,tr,l,r));
    }
};

segtree<int> t;
int n, k;

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

    cin>>n>>k;

    const int N = 3e5;

    t.init(N+200);

    for (int i=0; i<n; i++) {
	int x;
	cin>>x;
	int lo = max(1,x-k);
	int hi = min(N,x+k);
	int res = t.qry(1,1,N,lo,hi);
	t.upd(1,1,N,x,res+1);
    }

    cout<<t.qry(1,1,N,1,N)<<endl;    
    
    return 0;
}


Measured memory_bytes: 7916
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include <string>
#include <math.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
  int x,a; cin >>x>>a;
  cout << (x<a?0:10) << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = list(map(int, input().split()))
i = 0
ans = 0
while True:
    t_min = float('inf')
    t_max = 0
    for j in range(m):
        t = a[i % n]
        t_min = min(t_min, t)
        t_max = max(t_max, t)
        i += 1
    ans += t_max - t_min
    if i % n == 0:
        break
print(ans)


Measured memory_bytes: 5620
using System;
namespace AISing.Problems
{
    class C
    {
        static void Main()
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            long n = long.Parse(Console.ReadLine());
            for (int i = 1; i <= n; i++) {
                long res = 0;
                for (int x = 1; x*x <= i; x++)
                {
                    for (int y = x; y*y <= i; y++)
                    {
                        for (int z = y; z*z <= i; z++)
                        {
                            if (x*x + y*y + z*z + x*y + y*z + z*x == i)
                            {
                                if (x == y & y == z)
                                {
                                    res += 1;
                                }
                                else if (x == y | y == z)
                                {
                                    res += 3;
                                }
                                else
                                {
                                    res += 6;
                                }
                            }
                        }
                    }
                }
                Console.WriteLine(res);
            }
            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27468