akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359

int main(){
   int N,X,T;
   cin >> N>>X>>T;
   if(N%X!=0){
    cout << (N/X+1)*T<<endl;
   }
   else{
       cout << (N/X)*T<<endl;
   }
}

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

int main(){
	char c; cin>>c;
	if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o') cout<<"vowel"<<endl;
	else cout<<"consonant"<<endl;
}

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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int a,b,c;cin>>a>>b>>c;

  cout<<min(a+b, min(b+c, c+a))<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
int32_t main()
{
	int a,b,k;
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++)
	{
		if(i%k ==0)
		{cout<<"OK";return 0;}
	}
	cout<<"NG";
	
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
#include <set>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}
signed main(void) {
	int h, w;
	cin >> h >> w;
	if (h == 1 || w == 1)print(1);
	else if (h % 2 == 1 && w % 2 == 1)print((h*w + 1) / 2);
	else print(h * w / 2);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

long long ext_gcd(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1, y = 0;
        return a;
    }
    long long x2, y2;
    long long d = ext_gcd(b, a%b, x2, y2);
    x = y2;
    y = x2 - (a / b)*y2;
    return d;
}

int main()
{
    ll n;
    cin >> n;
    if(n == 1){
        cout << 1 << endl;
        return 0;
    }
    ll m = n;
    vector<ll> v;
    for(ll i = 2; i * i <= n; i++){
        if(m % i == 0){
            ll s = 1;
            while(m % i == 0){
                m /= i;
                s *= i;
            }
            v.push_back(s);
        }
    }
    if(m > 1) v.push_back(m);
    int k = v.size();
    ll ans = n - 1;
    if(v[0] % 2 == 0){
        ans = n * 2 - 1;
    }
    for(int i = 0; i < (1 << k); i++){
        ll l = 1, r = 1;
        for(int j = 0; j < k; j++){
            if((i >> j) & 1) l *= v[j];
            else r *= v[j];
        }
        if(l > r){
            if(l % 2 == 0) l *= 2;
            if(r % 2 == 0) r *= 2;
            ll x = 1, y = 0;
            ext_gcd(l, r, x, y);
            x = abs(x);
            y = abs(y);
            if(x == 0 || y == 0){
                x += r;
                y += l;
            }
            ans = min(ans, min(l * x, r * y));
        }
    }
    cout << ans << endl;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    ll score = 0;
    vector<ll> sum;
    rep (i, n) {
        int a, b;
        cin >> a >> b;
        sum.push_back(a + b);
        score -= b;
    }
    sort(sum.begin(), sum.end(), greater<ll>());
    rep (i, n) {
        if (!(i % 2)) score += sum[i];
    }
    cout << score << endl;
    
    return 0;
}



Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <map>
#include <bitset>
#include <stack>
#include <cassert>
using namespace std;
typedef long long LL;
const int M = 1e6 + 5;
const int N = 100000 + 5;
const LL mod = 19260817;
const int MAX = 5e5 + 5;
const int MAXV = 100000 + 5;
const LL INF = (1LL << 62);
const int inf = 0x3f3f3f3f;
const double pi = acos(-1.);
int a[N];
int main() {
#ifdef local
    freopen("input", "r", stdin);
//    freopen("w", "w", stdout);
//    freopen("input", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)cin >> a[i];
    sort(a, a + n);
    if(a[n - 1] - a[0] > 1) {
        cout << "No" << endl;
    } else {
        if(a[0] == a[n - 1]) {
            if(a[0] * 2 <= n || a[0] == n - 1)
                cout << "Yes" << endl;
            else cout << "No" << endl;
        } else {
            int sm = 0;
            for(int i = 0; i < n; i++) {
                if(a[i] == a[0])sm++;
            }
            if(((a[n - 1] - sm) * 2 <= (n - sm) && a[n - 1] > sm)) {
                cout << "Yes" << endl;
            } else cout << "No" << endl;

        }
    }
}



Measured memory_bytes: 640
def main():
    n = int(input())
    count = {"A":0, "Un":0}
    for _ in range(n):
        s = input()
        count[s] += 1
        if count["A"] < count["Un"]:
            return False
    if count["A"] == count["Un"]:
        return True
    else:
        return False

if __name__ == '__main__':
    if main():
        print("YES")
    else:
        print("NO")



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

int main(){
	int n;
	cin >> n;
	int s[4] = {0, 0, 0, 0};
	string st;
	for(int i = 0; i < n; ++i){
		cin >> st;
		if(st == "AC") s[0]++;
		else if(st == "WA") s[1]++;
		else if(st == "TLE") s[2]++;
		else if(st == "RE") s[3]++;
	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n" , s[0], s[1], s[2], s[3]);
	return 0;
}

Measured memory_bytes: 3720
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < A[i].size(); j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	int A, B;
	int V, W;
	cin >> A >> V >> B >> W >> T;
	B = abs(A - B);
	A = 0;
	int C = A + V * T;
	int D = B + W * T;
	if (C >= D) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdlib>
#include <algorithm>

using namespace std;
const static int N_MAX = 1000000;
const static int P_MAX = 101;

int era[ N_MAX ] = { 0 };
int primeList[ N_MAX ];
int invPrimeList[ N_MAX ];
int ctr = 0;

int main() {
  era[ 0 ] = 1;
  era[ 1 ] = 1;
  for( int i = 2; i < N_MAX; i++ ) {
    if( era[ i ] ) { continue; }
    for( int j = i * 2; j < N_MAX; j += i ) {
      era[ j ] = 1;
    }
  }
  
  for( int i = 0; i < N_MAX; i++ ) {
    if( !era[ i ] ) {
      invPrimeList[ i ] = ctr;
      primeList[ ctr++ ] = i;
    }
  }

  while( 1 ) {
    int n, p;
    int table[ P_MAX * P_MAX ];
    cin >> n >> p;
    if( n == -1 && p == -1 ) { return EXIT_SUCCESS; }

    int i;
    for( i = n + 1; i < N_MAX; i++ ) {
      if( !era[ i ] ) { break; }
    }

    int pid = invPrimeList[ i ];
    int k = 0;
    for( int i = 0; i < P_MAX; i++ ) {
      for( int j = i; j < P_MAX; j++ ) {
        table[ k++ ] = primeList[ pid + i ] + primeList[ pid + j ];
      }
    }

    sort( table, table + k );
    
    cout << table[ p - 1 ] << endl;
  }
}

Measured memory_bytes: 12916
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String a = sc.next();
		char b = a.charAt(0);
		char c = a.charAt(1);

		String ans = "No";

		if(b=='9'|c=='9'){
			ans = "Yes";
		}

		// 出力
		System.out.println(ans);
	}
}


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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
 int n;cin>>n;vi a(n);rep(i,n)cin>>a[i];
  deque<int> d;
  rep(i,n){
   if(i%2==0)d.push_front(a[i]);
    else if(i%2==1)d.push_back(a[i]);
  }
  if(n%2==0)reverse(all(d))
  rep(i,n)cout<<d[i]<<" ";
  cout<<endl;
}





Measured memory_bytes: 3840
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;
use std::io::Write;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn valid(a: i32, b: i32) -> bool {
    !((a == 0) ^ (b == 0))
}

fn main() {
    let s: String = read();
    let s: Vec<u8> = s.into_bytes();

    let mut cnt = vec![0; 256];
    for i in 0..s.len() {
        cnt[s[i] as usize] += 1;
    }

    if valid(cnt['S' as usize], cnt['N' as usize]) && valid(cnt['E' as usize], cnt['W' as usize]) {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
ass, bss, css = input().split(" ")

a = int(ass)
b = int(bss)
c = int(css)

if a < b:
    if b < c:
        print(a,b,c)
    else:
        if a < c:
            print(a,c,b)
        else:
            print(c,a,b)
else:
    if a < c:
        print(b,a,c)
    else:
        if b < c:
            print(b,c,a)
        else:
            print(c,b,a)

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

int main(){
    string s;
    cin >> s;
    
    if(s=="ABC"){
        cout << "ARC" << endl;
    }else{
        cout<< "ABC" << endl;
    }
}

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

int a[100][100];
int dp[100][100];
int n;

int main()
{
    string s;
    while(getline(cin, s)){
        int k = 0;
        stringstream ss(s);
        while(ss >> a[n][k]){
            ss.ignore();
            k++;
        }
        n++;
    }
    
    dp[0][0] = a[0][0];
    
    for(int i = 1; i < n / 2 + 1; ++i){
        for(int j = 0; j <= i; ++j){
            if(j == 0) dp[i][j] = a[i][j] + dp[i-1][j];
            else if(j == i) dp[i][j] = a[i][j] + dp[i-1][j-1];
            else dp[i][j] = a[i][j] + max(dp[i-1][j], dp[i-1][j-1]);
        }
    }
    
    for(int i = n / 2 + 1; i < n; ++i){
        for(int j = 0; j < n - i; ++j){
            dp[i][j] = a[i][j] + max(dp[i-1][j], dp[i-1][j+1]);
        }
    }
    
    cout << dp[n-1][0] << endl;
}

Measured memory_bytes: 1304
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp  make_pair
#define pb  push_back
#define endl "\n"
#define rep(i,a,n) for(int i=a;i<n;i++)
const int mod = 1e9 + 7;
void solve() {
	int n;
	cin >> n;
	if (n == 0) {
		cout << 1;
	}
	else {
		cout << 0;
	}

}
int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	int t;
	t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3636
x1, y1, x2, y2 = gets.split.map(&:to_i)
w = x2 - x1
h = y2 - y1
x3 = x2 - h
y3 = y2 + w
x4 = x3 - w
y4 = y3 - h
puts "#{x3} #{y3} #{x4} #{y4}"

Measured memory_bytes: 1788
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,x=parseMap(split(readline()))
    xi=parseMap(split(readline()))
    push!(xi,x)
    sort!(xi)
    dif=[xi[end]-xi[i] for i in 1:n]
    ans=dif[1]
    for i in 1:n
        ans=gcd(dif[i],ans)
    end
    println(ans)
end
main()

Measured memory_bytes: 132328
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    a,b,c=map(int,input().split())
    cunt=0
    if a==b and b==c and a%2==0:
        print(-1)
        sys.exit()
    while True:
        if a%2 or b%2 or c%2:
            print(cunt)
            break
        cunt+=1
        a1,b1,c1=a,b,c
        a=(b1+c1)//2
        b=(a1+c1)//2
        c=(a1+b1)//2

if __name__=='__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int DIRX[4] = {-1,0,1,0};
int DIRY[4] = {0,-1,0,1};

int main(){
	int h,w;
	char board[50][50];
	cin >> h >> w;
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			cin >> board[j][i];
		}
	}

	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			if(board[j][i] != '#')continue;
			bool flag = 0;
			for(int k = 0;k < 4;k++){
				int nx = j + DIRX[k];
				int ny = i + DIRY[k];
				if(nx < 0 || ny < 0 || nx >= w || ny >= h)continue;
				if(board[nx][ny] == '#')flag = 1;
			}
			if(!flag){cout << "No" << endl;return 0;}
		}
	}
	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
    for(;;){
	int n;
	cin>>n;
	if(n==0)break;
	int a[1010],b[1010],c[1010];
	char d[1010];

	for(int i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];

	}
	for(int i=0;i<n;i++){
        if(a[i]==100||b[i]==100||c[i]==100){
            d[i]='A';
        }
        else if((a[i]+b[i])/2>=90)d[i]='A';


        else if((a[i]+b[i]+c[i])/3>=80)d[i]='A';

        else if((a[i]+b[i]+c[i])/3>=70)d[i]='B';

        else if((a[i]+b[i]+c[i])/3>=50&&a[i]>=80)d[i]='B';

        else if((a[i]+b[i]+c[i])/3>=50&&b[i]>=80)d[i]='B';

        else d[i]='C';

	}
	for(int i=0;i<n;i++){
        cout<<d[i]<<endl;
	}

    }
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
int main(){
    int h,w;
    while(true){
        cin >> h >> w;
        if(h != 0 or w != 0){
            for(int i = 1; i <= h; i++){
                for(int j = 1; j <= w; j++){
                    cout << "#";
                }
                cout << endl;
            }
            cout << endl;
        } else {
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;
int main(){
  int n;
  cin >> n;
  vector<long> a(n*3);
  for(int i = 0; i <n*3; i++) cin >> a[i];

  sort(a.begin(), a.end()); 
  vector<long> mid(n);
  for(int i = 0; i < n; i++) {
    mid[i] = a[3*n -2 -i*2];
  }

  cout << accumulate(mid.begin(), mid.end(), 0L) << endl;
 return 0;
}


Measured memory_bytes: 6392
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int k,s[10],g[10],ans;
void dfs(int c,int step){
	if(c==k){
		if(ans>step)ans=step;
	}else if((s[c]-g[c]+10)%10==0)dfs(c+1,step);
	else{
		for(int e=c+1;e<=k;e++){
			int mv=g[c]-s[c];
			for(int i=c;i<e;i++)s[i]+=mv;
			dfs(c+1,step+1);
			for(int i=c;i<e;i++)s[i]-=mv;
		}
	}
}
int main(){
	while(cin>>k,k){
		char buf[11];
		cin>>buf;rep(i,k)s[i]=buf[i]-'0';
		cin>>buf;rep(i,k)g[i]=buf[i]-'0';
		ans=10;dfs(0,0);
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 872
package main

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

func solve(sc *scanner, wr *bufio.Writer) {
	n := sc.getInt()
	as := sc.getInts(n)
	s := sum(as...)

	ans := -1
	now := 100000000
	for i, a := range as {
		if abs(s-now) > abs(s-a*n) {
			ans = i
			now = a * n
		}
	}

	fmt.Fprintln(wr, ans)
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func main() {
	sc := newScanner()
	wr := bufio.NewWriter(os.Stdout)
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)

	solve(sc, wr)
	wr.Flush()
}

// input ------------------------
type scanner struct {
	*bufio.Scanner
}

func newScanner() *scanner {
	sc := bufio.NewScanner(os.Stdin)
	return &scanner{sc}
}
func (sc *scanner) getInt() int {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getInt2() (int, int) {
	return sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt3() (int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt4() (int, int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInts(n int) []int {
	ret := make([]int, n)
	for i := range ret {
		ret[i] = sc.getInt()
	}
	return ret
}
func (sc *scanner) getString() string {
	sc.Scan()
	return sc.Text()
}
func (sc *scanner) getRunes() []rune {
	return []rune(sc.getString())
}
func (sc *scanner) getFloat() float64 {
	sc.Scan()
	ret, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := range ret {
		ret[i] = sc.getFloat()
	}
	return ret
}

// math ----------------------------
func sum(ns ...int) int {
	var sum int
	for _, n := range ns {
		sum += n
	}
	return sum
}

func max(ns ...int) int {
	max := ns[0]
	for i := 1; i < len(ns); i++ {
		if max < ns[i] {
			max = ns[i]
		}
	}
	return max
}

func min(ns ...int) int {
	min := ns[0]
	for i := 1; i < len(ns); i++ {
		if min > ns[i] {
			min = ns[i]
		}
	}
	return min
}

func pow(a, b int) int {
	ret := 1
	for b > 0 {
		if b&1 > 0 {
			ret = ret * a
		}
		a = a * a
		b >>= 1
	}
	return ret
}


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

int main(){
    ll n,m,l;
    cin >> n >> m >> l;
    ll a[n][m],b[m][l],c[n][l];
    
    rep(i,0,n){
        rep(j,0,l){
            c[i][j] = 0;
        }
    }
    
    rep(i,0,n){
        rep(j,0,m){
            cin >> a[i][j];
        }
    }
    
    rep(i,0,m){
        rep(j,0,l){
            cin >> b[i][j];
        }
    }
    
    rep(i,0,n){
        rep(j,0,l){
            rep(k,0,m){
                c[i][j] += a[i][k]*b[k][j];
            }
        }
    }
    
    rep(i,0,n){
        rep(j,0,l){
            if(j != 0) cout << " ";
            cout << c[i][j];
        }
        cout << endl;
    }
    return 0;
}


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

int main()
{
  int n;
  vector<uintmax_t> a;
  uintmax_t add_sum, r_sum = 0, divider = pow(10, 9) + 7;

  cin >> n;
  for (int i = 0; i < n; i++)
  {
    uintmax_t tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  sort(a.begin(), a.end());

  add_sum = a[n - 1];
  for (int i = n - 2; i >= 0; i--)
  {
    r_sum += a[i] * add_sum % divider;
    add_sum += a[i];
    r_sum %= divider;
    add_sum %= divider;
  }

  cout << r_sum << endl;
}


Measured memory_bytes: 5364
n = int(input())
s = [input() for i in range(n)]
l, r = [], []
for i in s:
    a, b = 0, 0
    for j in range(len(i)):
        if i[j] == "(":
            b += 1
        if i[j] == ")":
            if b <= 0:
                a += 1
            else:
                b -= 1
    if b - a > 0:
        l.append([a, b])
    else:
        r.append([a, b])
l.sort(key=lambda x:x[0])
r.sort(key=lambda x:x[1], reverse=True)
li = l + r
ans = 0
for i in li:
    ans -= i[0]
    if ans < 0:
        exit(print("No"))
    ans += i[1]
print("Yes" if ans == 0 else "No")

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


public class Test
{	
    public static void Main()
	{
	    int[] n = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        if((n[0]*n[1])%2 == 0) Console.WriteLine("No");
        else Console.WriteLine("Yes");
        

	} 
}

Measured memory_bytes: 13268
n, t = map(int, input().split())
a = list(map(int, input().split()))
m = a[-1]
tmp = 0
cnt = 0
for i in range(n - 2, -1, -1):
    p = m - a[i]
    if p > tmp:
        tmp = p
        cnt = 1
    elif p == tmp:
        cnt += 1
    m = max(m, a[i])
print(cnt)


Measured memory_bytes: 14252
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "", 1 << 27);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastReader in = new FastReader(inputStream);
            PrintWriter out = new PrintWriter(outputStream);
            ADontBeLate solver = new ADontBeLate();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class ADontBeLate {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int d = s.nextInt(), t = s.nextInt(), se = s.nextInt();
            w.println(se * t >= d ? "Yes" : "No");
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 32812
import sys
S = input()
T = input()
alphabet = [chr(i) for i in range(97, 97+26)]

dict_1 = {}
dict_2 = {}

for i in range(len(S)):
    if dict_1.setdefault(S[i],T[i]) != T[i]:
        print("No")
        sys.exit()
    if dict_2.setdefault(T[i],S[i]) != S[i]:
        print("No")  
        sys.exit()  
print("Yes")

Measured memory_bytes: 3632
#include<stdio.h>

int main(void)
{
	int i , j;
	int sum;
	
	for(i=1; i<=9 ; i++){
		for(j=1; j<=9 ;j++){
			sum=i*j;
			printf("%dx%d=%d\n" ,i,j,sum);
		}
	}
	return 0;
}

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

#define endl "\n"

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string input;
    cin >> input;
    int n = input.length(), doctoral = 0, postdoctoral = 0;
    int dp[n + 1] = {0};
    bool prev_P = false;
    for (int i = 1; i <= n; ++i) {
        char c = input[i - 1];
        if (c == 'P') {
            prev_P = true;
            dp[i] = dp[i - 1];
        } else if (c == 'D') {
            dp[i] = dp[i - 1] + 1;
            if (prev_P) {
                dp[i]++;
                prev_P = false;
            }
        } else { // ?
            // set to D
            dp[i] = dp[i - 1] + 2;
            input[i - 1] = 'D';
        }
    }

    cout << input << endl;

    return 0;
}

Measured memory_bytes: 4556
#include<bits/stdc++.h>
#define ll long long
#define fin(x) scanf("%lld",&x)
#define fout(x) printf("%lld\n",x)
#define pll pair<ll,ll>
#define mp(x,y) make_pair(x,y)
#define cases int t;  scanf("%d",&t);   while(t--)
#define MOD 1000000007
#define MAXN 123456
#define read() freopen("lele.txt","r",stdin)
#define write() freopen("dede.txt","w",stdout)

using namespace std;

int main()
{
    ll a, b;
    fin(a); fin(b);
    ll ans = (a * b) / __gcd(a, b);
    fout(ans);
    return 0;
}

Measured memory_bytes: 256
input = gets.chomp.split("\s")
a, b, c = input[0].to_i, input[1].to_i, input[2].to_i

# bがcより大きい場合、bをcにする（cにはb以上の約数はない）
if b > c then b = c
end

#カウント
count = 0
for i in a..b
	if c % i == 0 then count += 1
	end
end

puts count

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

int main()
{
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	if ((x + r) <= W && 0 <= (x - r)) {
		if ((y + r) <= H && 0 <= (y - r)) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else {
		cout << "No" << endl;
	}

    return 0;
}

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


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    string a[n];
    cin>>a[0];
    //cout<<a[0]<<endl;
    ll r = a[0].length();
    char er = a[0][r-1];
   // cout<<er<<endl;
    ll flag = 1;
    for(ll i=1;i<n;i++)
    {
        string tmp;

    cin>>tmp;
    a[i]=tmp;
    ll t = tmp.length();
    if(a[i][0]!=er)
    {
        flag = -1;
       // break;
    }
    for(ll j=0;j<i;j++)
    {
        if(tmp==a[j])
        {
            flag = -1;
           // break;
        }
    }
    er = a[i][t-1];
    //cout<<flag<<endl;
    }
    if(flag == 1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mkp make_pair
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
int main()
{fastio
ll n,k,i,j;
cin>>n>>k;
ll arr[n];
for(i=0;i<n;i++)//arr[i]=i+1;
cin>>arr[i];
ll dp[k+1]={0};
for(i=0;i<=k;i++)
{  ll f=1;
	for(j=0;j<n&&f;j++)
	{
		if(i>=arr[j])
		{
			if(dp[i-arr[j]]==0)
			{dp[i]=1;f=0;
			}
		}
		
	}
}
//for(i=0;i<=k;i++)cout<<dp[i]<<" ";
if(dp[k])cout<<"First\n";
else cout<<"Second\n";
return 0;
}

Measured memory_bytes: 1024
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N_MAX = 100002;

int n;

ll a[N_MAX], b[N_MAX];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i] >> b[i];
    ll ans = 0;
    for(int i = n; i >= 1; i--)
    {
        a[i] += ans;
        ll k = (a[i] + b[i] - 1) / b[i] * b[i];
        ans += k - a[i];
    }
    cout << ans << "\n";
    return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int ans = 0;
    REP(i,A+1){
        REP(j,B+1){
            REP(k,C+1){
                int x = 500 * i + 100 * j + 50 * k;
                if(x == X) ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <bitset>
using namespace std;
const int maxn=200010;

int n,top,a[maxn];
struct node{
	int w,a;
}zhan[maxn];
bool bz;

void doit(int p,int q)
{
	if (p==0)
	{
		bz=false;
		return;
	}
	while (zhan[top].w>p)
	{
		top--;
	}
	if (zhan[top].w==p) zhan[top].a++;
	else 
	{
		top++;
		zhan[top].w=p;
		zhan[top].a=2;
	}
	if (zhan[top].a==q+1)
	{
		if (top>0)
		{
			top--;
			doit(p-1,q);
		}
	}
}

bool pd(int x)
{
	top=0;zhan[0].w=0;
	bz=true;
	for (int i=1;i<=n;i++)
	{
		if (a[i]<=a[i-1])
		{
			doit(a[i],x);
		}
	}
	return bz;
}

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	
	int l=2;
	int r=100000000;
	int ans=0;
	while (l<=r)
	{
		int mid=(l+r)/2;
		if (pd(mid))
		{
			ans=mid;
			r=mid-1;
		}
		else
		{
			l=mid+1;
		}
	}
	int k=0;
	for (int i=1;i<n;i++)
	{
		if (a[i]>=a[i+1])
		{
			k=1;
		}
	}
	if (k==0) ans=1;
	printf("%d\n",ans);
}

Measured memory_bytes: 4572
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int n, h;
    cin >> n >> h;
    vector<string> s(n);
    vector<int> t(n);
    for(int i=0; i<n; ++i)
        cin >> s[i] >> t[i];

    int correct = 0;
    int type = 0;
    int i = 0;
    int j = 0;
    for(;;){
        cout << "? " << s[i] << endl;
        char c;
        cin >> c;
        ++ type;

        if(tolower(s[i][j]) == tolower(c)){
            ++ correct;
            s[i][j] = '_';
            ++ j;
            if(j == s[i].size()){
                ++ i;
                j = 0;
                if(i == n){
                    int p = correct * 1000 / type;
                    cout << "! Game Clear " << p / 10 << '.' << p % 10 << endl;
                    return 0;
                }
            }
        }
        else{
            -- t[i];
            if(t[i] < 0){
                -- h;
                ++ i;
                j = 0;
                if(h == 0){
                    cout << "! Game Over" << endl;
                    return 0;
                }
            }
        }
    }
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  // 
  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  string s;cin>>s;
  cout<<s.substr(0,5)<<" "<<s.substr(6,7)<<" "<<s.substr(14, 5)<<"\n";
  return 0;
}


Measured memory_bytes: 256
let md = 998244353

let pow a b =
  let rec f a b c =
    if b = 0 then c
    else if (b land 1) = 1 then f (a * a mod md) (b lsr 1) (c * a mod md)
    else f (a * a mod md) (b lsr 1) c
  in f a b 1

let solve2 a m =
  let rec f i v ans =
    if i = m + 1 then ans
    else f (i + 1) a.(i) (ans * pow v a.(i) mod md)
  in f 0 1 1

let solve n d =
  let a = Array.make n 0 in
  let m = Array.fold_left (fun m d -> a.(d) <- a.(d) + 1; max m d) 0 d in
  if a.(0) = 1 then solve2 a m else 0

let () =
  let n = read_int() in
  let d = Array.init n (fun _ -> Scanf.scanf " %d" (fun i -> i)) in
  let ans = if d.(0) = 0 then solve n d else 0 in
  Printf.printf "%d\n" ans


Measured memory_bytes: 7520
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str1[] = br.readLine().split("");
		String str2[] = br.readLine().split("");

		boolean flag = false;
		for (int i = str1.length - str2.length; i >= 0; i--) {
			flag = false;
			for (int j = 0; j < str2.length; j++) {
				if (!str1[i + j].equals(str2[j]) && !str1[i + j].equals("?")) {
					flag = true;
					break;
				}
			}
			if (!flag) {
				System.arraycopy(str2, 0, str1, i, str2.length);
				break;
			}
		}

		if (str1.length < str2.length) {
			flag = true;
		}

		if (flag) {
			System.out.println("UNRESTORABLE");
		} else {
			for (int i = 0; i < str1.length; i++) {
				if (str1[i].equals("?")) {
					str1[i] = "a";
				}
				System.out.print(str1[i]);
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 1000000007
    

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

  bool sortbysec(const pair<int,int> &a,const pair<int,int> &b)
  {

    if(a.s==b.s)
    {
      return a.f<b.f;
    }
    return a.s<b.s;
  }
  int32_t main()
  {         

      IOS

      
      int n,y;
      cin>>n>>y;

      int curr=0;
      int ans=1;

      for(int i=1;i<=n;i++)
      {
        int x;
        cin>>x;
        curr+=x;
        if(curr<=y)
        {
          ans++;
        }
      }

      cout<<ans;
      return 0;
  }           

Measured memory_bytes: 256
using System;

public class D
{
    static void Main()
    {
        var w = Console.ReadLine().Split(' ');
        int n = int.Parse(w[0]);
        int k = int.Parse(w[1]);

        var s = Console.ReadLine();

        int a = 0;
        for (int i = 1; i < n; i++)
        {
            if (s[i] == s[i - 1]) a++;
        }

        Console.WriteLine((n - a) / 2 <= k ? n - 1 : a + k * 2);
    }
}

Measured memory_bytes: 13116
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int x, y; cin >> x >> y;
  int ans = 0;
  ans += max(0, (4-x)*100000);
  ans += max(0, (4-y)*100000);
  if(x==1 && y==1) ans += 400000;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL

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

int N;
ll K;

int main()
{
	scanf("%d",&N);
	int ans=0;
	int a,b=0,c=0;
	for(int i=0;i<N;i++){
		scanf("%d",&a);
		if(a==b || i==0){
			c++;
			b=a;
		}else{
			ans += c/2;
			c=1;
			b=a;
		}
	}
	ans += c/2;
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;

int main(){
  int N,M; cin >> N >> M;
  vector<int> switches(N,0);
  for(int i = 0; i < M; i++){
    int k; cin >> k;
    for(int j = 0; j < k; j++){
      int s; cin >> s; s--; switches[s] |= 1 << i;}}
  
  int cnt = 0; int p = 0;
  for(int i = 0; i < M; i++){ int q; cin >> q; p |= q << i;}
  
  for(int i = 0; i < ( 1 << N ); i++){
    int key = 0;
    for( int j = 0; j < N; j++){
      if( ( i >> j ) & 1){ key ^= switches[j];}}
    
    if( key == p){ cnt++;}}
  
  cout << cnt << endl; return 0;}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        String S = scan.next();
        char[] d = S.toCharArray();
        int[] E = new int[N+2];
        E[0] = 0;
        for (int i = 0; i < N; i++) {
            E[i+1] = E[i] + (d[i] == 'W' ? 1 : 0);
        }
        E[N+1] = E[N];
        int[] W = new int[N+2];
        W[N+1] = 0;
        for (int i = N-1; 0 <= i; i--) {
            W[i+1] = W[i+2] + (d[i] == 'E' ? 1 : 0);
        }
        W[0] = W[1];
        int answer = Integer.MAX_VALUE;
        for (int i = 1; i <= N; i++) {
            answer = Math.min(answer, E[i-1]+W[i+1]);
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 32056
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
int main() {
 ll h,n,sum=0;
 cin>>h>>n;
 ll a[n+1];
 for(ll i=0;i<n;i++){
 cin>>a[i];
 sum+=a[i];
}
if(sum>=h)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}

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

const int N = 1e4;
char str[N];
int main()
{
    scanf("%s",str);
    int len = strlen(str);
    bool flag = true;
    for(int i = 0; i < len/2; i++) {
        if(str[i] != str[len-i-1]) {
            flag = false; break;
        }
    }
    if(flag) puts("Yes");
    else puts("No");


return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    cout << min({a * b * (c % 2), b * c * (a % 2), c * a * (b % 2)}) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int u[100][100];
  int n,i,ii,t,kk,c;

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&t);
    scanf("%d",&u[t][0]);
    for(ii=1;ii<=u[t][0];ii++)
      scanf("%d",&u[t][ii]);
  }

  for(i=1;i<=n;i++){
    kk=0;
    c=1;
    for(ii=1;ii<=n;ii++){
      if(kk)printf(" ");
      if(ii==u[i][c]){
	printf("1");
	kk++;
	c++;
      }else{
	printf("0");
	kk++;
      }
    }
    printf("\n");
  }
  
  return 0;
}



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

char F[102][102];
void DFS_R(int Y,int X){
  if(F[Y][X]!='@'){
    return;
  }
  F[Y][X]='.';
  DFS_R(Y-1,X  );
  DFS_R(Y  ,X+1);
  DFS_R(Y+1,X  );
  DFS_R(Y  ,X-1);
}
void DFS_K(int Y,int X){
  if(F[Y][X]!='#'){
    return;
  }
  F[Y][X]='.';
  DFS_K(Y-1,X  );
  DFS_K(Y  ,X+1);
  DFS_K(Y+1,X  );
  DFS_K(Y  ,X-1);
}
void DFS_M(int Y,int X){
  if(F[Y][X]!='*'){
    return;
  }
  F[Y][X]='.';
  DFS_M(Y-1,X  );
  DFS_M(Y  ,X+1);
  DFS_M(Y+1,X  );
  DFS_M(Y  ,X-1);
}

int main(){
  int H,W;
  cin>>H>>W;
  while(H!=0){
    for(int y=1;y<=H;y++){
      for(int x=1;x<=W;x++){
        cin>>F[y][x];
      }
    }
    int cntR=0;
    int cntK=0;
    int cntM=0;
    for(int y=1;y<=H;y++){
      for(int x=1;x<=W;x++){
        if(F[y][x]=='@'){
          cntR++;
          DFS_R(y,x);
        }else if(F[y][x]=='#'){
          cntK++;
          DFS_K(y,x);
        }else if(F[y][x]=='*'){
          cntM++;
          DFS_M(y,x);
        }
      }
    }
    int cnt=0;
    cnt=cntR+cntK+cntM;
    cout<<cnt<<endl;
    cin>>H>>W;
  }
  return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;cin>>n;
  vector<int> count(n+1,0);
  for(int i=0;i<n-1;i++)
  {
    int x;cin>>x;
    count[x]++;
  }
  for(int i=1;i<=n;i++)
    cout<<count[i]<<endl;
  return 0;
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	int k; cin >> k;
	string s="00000000000000000";
	int p=0;
	while(k--){
		for(int i=0;1;i++){
			if(s[i]<=s[i+1]&&s[i]!='9'){
				s[i]++;
				for(int j=i-1;j>=0;j--){
					if(s[j+1]=='0')
						s[j]='0';
					else
						s[j]=s[j+1]-1;
				}
				break;
			}
			if(i==p){
				if(s[i]=='9'){
					REP(j,i+1) s[j]='0';
					s[i+1]='1';
					p++;
				}
				else{
					s[i]++;
					for(int j=i-1;j>=0;j--){
						if(s[j+1]=='0')
							s[j]='0';
						else
							s[j]=s[j+1]-1;
					}	
				}
				break;
			}
		}
	}
	reverse(ALL(s));
	bool f=0;
	REP(i,s.size()){
		if(s[i]!='0'||f){
			f=1;
			cout << s[i];
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	int N = scan.nextInt();
	int[] a = new int[N];
	int Alice = 0;
	int Bob = 0;
	int diff = 0;
	
	for(int i = 0; i < N; i++){
	    a[i] = scan.nextInt();
	}

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

	for(int i = 0; i < N; i++){
	    if(i % 2 == 0){
		Alice += a[i];
	    }else{
		Bob += a[i];
	    }
	}

	diff = Alice - Bob;

	System.out.println(diff);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <fstream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <cmath>
#include <sstream>
#define F first
#define S second
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define FORI(i,k,n) for(int i=k;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
using namespace std;
typedef pair<double, double> pdd;
const double EPS = 10e-6;
double wid(pdd a, pdd b) {
	return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second));
}
double yoge(pdd a, pdd b, pdd c) {
	double A, B, C;
	C = wid(a, b); A = wid(b, c); B = wid(c, a);
	return abs(acos((B*B+C*C-A*A)/(2*B*C)));
}
int main() {
	pdd p[4];
	while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&p[0].first,&p[0].second,&p[1].first,&p[1].second,&p[2].first,&p[2].second,&p[3].first,&p[3].second)!=EOF) {
		double x=yoge(p[0],p[3],p[1])/3.1415926535*180+
			yoge(p[1],p[0],p[2])/3.1415926535*180+
			yoge(p[2],p[1],p[3])/3.1415926535*180+
			yoge(p[3],p[2],p[0])/3.1415926535*180-360;
		if(x<EPS&&x>-1*EPS)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}

}

Measured memory_bytes: 1268