akhauriyash/Code-Regression huggingface dataset:
/*
Problem 0101 : Aizu PR
*/
#include <stdio.h>
#include <string.h>

int main(void){
	char s[1001];
	int i , n , j;
	scanf("%d" , &n);
	for(j=1;j<=n;j++){
		scanf("%*c%[^\n]" , s);
		i = 0;
		while(s[i] != '\0'){
			if(s[i] == 'H'){
				if(s[i+1] == 'o'
					&& s[i+2] == 's'
					&& s[i+3] == 'h'
					&& s[i+4] == 'i'
					&& s[i+5] == 'n'
					&& s[i+6] == 'o'){
					printf("Hoshina");
					i += 7;
				}else{
					printf("%c" , s[i]);
					i++;
				}
			}else{
				printf("%c" , s[i]);
				i++;		
			}
		}
		printf("\n");
	}

	return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin>>vec.at(i);
    }
    bool test;
    test = true;
    for(int j=0;j<n;j++){
        if(vec.at(j) % 2 == 0 ){
            if(vec.at(j)%3==0 || vec.at(j)%5==0 ){
                test = true;
            }else{
                test = false;
                goto EXIT;
            }
        }
    }
    EXIT:
    if(test){
        cout << "APPROVED" <<endl;
    }else{
        cout << "DENIED" <<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

long long lcm(long long a, long long b)
{
   return a * b / gcd(a, b);
}

int main()
{
   long long a, b;
   cin >> a >> b;

   cout << lcm(a, b) << endl;
   return 0;
}

Measured memory_bytes: 256
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

N,M=map(int,input().split())
uni=UnionFind(N)
L=[]
for i in range(M):
    l=list(map(int,input().split()))
    L.append(l)
for i in range(M):
    uni.Unite(L[i][0],L[i][1])
x=-1
for i in range(N+1):
    if uni.root[i]<0:
        x+=1
print(x)


    



Measured memory_bytes: 84348
#include<stdio.h>
int main()
{
    int A[4],i,s=0;
    for(i=1;i<=3;i++){
        scanf("%d",&A[i]);}

    for(i=1;i<=3;i++)
        {
        s=s+A[i];
    }

    if(s>=22)
        printf("bust");
    else
        printf("win");
    return 0;
}



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

int main(){
	for(;;){
		int n;
		string s;
		cin>>n>>s;
		if(n==0)break;
		vector<int> d(n,0);
		int ba=0;
		for(int i=0,j=0; i<s.length(); i++,j++)
			if(s[i]=='M') d[j%n]++;
			else if(s[i]=='S') { ba+=d[j%n]+1; d[j%n]=0; }
			else if(s[i]=='L') { d[j%n]+=ba+1; ba=0; }
		sort(d.begin(), d.end());
		for(int i=0; i<n; i++) cout<<d[i]<<' ';
		cout<<(100-accumulate(d.begin(),d.end(),0))<<endl;
	}
}

Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std ; 
 
int dp[1000000] ;  
 
 
template<typename T> 
class Graph {
 
	map<int, list<int> >adjlist ; 
 
 
public:
 
	Graph()
	{
 
	}
 
	void addEdge(int u , int v)
	{
		adjlist[u].push_back(v); 
		
	}
 
	bool isneighbour(int node )
	{
		int f=0 ; 
		for(auto k: adjlist[node])
		{
			f++; 
		} 
		if(f==0)
		{
			return false ; 
		}
		return true ; 
 
	}
 
	int  dfshelper(int node, map<int, bool>& visited)
	{
		if(!isneighbour(node))
		{
			return 0 ; 
		}
 
		if(dp[node] !=-1)
		{
			return dp[node] ; 
		}
 
		int ans =0; 
		for(auto neighbour : adjlist[node])
		{
			int sub=1+dfshelper(neighbour, visited) ; 
			ans=max(ans, sub); 
 
			
		}
		return dp[node]= ans ; 
	
 
	}
 
	void DFS()
	{
		map<int , bool> visited ; 
		int Ans =1 ; 
		
		memset(dp, -1, sizeof(dp)) ; 
		for(auto i : adjlist )
		{
			int  src=i.first ; 
			
				
				int sub = dfshelper(src, visited); 
				Ans=max(Ans, sub) ; 
				
			
		} 
 
		cout<<Ans ; 
	}
 
 
 
 
} ; 
 
 
 
 
 
int main()
{
 
	Graph <int > g; 
	int n, e; 
	cin>> n>> e; 
	for(int i=0 ; i<e; i++)
	{
		int x,y;
		cin>>x>>y ; 
		g.addEdge(x,y); 
 
	}
	// g.print() ; 
	g.DFS(); 
 
	return 0 ; 
 
}

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

int main(void)
{
	int a[3][3], b[10], n, i, j,N;
	int c[3][3] = {0};
	for(i = 0;i < 3;i++)
	{
		for(j = 0;j < 3;j++)
		{
		cin >> a[i][j];
		}
	}
	cin >> N;
	for(n = 0;n < N;n++)
	{
		cin >> b[n];
		for(i = 0;i < 3;i++)
		{
			for(j = 0;j < 3;j++)
			{
				if(a[i][j] == b[n])
				{
					c[i][j] = 1;
				}
			}
		}
	}	
	
	if( c[0][0] * c[0][2] * c[0][1] ||
	    c[1][0] * c[1][2] *c[1][1] ||
	    c[2][0] * c[2][2] *c[2][1] ||
	    c[0][0] * c[1][0] *c[2][0] ||
	    c[0][1] * c[1][1] *c[2][1] ||
	    c[0][2] * c[1][2] *c[2][2] ||
	    c[0][0] * c[1][1] *c[2][2] ||
	    c[2][0] * c[1][1] *c[0][2] 
	    )
	{
	    cout << "Yes";
	}
	else
	{
	    cout << "No";
	}
}


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

using namespace std;
using ll = long long;
#define mod 1000000007
ll mypower(ll a, ll b, ll p)
{
    ll ans = 1;
    a = a%p;
    while(b)
    {
        if(b%2)
            ans = ans*a % p;
        b=b/2;
        a = a*a % p;
    }
    return ans;
}
int main() {
    int n;
    cin >> n;
    ll arr[n+1];
    int i;
    for(i=1;i<=n;i++)
        cin >> arr[i];
    ll pref[n+1];
    pref[1] = arr[1]+1;
    map<ll,ll> mp;
    mp[arr[1]+1]++;
    ll cnt = 0;
    for(i=2;i<=n;i++)
    {
        if(i > arr[i])
        {
            ll val = i - arr[i];
            if(mp.find(val) != mp.end())
                cnt+=mp[val];
        }
        mp[arr[i]+i]++;
    }
    cout << cnt << '\n';
}

Measured memory_bytes: 17540
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;

int a[100005];

int fun(int x, int y)
{
	if (x - y < 0) return y - x;
	else return x - y;
}

int main()
{
	int n, t, x, y, xx, yy, s, e, tt, q;
	while (~scanf("%d", &n))
	{
		e = 0;
		int i;
		x = y = t = q = 0;
		for (i = 0; i < n; i++)
		{
			scanf("%d%d%d", &tt, &xx, &yy);
			t = tt - q;
			q = tt;
			if (e == 0)
			{
				s = fun(xx, x) + fun(yy, y);
				if (t < s)
				{
					e++;
				}
				else
				if ((t - s) % 2 != 0)
				{
				    e++;
				}
				x = xx, y = yy;
			}
		}
		if (e == 0)
		printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

int main(){
    int n, a, b;
    cin >> n >> a >> b;

    ll all_sum = 0;
    repi(i, 1, n+1){
        string num = to_string(i);
        ll sum = 0;
        for(auto itr = num.begin(); itr != num.end(); itr++){
            sum += *itr - '0';
        }

        if(a <= sum && sum <= b) all_sum += i;
    }

    cout << all_sum << endl;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,c,k = LI()
    s = input()
    k += 1
    dpl = [0]*n
    if s[0] == "o":
        dpl[0] = 1
    else:
        dpl[0] = 0
    for i in range(1,n):
        dpl[i] = dpl[i-1]
        if s[i] == "o":
            dpl[i] = max(dpl[i-k]+1,dpl[i])
    dpr = [0]*n
    if s[-1] == "o":
        dpr[-1] = 1
    else:
        dpr[-1] = 0
    for i in range(n-1)[::-1]:
        dpr[i] = dpr[i+1]
        if s[i] == "o":
            dpr[i] = max(dpr[(i+k)%n]+1, dpr[i])
    dpl = [0]+dpl
    dpr += [0]
    ans = []
    for i in range(n):
        if dpl[i]+dpr[i+1] < c:
            print(i+1)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 54604
#include<iostream>
#include<string>
#include<algorithm>
#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main()
{
    int N;
    cin >> N;
    int dmax = N / 7;
    bool can = false;
    REP(i, dmax + 1){
        REP(j, N + 1){
            int price = 7 * i + 4 * j;
            if (price == N){
                can = true;
            }
            if (price > N){
                break;
            }
        }
    }    
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

typedef long long ll;
vector<vector<int> >  g,gv;
vector<int>t;
vector<bool>flag;
vector<int>cmp;
int cnt = 0;
int p = 0;
void dfs(int i){
    if(flag[i])return;
    flag[i] = true;
    for(auto x:g[i]){
        dfs(x);
    }
    t[i] = cnt;
    cnt++;
}
void redfs(int i){
    if(flag[i])return;
    flag[i] = true;
    for(auto x:gv[i]){
        redfs(x);
    }
    cmp[i] = p;
}


int main(){
    int n,m;
    cin >> n >> m;
    g.resize(n);
    gv.resize(n);
    t.resize(n);
    flag.resize(n);
    cmp.resize(n);
    for(int i=0;i<m;i++){
        int s,t;
        cin >> s >> t;
        g[s].push_back(t);
        gv[t].push_back(s);
    }
    for(int i=0;i<n;i++){
        dfs(i);
    }
    vector<pair<int,int> >v;
    for(int i=0;i<n;i++){
        v.push_back(make_pair(t[i],i));
        flag[i] = 0;
    }
    sort(v.rbegin(),v.rend());
    for(int i=0;i<n;i++){
        cout << v[i].second << endl;
    }
    return 0;
}


Measured memory_bytes: 4368
#include <iostream>
#include <utility>
using namespace std;

__int128 mod_pow(__int128 x, __int128 k, __int128 mod){
  __int128 ret = 1;
  while(k){
    if(k&1) ret *= x, ret %= mod;
    x *= x, x %= mod;
    k >>= 1;
  }
  return ret;
}
 
pair<__int128, __int128> rec(__int128 x, __int128 k, __int128 mod){
  if(k == 1) return {1,0};
  pair<__int128,__int128> p = rec(x,k/2,mod);
  __int128 f = p.first, s = p.second;
  __int128 f_ = (f*(1+mod_pow(x,k/2,mod))%mod)%mod;
  if(k%2) f_ += mod_pow(x,k-1,mod), f_ %= mod;
  __int128 s_ = (s + (((s+(f*(k/2))%mod)%mod)*mod_pow(x,k/2,mod))%mod)%mod;
  if(k%2) s_ += (((k-1)%mod)*mod_pow(x,k-1,mod))%mod, s_ %= mod;
  f_ %= mod, s_ %= mod;
  return {f_,s_};
}

int main(){
  long long L_, A_, B_, M_;
  cin >> L_ >> A_ >> B_ >> M_;
  __int128 L = L_, A = A_, B = B_, M = M_;

  A += B*(L-1);
  B *= -1;

  constexpr int max_len = 18;
  
  __int128 s = 0;
  __int128 ans = 0;
  __int128 D[max_len+1];
  D[0] = 1;
  for(int k = 0; k < max_len; ++k) D[k+1] = (D[k]*10);

  __int128 prev_r = 0;
  for(int k = max_len; k >= 0; --k){
    __int128 d_ = D[k];
    if(d_ > A) continue;
    __int128 l = prev_r, r = (A-d_)/(-B) + 1;
    r = max(l,r);
    r = min(L,r);

    // cerr << k+1 << " " << l << " " << r << endl;
    // cerr << s << endl;
    
    if(l < r){
      pair<__int128,__int128> p = rec(mod_pow(10,k+1,M),r-l,M);
      __int128 t = (p.first*((A%M+(((B%M+M)%M)*(l%M))%M)%M))%M;
      t += (p.second*((B%M+M)%M))%M;
      t %= M;
      t *= mod_pow(10,s,M);
      ans += t%M;
      ans %= M;
      s += (r-l)*(k+1);
    }
    
    prev_r = r;
  }
  cout << (long long)ans << endl;
}


Measured memory_bytes: 384
#include <atcoder/all>
#include <cstdio>
#include <vector>

using namespace std;
using namespace atcoder;

int main(void) {
    int N;
    int M;

    scanf("%d %d", &N, &M);

    dsu d(N);
    
    for(int i = 0; i < M; i++) {
        int A, B;
        scanf("%d %d", &A, &B);

        d.merge((A - 1), (B - 1));
    }
    
    vector<vector<int>> res = d.groups();
    
    printf("%d\n", (int)(res.size()-1));

    return 0;
}


Measured memory_bytes: 9100
#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include <vector>
#include <queue>

using namespace std;

int main(void){
  int N,cnt=0,i;
  int syurui[5]={0};
  char x;
  scanf("%d",&N);

  for(i=0;i<N;i++){
    scanf(" %c", &x);
    
    if		(x=='P'){
      syurui[0]=1;
    }else if(x=='W'){
      syurui[1]=1;
    }else if(x=='G'){
      syurui[2]=1;
    }else if(x=='Y'){
      syurui[3]=1;
    }else{
      //printf("Input Error when i is %d\n",i);
    }
  }

  for(i=0;i<4;i++){
    //printf("now syurui[%d] is %d\n", i, syurui[i]);
  }

  
  for(i=0;i<4;i++){
    if(syurui[i]==1){
      cnt++;
      //printf("now i is %d and cnt is %d\n", i,cnt);
    }
  }

  if(cnt==3){
    printf("Three\n");
  }else if(cnt==4){
    printf("Four\n");
  }else{
    printf("%d\n",cnt);
  }

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            double x = 0.0, y = 0.0, rad = 90.0 * Math.PI / 180;
            int d = -1, a = -1;

            while (d != 0 && a != 0)
            {
                string[] input = Console.ReadLine().Split(',');
                d = int.Parse(input[0]);
                a = int.Parse(input[1]);

                x += d * Math.Cos(rad);
                y += d * Math.Sin(rad);

                rad -= a * Math.PI / 180;
            }

            Console.WriteLine("{0}\n{1}", (int)x, (int)y);
        }
    }
}

Measured memory_bytes: 9104
#include <stdio.h>

int main( void ) {
	int n, sum, elmNum[ 9 ] = { 5, 3, 3, 3, 3, 3, 4, 3, 4 };
	char ch[ 9 ][ 6 ] = { ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" }, key, tmp;

	scanf( "%d%*c", &n );
	while ( n-- ) {
		while ( scanf( "%c", &key ), key != '\n' ) {
			if ( key == '0' )
				continue;

			for ( sum = 0; scanf( "%c", &tmp ), tmp != '0'; sum++ ) ;
			putchar( ch[ key - '1' ][ sum % elmNum[ key - '1' ] ] );
		}

		putchar( '\n' );
	}

	return 0;
}

Measured memory_bytes: 568
#include <iostream>
#include <string>
using namespace std;
int main() {
    string s,t;
    cin>>s>>t;

    int lenS=s.length();
    int lenT=t.length();
    int ans=1e4;
    for (int i=0; i+lenT<=lenS; i++) {
        int change=0;
        for (int j=0; j<lenT; j++) {
            if (s[i+j]!=t[j]) {
                change++;
            }
        }
        ans = min(ans, change);
    }

    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;


signed main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int sum = 0;
    if (a + b > 2 * c) {
        int num_c = min(x, y);
        sum += min(max(x, y) * c * 2, num_c * c * 2 + (x - num_c) * a + (y - num_c) * b);
    }
    else {
        sum += a * x + b * y;
    }
    cout << sum << "\n";
}

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

using namespace std;

#define ll long long
#define pi pair<int, int>
#define pb push_back
#define fr first
#define sc second
#define endl '\n'

const int mxn = 1e6 + 5;
const ll MOD =  1e9 + 7;
int arr[mxn];
int n, m, k, q;
string s, t;

void solve() {
    int d, t, s;
    cin >> d >> t >> s;
    cout << ((t * s >= d) ? "Yes" : "No") << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    //cin >> T;
    while(T--) solve();
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

const int maxN = 100005;

class TaskB {
private:
	Debugger debugger;

public:
	void solveOne(int it){
		int cards[3];
		for(int i = 0; i < 3; i++){
			cin >> cards[i];
		}
		int k;
		cin >> k;
		int ans = 0;
		for(int i = 0; i < 3 and k > 0; i++){
			if(k - cards[i] >= 0){
				if(i == 0){
					ans += cards[i];
				}else if(i == 2){
					ans -= cards[i];
				}
			}else{
				if(i == 0){
					ans += k;
				}else if(i == 2){
					ans -= k;
				}
			}
			k -= cards[i];
		}
		cout << ans << endl;


	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskB solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 3648
O, E = [input() for _ in range(2)]

pass_word = []
for i in range(len(O)):
  if len(O) > len(E) and i == len(O) - 1:
    pass_word.append(O[i])
  else:
    pass_word.append(O[i])
    pass_word.append(E[i])

ans = "".join(pass_word)
print(ans)

Measured memory_bytes: 3060
N = int(input())
s = input()
l = 0
t = 0
for v in s:
    if v == '(':
        t += 1
    else:
        t -= 1
        if t < 0:
            t = 0
            l += 1
if t > 0:
    s += ')' * t
print('(' * l + s)

Measured memory_bytes: 3060
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, a[111], c = 0;

  std::cin >> N;

  for (int i = 0; i < N; i ++)
    std::cin >> a[i];

  for (int i = 0; i < N; i ++)
    for (int j = 1; j < N; j ++)
      if (a[j] == a[j - 1]) {
        a[j] = 0;
        
        c ++;
      }

  std::cout << c << std::endl;

  return 0;
}


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

const int MOD = 1e9+7, LIM = 1000;
int n, m, a[LIM], b[LIM], cnt;
ll ans = 1;

int main() {
    cin >> n >> m;
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    sort(a, a + n);
    sort(b, b + m);

    int ai = n - 1, bi = m - 1;
    for (int i = n * m; i > 0; i--, cnt++) {
        if (a[ai] == i && b[bi] == i) {
            ai--; bi--;
        } else if (a[ai] == i) {
            ai--;
            ans = ans * (m - bi - 1) % MOD;
        } else if (b[bi] == i) {
            bi--;
            ans = ans * (n - ai - 1) % MOD;
        } else {
            ans = ans * ((m - bi - 1) * (n - ai - 1) - cnt) % MOD;
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int ans;
  rep(i, max(a, b)) {
    cout << min(a, b);
  }
  cout << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#include <unordered_map>
#define inputarr(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define prllarr(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" ";
#define pb push_back
#define ll long long
#define mod 1000000007
#define foi ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define in(n) scanf("%lld",&n);
#define in2(x,y) scanf("%lld %lld",&(x),&(y));
#define in3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z));
#define out(n) printf("%lld\n",n);
#define out2(x,y) printf("%lld %lld\n",x,y);
#define test(t)  ll t; in(t);while(t--)
#define set(arr,n,s) for(ll i=0;i<n;i++){arr[i]=s;}


ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1){res=(res*x)%p;} y=y>>1;x=(x*x)%p;}return res;}
ll modInverse(ll a,ll p){return power(a,p-2,p);}//used with feemat little

ll gcd(ll x,ll y){if(x==0 || y==0){return max(y,x);}return gcd(y%x,x);}
ll gcdExtended(ll a,ll b,ll &x,ll &y){if(a==0){x=0;y=1;return b;}ll x1,y1;ll gcd = gcdExtended(b%a,a,x1,y1);x=y1-(b/a)*x1;y=x1;return gcd;}//o(log(b))
;
void prac(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
   #endif 
}
ll maxi=200003;
ll bit[200005];
pair<ll,ll> h[200005];
ll get(ll i){
	ll ans=0;
	for(;i;i-=(i&(-i)))ans=max(ans,bit[i]);
	return  ans;
}
void update(ll i,ll val){
	for(;i<=maxi;i+=(i&(-i)))bit[i]=max(bit[i],val);
}
ll dp[200005];


int main() 
{
  	// prac();
  	ll n;
  	in(n)
  	for(ll i=1;i<=n;i++){
  		in(h[i].first)
  	}
  	for(ll i=1;i<=n;i++){
  		in(h[i].second)
  	}
  	for(ll i=0;i<=maxi;i++)bit[i]=0;
  	
  	ll ans=0;
  	for(ll i=1;i<=n;i++){
  		ll hei=h[i].first;
  		hei--;
  		dp[i]=get(hei)+h[i].second;
  		update(h[i].first,dp[i]);
  		ans=max(dp[i],ans);

  	}
  	out(ans);



}
/*error-----
convert every int to long long eg-1LL
create array with proper analysis of problem constrain
check mod also
*/






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


int main() {
  int N ;
  cin >> N ; 
  vector<int> A(N) ; 
  map<int, int> P ;
  
  
  for(int i = 0 ; i < N ; i++){
    cin >> A.at(i) ; 
    P[A.at(i)] = i   ;
  }

  
  for(int i = 1 ; i <= N ; i++ ){
    cout << P.at(i)+1 << " " ; 
  }

}

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a==b) cout << "Draw" << endl;
  else if((a > b  && b!=1)|| a == 1) cout << "Alice" << endl;
  else cout << "Bob" << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    H, W, N = list(map(int, input().split()))
    sr, sc = list(map(int, input().split()))
    sr, sc = sr - 1, sc - 1
    S = input()
    T = input()
    K = [sc, W - sc - 1, sr, H - sr - 1]
    M = [W - 1, W - 1, H - 1, H - 1]
    Is = {'L': 0, 'R': 1, 'U': 2, 'D': 3}
    It = {'L': 1, 'R': 0, 'U': 3, 'D': 2}
    for s, t in zip(S, T):
        si, ti = Is[s], It[t]
        sti = It[s]
        K[si] -= 1
        if K[si] < 0:
            return False
        if K[sti] == M[sti]:
            K[sti] -= 1
            if K[sti] < 0:
                return False
        K[ti] += 1
        if K[ti] > M[ti]:
            K[ti] = M[ti]
    return True

print('YES' if main() else 'NO')


Measured memory_bytes: 41968
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    
    string ans = "Yes";
    rep(i, s.size())
    {
        if ((i + 1) % 2) //odd
        {
            if (s[i] == 'L')
            {
                ans = "No";
            }
        }
        else
        {
            if (s[i] == 'R')
            {
                ans = "No";
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
#field = [list(input()) for _ in range(H)]
field =[["."] * (W+1)]
for _ in range(H):
    tmp = ["."]
    tmp.extend(list(input()))
    field.append(tmp)

dp = [[10**9] * (W+1) for _ in range(H+1)]
dp[1][0] = 0
dp[0][1] = 0
for h in range(1,H+1):
    for w in range(1,W+1):
        if field[h][w] == ".":
            dp[h][w] = min(dp[h-1][w], dp[h][w-1])
        else:
            u = dp[h-1][w] if field[h-1][w] == "#" else dp[h-1][w] + 1
            l = dp[h][w-1] if field[h][w-1] == "#" else dp[h][w-1] + 1
            dp[h][w] = min(u,l)

print(dp[-1][-1])



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

using namespace std;

const int N = 1e5+10;
typedef long long ll;

vector<int> G[N];
int top[N],son[N],p[N],cnt[N];
int idx[N];
int tot = 0;

ll bit[N];
ll bit1[N];
int sz;

void add(int i,int x)
{
    ll tmp = i;
    while(i<=sz)
    {
        bit[i] += x;
        bit1[i] += (tmp - 1)*x;
        i += i&-i;
    }
}

ll getSum(int i)
{
    ll sum = 0,tmp = i;
    while(i>0)
    {
        sum += bit[i]*tmp;
        sum -= bit1[i];
        i -= i&-i;
    }
    return sum;
}

void dfs(int v)
{
    cnt[v] = 1;
    son[v] = -1;
    for(int i=0;i<G[v].size();i++)
    {
        int u = G[v][i];
        dfs(u);
        cnt[v] += cnt[u];
        p[u] = v;
        if(son[v]==-1 || cnt[son[v]] < cnt[u])  son[v] = u;
    }
}

void dfs1(int v,int t)
{
    if(v==-1) return;
    top[v] = t;
    idx[v] = ++tot;
    dfs1(son[v],t);
    for(int i=0;i<G[v].size();i++)
    {
        int u = G[v][i];
        if(u == son[v]) continue;
        dfs1(u,u);
    }
}

void addWeight(int v,int w)
{
    do{
        int t = top[v];
        int l = idx[t], r = idx[v];
        if(!t)
        {
            int s = idx[son[0]];
            add(s,w);
            add(r+1,-w);
        }else{
            add(l,w);
            add(r+1,-w);
        }
        v = p[t];
    }while(v != 0);
}

ll getWeight(int v)
{
    ll ans = 0;
    do{
        int t = top[v];
        int l = idx[t], r = idx[v];
        ans += getSum(r) - getSum(l-1);
        v = p[t];
    }while(v != 0);
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    sz = n;

    for(int i=0;i<n;i++)
    {
        int k;
        cin>>k;
        while(k--)
        {
            int child;
            cin>>child;
            G[i].push_back(child);
        }

    }

    dfs(0);
    dfs1(0,0);
    int q;
    cin>>q;
    while(q--)
    {
        int op;
        cin>>op;
        if(op){
            int v;
            cin>>v;
            cout<<getWeight(v)<<endl;
        }else
        {
            int v,w;
            cin>>v>>w;
            addWeight(v,w);
        }
    }
    return 0;
}



Measured memory_bytes: 16828
#include<bits/stdc++.h>
#define ll long long
#define lu long unsigned
#define ull unsigned long long

using namespace std;
bool sortbysec(const pair<string,int> &a,
              const pair<string,int> &b)
{
    return (a.second < b.second);
}
bool sortpair(const pair<int,int> &a,
              const pair<int,int> &b)
{
    if(a.first==b.first)
        return (a.second<b.second);
    else
        return(a.first>b.first);
}
bool s(const string &a, const string &b){
    bool ans;
    return (a.size()<b.size());
}
bool isPrime(int val){
    for(int i=2;i*i<=val;i++){
        if(val%i==0)
            return false;
    }
    return true;
}
ll int conc(ll int a,ll int b){
   stringstream ss;
   ss<<a<<b;
   ll int ans;
   ss>>ans;
   ss.clear();
   return ans;
}
ll int binexp(int a,int b){
    ll int res=1;
    while(b!=0){
        if(b&1){
            res*=a;
            b--;
        }else{
            a*=a;
            b/=2;
        }
    }
    return res;
}
int gcd(int a,int b){
    if(a%b==0){
        return b;
    }else{
        return gcd(a%b,b);
    }
}

void solve(){
    string s;
    cin>>s;
    int a[26]={0};
    for(int i=0;i<s.size();i++){
        if(a[s[i]-'a']!=0){
            cout<<"no";
            return;
        }else
            a[s[i]-'a']++;
    }
    cout<<"yes";
}


int main(){
    /*int t;
    cin>>t;
    while(t--)*/
        solve();


    return 0;
}



































































//1-(3+5-2+(3+19-(3-1-4+(9-4-(4-(1+(3)-2)-5)+8-(3-5)-1)-4)-5)-4+3-9)-4-(3+2-5)-10




















Measured memory_bytes: 3576
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < (i##_MACRO); i++)
#define RANGE(i, a, b) for(int i = (a); i < (b); i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), ((a) + (n))
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define MODNUM (static_cast<int>(1e9 + 7))
#define MOD(x) ((x) % MODNUM)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const int INF = 2e9;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

int main() {
	int x, y;
	scanf("%d %d", &x, &y);
	int result = 0;
	if(x == 1 && y == 1) {
		result += 400000;
	}
	if(x == 1) {
		result += 300000;
	}
	if(y == 1) {
		result += 300000;
	}
	if(x == 2) {
		result += 200000;
	}
	if(y == 2) {
		result += 200000;
	}
	if(x == 3) {
		result += 100000;
	}
	if(y == 3) {
		result += 100000;
	}
	printf("%d\n", result);
	return 0;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let s = iterator.next().unwrap();

    let mut ans = String::new();
    for c in s.chars() {
        if c == 'B' {
            ans.pop();
        } else {
            ans.push(c);
        }
    }

    return ans;
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

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

	int n, k;
	cin >> n >> k;
	vector<ll> as(n);
	for (ll& a : as) cin >> a;

	for (int i = k; i < n; ++i) {
		if (as[i-k] < as[i]) cout << "Yes\n";
		else cout << "No\n";
	}
}


Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int MM = 500;
const int MN = 100100;
const ll M = 998244353;
bitset<MM> bs[MM][2];
int pt[MM][2];
int get(int a, int b) {
	int st = max(pt[a][0],pt[b][1]);
	while(bs[a][0][st] || bs[b][1][st]) {
		st++;
	}
	return st;
}
void up(int a, int b, int val) {
	bs[a][0].set(val);
	bs[b][1].set(val);
	while(bs[a][0][pt[a][0]]) {pt[a][0]++;}
	while(bs[b][1][pt[b][1]]) {pt[b][1]++;}
}
ll mul(ll a, ll b) {
	return (a*b)%M;
}
ll bp(ll b, ll p) {
	ll ac = 1;
	while(p) {
		if(p&1) {ac = mul(ac,b);}
		b = mul(b,b);
		p >>= 1;
	}
	return ac;
}
ll wor[MM][3];
vvi g[3];
int ro[3];
ll po[MN];
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	memset(pt,0,sizeof(pt));
	memset(wor,0,sizeof(wor));
	int n;
	cin >> n;
	po[0] = 1;
	ll B = bp(10,18);
	for(int i=1;i<MN;i++) {
		po[i] = mul(po[i-1],B);
	}
	for(int i=0;i<3;i++) {
		g[i].assign(n,vi());
		int m;
		cin >> m;
		for(int j=0;j<m;j++) {
			int a,b;
			cin >> a >> b;a--;b--;
			if(a < b) {swap(a,b);}
			g[i][a].push_back(b);
		}
		int ctr = 0;
		vi cu,nu;
		for(int j=0;j<n;j++) {
			cu.push_back(j);
		}
		bitset<MN> ko;
		while(!cu.empty()) {
			ko.reset();
			nu.clear();
			for(int j=cu.size()-1;j>=0;j--) {
				int u = cu[j];
				if(ko[u]) {
					nu.push_back(u);continue;}
				wor[ctr][i] += po[u+1];
				if(wor[ctr][i] >= M) {wor[ctr][i] -= M;}
				for(int k=0;k<g[i][u].size();k++) {
					ko.set(g[i][u][k]);
				}
			}
			ctr++;
			cu = nu;
			reverse(cu.begin(),cu.end());
		}
		ro[i] = ctr;
	}
	ll res = 0;
	for(int i=0;i<ro[0];i++) {
		for(int j=0;j<ro[1];j++) {
			int re = get(i,j);
			if(re < ro[2]) {
				res += mul(wor[i][0],mul(wor[j][1],wor[re][2]));
				up(i,j,re);
			}
		}
	}
	res %= M;
	cout << res << '\n';
}


Measured memory_bytes: 14384
#include<iostream>
#include<cstdlib>
#include<vector>
#include<algorithm>

using namespace std;

typedef long long llong;

const llong INF = 100001000010000100;

llong x[100010],y[100010];

int main()
{
    
    int w,h,n;
    vector<llong> vx,vy;
    
    cin >> w >> h >> n;
    for(int i=0;i<n;i++){
        cin >> x[i] >> y[i];
        vx.push_back(x[i]);
        vy.push_back(y[i]);
    }
    
    sort(vx.begin(),vx.end());
    sort(vy.begin(),vy.end());
    
    llong sum[10][10];
    
    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            
            int dx = (n-1)/2 + i;
            int dy = (n-1)/2 + j;
            llong ma = 0;
            
            sum[i][j] = 0;
            
            for(int k=0;k<n;k++){
                sum[i][j] += 2*(llabs(vx[dx]-x[k])+llabs(vy[dy]-y[k]));
                ma = max(ma,llabs(vx[dx]-x[k])+llabs(vy[dy]-y[k]));
            }
            sum[i][j] -= ma;
        }
    }
    
    int ax=0,ay=0;
    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            if(sum[ax][ay] > sum[i][j]){
                ax = i;
                ay = j;
            }
        }
    }
    
    cout << sum[ax][ay] << endl;
    cout << vx[(n-1)/2+ax] << " " << vy[(n-1)/2+ay] << endl;
    
    return(0);
}


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

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

int main(){
  int n;
  cin>>n;
  ll ans;
  cin>>ans;
  for(int i=1;i<n;i++){
    ll p;
    cin>>p;
    ans=gcd(p,ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc  = new Scanner(System.in);
		int[] x = new int[3];
		x[0] = sc.nextInt();
		x[1] = sc.nextInt();
		x[2] = sc.nextInt();
		java.util.Arrays.sort(x);
		System.out.println(x[0]+" "+x[1]+" "+x[2]);
	}
}



Measured memory_bytes: 26044
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	string s;
	cin >> s;

	int ans = 0;
	vector<int> x;
	int X = 0;
	for (int i = 0; i < N; ++i) {
		if (i == N - 1) {
			x.push_back(X);
			continue;
		}
		if (s[i] == s[i + 1]) { ++ans; }
		else {
			x.push_back(X);
			X = 1 - X;
		}
	}

	int k = x.size();
	if (k % 2 == 1) {
		ans += 2 * min(k / 2, K);
	} else {
		k = k / 2 - 1;
		ans += 2 * min(k, K);
		K -= k;
		if (K > 0) { ans += 1; }
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1020
import           Control.Monad
import           Control.Applicative

main :: IO ()
main = do
  [h, w] <- map read . words <$> getLine
  s <- replicateM h getLine

  putStrLn $ replicate (w + 2) '#'
  forM_ s $ \c -> putStrLn $ "#" ++ c ++ "#"
  putStrLn $ replicate (w + 2) '#'

Measured memory_bytes: 1404
#include <bits/stdc++.h>
#define MOD 100000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

ll choose2(ll n){
    return n * (n - 1) / 2;
}

int main(){
    ll N;
    cin >> N;
    VL A(N);
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, N) A[i]--;

    VL cnt(N + 1);
    rep(i, 0, N) cnt[A[i]]++;

    ll total = 0;
    rep(i, 0, N + 1) total += choose2(cnt[i]);

    rep(k, 0, N){
        ll ans = total;
        ans -= choose2(cnt[A[k]]);
        ans += choose2(cnt[A[k]]- 1);
        cout << ans << endl;
    }

    return 0;
}


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

int main(void)
{
	int N;
	cin >> N;
	for (int i = N; i; i--)
	{
		for (int j = 1; j < i; j++) cout << __builtin_ctz(j) + 1 << " ";
		cout << endl;
	}
	return 0;
}


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

int main() {
  int n, cnt1 = 0, cnt2 = 0, k;
  string s;
  cin >> n >> k >> s;
  for (int i = 1; i < s.length(); i++) {
    if (s[i] == s[i - 1]) {
      cnt1++;
    } else {
      cnt2++;
    }
  }
  cout << min(n - 1, cnt1 + 2 * k) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
  
int ctoi(char c) {
  return c - '0';
}

int main() {
  vector<int> c(4);
  for (int i = 0; i < 4; i++) { 
    char h;
    cin >> h;
    c[i] = ctoi(h);
  }  

  for (int i = 0; i < 1 << 3; i++) {
    bitset<3> b(i);
    
    int total = c[0]; 
    string s = to_string(c[0]);
    for (int j = 0; j < 3; j++) {
      if (b.test(j)) {
        total += c[j + 1];
        s += '+' + to_string(c[j + 1]);
      } else {
        total -= c[j + 1];
        s += '-' + to_string(c[j + 1]);
      }
    }
    
    if (total == 7) {
      cout << s << "=7" << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
const ll inf = 2e18;
// ダイクストラO(elogv)
struct edge{
  ll to, cost;
  edge(ll t, ll c) {
    to = t, cost = c;
  }
};
typedef pair<ll, ll> P;
ll N, M, S, T;
vector<edge> G1[200005];
ll d1[200005];
void dijkstra1(int s){
  priority_queue<P, vector<P>, greater<P> >que;
  FOR(i,0,200005) d1[i] = inf;
  d1[s] = 0;
  que.push(P(0, s));
  while(!que.empty()){
    P p = que.top(); que.pop();
    ll v = p.second;
    if(d1[v] < p.first) continue;
    for(auto &e : G1[v]){
      if(d1[e.to] > d1[v] + e.cost){
        d1[e.to] = d1[v] + e.cost;
        que.push(P(d1[e.to], e.to));
      }
    }
  }
}
ll d2[200005];
vector<edge> G2[200005];
void dijkstra2(int s){
  priority_queue<P, vector<P>, greater<P> >que;
  FOR(i,0,200005) d2[i] = inf;
  d2[s] = 0;
  que.push(P(0, s));
  while(!que.empty()){
    P p = que.top(); que.pop();
    ll v = p.second;
    if(d2[v] < p.first) continue;
    for(auto &e : G2[v]){
      if(d2[e.to] > d2[v] + e.cost){
        d2[e.to] = d2[v] + e.cost;
        que.push(P(d2[e.to], e.to));
      }
    }
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M >> S >> T;
  FOR(i,0,M){
    ll u, v, a, b;
    cin >> u >> v >> a >> b;
    // 円だけ
    G1[u].push_back(edge(v, a));
    G1[v].push_back(edge(u, a));

    // どっちもOK
    //G2[u].push_back(edge(v, a));
    //G2[v].push_back(edge(u, a));
    G2[u].push_back(edge(u+N, 0));
    G2[u+N].push_back(edge(u, 0));
    G2[v].push_back(edge(v+N, 0));
    G2[v+N].push_back(edge(v, 0));
    G2[u+N].push_back(edge(v+N, b));
    G2[v+N].push_back(edge(u+N, b));
  }
  dijkstra1(S);
  dijkstra2(T+N);
  vector<ll> ans(N);
  ll MIND = 2e18;
  FOR(i,0,N){
    MIND = min(MIND, d1[N-i] + d2[N-i+N]);
    ans[N-i-1] = 1000000000000000 - MIND;
  }
  for(ll a : ans) {
    cout << a << endl;
  }
}

Measured memory_bytes: 34560
#include<stdio.h>
#define N 10000

int main(void){
  int i,c,sf,num,j,k,l;
  char n[11];
  int seq[11],ans[N];
  char hoge;

  for(i=0;;i++){
    c=scanf(" %s",n);
    if(c==EOF){
      break;
    }

    for(j=0;j<10;j++){
      seq[j]=n[j]-'0';
    }

    for(j=0;j<9;j++){
      for(k=0;k<9-j;k++){
        seq[k]=(seq[k]+seq[k+1])%10;
      }
    }
    ans[i]=seq[0];
  }
  num=i;
  for(i=0;i<num;i++){
    printf("%d\n",ans[i]);
  }
  return 0;
}

Measured memory_bytes: 0
n = int(input())
s = [input() for i in range(n)]
ans_list = [100000] * 26
ans = ""
ord_a = ord("a")
for i in s:
  mini_ans = [0] * 26
  for j in i:
    mini_ans[ord(j) - ord_a] += 1
  o = 0
  for ans1,now in zip(ans_list,mini_ans):
    ans_list[o] = min(ans1,now)
    o += 1
for i,j in enumerate(ans_list):
  ans += chr(ord_a + i) * j
print(ans)
  

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

#define max 4001

int main(){

	int a,b,c,temp;
		cin>>a >>b >>c;
		
		a=a+b+c;
		b=a-(b+c);
		c=a-(b+c);
		a=a-(b+c);

	 	cout<<a <<" "<<b <<" "<<c;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s, a;
  a = "Good";
  cin >> s;
  for (int i = 0; i<(s.size()-1); i++){
    if (s.at(i)==s.at(i+1)){
      a = "Bad";
      break;
    }
  }
  cout << a;
}

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

const int max_N = 1e3 + 21;

int n;

bool vis[4];

char s[max_N];

int main(){
	scanf("%s",s);
	n=strlen(s);
	for(int i=0;i<n;++i){
		switch(s[i]){
			case('N'): vis[0]=1; break;	
			case('S'): vis[1]=1; break;
			case('E'): vis[2]=1; break;
			case('W'): vis[3]=1; break;
		}
	}
	if((vis[0]^vis[1])||(vis[2]^vis[3]))puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

struct pos
{
	int x, y, h;
};

int main()
{
	int N;
	cin >> N;

	vector<pos> points(N);

	pos base_p;
	for (int i = 0; i < N; i++)
	{
		cin >> points[i].x >> points[i].y >> points[i].h;

		if (points[i].h > 0)
		{
			base_p = points[i];
		}
	}

	pos ans;
	for (int x = 0; x <= 100; x++)
	{
		for (int y = 0; y <= 100; y++)
		{
			pos c = { x, y, base_p.h + abs(x - base_p.x) + abs(y - base_p.y)};

			bool flag = true;
			for (int i = 0; i < N; i++)
			{
				if (max(c.h - abs(points[i].x - c.x) - abs(points[i].y - c.y), 0)
					!= points[i].h)
				{
					flag = false;
					break;
				}
			}

			if (flag)
			{
				ans = c;
				break;
			}
		}
	}

	cout << ans.x << " " << ans.y << " " << ans.h << endl;

	return 0;
}

Measured memory_bytes: 256
T[20][20],X,Y,p,q,i;
#define t T[y][x]
void R(x,y){(0<=x&&x<X&&0<=y&&y<Y&&t)?t=0,i++,R(x-1,y),R(x+1,y),R(x,y-1),R(x,y+1):0;}
main(x,y){for(;scanf("%d%d",&X,&Y),X;i=0,R(p,q),printf("%d\n",i))
for(i=0;i<X*Y;i++)switch(x=i%X,y=i/X,getchar()){
	case 10:i--;break;
	case'@':p=x;q=y;
	case'.':t=1;break;
	case'#':t=0;
}exit(0);}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<string>
using namespace std;
 
int main(){
    int N,Q; cin>>N>>Q;
    string str;cin>>str;

    vector<int>s(N+1,0);
    for(int i=0;i<N;i++){
        if(i+1<N && str[i]=='A' &&str[i+1]=='C')s[i+1]=s[i]+1;
        else s[i+1]=s[i];
        }
    for (int q=0;q<Q;q++){
        int l,r;cin>>l>>r;
        l--,r--;
        cout<<s[r]-s[l]<<endl;
    }
    }



Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a,b,c,d;
    string s,s1;
    cin >> a >> b >> c >> d;
    if (a+b > c+d) cout << "Left" << endl;
    else if (a+b < c+d) cout << "Right" << endl;
    else cout << "Balanced" << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
    ll X,Y,A,B,C;
    cin >>X>>Y>>A>>B>>C;
    vector<ll> vecA(A);
    vector<ll> vecB(B);
    vector<ll> vecC(C);
    vector<ll> vecD(A+B+C);
    
    ll max=0;
    for (ll i = 0; i < A; i++) {
        cin >> vecA.at(i);
    }
    for (ll i = 0; i < B; i++) {
        cin >> vecB.at(i);
    }
    for (ll i = 0; i < C; i++) {
        cin >> vecC.at(i);
    }
    sort(vecA.begin(),vecA.end());
    sort(vecB.begin(),vecB.end());
    
    for(ll i=0;i<X;i++){
        vecD.at(i)=vecA.at(vecA.size()-i-1);
    }
    for(ll i=0;i<Y;i++){
        vecD.at(i+X)=vecB.at(vecB.size()-i-1);
    }
    for(ll i=0;i<C;i++){
        vecD.at(i+X+Y)=vecC.at(i);
    }
    sort(vecD.begin(),vecD.end());
    for(ll i=0;i<X+Y;i++){
    // cout << vecD.at(vecD.size()-i-1) <<endl;
        max+=vecD.at(vecD.size()-i-1);
    }
    cout << max;
}

Measured memory_bytes: 4992
package main

import "fmt"

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func main() {
	var A, B, C int
	fmt.Scan(&A, &B, &C)
	ans := 0
	for M := max(A, max(B, C)); ; M++ {
		ans = 3*M - (A + B + C)
		if ans%2 == 0 {
			ans /= 2
			break
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	int* a = new int[n];
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	bool flag = true;
	int count = 0;
	while (flag) {
		flag = false;
		for (int i = 0;i < n- 1;i++) {
			if (a[i] > a[i + 1]) {
				swap(a[i], a[i + 1]);
				count++;
				flag = true;
			}
		}
	}
	for (int i = 0;i < n - 1;i++) {
		cout << a[i] << " ";
	}
	cout << a[n - 1] << endl;
	cout << count << endl;
}


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

using namespace std;

int main() {
    int x;
    scanf("%d", &x);
    int y;
    scanf("%d", &y);

    double divided = y / (double) x;

    if (y % 2 != 0){
        printf("No\n");
    }
    else if (divided >=2 && divided <=4){
        printf("Yes\n");
    } else {
        printf("No\n");
    }
}


Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n), v(n+1);
  rep(i,n){
    cin >> a[i];
    v[a[i]]++;
  }
  auto c = [](ll n){ return n*(n-1)/2; };
  ll ans = 0;
  rep(i,n) ans += c(v[i+1]);

  rep(i,n){
    ll x = v[a[i]];
    ll d = 0;
    if(x>1) d = c(x)-c(x-1);
    cout << ans-d << endl;
  }
}

Measured memory_bytes: 4096
n, k = map(int, input().split())

if k % 2 == 1:
    d = n // k
    print(d ** 3)
else:
    l = k // 2
    d1 = (n + l) // k
    d2 = n // k
    print(d1 ** 3 + d2 ** 3)


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

int main()
{
    int i, n = 3, ck = 0;
    string s;

    cin>>s;

    for(i=1;i<n;i++)
    {
        if(s[0]!=s[i])
        {
            ck = 1;
            break;
        }
    }

    if(ck==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    ll a[n + 2], sum = 0, cur = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum += abs(cur - a[i]);
        cur = a[i];
        if (i == n) sum += abs(cur - 0);
    }
    a[0] = a[n + 1] = 0;
    for (int i = 1; i <= n; i++) {
        cout << sum - (abs(a[i - 1] - a[i]) + abs(a[i] - a[i + 1])) + abs(a[i - 1] - a[i + 1]) << '\n';
    }
}

Measured memory_bytes: 2048