akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
struct aa {
	int x;
	int y;
	int time;
};

const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };
int getdis(const int fromx, const int fromy, const int gx, const int gy,const vector<vector<int>>&field) {
	vector<vector<int>>memo(1002, vector<int>(1002, 99999999));
	memo[fromy][fromx] = 0;
	queue<aa>que;
	que.push(aa{ fromx,fromy,0 });
	int ans = 0;
	while (!que.empty()) {
		aa atop = que.front();
		que.pop();
		const int ax = atop.x;
		const int ay = atop.y;
		if (ax == gx&&ay == gy) {
			ans = atop.time;
			break;
		}
		for (int i = 0; i < 4; ++i) {
			const int nex = ax + dx[i];
			const int ney = ay + dy[i];
			if (field[ney][nex]) {

			}
			else {
				if (memo[ney][nex]>atop.time + 1) {
					memo[ney][nex] = atop.time + 1;
					que.push(aa{ nex,ney,atop.time + 1 });
				}
			}
		}
	}
	return ans;
}

int main() {
	int H, W, C; cin >> H >> W >> C;
	vector<vector<int>>field(H + 2, vector<int>(W + 2,1));
	vector<int>xs(C+1), ys(C + 1);
	int sx, sy;
	for (int i = 0; i < H; ++i) {
		string st; cin >> st;
		for (int j = 0; j < W; ++j) {
			if (st[j] == '.')field[i + 1][j + 1] = false;
			else if (st[j] == 'X') {

			}
			else {
				field[i + 1][j + 1] = false;
				if (st[j] == 'S') {
					xs[0] = j + 1;
					ys[0] = i + 1;
				}
				else {
					xs[st[j] - '0'] = j + 1;
					ys[st[j] - '0'] = i + 1;
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < C; ++i) {
		ans += getdis(xs[i], ys[i], xs[i + 1], ys[i + 1], field);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10624
#include<stdio.h>

int main(){

	int A,B,C;
	int Flag = 0;

	scanf("%d %d %d",&A,&B,&C);

	for(int i=1; i<100; i++){
		if( (A*(100+i)) % B == C ){
			printf("YES");
			return 0;
		}else{
			/*何もしない*/
		}
	}
	
	printf("NO");

	return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#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(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

template<class T> inline int sgn(T n) { if (n > 0) return 1; else if (n < 0) return -1; else return 0; }

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int n, m;
const int MAX = 10;
vi to[MAX];
int ans = 0;


void dfs(int cnt, int v, vi checked) {
  if (cnt == n-1) {
    ans++;
    return;
  }

  checked[v] = true;

  for (auto x : to[v]) {
    if (!checked[x]) {
      dfs(cnt+1, x, checked);
    }
  }
  return;
}

int main () {
  cin >> n >> m;
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  
  vi checked(MAX,false);
  dfs(0,0,checked);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

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

int solve(){
  int n;cin>>n;
  int a[n]; rep(i, n) {cin>>a[i];}

  int res = a[0];
  rep(i, 1, n){
    res = gcd(res, a[i]);
  }

  cout << res << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
  int A,B,C=0;
  cin>>A>>B;
  int D[A];
  for(int i=0;i<A;i++){
    cin>>D[i];
    if(D[i]>=B) C++;
  }
  cout<<C;
  return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

constexpr auto INF = INT_MAX/2;
constexpr auto MOD = 1000000007;

int main() {

	int n;
	cin >> n;
	vi t(n), a(n);
	rep(i, n)cin >> t[i] >> a[i];

	ll vt = t[0], va = a[0];

	rep(i, n) {

		ll vt1 = vt + t[i] - ((vt - 1) % t[i] + 1);
		ll va1 = vt1 / t[i] * a[i];

		ll va2 = va + a[i] - ((va - 1) % a[i] + 1);
		ll vt2 = va2 / a[i] * t[i];


		if (vt1 < vt || va1 < va) {
			vt = vt2;va = va2;
		}
		else if(vt2 < vt || va2 < va) {
			vt = vt1;va = va1;
		}
		else {
			vt = min(vt1, vt2);va = min(va1, va2);
		}
	}

	cout << vt + va << endl;

}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

map<pair<ll, ll>, ll> ans;

bool check(ll a, ll b) {
    if (b % 2) return false;
    ll x = 1;
    while ((b & x) == 0) x *= 2;
    b ^= x;
    ++b;
    return (a > b);
}

ll solve(ll a, ll b) {
    if (a == b) return 1;
    auto it = ans.find({a, b});
    if (it != ans.end()) return it->sn;
    ll rez = solve((a + 1) / 2, b / 2) + solve(a / 2, b / 2);
    if (check(a, b)) --rez;
    ans[{a, b}] = rez;
    //cerr << a << ' ' << b << ' ' << rez << '\n'; // -1 if we can;t get (b + 1) and b % 2 == 0;
    return rez;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b;
    cin >> a >> b;
    cout << solve(a, b) << '\n';
}


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

class Program
{
	static void Main(string[] args)
	{
		int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
		int A = intArray[0];
		int B = intArray[1];

		Console.WriteLine(A * B);
	}

	/// <summary>
	/// アナグラム
	/// </summary>
	/// <param name="word1"></param>
	/// <param name="word2"></param>
	/// <returns></returns>
	static bool IsAnagramOf(string word1, string word2)
	{
		return word1.OrderBy(x => x).SequenceEqual(word2.OrderBy(x => x));
	}
	/// <summary>
	/// 最小公倍数
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	public static long Lcm(long a, long b)
	{
		return a * b / Gcd(a, b);
	}

	/// <summary>
	/// 最大公約数
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	public static long Gcd(long a, long b)
	{
		if (a < b)
			// 引数を入替えて自分を呼び出す
			return Gcd(b, a);
		while (b != 0)
		{
			var remainder = a % b;
			a = b;
			b = remainder;
		}
		return a;
	}
}




//string s = Console.ReadLine();
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];
//int N = int.Parse(Console.ReadLine());
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
//Boolean ok = false;

//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.ReadKey();
//Console.WriteLine(cnt);

//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];


Measured memory_bytes: 28144
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template< typename T > istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,t;
    cin>>n>>t;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    vec b(n);
    int mi=a[0];
    rep(i,n){
        chmin(mi,a[i]);
        b[i]=mi;
        // cout<<b[i]<<endl;
    }
    vec c(n);
    map<int,int> mp;
    rep(i,n){
        mp[INF-(a[i]-b[i])]++;
    }
    for(auto x:mp){
        cout<<x.sc<<endl;
        return 0;
    }
    
}

Measured memory_bytes: 8832
ROUTE, WALL = 0, 1
def main():
    H, W = [int(n) for n in input().split()]
    H, W = H+1, W+1
    grid = [[ROUTE]*W for i in range(H)]
    for h in range(H):
        if h == 0:
            grid[0] = [WALL] * W
            continue
        instr = "#" + input()
        for w, c in enumerate(instr):
            grid[h][w] = ROUTE if c == "." else WALL
    dp = [-1]*(H*W)
    dp[coord_to_num(W, 1,1)]=1
    for crd in range(H*W):
        if dp[crd] != -1:
            continue
        h, w = num_to_coord(W, crd)
        if grid[h][w] == WALL:
            dp[crd] = 0
            continue
        up = dp[coord_to_num(W,h-1, w)]
        down = dp[coord_to_num(W, h, w-1)]
        dp[coord_to_num(W, h, w)] = up+down
    print(dp[coord_to_num(W, H-1, W-1)] % (10 ** 9 + 7))


def num_to_coord(W, num):
    return (num//W, num%W)
def coord_to_num(W, h, w):
    return h * W + w

if __name__ == "__main__":
    main()

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

int vis[105];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x,n;
	cin >> x >> n;
	for (int i = 1; i <= n; i++)
	{
		int t = 0;
		cin >> t;
		vis[t] = 1;
	}
	int ans;
	for (int i = 0; i <= 100; i++)
	{
		if( x - i < 0 )
		{
			ans = x - i;
			break;
		}
		if( vis[x-i] == 0 )
		{
			ans = x - i;
			break;
		}
		if( vis[x+i] == 0 )
		{
			ans = x + i;
			break;
		}
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3692
#!/usr/bin/env python3
import sys


def solve(x0, y0, x1, y1):
    print(x1 - (y1 - y0), y1 + (x1 - x0), x0 - (y1 - y0), y0 + (x1 - x0))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    x0 = int(next(tokens))
    y0 = int(next(tokens))
    x1 = int(next(tokens))
    y1 = int(next(tokens))
    solve(x0, y0, x1, y1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

using namespace std;

int main() {

	int a[100001], sum, n, flag = 0, m, count = 0;

	cin >> n;


	if (n < 10) {
		cout << n << endl;
	}
	else if (n < 100) {
		cout << 9 << endl;
	}
	else if (100 <= n && n < 1000) {
		cout << n - 90 << endl;
	}
	else if (1000 <= n && n < 10000) {
		cout << 909 << endl;
	}
	else if (10000 <= n && n < 100000) {
		cout << n - 90 - 9000 << endl;
	}
	else if (n == 100000) {
		cout << 90909 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

int main() {
  int k, x;
  cin >> k >> x;
  // [x-k, x+k]
  rep(i, x - k + 1, x + k) cout << i << endl;
  return 0;
}

Measured memory_bytes: 3628
# AOJ 0229 Big Hit !
# Python3 2018.6.25 bal4u
 
while 1:
    b, r, g, c, s, t = map(int, input().split())
    if (b|r|g|c|s|t) == 0: break
    ans = 100
    ans += 15*b+(15-2)*5*b
    t -= 5*b
    ans += 15*r+(15-2)*3*r
    t -= 3*r
    ans += 7*g
    ans += 2*c
    t -= s
    ans -= 3*t
    print(ans);


Measured memory_bytes: 5592
text = input()
result=[0]*len(text)
N=len(text)

####RRR...(n個)...RL...(m個)...Lのとき
####n+mが偶数なら(n+m)/2個ずつ
####奇数ならnが奇数のときRに(n+m+1)/2,Lに(n+m-1)/2
####nが偶数のときRに(n+m-1)/2,Lに(n+m+1)/2たまる

s=0
i=0
j=0
while j<N :
  while text[i]=="R" :
    i+=1
  j=i+1
  while (j<N and text[j]=="L") :
    j+=1
  if (j-s)%2==0:
    result[i-1]=(j-s)//2
    result[i]=(j-s)//2
  else:
    result[i-1]=(j-s-1)//2
    result[i]=(j-s-1)//2
    result[i-(s-i)%2]+=1
  s=j
  i=s+1

print(' '.join(map(str, result)))



Measured memory_bytes: 10484
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8 ff=unix


def solv(n, k, p):
    total = sum(p[0:k])
    max_total = total
    pl = p[0]
    for i in range(1, n-k+1):
        pr = p[i+k-1]
        total = total - pl + pr
        if total > max_total:
            max_total = total
        pl = p[i]
    return (max_total + k) / 2


if __name__ == "__main__":

    n, k = map(int, input().split())
    p = tuple(map(int, input().split()))

    ans = solv(n, k, p)

    print(ans)


Measured memory_bytes: 25316
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	vector<int> h(n);
	rep(i, 0, n - 1)cin >> h[i];
	
	vector<int> dp(n);
	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);
	rep(i, 2, n - 1)dp[i] = min(abs(h[i] - h[i - 1]) + dp[i - 1], abs(h[i] - h[i - 2]) + dp[i - 2]);
	cout << dp[n - 1] << endl;
}

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

#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 FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

int main() {
  ll n;
  cin >> n;
  map<P, ll> mp;
  FOR(now, 1, n + 1) {
    ll cnt = 0;
    ll i = now;

    while (i > 0) {
      i /= 10;
      ++cnt;
    }
    ll tmp = 1;
    ll l, r;
    i = now;
    while (i > 0) {
      if (tmp == cnt) {
        l = i;
      }
      if (tmp == 1) {
        r = i % 10;
      }
      i /= 10;
      ++tmp;
    }

    mp[P(l, r)]++;
  }

  ll ans = 0;
  for (auto x : mp) {
    if (x.first.first == x.first.second) {
      ans += x.second + x.second * (x.second - 1);
    } else {
      ans += x.second * mp[P(x.first.second, x.first.first)];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<tuple>

using namespace std;

int main(){
    int n,m;
    cin >> n >> m;

    tuple<int, int, int> data[m];

    for(int i=0;i<m;i++){
        int p, y;
        cin >> p >> y;
        data[i] = make_tuple(y, p, i);
    }

    sort(data, data + m);

    int cnt[n+1];
    fill(cnt, cnt + n + 1, 0);

    pair<int, int> id[m];

    for(int i=0;i<m;i++){
        int y, p, idx;
        tie(y, p, idx) = data[i];
        cnt[p]++;
        id[idx] = make_pair(p, cnt[p]);
    }

    for(int i=0;i<m;i++){
        cout << setfill('0') << setw(6) << id[i].first;
        cout << setfill('0') << setw(6) << id[i].second << endl;
    }

    return 0;
}

Measured memory_bytes: 3840
/*
ID: amagica1
TASK: ariprog
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define NINF -INF
#define mp make_pair
#define boost() cin.tie(0); cin.sync_with_stdio(0)
#define For(i, a, b) for(int i=a; i<b; i++)
#define FOR(i, a, b) for(int i=a; i<=b; i++)
#define Rev(i, a, b) for(int i=a; i>b; i--)
#define REV(i, a, b) for(int i=a; i>=b; i--)
typedef long long ll;
typedef long double ld;
typedef int64_t l;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
const int MOD = 1e9 + 7;
const int MAXN = 100005;
ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
int N, U, V, dis1[MAXN], dis2[MAXN]; bool vis[MAXN]; vector<int> adj[MAXN];
void dfs1(int cur) {
    vis[cur]=true;
    for(int v : adj[cur]) {
        if(!vis[v]) {
            dis1[v] = dis1[cur] + 1;
            dfs1(v);
        }
    }
}
void dfs2(int cur) {
    vis[cur] = true;
    for (int v : adj[cur]) {
        if (!vis[v]) {
            dis2[v] = dis2[cur] + 1;
            dfs2(v);
        }
    }
}
int main() {
    //-----------FILE------------//
    // freopen("ariprog.in", "r", stdin);
    // freopen("ariprog.out", "w", stdout);
    //----------------------------//
    scanf("%d %d %d", &N, &U, &V);
    for(int i=0, a, b; i<N-1; i++) {
        scanf("%d %d", &a, &b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    vis[U]=true; dis1[U]=0; dfs1(U); // 1 is takahashi
    memset(vis, false, sizeof(vis));
    vis[V]=true; dis2[U]=0; dfs2(V); // 2 is aoki
    int ans=0;
    for(int i=1; i<=N; i++) {
        if(dis2[i] > dis1[i]) {
            ans = max(ans, dis2[i]);
        }
    }
    printf("%d\n", ans-1);
}

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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main() {
    int H, W;
    cin >> H >> W;
    if (min(H, W) > 1) {
        cout << ((ll)H * W + 1) / 2 << endl;
    } else {
        cout << 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()
import string
abcs = string.ascii_lowercase

ans = 0
for sakaime in range(N):
    cnt = 0
    left = S[:sakaime]
    right = S[sakaime:]
    for alpha in abcs:
        if alpha in left and alpha in right:
            cnt += 1
    ans = max(ans, cnt)
    
print(ans)

Measured memory_bytes: 3772
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}
//}}}

void main() {
  Scanner sc = new Scanner;
  int X, Y;
  sc.scan(X, Y);

  writeln(X + Y / 2);
}


Measured memory_bytes: 256
a=[]
b=[]
for i in range(5):
    a.append(int(input()))
    if str(a[i])[-1]=='0':
        b.append(10)
    else:
        b.append(int((str(a[i])[-1])))
        a[i]=a[i]//10*10+10
print(sum(a)-(10-min(b)))

Measured memory_bytes: 3064
"""
/usr/bin/python3
Info Fields (opt.)
- Type: 
- Keywords:
- Notes:
"""
from sys import stdin, exit

if __name__ == '__main__':

   n=input()
     #  // all = [int(x) for x in input().split(' ')]
   if n == 'ABC':
       print("ARC")
   else:
       print("ABC")


Measured memory_bytes: 9028
#import <stdio.h>

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

    int V[N];
    for (int i = 0; i < N; i++) {
        scanf("%d", &V[i]);
    }

    int count = 0;

    // sort
    for (int i = 0; i < N; i++) {
        int min = i;

        for (int j = i; j < N; j++) {
            if (V[j] < V[min]) {
                min = j;
            }
        }

        if (min != i) {
            int temp = V[min];
            V[min] = V[i];
            V[i] = temp;
            count++;
        }
    }


    // output answer
    for (int i = 0; i < N; i++) {
        printf("%d", V[i]);
        if (i < N - 1) {
            printf(" ");
        } else {
            printf("\n");
        }
    }

    printf("%d\n", count);

    return 0;
}



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

const int MAXH = 101;
const int MAXW = MAXH;

int H, W;
char g[MAXH][MAXW];

int main() {
  while(cin >> H >> W && (H|W)) {
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
        cin >> g[i][j];
      }
    }
    int x, y;
    x = y = 0;
    while(1) {
      char c = g[y][x];
      g[y][x] = '#';
      if(c == '>') ++x;
      if(c == '<') --x;
      if(c == '^') --y;
      if(c == 'v') ++y;
      if(c == '.') {
        cout << x << " " << y << endl;
        break;
      }
      if(c == '#') {
        cout << "LOOP" << endl;
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
 
int main(int argc, char const *argv[])
{
  string w;
  cin >> w;
  bool b = true;
 
  for(char ch = 'a'; ch <= 'z'; ch++)
  {
    int num = 0;
    for(int i = 0; i < w.length(); i++)
    {
      if(w[i] == ch)
        num++;
    }
    if(num % 2 != 0)
    {
      b = false;
      break;
    }
  }
  cout << (b ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <queue>
#include <set>
#include <math.h>
using namespace std;

int MAX_N = 1000;

int main(){
  
  int N;
  double T;
  double A;
  int H[MAX_N];
  /* read input */
  scanf("%d", &N);
  scanf("%lf", &T);
  scanf("%lf", &A);
  for(int i = 0; i < N; i++){
    scanf("%d", H+i);
  }
  
  int palace = 0;
  for(int i = 0; i < N; i++){
    if(fabs(A - T + 0.006*(double)H[i]) < fabs(A - T + 0.006*(double)H[palace])){
      palace = i;
    }
  }
  
  printf("%d", palace+1);
  
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = (a), i##_end_ = (b); i <= i##_end_; ++i)
#define clear(a, b) memset((a), (b), sizeof(a))
typedef long long LL;
int n, k;
int read() {
	int x = 0, flag = 1;
	char ch = getchar();
	while(!isdigit(ch)) {
		if(ch == '-') flag = -1;
		ch = getchar();
	}
	while(isdigit(ch)) {
		x = x * 10 + ch - 48;
		ch = getchar();
	}
	return x * flag;
}
int main() {
#ifdef Qrsikno
	freopen("AGC002_1.in", "r", stdin);
	freopen("AGC002_1.out", "w", stdout);
#endif
	int a = read(), b = read();
	if(a > b) swap(a, b);
	if(a == 0 || b == 0) puts("Zero");
	else
	if(a < 0 && b > 0) 
		puts("Zero");
	else 
		if(a > 0)
			puts("Positive");
		else if(a < 0) 
			if((b - a + 1) & 1) puts("Negative");
			else puts("Positive");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int>>;
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    ll a,b,k;
    cin >> a >> b >> k;
    a = a - k;
    if(a < 0){
        b = b + a;
    }
    if(a < 0) a = 0;
    if(b < 0) b = 0; 
    cout << a << " " <<  b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2;
    int dx=x2-x1, dy= y2-y1;
    int x3,x4,y3,y4;
    x3=x2-dy; y3= y2+dx;
    x4=x1-dy; y4= y1+dx;
    cout<<x3<<' '<<y3<<' '<<x4<<' '<<y4<<endl;
}

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

typedef vector<int> vec;
typedef vector<vec> mat;

const int INF = 1 << 28;

int main() {
    int N, M;
    while (cin >> N >> M, N || M) {
        vec B(N), R(M);
        for (auto &i : B) cin >> i;
        for (auto &i : R) cin >> i;
        
        vector<set<int>> m(N + M);

        for (int i = 0; i < N; i++) {
            for (int j = 0; j < M; j++) {
                if (__gcd(B[i], R[j]) > 1) {
                    m[i].insert(j + N);
                    m[j + N].insert(i);
                }
            }
        }

        int res = 0;

        while (1) {
            int min_i = INF;
            int I;
            for (int i = 0; i < N; i++) {
                if (m[i].size() > 0 && min_i > m[i].size()) {
                    min_i = m[i].size();
                    I = i;
                }
            }

            if (min_i == INF) break;

            int min_j = INF;
            int J;
            for (auto j : m[I]) {
                if (m[j].size() > 0 && m[j].size() < min_j) {
                    min_j = m[j].size();
                    J = j;
                }
            }

            m[I].clear();
            
            if (min_j != INF) {
                res++;
                m[J].clear();
            }
        }

        cout  << res << endl; 
    }

    return 0;
}

Measured memory_bytes: 13932
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=("; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) { REP(i, a.size()) {cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

int main()
{

	ll N;
	cin >> N;
	vec h(N);
	ll maxh = 0;
	REP(i, N) {
		cin >> h[i];
		Max(maxh, h[i]);
	}

	bool is_continue = false;
	ll ans = 0;
	FOR(i, 1, 101) {
		is_continue = false;
		REP(j, N) {
			if (is_continue) {
				if (h[j] < i) is_continue = false;

			} else {
				if (h[j] >= i) {
					ans++;
					is_continue = true;
				}
			}
		}

	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int a, b, c; cin >> a >> b >> c;
	if (a + b + c >= 22)cout << "bust" << endl;
	else cout << "win" << endl;
}

Measured memory_bytes: 256
house = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n=int(input())
for x in range(n):
    a,b,c,d=map(int,input().split())
    house[a-1][b-1][c-1]+=d
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(f' {house[i][j][k]}',end="")
        print()
    if int(i)<3: print("#"*20)


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

ll N;

int main() {
    cin >> N;
    cout << N*(N-1)/2 << endl;
}

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

long long n, res = 0;
string s;

int main() {
  cin >> n >> s;
  for(int i = 0; i + 2 < n; ++i)
    if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
      ++res;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
S = gets.chomp
K = gets.to_i

if S.chars.all? { |ch| ch ==  '1' }
  puts 1
else
  if K > 100
    puts S.chars.find { |ch| ch > '1' }
  else
    if S[0..(K - 1)].chars.all? { |ch| ch == '1' }
      puts 1
    else
      puts S.chars.find { |ch| ch > '1' }
    end
  end
end


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

int main()
{
  int A, B, C, D, E;
  cin >> A >> B >> C >> D >> E;
  int a, b, c, d, e, n, v;
  a = A%10;
  b = B%10;
  c = C%10;
  d = D%10;
  e = E%10;
  int N[5]={a,b,c,d,e};
  n = 0;
  v = A+B+C+D+E;
  sort(N, N+5,greater<int>());
  for(int i=0; i<5;i++){
    if(N[i] != 0) {
      n=N[i];
      v+=10-N[i];
    }
  }
  if (n !=0){
  v -=10-n;
  }
  cout << v <<endl;
}


Measured memory_bytes: 256
#include <cstdio>

int n, m;

int main() 
{
	scanf("%d%d", &n, &m);
	if (n & 1) for (int i = 0; i < m; ++i) printf("%d %d\n", i + 1, n - 1 - i);
	else {
		int k = (m - 1) / 2 + 1;
		for (int i = 0; i < k; ++i) printf("%d %d\n", i + 1, n - i);
		for (int i = k; i < m; ++i) printf("%d %d\n", i + 1, n - i - 1);
	}
	return 0;
}


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

int main(int argc, char const *argv[])
{
  int n;
  cin>>n;
  int s= 0;
  int c=n;
  while (c>0) {
    s+=c%10;
    c/=10;
  }
  if (n%s==0)
  {
    printf("Yes");
  }
  else {
    printf("No");
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n =scan.nextInt();
		int a[]=new int[n+1];
		int b[]=new int[n];
		for(int i=0;i<n+1;i++) {
			a[i]=scan.nextInt();
		}
		for(int i=0;i<n;i++) {
			b[i]=scan.nextInt();
		}
		scan.close();

		long sum=0;
		for(int i=0;i<n;i++) {
			int x=Math.min(b[i],a[i]);
			sum+=x;
			x=Math.min(b[i]-x,a[i+1]);
			a[i+1]-=x;
			sum+=x;
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 65068
/*
Arthor : Ender_zzm
E-mail zzm_ender_wiggin@outlook.com
Blog oi.ender-zzm.pro
*/
#include <bits/stdc++.h>
using namespace std;

template<class T>
inline void read(T &a) {
    register T x = 0, flag = 1;
    register char ch;
    while (!isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), isdigit(ch = getchar()));
    a = x * flag;
}

template <class T>
inline void write(T x) {
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define For(i, a, b) for (int i = (a); i <= (b); i++) 
#define Rep(i, a, b) for (int i = (a); i >= (b); i--) 
#define For_edge(x) for (int i = head[x]; i; i = net[i])
#define mem0(a) memset(a, 0, sizeof a)

int main() {
	int a, b;
	cin >> a >> b;
	cout << a * b;
	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans,a,b,c,d;
unordered_map<ll,ll>mp;
ll solve(ll n)
{
    ll r1,r2,r3;
	if(n==1)
		return d;
	if(n==0)
	return 0;
	if(mp.find(n)!=mp.end())
	    return mp[n];
	r1=n%2;
	r2=n%3;
	r3=n%5;
	ll k1=r1*d+a+solve((n-r1)/2);
	ll k2=r2*d+b+solve((n-r2)/3);
	ll k3=r3*d+c+solve((n-r3)/5);
	ll k4=1e18+1;
	ll k5=1e18+1;
	ll k6=1e18+1;
	if(n>2)
	k4=(2-r1)*d+a+solve((n+2-r1)/2);
	if(n>1)
	k5=(3-r2)*d+b+solve((n+3-r2)/3);
	if(n>1)
	k6=(5-r3)*d+c+solve((n+5-r3)/5);
	mp[n]=min(k1,min(k2,min(k3,min(k4,min(k5,k6)))));
	ll u=n*d;
	if(u>0)
	mp[n]=min(mp[n],n*d);
	return mp[n];
}
int main()
{
	ll t,n;
	cin>>t;
	while(t--)
	{
	     cin>>n>>a>>b>>c>>d;
	     mp.clear();
	     cout<<solve(n)<<endl;
	}
}

Measured memory_bytes: 4156
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

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

	static class TaskA {
		public void solve(int testNumber, Scanner sc, PrintWriter out) {

			int n = sc.nextInt();
			int[] a = sc.nextIntArray(n);

			int ans = 0, prev = -1, conti = 1;
			for (int i = 0; i < n; i++) {
				if (prev == a[i]) {
					conti++;
				} else {
					ans += conti / 2;
					conti = 1;
					prev = a[i];
				}
			}
			ans += conti / 2;

			out.println(ans);

		}

	}

	static class Scanner {
		private final InputStream in;
		private final byte[] buffer;
		private int ptr;
		private int buflen;

		public Scanner(InputStream in) {
			this.in = in;
			this.buffer = new byte[1024];
			this.ptr = 0;
			this.buflen = 0;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) return true;
			else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) return false;
			}
			return true;
		}

		private byte readByte() {
			if (hasNextByte()) return buffer[ptr++];
			return -1;
		}

		private boolean isPrintableChar(byte c) {
			return '!' <= c && c <= '~';
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
				ptr++;
			}
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

		public int nextInt() {
			if (!hasNext()) throw new NoSuchElementException();
			int n = 0;
			boolean minus = false;
			byte b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) throw new NumberFormatException();
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}

	}
}



Measured memory_bytes: 23380
#include <bits/stdc++.h>
#define rep(n) for(int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define dump(x) cout << " " << #x << "=" << x
#define dumpn(x) cout << " " << #x << "=" << x << endl
#define vdump(v) for(size_t T=0; T<v.size(); ++T){cout << " " << #v << "[" << T << "]=" << v[T];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    lint h, w;
    cin >> h >> w;
    
    lint ans = 1e15;
    
    // 縦にカット
    {
        if (w%3 == 0) {
            ans = 0;
        }
        else {
            ans = min(ans, h);
        }
    }
    
    // 横にカット
    {
        if (h%3 == 0) {
            ans = 0;
        }
        else {
            ans = min(ans, w);
        }
    }
    
    auto diff = [](lint a, lint b, lint c) -> lint {
        lint max_s = max(a, max(b, c));
        lint min_s = min(a, min(b, c));
        return max_s - min_s;
    };
    
    // |- カット
    repeat_from_to(i, 1, w-1) {
        lint s1 = h * i;
        lint s2 = (h/2) * (w-i);
        lint s3 = (h-h/2) * (w-i);
        ans = min(ans, diff(s1, s2, s3));
    }
    
    // T カット
    repeat_from_to(i, 1, h-1) {
        lint s1 = i * w;
        lint s2 = (h-i) * (w/2);
        lint s3 = (h-i) * (w-w/2);
        ans = min(ans, diff(s1, s2, s3));
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        
        Scanner sc=new Scanner(System.in);
        int n;
        
        while( !((n=sc.nextInt())==0) ){
            int[] a=new int[n];
            double sum=0.0;
            double sum2=0.0;
            double s;
            for(int i=0; i<n ;i++){
                a[i]=sc.nextInt();
                /*System.out.println(a[i]);*/
                sum+=(double)a[i]/n;
                sum2+=(double)a[i]*a[i]/n;
            }
            /*System.out.println(sum);*/
            /*System.out.println(sum2);*/
            s=(double)Math.sqrt((double)(sum2-sum*sum));
            System.out.println(String.format("%.8f",s));
            
        }
        
    }
}


Measured memory_bytes: 31976
#include<iostream>
using namespace std;
int main(){
   int H,W;
   while(true){
      cin>>H>>W;
      if(H==0&&W==0){
         break;
      }
      for(int i=0;i<H;i++){
         for(int a=0;a<W;a++){
             cout<<"#";
         }
      cout<<"\n";
      }
   cout<<"\n";
   }
} 


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

int main() {
	int m, d;
	string week[] = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
			"Saturday", "Sunday" };
	int day[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	while (cin >> m >> d) {
		if (m == 0)break;
		bool flag=false;
		int mc = 1;
		int cnt = 3;
		while (1) {
			for (int i = 1; i <= day[mc - 1]; ++i, cnt++) {
				if (mc == m && d == i) {
					cout << week[cnt % 7] << endl;
					flag=true;
					break;
				}
			}
			if(flag)break;
			mc++;
		}
	}
	return 0;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, D, N, ans=0;
    vector<int> V(3);
    char tmp1, tmp2;
    string S;
    bool flag=true;
    
    cin >> S ;

    if(S[0]=='9' || S[1]=='9')
    	cout << "Yes"<<endl;
    else
	cout << "No"<<endl;

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;
    // if(A+B==C || B+C==A || C+A==B)
    // 	puts("Yes");
    // else
    // 	puts("No");
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
q = int(input())

def counta(b, e, k):
    B = A[b : e]
    print(B.count(k))


for i in range(q):
    queryi = list(map(int, input().split()))
    counta(queryi[0], queryi[1], queryi[2])



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

using namespace std;
typedef long long ll;

int main() {
  ll N; cin >> N;
  string S; cin >> S;
  ll black = 0, white = 0, ans = N;
  for (ll j=0; j < N; ++j) {
    if (S[j] == '#') {
      black += 1;
    } else {
      white += 1;
    }
  }
  ll tb = 0, tw = 0;
  for (ll j=0; j < N; ++j) {
    ans = min(ans, tb + (white-tw));
    if (S[j] == '#') {
      tb += 1;
    } else {
      tw += 1;
    }
  }
  ans = min(ans, tb + (white-tw));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
	char str[101];
	int n;
	cin>>n>>str;
	int x=0;
	int max=0;
	int i=0;
	while(n--){
		if(str[i]=='I'){
			x++;
		}
		else if(str[i]=='D'){
			x--;
		}
		if(x>max){
			max=x;
		}
		i++;
	}
	cout<<max<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
	char str[200001];
	int i = 0, len;

	scanf("%s", str);

	len = strlen(str);
	while(str[i] != 'A')
		i++;
	while(str[len] != 'Z')
		len--;
	printf("%d", len - i + 1);

	return 0;
}


Measured memory_bytes: 384
N = int(input())
s_list = [input() for _ in range(N)]
end_a_num = 0
start_b_num = 0
same_num = 0
ans = 0
for s in s_list:
    ab_num = s.count('AB')
    ans += ab_num
    if s[-1] == 'A':
        end_a_num+=1
    if s[0]=='B':
        start_b_num+=1
    if s[-1]=='A' and s[0]=='B':
        same_num+=1


ans+= min(end_a_num,start_b_num)
if end_a_num==start_b_num and end_a_num==same_num and end_a_num>0:
    ans-=1


print(ans)

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
using namespace std;

const ll N = 7005;
const ll MOD = 1e9+7;

int main()
{

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	

	ll n,m;
	cin >> n >> m;
	ll s[m+1],c[m+1];
	for(int i =1;i<=m;i++) cin >> s[i] >> c[i];

	for(ll x = 0;x<=999;x++){
		vll dig;
		ll y =x;
		if(y == 0) dig.pb(0LL);
		while(y){
			dig.pb(y%10);
			y/=10;
		}
		if(dig.size() != n) continue;
		bool poss=true;
		reverse(dig.begin(),dig.end());
		for(int j =1;j<=m;j++){
			if(dig[s[j]-1] != c[j]){
				poss=false;break;
			}
		}
		if(poss) {cout << x << "\n";return 0;}
	}
	cout << "-1\n";
	return 0;	
}

Measured memory_bytes: 256
#!/usr/bin/env python3


def main():
    S = input()
    N = len(S)

    mod_count = [0] * 2019
    mod_count[0] = 1
    ssum = 0
    for i, c in enumerate(S[::-1]):
        ssum = (ssum + int(c) * pow(10, i, 2019)) % 2019
        mod_count[ssum] += 1

    print(sum([m * (m - 1) for m in mod_count]) // 2)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9348