akhauriyash/Code-Regression huggingface dataset:
package main

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

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

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

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

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

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

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

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

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

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

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	aa := make([]int, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner) - 1
	}
	ans := 0
	for i := 0; i < n; i++ {
		if i == aa[aa[i]] {
			ans++
		}
	}

	fmt.Fprintln(writer, ans>>1)
}


Measured memory_bytes: 2560
#include <iostream>

using namespace std;
int sum[4];
double dp[301][301][2];

int main() {
    int N;
    scanf("%d", &N);
    for (int i=0;i<N;i++) {
        int a;
        scanf("%d", &a);
        sum[a]++;
    }
    double fail;
    for (int k=0;k<=sum[3];k++)
        for (int j=0;j<=sum[3] + sum[2] - k;j++)
            for (int i=0;i<=N - j - k;i++) {
                fail = 1.0 / (1 - (double)(N - i - j - k)/N); 
                double divis = (i + j + k);

                dp[i][j][k % 2] = 0;

                if (i) {
                   
                    dp[i][j][k % 2] += i / divis * (dp[i - 1][j][k % 2]);
                }
                if (j)
                    dp[i][j][k % 2] += j / divis * (dp[i + 1][j - 1][k % 2]);
                if (k)
                    dp[i][j][k % 2] += k / divis * (dp[i][j + 1][(k + 1) % 2]);
                if (i + j + k) 
                    dp[i][j][k % 2] += fail;
            }

    printf("%.9lf\n", dp[sum[1]][sum[2]][sum[3] % 2] );
}

Measured memory_bytes: 5196
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [[input().split()] for _ in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n,m=n1()
ps=s2(m)
OK=NG=0
d={str(i):[False,0] for i in range(1,n+1)}
for line in ps:
    num=line.split()[0]
    ans=line.split()[1]
    if d[num][0]==False:
        if ans=="AC":
            OK+=1
            d[num][0]=True
        else:
            d[num][1]+=1
for i,b in d.items():
    if b[0]:
        NG+=b[1]
print(OK,NG)

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

using namespace std;

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

#define ALL(obj)	(obj).begin(),(obj).end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define VEC vector

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				Vint;
typedef vector<Vint>			VV;

template<typename T>string join(const v(T)&v)
{stringstream s;REP(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		400010

const ll LINF = (ll)9e18+7;		//
const int INF = 100100100;			//2,147,483,647 (Max int)
const ll MOD = 1e9+7;
// テンプレ終了
//====================================================================//

// int DP[MAX];


//
int main(){
	int N;cin >> N;
	Vint A(N,0);

	REP(i,N-1){
		int t;cin >> t;
		A[t-1]++;
	}

	REP(i,N)cout << A[i] << endl;

	return 0;
}




Measured memory_bytes: 3984
//gauravsinghh
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 1000000000
#define lim 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
 
int main(){
    IOS
    //io_set();
   	ll n;
   	string s;
   	cin >> n >> s;
   	ll c = 1;
   	fo(i, 1, n-1){
   		if(s[i]!=s[i-1]){
   			c++;
   		}
   	}
   	cout << c << endl;
    return 0;
} 

Measured memory_bytes: 512
// In The Name Of Allah
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e12;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pii;
const ll mod = 1e9 + 7;
 
void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const ll M = 26 + 10;
const ll N = 30 * 100 + 10;

double dp[N][N] , a[N];

int main()	
{
	faster();
	int n;
	cin >> n;
	cout << fixed << setprecision(9);
	double ans = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	dp[0][0] = 1;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j <= n; j++)
		{
			dp[i + 1][j] = dp[i][j] * (1 - a[i]);
			if(j > 0)
			{
				dp[i + 1][j] += dp[i][j - 1] * a[i];
			}
		}
	}
	for (int i = n / 2 + 1; i <= n; i++)
	{
		ans += dp[n][i];
	}
	cout << ans << endl;
}

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

class Program {
	static string ReadLine() { return Console.ReadLine(); }
	static int ReadInt() { return int.Parse(ReadLine()); }
	static int[] ReadInts() { return ReadLine().Split().Select(int.Parse).ToArray(); }
	static string[] ReadStrings() { return ReadLine().Split(); }

	static void Main() {
		for (int i = 1; i < 10; i++) {
			for (int j = 1; j < 10; j++) {
				Console.WriteLine("{0}x{1}={2}", i, j, i * j);
			}
		}
	}
}

Measured memory_bytes: 9096
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>


const int MAX_N = 1050;
int N;
long long a[MAX_N];
long long AC[MAX_N];

void exec(const int i) {
    if (i == 1) {
        for (int j = 1; j <= N-1; j++) {
            a[j] = a[j+1];
        }
        N--;
    } else if (i == N) {
        N--;
    } else {
        a[i-1] += a[i+1];
        for (int j = i; j + 2 <= N; j++) {
            a[j] = a[j+2];
        }
        N -= 2;
    }
}

int main(int argc, char **argv) {
    std::cin >> N;
    for (int i = 1; i <= N; i++) {
        std::cin >> a[i];
    }

    long long sum[2] = {};
    long long max = a[1];
    int max_pos = 1;
    for (int i = 1; i <= N; i++) {
        if (0 <= a[i]) {
            sum[i%2] += a[i];
        }
        if (max < a[i]) {
            max = a[i];
            max_pos = i;
        }
    }

    //std::cout << sum[0] << " " << sum[1] << std::endl;

    std::vector<int> proc;

    if (sum[0] <= 0 && sum[1] <= 0) {
        //std::cout << "max_pos:" << max_pos << " " << N << std::endl;
        const int Nc = N;
        for (int i = max_pos + 1; i <= Nc; i++) {
            proc.push_back(N);
            exec(N);
            //std::cout << "N:" << N << std::endl;
        }
        for (int i = 1; i < max_pos; i++) {
            proc.push_back(1);
            exec(1);
            //std::cout << "N:" << N << std::endl;
        }
    } else {
        if (sum[1] < sum[0]) {
            exec(1);
            proc.push_back(1);
        }

        while (a[1] <= 0) {
            exec(1);
            proc.push_back(1);
            exec(1);
            proc.push_back(1);
        }

        while (1 < N) {
            if (N == 2) {
                exec(2);
                proc.push_back(2);
            } else {
                if (0 < a[3]) {
                    exec(2);
                    proc.push_back(2);
                } else {
                    exec(3);
                    proc.push_back(3);
                }
            }
        }
    }

    std::cout << a[1] << std::endl;
    std::cout << proc.size() << std::endl;
    for (int i = 0; i < proc.size(); i++) {
        std::cout << proc[i] << std::endl;
    }
    
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;
int main() {
    int n[26];
    string str;
    for (int i=0; i<26; i++) {
        n[i]=0;
    }
    while(getline(cin, str)){
   
        for (int i=0; i<str.size(); i++) {
            if( str[i] >= 'a' && str[i]<='z'){
                n[str[i]-'a']++;
            }
            if( str[i] >= 'A' && str[i]<='Z'){
                n[str[i]-'A']++;
            }
        }
        if (str.size() == 0) break;
    }
    for (int i=0; i<26; i++) {
        cout << char('a'+i) << " : " << n[i]<<endl;
    }
}



Measured memory_bytes: 3132
import java.util.Scanner;

//AtCoder Beginner Contest 150
//A - 500 Yen Coins
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long K = Long.parseLong(sc.next());
		long X = Long.parseLong(sc.next());
		sc.close();

		if (K * 500 >= X) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main()
{
    Hello
    int n;
    string s, t;
    cin >> n >> s >> t;
    for(int i = 0; i < n; i++)
        cout << s[i] << t[i];
    return 0;
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		String abc = sc.next();
		String[] abcList = abc.split("");

		if(abcList[Y-1].equals("A")) {
			abcList[Y-1] = "a";
		}else {
			if(abcList[Y-1].equals("B")) {
				abcList[Y-1] = "b";
			}else {
				abcList[Y-1] = "c";
			}
		}

		for(String ans:abcList) {
			System.out.print(ans);
		}
	}
}


Measured memory_bytes: 21844
#define _[2<<17]
n,i,flag;A _,B _,T _,F _;long M,D _,P _,R _,R2 _;s(u,i,p,I){i?s(u,T[i],p),R[i]=(I=B[i])-p?s(I,F[I],u),D[u]=D[u]*-~D[I]%M:D[u]:++D[u];}S(u,x,p,i,I){for(i=F[u];I=B[i];I-p?S(I,R[i]*x%M+1,u),x=x*-~D[I]%M:0)i=T[i];P[u]=x%M;}main(u,v){for(;~scanf("%d%d",&u,&v);)i++?A[i-1]=B[i]=u,B[i-1]=A[i++]=v:(n=u,M=v);for(;--i;F[A[i]]=i)T[i]=F[A[i]];s(*R=1,F[1]);for(S(1,1);i++<n;)printf("%d ",P[i]);for(i=0;i<2<<17;i++)flag+=R[i]!=R2[i];return 0*flag;}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MOD = 1e9+7;
const ll LINF = 1e18;
const int INF = 1e9;
ll A, B, C, D, E, F, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

vvi G(100100);
queue<int> que;
vi dist(100100); 

int main()
{
    cin >> N >> M;
    G.assign(N,vi());
    dist.assign(N,-1);
    for (int i = 0; i < M; i++) 
    {
        cin >> A >> B;
        G[A-1].push_back(B-1);
        G[B-1].push_back(A-1);
    }

    dist[0] = 0;
    que.push(0);

    while(!que.empty())
    {
        int v = que.front();
        que.pop();

        for(auto nv : G[v])
        {
            if (dist[nv] != -1) continue;

            dist[nv] = v;
            que.push(nv);
        }

    }

    if(count(all(dist),-1) != 0) 
    {
        cout <<"No";
        return 0;
    }

    cout << "Yes"<< endl;
    rep2(i,1,N)
    {
        cout << dist[i]+1 << endl;
    }


    
    return 0;
}

Measured memory_bytes: 10236
def solve(x, y):
    if (x + y) % 3 != 0:
        return 0
    n = (x + y) // 3
    r = min((2 * y - x) // 3, (2 * x - y) // 3)
    return cmb(n, r, mod)

_x, _y = map(int, input().split())

mod = 10 ** 9 + 7
g1 = [1, 1] # 元テーブル
g2 = [1, 1] # 逆元テーブル
inverse = [0, 1] # 逆元テーブル計算用テーブル

for i in range(2, max(_x, _y) + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((- inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

def cmb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod

print(solve(_x, _y))


Measured memory_bytes: 123768
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};



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

  rep(i,w+2)
  cout<<'#';
  cout<<endl;
  rep(j,h){
    rep(i,3){
      if(i==0)
      cout<<'#';
      else if(i==2)
      cout<<'#'<<endl;
      else
      cout<<a[j];
    }
  }
  rep(i,w+2)
  cout<<'#';
  cout<<endl;



  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
double EPS = 0.0000000001;
int sign(double x){
	if (x > EPS){
		return 1;
	} else if (x < -EPS){
		return -1;
	} else {
		return 0;
	}
}
bool equals(double x, double y){
	return abs(x - y) < EPS;
}
struct point{
	double x;
	double y;
	point(){
		x = 0;
		y = 0;
	}
	point(double X, double Y){
		x = X;
		y = Y;
	}
	point operator +(){
		return point(x, y);
	}
	point operator -(){
		return point(-x, -y);
	}
	point operator +(point P){
		return point(x + P.x, y + P.y);
	}
	point operator -(point P){
		return point(x - P.x, y - P.y);
	}
	point& operator +=(point P){
		x += P.x;
		y += P.y;
		return *this;
	}
	point& operator -=(point P){
		x -= P.x;
		y -= P.y;
		return *this;
	}
	point operator *(double k){
		return point(x * k, y * k);
	}
	point operator /(double k){
		return point(x / k, y / k);
	}
	point& operator *=(double k){
		x *= k;
		y *= k;
		return *this;
	}
	point& operator /=(double k){
		x /= k;
		y /= k;
		return *this;
	}
	bool operator ==(point P){
		return equals(x, P.x) && equals(y, P.y);
	}
	bool operator !=(point P){
		return !(*this == P);
	}
	bool operator <(point P){
		return sign(P.x - x) == 1 || (equals(x, P.x) && sign(P.y - y) == 1);
	}
	bool operator >(point P){
		return (P < *this);
	}
	point& rotate(double t){
	    double X = x * cos(t) - y * sin(t);
	    double Y = x * sin(t) + y * cos(t);
	    x = X;
	    y = Y;
	    return *this;
	}
	point& rotate(point P, double t){
	    *this -= P;
	    (*this).rotate(t);
	    *this += P;
	    return *this;
	}
	point& rotate90(){
	    swap(x, y);
	    x = -x;
	    return *this;
	}
};
istream& operator >>(istream &is, point &p){
	double x, y;
	is >> x >> y;
	p = point(x, y);
	return is;
}
ostream& operator <<(ostream &os, point p){
	os << p.x << ' ' << p.y;
	return os;
}
double norm(point P){
	return P.x * P.x + P.y * P.y;
}
double abs(point P){
	return sqrt(norm(P)); 
}
double dot(point P, point Q){
	return P.x * Q.x + P.y * Q.y;
}
struct line{
	point A;
	point B;
	line(){
	}
	line(point P, point Q){
		A = P;
		B = Q;
	}
	line(double a, double b){
		A = point(0, b);
		B = point(1, a + b);
	}
	line(double a, double b, double c){
		if (sign(b) == 0){
			A = point(-c / a, 0);
			B = point(-c / a, 1);
		} else {
			A = point(0, -c / a);
			B = point(1, -(b + c) / a);
		}
	}
};
istream& operator >>(istream &is, line &L){
	point A, B;
	is >> A >> B;
	L = line(A, B);
	return is;
}
ostream& operator <<(ostream &os, line L){
	os << L.A << ' ' << L.B;
	return os;
}
point vec(line L){
	return L.B - L.A;
}
point projection(point P, line L){
	return L.A + vec(L) * dot(P - L.A, vec(L)) / norm(vec(L));
}
int main(){
  cout << fixed << setprecision(20);
  line L;
  cin >> L;
  int q;
  cin >> q;
  for (int i = 0; i < q; i++){
    point P;
    cin >> P;
    cout << projection(P, L) << endl;
  }
}


Measured memory_bytes: 3288
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author emli
 */


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

typedef long long ll;
#define all(x) x.begin(),x.end()
class APluralForm {
public:
    void solve(std::istream& cin, std::ostream& cout) {
		ios::sync_with_stdio(false);
        cin.tie(nullptr);
        string s;
        cin >> s;


        if (s.back() == 's'){
            s = s + "es";
        }else {
            s = s + "s";
        }
        cout << s << endl;
	}
};


#define loveAfterTheGame main

int loveAfterTheGame() {
	APluralForm solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<stdlib.h>
int main(void){
    int x,n;

    std::cin>>n>>x;
    int *l=(int*)malloc((n)*sizeof(int));
    for(int i=0; i<n;i++){
        std::cin>>*(l+i);
    }
    int i;
    for(i=0;i<n;i++){
        if((x-=*(l+i))<0){
            break;
        }
    }
    std::cout<<(i+1);
    return 0;
}

Measured memory_bytes: 256
n=int(input())
arr=list(map(int,input().split()))
ans1=0
ans2=0
if arr[0]>0:
  lsum=arr[0]
else:
  lsum=1
  ans1+=1-arr[0]
for i in range(1,n):
  if i%2==1:
    if arr[i]<-lsum:
      lsum+=arr[i]
    else:
      ans1+=(abs(lsum)+1)+arr[i]
      lsum=-1
  else:
    if abs(lsum)<arr[i]:
      lsum+=arr[i]
    else:
      ans1+=(abs(lsum)+1)-arr[i]
      lsum=1
if arr[0]<0:
  lsum=arr[0]
else:
  ans2+=arr[0]+1
  lsum=-1
for i in range(1,n):
  if i%2==0:
    if arr[i]<-lsum:
      lsum+=arr[i]
    else:
      ans2+=(abs(lsum)+1)+arr[i]
      lsum=-1
  else:
    if abs(lsum)<arr[i]:
      lsum+=arr[i]
    else:
      ans2+=(abs(lsum)+1)-arr[i]
      lsum=1
ans=min(ans1,ans2)
print(ans)

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

class Program {
    static void Main (string[] args) {
        var inp = Console.ReadLine().Split(' ');
        int A = int.Parse(inp[0]);
        int B = int.Parse(inp[1]);
        int H = int.Parse(inp[2]);
        int M = int.Parse(inp[3]);

        float angle = Math.Abs(
          (
          (H + (float)M / 60f) * 30
          ) - M * 6
          );
        float f_angle = angle <= 180 ? angle : 360 - angle;
        double C = 0;
        C = Math.Sqrt(A * A + B * B - 2 * A * B * Math.Cos(f_angle * Math.PI / 180.0));

        //Console.WriteLine(f_angle);
        //Console.WriteLine(Math.Cos(f_angle * Math.PI / 180.0));
        Console.WriteLine(C);
    }
}

Measured memory_bytes: 27900
// Contest: AtCoder Beginner Contest 166 (https://atcoder.jp/contests/abc166)
// Problem: A: A?C (https://atcoder.jp/contests/abc166/tasks/abc166_a)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion }}}

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

    string s; cin >> s;
    cout << (s == "ABC" ? "ARC" : "ABC") << '\n';

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10;

ll dp[200][200], vl[200][200];

int main()
{
    fastInp;

    ll n;
    cin >> n;
    
    for (int j = 0; j < 2; j++) {
        for (int i = 0; i < n; i++) {
            cin >> vl[j][i];
            dp[j + 1][i + 1] = max(dp[j][i + 1] + vl[j][i], dp[j + 1][i] + vl[j][i]);
        }
    }

    cout << dp[2][n];
    return 0;
}

Measured memory_bytes: 3536
let id x = x
let s = Scanf.scanf "%s\n" id
let n = String.length s

let rec func c =
  if c = (n-1) then true else
    not( String.contains_from s (c+1) s.[c]) && func (c+1)
      
let ans = if func 0 then "yes" else "no"

let () =
  Printf.printf "%s\n" ans

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

using namespace std;


int main(){
    int len_set1,len_set2;
    int temp;
    

    scanf("%d",&len_set1);
    vector<int> set_array1(len_set1);
    for(int i = 0; i < len_set1;i++){
        scanf("%d",&temp);
        set_array1[i] = temp;
    }

    scanf("%d",&len_set2);
    vector<int> set_array2(len_set2);
    for(int i = 0; i < len_set2;i++){
        scanf("%d",&temp);
        set_array2[i] = temp;
    }

    vector<int> intersection_set;
    set_intersection(set_array1.begin(),set_array1.end(),
                     set_array2.begin(),set_array2.end(),
                     inserter(intersection_set,intersection_set.end()));

    for(auto itr = intersection_set.begin();itr!=intersection_set.end();itr++){
        printf("%d\n",*itr);
    }
    return 0;   
}



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


int main() {

  int n,m;
  cin>>n>>m;

  vector<tuple<int, int, int, int >> tuples(m);
  for(int i=0;i<m;i++){
    int p,y;
    cin>>p>>y;
    tuples.at(i) = make_tuple(p,y,i,0);
  }

  sort(tuples.begin(),tuples.end());

  int previous=get<0>(tuples.at(0));
  get<3>(tuples.at(0))=1;
  int cnt=1;
  for(int i=1;i<m;i++){
    if(get<0>(tuples.at(i))==previous){
      cnt++;
      get<3>(tuples.at(i))=cnt;
    }else{
      cnt=1;
      get<3>(tuples.at(i))=cnt;
      previous=get<0>(tuples.at(i));
    }
  }

  for(int i=0;i<m;i++){
    int wk = get<0>(tuples.at(i));
    get<0>(tuples.at(i))=get<2>(tuples.at(i));
    get<2>(tuples.at(i))=wk;
  }

  sort(tuples.begin(),tuples.end());

  for(int i=0;i<m;i++){
    cout<<setfill('0')<<right<<setw(6)<<get<2>(tuples.at(i))<<setfill('0')<<right<<setw(6)<<get<3>(tuples.at(i))<<endl;
  }

  return 0;
}




Measured memory_bytes: 4840
n = gets.to_i
a = gets.split().map(&:to_i)

left = Array.new(n)
right = Array.new(n)

left[0] = a[0]
right[-1] = a[-1]

(n-1).times do |i|
  left[i+1] = left[i].gcd(a[i+1])
end

(n-1).times do |i|
  right[n-2-i] = right[n-1-i].gcd(a[n-2-i])
end

ans = []

n.times do |i|
  if i == 0
    ans << right[i+1]
  elsif i == n-1
    ans << left[i-1]
  else
    ans << left[i-1].gcd(right[i+1])
  end
end

puts ans.max


Measured memory_bytes: 11020
#include<iostream>

using namespace std;

int main(){

    int N;
    bool flag;
    int cnt=0;

    cin >> N;

    int d[N];

    for(int i=0;i<N;++i){
        cin >> d[i];
    }

    for(int i=0;i<N;++i){
        flag = true;
        for(int j=0;j<i;++j){
            if(d[j]==d[i]){
                flag =false;
                break;
            }
        }
        if(flag){
            cnt += 1;
        }
    }

    cout << cnt;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define FOR(i,a,b)  for(int i = (a); i <= (b); ++i)

using namespace std;
constexpr int MOD = 10e9+7;
constexpr int INF = 1LL << 60;
template <class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}  
template <class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}  


int primeNum[110];
int pNum(int i,int N){
    int ans = 0;
   FOR(j,2,N){
      if(primeNum[j] >= i){
          ans ++ ;
      } 
   }
   return ans;
}

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

    int N ;    
    cin >> N;
    fill(primeNum,primeNum + N,0);
    FOR(i,2,N){
        int isPrime = 1;
        FOR(j,2,i-1){
            if(i % j == 0) isPrime = 0;
        }

        if(isPrime) {
            int p = i;
            int tmp = N/p;
            while(tmp > 0){
                
                tmp = N/p;
                primeNum[i] += tmp;
                p *= i;
            }
        } else {
            primeNum[i] = -1; //素数でない
        }
    }
    int ans = pNum(74,N) + pNum(24,N)*(pNum(2,N)-1/*同じものは使えない*/) + (pNum(4,N)-1) * pNum(14,N) + (pNum(2,N)-2)*pNum(4,N) * (pNum(4,N)-1)/2;
    cout << ans << endl;
    
}

Measured memory_bytes: 256
N,M,C = map(int,input().split())
B = list(map(int,input().split()))

A = []
ans = 0
S = 0

for i in range(N):
    tmp = list(map(int,input().split()))
    for j in range(len(tmp)):
        S += tmp[j]*B[j]
    S += C

    if S>0:
        ans += 1
    
    S = 0

print(ans)

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

int main(){
	string q,x,y;
	int a,b,c,t;
	a = 1;
	b = 0;
	c = 0;
	t = 0;
	while(cin >> q){
		x = q[0];
		y = q[2];


		if(x != "C" && y != "C"){
			t = b;
			b = a;
			a = t;

		}
		if(x != "A" && y != "A"){
			t = b;
			b = c;
			c = t;

		}
		if(x != "B" && y != "B"){
			t = c;
			c = a;
			a = t;

		}

	}
	if(a == 1)
		cout << "A" << endl;
	if(b == 1)
		cout << "B" << endl;
	if(c == 1)
		cout << "C" << endl;

	return 0;
}


Measured memory_bytes: 3064
# coding: utf-8
# Your code here!

n,m = map(int,input().split())

#こっからunion-find

#各ノードの親を格納するリスト
par = [i for i in range(n+1)]
#各木の根に対するrankを格納するリスト
rank = [0 for i in range(n+1)]

#xの根を発見する
#発見するだけでなくxと通過したノードを根の直下に配置する
def find(x):
    #自分の親が自分なら根
    if x==par[x]:
        return x
    else:
        #違う場合は親の根を自分の親にする
        par[x]=find(par[x])
        return par[x]


#xとyが含まれる木を合併する
def unite(x,y):
    #xの根,yの根をrx,ryとする
    rx=find(x)
    ry=find(y)
    
    #根が同じならもともと同じ木なのでok
    if rx==ry:
        return
    
    #根が異なる場合はrankが大きい木に小さい木をくっつける（rankを増やさないため）
    if rank[rx]<rank[ry]:
        par[rx]=ry
    else:
        par[ry]=rx
    #rankが等しい気を合併した時のみrankが増える
    if rank[rx]==rank[ry]:
        rank[rx]+=1

#x,yが同じ木に含まれるかの判定
def some(x,y):
    return find(x)==find(y)

#union-find終わり

#入力x,yを同じグループに
for i in range(m):
    x,y,z=map(int,input().split())
    unite(x,y)

#すべてのノードを根の直下に配置
for i in range(1,n+1):
    find(i)

#木の数を数える(根の種類を数える)
ans=len(set(par))-1

print(ans)


Measured memory_bytes: 13984
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func splitDigit(n int) []int {
	digit := make([]int, 0, 20)
	for n > 0 {
		digit = append(digit, n%10)
		n /= 10
	}
	return digit
}

func solve(n int) int {
	digit := splitDigit(n)
	k := len(digit)
	c := digit[k-1]
	for i := 0; i < k-1; i++ {
		if digit[i] != 9 {
			return c + 9*(k-1) - 1
		}
	}

	return c + 9*(k-1)
}

func main() {
	n, _ := strconv.Atoi(input())
	fmt.Println(solve(n))
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
using namespace std;

const int H = 10;
const int W = H;
int G[H][W];

int main() {
  fill(G[0], G[H], 0);
  int x, y, size;
  while(scanf("%d,%d,%d", &x, &y, &size) != EOF) {
    vector<pair<int,int> > v;
    if(size >= 1) {
      v.push_back(make_pair(0,0));
      v.push_back(make_pair(1,0));
      v.push_back(make_pair(0,1));
      v.push_back(make_pair(-1,0));
      v.push_back(make_pair(0,-1));
    }
    if(size >= 2) {
      v.push_back(make_pair(1,1));
      v.push_back(make_pair(1,-1));
      v.push_back(make_pair(-1,1));
      v.push_back(make_pair(-1,-1));
    }
    if(size >= 3) {
      v.push_back(make_pair(2,0));
      v.push_back(make_pair(0,2));
      v.push_back(make_pair(-2,0));
      v.push_back(make_pair(0,-2));
    }
    for(int i = 0; i < v.size(); ++i) {
      int nx = x + v[i].first;
      int ny = y + v[i].second;
      if(nx < 0 || nx >= W) continue;
      if(ny < 0 || ny >= H) continue;
      ++G[ny][nx];
    }
  }
  int koi = 0;
  int space = 0;
  for(int i = 0; i < H; ++i) {
    for(int j = 0; j < W; ++j) {
      space += G[i][j] == 0;
      koi = max(koi, G[i][j]);
    }
  }
  cout << space << endl;
  cout << koi << endl;
  return 0;
}

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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    double R;
    cin>>R;
    double ans =  R * 2 * 3.14159;
    cout << setprecision(7) <<  ans << endl;
}

Measured memory_bytes: 3788
#include<iostream>
#include<string>
using namespace std;
int main(){
  string t;
  int n[4]={0,0,0,0};
  while(cin>>t){
  if(t.substr(t.find(",")+1)=="A")n[0]++;
  if(t.substr(t.find(",")+1)=="B")n[1]++;
  if(t.substr(t.find(",")+1)=="AB")n[2]++;
  if(t.substr(t.find(",")+1)=="O")n[3]++;}
  cout<<n[0]<<endl<<n[1]<<endl<<n[2]<<endl<<n[3]<<endl;
}

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

#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)


using namespace std;
using ll = long long;

void solve() {
    int a, b;
    cin >> a >> b;
    int i = 0;
    while (a * i - i + 1 < b) {
        ++i;
    }
    cout << i << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);

    solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;
public class Main {
    
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	// 入力
	int a = sc.nextInt();
	int res = 0;
	int gcd1 = 0;
	int gcd2 = 0;
    
    for(int i=1;i<=a;i++) {
        for(int j=1;j<=a;j++) {
            gcd1 = gcd(i, j);
            for(int k=1;k<=a;k++) {
                gcd2 = gcd(gcd1, k);
                res += gcd2;
            }
        }
        gcd1 = 0; //初期化
        gcd2 = 0; //初期化
    }
	// 出力
    System.out.println(res);
	}
	
	//最大公約数算出
	public static int gcd(int m, int n) {
	    int r = 0;
	    int a = 0;
	    int b = 0;
	    if(m >= n) {
	        a = m;
	        b = n;
	    } else {
	        a = n;
	        b = m;
	    }
        while( (r = a % b) != 0 ) {
            if(r != a) { 
                a = b;
                b = r;
            } else {
                b = a;
            }
        }
        return b;
    }
}

Measured memory_bytes: 35828
#include <iostream>
#include <cstdint>

using namespace std;

int main() {
  int64_t H, N;
  cin >> H >> N;
  
  int64_t total = 0;
  for (size_t n = 0; n < N; ++n) {
    int64_t A;
    cin >> A;
    total += A;
  }
  if (total >= H) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}


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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N,Q;
    cin>>N>>Q;
    string S;
    cin>>S;
    vector<int> sum(N+2,0);
    for (int i=1;i<N;i++) {
        if (S[i] == 'C' && S[i-1] == 'A') {
            sum[i]++;
        }
        sum[i] += sum[i-1];
    }
    
    vector<pair<int,int>> queri(Q);
    REP(i,Q) {
        cin>>queri[i].fi>>queri[i].se;
    }
    REP(i,Q) {
        int l,r;
        l = queri[i].fi - 1;
        r = queri[i].se - 1;
        cout<<sum[r] - sum[l]<<endl;
    }
    return 0;
}

Measured memory_bytes: 2176
package main

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

func main() {
	N, W := ReadInt(), ReadInt()
	v := make([]int, N)
	w := make([]int, N)
	for i := 0; i < N; i++ {
		v[i], w[i] = ReadInt(), ReadInt()
	}
	fmt.Println(KnapsackDP(N, W, v, w))
}

// 01ナップサック問題 (重さが大きい場合) O(NV)
func KnapsackDP(N, W int, v, w []int) int {
	maxValue := 100 * N
	dp := make([][]int, N+1)
	for i := 0; i < N+1; i++ {
		dp[i] = make([]int, maxValue+1)
		for j := 0; j < maxValue+1; j++ {
			dp[i][j] = 1 << 60
		}
	}
	dp[0][0] = 0
	for i := 0; i < N; i++ {
		for sumV := 0; sumV <= maxValue; sumV++ {
			dp[i+1][sumV] = dp[i][sumV]
			if sumV >= v[i] {
				dp[i+1][sumV] = Min(dp[i+1][sumV], dp[i][sumV-v[i]]+w[i])
			}
		}
	}
	ans := 0
	for sumV := 0; sumV <= maxValue; sumV++ {
		if dp[N][sumV] <= W {
			ans = sumV
		}
	}
	return ans
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}



Measured memory_bytes: 9800
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
ll N;
int A[200000];
int cnt[1000001];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    ll ans = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        cnt[A[i]]++;
    }
    for(int i = 0; i < N; i++){
        int tmp = 0;
        for(int j = 1; j*j <= A[i]; j++){
            if(A[i]%j == 0){
                if(cnt[j] > 0)tmp += cnt[j];
                if(j*j != A[i]){
                    if(cnt[A[i]/j] > 0) tmp += cnt[A[i]/j];
                }
            }
        }
        if(tmp == 1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8164
#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++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

bool r[100005];
int pe[100005];

int main(){
    int n, m;
    cin >> n >> m;
    
    int ac = 0;

    rep(i, m){
        int p;
        string s;
        cin >> p >> s;
        p--;
        if(r[p]) continue;
        if(s=="WA"){
            pe[p]++;
        }else{
            r[p] = true;
            ac++;
        }
    }

    int ansp = 0;
    rep(i, n){
        if(r[i]){
            ansp += pe[i];
        }
    }

    cout << ac << " " << ansp << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 768
import math
a, b, x = map(int, input().split())

btm = a*a
air = b * btm - x
if air > x:
  l = 0
  r = 90
  while l < r - 0.00000000001:
    mid = (l + r) / 2
    if x * 2 < a * b * b * math.tan(math.radians(90-mid)):
      l = mid
    else:
      r = mid

  print(l)

else:
  l = 0
  r = 90
  while l < r - 0.00000000001:
    mid = (l + r) / 2
    if air * 2 <= btm * a * math.tan(math.radians(90-mid)):
      l = mid
    else:
      r = mid

  print(90 - r)

Measured memory_bytes: 3064
a1 = gets.split.map(&:to_i)
a2 = gets.split.map(&:to_i)
a3 = gets.split.map(&:to_i)
N = gets.to_i

N.times do |i|
  b = gets.to_i
  a1[0] = "○" if a1[0] == b
a2[0] = "○" if a2[0] == b
a3[0] = "○" if a3[0] == b
a1[1] = "○" if a1[1] == b
a2[1] = "○" if a2[1] == b
a3[1] = "○" if a3[1] == b
a1[2] = "○" if a1[2] == b
a2[2] = "○" if a2[2] == b
a3[2] = "○" if a3[2] == b
end

if a1[0] == "○" && a1[1] == "○" && a1[2] == "○"
    puts "Yes"
    exit
end
if a2[0] == "○" && a2[1] == "○" && a2[2] == "○"
    puts "Yes"
    exit
end
if a3[0] == "○" && a3[1] == "○" && a3[2] == "○"
    puts "Yes"
    exit
end
if a1[0] == "○" && a2[0] == "○" && a3[0] == "○"
    puts "Yes"
    exit
end
if a1[1] == "○" && a2[1] == "○" && a3[1] == "○"
    puts "Yes"
    exit
end
if a1[2] == "○" && a2[2] == "○" && a3[2] == "○"
    puts "Yes"
    exit
end
if a1[0] == "○" && a2[1] == "○" && a3[2] == "○"
    puts "Yes"
    exit
end
if a1[2] == "○" && a2[1] == "○" && a3[0] == "○"
    puts "Yes"
    exit
end
puts "No"

Measured memory_bytes: 1788
//ColorfulSlimes2.java
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int slimes[]=new int[n];
		for(int i=0; i<n; i++){
            slimes[i]=sc.nextInt();
        }
        int ans=0;

        for(int i=0; i<n-1; i++){
            if(slimes[i]==slimes[i+1]){
                slimes[i+1]=-1;
                ans++;
            }
        }
        System.out.println(ans);
        sc.close();
    }
}

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

int main(){
	int n,sum;
	sum = 0;
	cin >> n;
	vector<int> b(n-1);
	vector<int> a(n);
	for(int i=0;i<n-1;i++){
		cin >> b.at(i);
	}
	a.at(0)=b.at(0);
	a.at(n-1)=b.at(n-2);
	for(int i=1;i<n-1;i++){
		a.at(i)=min(b.at(i-1),b.at(i));
	}
	for(int i=0;i<n;i++){
		sum += a.at(i);
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define in freopen("in.txt","r",stdin)
//#define out freopen("out.txt","w",stdout) 
ll n,m,k,t,l,r;
ll a,b,c,d;
char A,B,C,X,Y,Z;
ll ans,MAX,MIN,sum;
ll ax[1000];
char str[100000];
ll dx[200][200];
ll bx[2000];


int main()
{
    ll i,j;
    t=1;
    //scanf("lld",&t);
    while(t--)
    {
      sum=0;
      memset(bx,0,sizeof(bx));
        ll flag=0;
        cin>>n>>k;
        for(i=1;i<=k;i++)
        {
          cin>>ax[i];
          for(j=1;j<=ax[i];j++)
          {
            cin>>dx[i][j];
            bx[dx[i][j]]=1;
          }
        }
        for(i=1;i<=n;i++)
        {
          if(bx[i]==0)
          sum++;
        }
        cout<<sum;
    }
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  int ans=0;
  for(int i=1;i<=n;i++){
    int a;
    cin>>a;
    if(i%2==1 && a%2==1) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std ;
priority_queue< pair< int , int > > pq ;
int main(){
    int N ,H ;
    cin >> N >> H ;
    while( N-- ){
         int a , b ;
         scanf( "%d%d" , &a , &b ) ;
         pq.push( make_pair( a , 1 ) ) ;
         pq.push( make_pair( b , 0 ) ) ;
    }
    int res = 0 ;
    int cnt = 0 ;
    while( 1 ){
          int f = pq.top().first ;
          int s = pq.top().second ;
          res += f ; cnt++ ;
          if ( !s ) pq.pop() ;
          if ( res >= H ) break ;
          else
           if ( s ){
               cnt += ( H - res + f - 1 ) / f ;
               break ;
           }
    }
    cout << cnt << endl ;
    return 0 ;
}

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n; cin >> n;
    vector<vector<ll>> f(n, vector<ll>(10)), p(n, vector<ll>(10));
    rep(i, n) {
        rep (j, 5) {
            cin >> f[i][j] >> f[i][j+5];
        }
    }
    rep(i, n) {
        rep (j, 11) {
            cin >> p[i][j];
        }
    }
    // for (auto elem1 : f) {
    //     for (auto elem : elem1) cout << elem << " "; cout << endl;
    // }

    // for (auto elem1 : p) {
    //     for (auto elem : elem1) cout << elem << " "; cout << endl;
    // }

    ll max_num = -inf;

    for (ll bit = 1; bit < (1<<10); bit++) {
        ll num = 0;
        rep (i, n) {
            ll count = 0;
            rep (j, 10) {
                ll m = (bit>>j) & 1 & f[i][j];
                // cout << m << " ";
                count += m;
            }
            // cout << endl;
            // cout << count << endl;
            num += p[i][count];
        }
        // cout << "num: " << num << endl;
        max_num = max(max_num, num);
    }
    cout << max_num << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CWalkOnMultiplicationTable solver = new CWalkOnMultiplicationTable();
        solver.solve(1, in, out);
        out.close();
    }

    static class CWalkOnMultiplicationTable {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong();
            long ans = Long.MAX_VALUE;
            for (int i = 1; i <= Math.sqrt(n); i++) {
                if (n % i == 0) {
                    long a = i - 1;
                    long b = n / i - 1;
                    ans = Math.min(ans, a + b);
                }
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 21588
#include<bits/stdc++.h>
typedef long long ll;
#define pii pair<int,int>
#define ff first
#define ss second
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}

int main()
{
    fast();
    int x,a,b;
    cin>>x>>a>>b;
    if(a%x==0||b%x==0)
    cout<<"OK\n";
    else if(x*((a/x)+1)>=a&&x*((a/x)+1)<=b)
        cout<<"OK\n";
    else
        cout<<"NG\n";

    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define str string
#define pb push_back
#define vc vector
#define ci cin
#define co cout
// remove fropen in online judge
int main()
{ 
 

  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,k;
    cin>>n>>x>>k;
    k=ceil((double)n/(double)x)*k;
    cout<<k;
    
}


Measured memory_bytes: 3608