akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var a = new int[N];
		for(int i=0;i<N;i++) a[i] = A[i]; 
		
		Array.Sort(a);
		
		long M = (long)N * (N + 1) / 2;
		int l = 0, r = N;
		if(cntSeg(a[l]) > M / 2){
			Console.WriteLine(a[l]);
			return;
		}
		while(r - l > 1){
			int c = (r + l) / 2;
//Console.WriteLine("{0} {1}",a[c],cntSeg(a[c]));
			if(cntSeg(a[c]) <= M / 2){
				l = c;
			} else {
				r = c;
			}
		}
		
		Console.WriteLine(a[r]);
		
	}
	
	
	long cntSeg(int v){
		
		int[] b = new int[N];
		for(int i=0;i<N;i++){
			b[i] = A[i] <= v ? -1 : 1;
		}
		
		int ofs = 200000;
		int MM = 2 * ofs;
		var BT = new BIT(MM);
		
		int tot = 0;
		for(int i=0;i<N;i++){
			tot += b[i];
			BT.Add(tot + 1 + ofs, 1);
		}
		
		long cnt = 0;
		tot = 0;
		for(int i=0;i<N;i++){
			cnt += BT.Sum(tot + ofs);
			tot += b[i];
			BT.Add(tot + 1 + ofs, -1);
		}
		
		return cnt;
	}
	
	
	
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}



class BIT{
	int MM;
	int n;
	long[] bit;
	public BIT(int n_){
		n = n_;
		MM = 1 << 2;
		while(MM < n * 2) MM <<= 1;
		bit = new long[MM + 1];
	}
	//1-origin!!
	public void Add(int i, long x){
		while(i <= n){
			bit[i] += x;
			i += (i&-i);
		}
	}
	
	// i=>sum(a_1,...,a_i)
	// i=0 -> return 0;
	public long Sum(int i){
		long s = 0;
		while(i > 0){
			s += bit[i];
			i -= (i&-i);
		}
		return s;
	}
}




Measured memory_bytes: 28124
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {
			var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long H = inputArray[0];
			long W = inputArray[1];

			_maryokuInfo = new List<long[]>();

			for (int i = 0; i <= 9; i++) {
				var inparr = retreiveLongArray();
				_maryokuInfo.Add(inparr);
			}
			//各数字を変えるのに必要な魔力を求める

			var changeMaryoku = new Dictionary<long, long>();

			for (int i = 0; i <= 9; i++) {

				if (i == 1) {
					continue;
				}
				var usedNum = new Dictionary<long, bool>();
				for (int j = 0; j <= 9; j++) {
					usedNum.Add(j, false);
				}
				usedNum[i] = true;
				usedNum[1] = true;

				_minMaryoku = int.MaxValue;
				DFS(i,0, usedNum);

				changeMaryoku.Add(i, _minMaryoku);
			}
			
			var wallCount = new Dictionary<int, long>();
			for (int j = 0; j <= 9; j++) {

				if (j == 1) {
					continue;
				}
				wallCount.Add(j, 0);
			}

			//登場回数を数える
			for (int i = 0; i < H; i++) {
				var line = retreiveLongArray();

				for (int j = 0; j < W; j++) {
					//-1と1意外の数を数える
					int num = (int)line[j];
					if (num != -1 && num != 1) {
						wallCount[num]++;
					}
				}
			}

			//最小魔力の計算
			long needMaryoku = 0;
			for (int i = 0; i <= 9; i++) {

				if (i == 1) {
					continue;
				}
				needMaryoku += wallCount[i] * changeMaryoku[i];
			}

			Console.WriteLine(needMaryoku);

		}

		/// <summary>
		/// DFSでiから1にするための魔力を求める
		/// </summary>
		/// <param name="currentNum"></param>
		/// <param name="maryokuTotal"></param>
		/// <param name="usedNum"></param>
		private static void DFS(int currentNum, long maryokuTotal, Dictionary<long, bool> usedNum) {
			//1にするために必要な魔力
			var maryokuFor1 = _maryokuInfo[currentNum][1];

			if(_minMaryoku > (maryokuTotal + maryokuFor1)) {
				_minMaryoku = maryokuTotal + maryokuFor1;
			}

			usedNum[currentNum] = true;
			for (int i = 0; i <= 9; i++) {
				if (!usedNum[i]) {
					var maryoku = _maryokuInfo[currentNum][i];
					//次の数値にするための魔力が、1にするための魔力を上回っている場合、可能性なし
					if(maryoku >= maryokuFor1) {
						continue;
					}
					DFS(i, maryokuTotal + maryoku, usedNum);
				}
			}
			usedNum[currentNum] = false;
			return;
		}


		//その数字を1にするのに必要な最小魔力
		private static long _minMaryoku;

		//数字を変えるために必要な魔力の情報
		private static List<long[]> _maryokuInfo;

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 15580
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    rep(i, 4) {
        if (S[i] == S[i + 1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;

    return 0;
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S; cin >> S;
    if(S[2] == S[3] && S[4] == S[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main()
{
  int N,M,sum,n=0;
  int w[1500],h[1500],W[1000000]={},H[1000000]={};
 
  while(1){
    cin>>N>>M;
    if(N==0&&M==0)break;
    for(int i=0;i<N;i++)cin>>h[i];
    for(int i=0;i<M;i++)cin>>w[i];
    sum=0;
    for(int i=0;i<N;i++){
      for(int j=i;j<N;j++){
        n+=h[j];
    H[n]++;
      }
      n=0;
    }
    for(int i=0;i<M;i++){
      for(int j=i;j<M;j++){
        n+=w[j];
    W[n]++;
      }
      n=0;
    }
    for(int i=0;i<1000000;i++){
      sum+=H[i]*W[i];
      H[i]=0;W[i]=0;
    }
    cout<<sum<<endl;
  }
  return 0;
}

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

int main() {
	int n;	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)	cin >> a[i];
	for (int i = 1; i < n; i++) {
		if (a[i - 1] == a[i]) {
			a.erase(a.begin() + i);
			n--;
			i--;
		}
	}
	int ret = 1;
	bool updown = (a[0] < a[1]);
	for (int i = 2; i < n; i++) {
		if (updown&&a[i - 1] > a[i]) {
			i++;
			ret++;
			if (i < n)	updown = (a[i - 1] < a[i]);
		}
		else if (!updown&&a[i - 1] < a[i]) {
			i++;
			ret++;
			if (i < n)	updown = (a[i - 1] < a[i]);
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

long long int getgcd(long long int m, long long int n)
{
	if(n == 0) return m;
	else return getgcd(n, m % n);
}

int main()
{
	long long int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(a == c || b == d){
		cout << 0 << endl;
		return 0;
	}
	long long int x = abs(c - a);
	long long int y = abs(d - b);
	long long int gcd = getgcd(max(x, y), min(x, y));
	cout << (max(x, y) / gcd + min(x, y) / gcd - 1) * gcd << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int n,p[11111],i;
scanf("%d",&n);
int m[111],flag=0,k=0;
if(n<0){
n=-n;
flag=1;
}
for(i=0;i<11111;i++)
p[i]=0;
for(i=0;i<111;i++)
m[i]=0;
int t=0;
while(n!=0){
m[k]=n%4;
n=n/4;
k++;
}
for(i=0;i<k;i++){
if(flag==1){
if(m[i]==3){
p[t]++;
p[t+2]++;
p[t+3]++;
}
if(m[i]==2)
p[t+1]++;
if(m[i]==1){
p[t]++;
p[t+1]++;
}
}
else{
if(m[i]==3){
p[t]++;
p[t+1]++;
p[t+2]++;
}
if(m[i]==2){
p[t+1]++;
p[t+2]++;
}
if(m[i]==1)
p[t]++;
}
t+=2;
}
for(i=0;i<1111;i++){
while(p[i]>=2){
p[i]-=2;
p[i+1]++;
p[i+2]++;
}
if(p[i]==1)
t=i;
}
for(i=t;i>=0;i--)
printf("%d",p[i]);
printf("\n");
return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	
	int S,h,m;
	
	scanf("%d",&S);
	
	h=S/3600;
	S-=h*3600;
	
	m=S/60;
	S-=m*60;
	
	printf("%d:%d:%d\n",h,m,S);
	
	return 0;
}

Measured memory_bytes: 592
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = ""; tmp = 0; cnt = 0; ansli = []; tmpli = []; candili = []; stillset = set()
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def inp(): return int(sys.stdin.readline())
def st(): return input()
def s_list(): return list(input())
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]#NumberGrid
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def grid(n): return [s_list() for _ in range(n)]

# LCS
def main():
    s = st()
    t = st()
    slen = len(s)
    tlen = len(t)
    # まず，長さを求める
    # dp[i][j]=(sをi文字目、tをj文字目までみた時の最長共通部分列の長さ)とする
    dp = [[0 for j in range(tlen + 1)] for i in range(slen + 1)]
    # slenはSの長さ、tlenはTの長さとする
    for i in range(1, slen + 1):
        for j in range(1, tlen + 1):
            if s[i - 1] == t[j - 1]:
                dp[i][j] = dp[i - 1][j - 1] + 1  # この文字は使ったほうがいい
            else:
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])  # どっちかの最後の1文字は使わない

    # dp[slen][tlen]が求める長さ

    # 文字復元
    length = dp[slen][tlen]
    i = slen
    j = tlen
    ans = ""
    while length > 0:
        if s[i - 1] == t[j - 1]:
            ans += s[i - 1]
            i -= 1
            j -= 1
            length -= 1
        elif dp[i][j] == dp[i - 1][j]: # i文字目が無くても同じ，i文字目は使わない
            i -= 1
        else:
            j -= 1
    print(ans[::-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 125656
#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() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> a[i][j];
            a[i][j] %= 2;
        }
    }

    int b = 0, sy, sx, cnt = 0;
    vector<tuple<int, int, int, int>> ans;
    for (int i = 0; i < h; ++i) {
        if (i % 2 == 0) {
            for (int j = 0; j < w; ++j) {
                if (b == 1) {
                    ans.push_back(make_tuple(sy, sx, i + 1, j + 1));
                    sy = i + 1;
                    sx = j + 1;
                    ++cnt;
                }

                if (a[i][j] == 1) {
                    if (b == 0) {
                        sy = i + 1;
                        sx = j + 1;
                    }
                    b ^= 1;
                }
            }
        } else {
            for (int j = w - 1; j >= 0; --j) {
                if (b == 1) {
                    ans.push_back(make_tuple(sy, sx, i + 1, j + 1));
                    sy = i + 1;
                    sx = j + 1;
                    ++cnt;
                }

                if (a[i][j] == 1) {
                    if (b == 0) {
                        sy = i + 1;
                        sx = j + 1;
                    }
                    b ^= 1;
                }
            }
        }
    }

    cout << cnt << endl;
    for (const auto &k : ans) {
        int x1, y1, x2, y2;
        tie(y1, x1, y2, x2) = k;
        cout << y1 << " " << x1 << " " << y2 << " " << x2 << endl;
    }
    return 0;
}

Measured memory_bytes: 5232
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  string s; cin >> s;
  int sz = s.size();
  char mid = s[sz/2];
  int left = sz/2 - 1;
  int right = (sz-1) - left;
  int ans = (sz+1)/2;
  rep(i,sz/2) {
    if (s[left-i] != mid || s[right+i] != mid) break;
    ++ans;
  }
  cout << ans << endl;
  return 0;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")
int table[365][26];
int main()
{
		int D;
	cin >> D;
	vec(C);
	vec(Las);
	fx(26) {
		vecp(C);
		Las.push_back(0);
	}

	fx(D) {
		fy(26) {
			cin >> table[x][y];
		}
	}

	vec(T);
	srand((time(NULL)));
	fx(D) {
		pb(T, rand() % 26 + 1);
	}
	ll sum = 0;
	vector<int> S(D,0);

	int preDay = 0;
	fx(500) {
		int d;
		 
		 int dif = INT_MAX, ind = 0;
		 fw(D-1) {
			 if (S[w+1]-S[w]<dif) {
				 ind = w + 1;
				 dif = S[w + 1] - S[w];
			 }
		 }
		 d = ind;
		 if (d==preDay) {
			 d = (d + 1) % D + 1;
		 }
		 preDay = d;

		 for (int q = 1; q <= 26; q++) {
			 int pre = T[d - 1];
			 if (q == pre) { continue;}
			 T[d - 1] = q;
			 ll ans = 0;

			 fy(26) {
				 Las[y] = 0;
			 }
			 fw(D) {

				 ans += table[w][T[w] - 1];
				 Las[T[w] - 1] = w + 1;
				 fz(26) {
					 ans -= C[z] * (w + 1 - Las[z]);
				 }
				 S[w] = ans;
			 }
			 if (ans > sum) {
				 sum = ans;
			 }
			 else {
				 T[d - 1] = pre;
			 }
		 }
	
	}

	fx(D) {
		ce(T[x])
	}

    return 0;
}



Measured memory_bytes: 3660
// Problem : B - Trained?
// Contest : AtCoder - AtCoder Beginner Contest 065
// URL : https://atcoder.jp/contests/abc065/tasks/abc065_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
int main() 
{
	// && has higher precedence than ||
	ios_base::sync_with_stdio(0); cin.tie(0);    
	int N;
	cin>>N;
	vi v(N),flag(N);
	F0R(x,N)
	{
		int nb;
		cin>>nb;
		v[x]=nb-1;
	}
	int S=0,c=0;
	while(S!=1)
	{
		if(flag[S])
			break;
		flag[S]=1;
		S=v[S];
		c++;
	}
	if(S==1)
		cout<<c<<nl;
	else
		cout<<-1<<nl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3972
#include <bits/stdc++.h>
using i64 = long long;

template <class T>
std::vector<T> getDivisors(T n) {
    std::vector<T> ret;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    std::sort(ret.begin(), ret.end());
    return ret;
}

i64 f(i64 b, i64 n) {
    i64 ret = 0;
    while (n) {
        ret += n % b;
        n /= b;
    }
    return ret;
}

int main() {
    i64 n, s;
    std::cin >> n >> s;

    for (i64 i = 2; i * i <= n; i++) {
        if (f(i, n) == s) {
            std::cout << i << std::endl;
            return 0;
        }
    }

    auto ds = getDivisors(n - s);
    for (auto d : ds) {
        auto b = d + 1,
            d1 = (n - s) / d,
            d2 = s - d1;
        
        if (b > n / b && d1 < b && d2 < b && d2 >= 0) {
            std::cout << b << std::endl;
            return 0;
        }
    }

    if (n == s) {
        std::cout << n + 1 << std::endl;
    } else {
        std::cout << -1 << std::endl;
    }

    return 0;
}


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

int main()
{
    int n;
    std::cin >> n;
    int ar[n], ans = 0;
    int tmp = n + 1;
    for (int i = 0; i < n; i++) { std::cin >> ar[i]; }
    for (int i = 0; i < n - 1; i++)
    {
        if (ar[i] == ar[i + 1])
        {
            ans++;
            ar[i + 1] = tmp++;
        }
    }
    std::cout << ans << std::endl;
    return 0;
}

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

int main(){
    int n, m, cnt=0;
    string ans="No";
    cin >> n >> m;
    vector<int> a(n);
    for(int i=0; i<n; ++i){
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<int>());
    int sum = accumulate(a.begin(),a.end(),0);
    int k = sum/(4*m);

    for(int j=0; j<n; ++j){
        if(sum%(4*m)!=0 && a[j]>k){
            cnt++;
        }
        else if(sum%(4*m)==0 && a[j]>=k){
            cnt++;
        }
        else if(a[j]<k) break;
    }

    if(cnt>=m){
       ans="Yes"; 
    } 

    cout << ans << endl;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 7;
int tab[MAX];
int dp[MAX];
int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> tab[i];
    }
    dp[0] = 1e9;
    for(int i = 2; i <= n; i++)
        dp[i] = min(dp[i-2] + abs(tab[i-2] - tab[i]),
                    dp[i-1] + abs(tab[i-1] - tab[i]));
    cout << dp[n] << '\n';
    return 0;
}


Measured memory_bytes: 1024
// AtCoder165 C

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include <memory.h>
#include <malloc.h>
#include <stdlib.h>

// qsortで用いる比較用関数．*a<*bならaが先になる．
int compare(const void* a, const void* b) {
    return *(int*)a - *(int*)b;
}

int main() {

    int n,i;
    //int* a;  動的メモリの先頭アドレス用のポインタ
    long long int x;
    long long int yokin = 100;
    scanf("%lld", &x);
    
    // printf("%f",((log10(x)-2)/log10(1.01))+1);
    for(i=0;yokin < x;i++){
        yokin *= 1.01;
    }

    printf("%d",i);

    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(s) int(s.size())

typedef long long ll;
typedef unsigned long long ull;

using namespace std;




int main() {FIN;
    int n,k;
    cin>>n>>k;
    int a[k];
    memset(a, 0, sizeof(a));
    int pos = 0;
    fore(i,0,n){
        a[pos]++;
        pos++;
        pos %= k;
    }
    int maxi = -1;
    int mini = 1e9+10;
    fore(i, 0, k){
        maxi = max(a[i], maxi);
        mini = min(a[i], mini);
    }
    cout<<maxi-mini<<"\n";
}


Measured memory_bytes: 256
def cakes_and_donuts(N: int) -> bool:
    while N > 0:
        if N % 4 == 0:
            return True
        N -= 7

    return N == 0  # <=> N % 7 == 0


if __name__ == "__main__":
    N = int(input())
    yes = cakes_and_donuts(N)
    print('Yes' if yes else 'No')


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<string,int>> vpsi;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////

int n;
cin >> n;
int ans=0;
vi a(n),b(n),c(n-1);
rep(i,n)cin >> a[i];
rep(i,n){
    cin >> b[i];
    ans+=b[i];
}
rep(i,n-1)cin >> c[i];
rep(i,n-1){
    if(a[i]+1==a[i+1])ans+=c[a[i]-1];
}
fin(ans);

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    int a,b;
    while(scanf("%d%d",&a,&b)==2)
    {   double x;
        int c=10,e=b;
        while(b=b/10)
            c*=10;
        int d=a*c+e;
        x=sqrt(d);
        if((int)(10*x)%10==0)
            printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
	int n;
	int a[20];
	int w=0;
	scanf("%d",&n);
	int c=n;
	while(n!=0)
	{
		a[w++]=n%10;
		n=n/10;
	}
	int s;
	for(int i=0;i<w;i++)
	{
		s+=a[i];
	}
	if(c%s==0)
	printf("Yes\n");
	else
	printf("No\n");
	
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

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

  lint n, k, q;
  cin >> n >> k >> q;
  vector<lint> A(q), ans(n);
  rep(i, q) cin >> A[i];
  rep(i, n) ans[i] = k;

  rep(i, q) { ans[A[i] - 1]++; }
  rep(i, n) ans[i] -= q;

  rep(i, n) {
    if (0 < ans[i])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int unsigned long long
#define endl "\n"
using namespace std;

int32_t main() {
  ios;
  int t = 1;
  // cin>>t;
  while(t--) {
    int a,b,k;
    cin>>a>>b>>k;
    if(k <= a) {
      a-=k;
    } else {
      k-=a;
      a = 0;
      if(k <= b)
        b-=k;
      else
        b = 0;
    }
    cout<<a<<" "<<b;
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>

int main(void) {
	int n, ans;
	int nu1[4], nu2[4];
	int i, j;
	int blow = 0, hit = 0;
	
	for(;;) {
		
		scanf("%d %d", &n, &ans);
		if(n == 0 && ans == 0)
			break;
		
		for(i = 0; i < 4; i++) {
			nu1[i] = n % 10;
			nu2[i] = ans % 10;
			n /= 10;		ans /= 10;
		}
		
		for(i = 0; i < 4; i++) {
			
			if(nu1[i] == nu2[i]) {
				hit++;
				continue;
			} else {
				
				for(j = 0; j < 4; j++) {
					
					if(nu1[i] == nu2[j]) {
						blow++;
						break;
					}
				}
			}
		}
		
		printf("%d %d\n", hit, blow);
		hit = 0;		blow = 0;
	}
	
	return 0;
}

Measured memory_bytes: 600
#include<cstdio>
int n,m;
int main()
{
    while(~scanf("%d%d",&n,&m))
    {
        if(n<=0&&m>=0)puts("Zero");
        else if(n>0)puts("Positive");
        else if((m-n+1)%2)puts("Negative");
        else puts("Positive");
    }
}


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

using namespace std;

int main(){
    int w,h,x,y;
    cin>>w>>h>>x>>y;
    cout<<(double)w*h/2<<" ";
    if(w==x*2&&h==y*2)cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}

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

using namespace std;

bool isValid(int n) {
    return n >= 1 && n <= 9;
}

int main() {
    int a, b;
    cin >> a >> b;
    
    if (isValid(a) && isValid(b)) {
        cout << a * b << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{	
	int a[5];
	for(int i=0;i<5;i++)cin>>a[i];
	if(a[2]+a[4]<=a[0]&&a[2]-a[4]>=0&&a[3]+a[4]<=a[1]&&a[3]-a[4]>=0)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;	
}


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

int main()
{
	int n;
	cin >> n;
	char a[n] ,b[n], c[n];
	cin >> a >> b >> c;

	int ans = 0;
	for(int i = 0; i < n; i++){
		if(a[i] != b[i] && b[i] != c[i] && c[i] != a[i]){
			ans += 2;
		}else if(a[i] == b[i] && b[i] == c[i]){
		}else{
			ans++;
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
# solution
import io

nim,mike = map(int,input().split())
array = list(map(int,input().split()))
arrays = []
min_a = float("inf")
for a in array:
   min_a = min(a, min_a)
   arrays.append(min_a)
array2 = []
for a,b in zip(array, arrays):
   array2.append(a-b)
array2 = sorted(array2)
print(array2.count(array2[-1]))

Measured memory_bytes: 14252
using System;
using System.Collections.Generic;
using System.Linq;
using static Scanner;

class Program
{
    static void Main() => new Program().Solve();

    public void Solve()
    {
        int n = ReadInt();
        int x = ReadInt();
        int t = ReadInt();
        Console.WriteLine((n + x - 1) / x * t);
    }
}

static class Scanner
{
    static Queue<string> que = new Queue<string>();
    public static string Read() { if (!que.Any()) foreach (var s in Console.ReadLine().Split()) que.Enqueue(s); return que.Dequeue(); }
    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());
    public static decimal ReadDecimal() => decimal.Parse(Read());
    public static IEnumerable<string> Read(long n) { for (long i = 0; i < n; i++) yield return Read(); }
    public static IEnumerable<int> ReadInt(long n) => Read(n).Select(int.Parse);
    public static IEnumerable<long> ReadLong(long n) => Read(n).Select(long.Parse);
    public static IEnumerable<double> ReadDouble(long n) => Read(n).Select(double.Parse);
    public static IEnumerable<decimal> ReadDecimal(long n) => Read(n).Select(decimal.Parse);
}


Measured memory_bytes: 28272
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#define int64 long long

int64 aa[200000];
int64 memo[200000] = {0};
int64 flag = 0;

int64 go(int64 kk, int64 here)
{
	if(memo[here] && !flag)
	{
		int64 loop = memo[here] - kk;
		flag = 1;
		int64 next = (kk % loop) - 1;
		if(next < 0)
		{
			next += loop;
		}
		return go(next, aa[here]);
	}
	else
	{
		memo[here] = kk;
		if(kk == 0)
		{
			return here;
		}
		else
		{
			return go(kk - 1, aa[here]);
		}
	}
}

int main()
{
	int64 nn, kk;
	scanf("%lld %lld", &nn, &kk);
	for(int64 ii = 0;ii < nn;ii++)
	{
		scanf("%lld", &aa[ii]);
		aa[ii]--;	//街の番号と配列の添字を合わせる
	}
	int64 ans = go(kk, 0);
	ans++;
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    int sum=0;
    for(int i=1;i<=n;i++){
        int t=i;
        int fn=t%10;
        while(t>0){
            t/=10;
            fn+=t%10;
        }
        if(fn>=a&&fn<=b)sum+=i;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int sum(int n) {
    int ret = 0;
    for (int i = 1; i <= n; i++) {
        ret += i;
    }
    return ret;
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<double> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p.at(i);
    }

    for (int i = 0; i < n; i++) {
        int tmp = (int)p.at(i);
        p.at(i) = sum(tmp);
        p.at(i) /= tmp;
    }
    double max = 0;
    for (int i = 0; i < k; i++) {
        max += p.at(i);
    }
    double sum_e = max;
    for (int i = k; i < n; i++) {
        sum_e = sum_e - p.at(i-k) + p.at(i);
        if (max < sum_e) {
            max = sum_e;
        }
    }

    printf("%.10f\n", max);
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	private static final int LEN = 6;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] s = br.readLine().split("");
		if (s != null) {
			if (s.length == LEN) {
				System.out.println(s[2].equals(s[3]) && s[4].equals(s[5]) ? "Yes" : "No");
			}
		}
	}
}


Measured memory_bytes: 21332
H, W, D = map(int, input().split())
px = [0] * (H*W+1)
py = [0] * (H*W+1)
d = [0] * (H*W+1)

for y in range(H):
    line = list(map(int, input().split()))
    for x, A in enumerate(line):
        px[A] = x
        py[A] = y

for i in range(D+1, H*W+1):
    d[i] = d[i-D] + abs(px[i]-px[i-D]) + abs(py[i]-py[i-D])

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    print(d[R]-d[L])


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

int main() {
  long long N;
  cin >> N;
  long long L0 = 2, L1 = 1;

  long long Li, L_i1 = L1, L_i2 = L0;
  if (N == 1) Li = L1;
  for (long long i = 1; i < N; i++) {
    Li = L_i1 + L_i2;
    L_i2 = L_i1;
    L_i1 = Li;
  }
  cout << Li << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
void write(int x){
    if(x<0){putchar('-');x=-x;}	
    if(x>9)write(x/10);putchar(x%10+'0');
}
void read(int &x){
	int f=1;x=0;char s=getchar();
	while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
	while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
	x*=f;
}
int main(){
	int a,b,c;
	read(a);
	register int i,ans;
	for(i=1;i<=a;++i){
		read(b);
		read(c);
		ans+=c-b+1;
	}
	write(ans);
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

///////////////////////////////////////////////////////////////////////////////////////



int main() {
	ll a, b, x, ans = 0;
	cin >> a >> b >> x;
	if (a == 0) ans = (b / x) + 1;
	else {
		ans += (b / x);
		ans -= ((a - 1) / x);
	}
	wrln(ans);
	return 0;
}


Measured memory_bytes: 384
import java.util.Comparator;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());

		Map<String, Map<Integer, Integer>> cities = new TreeMap<>();
 		for(int i = 0; i < N; i++) {
 			String city = sc.next();
 			int score = Integer.parseInt(sc.next());
			if(!(cities.containsKey(city))) {
				cities.put(city, new TreeMap<>(Comparator.reverseOrder()));
			}
			cities.get(city).put(score, i + 1);
		}
 		sc.close();

 		 for (final Map.Entry<String, Map<Integer, Integer>> e : cities.entrySet()) {
 			 for (Map.Entry<Integer, Integer> e2 : e.getValue().entrySet()) {
 				 System.out.println(e2.getValue());
 			}
 		}

	}
}

Measured memory_bytes: 22732
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int a,b;
    string s;
    cin >> a >> b >> s;
    bool flag = true;
    REP(i,a){
        if(s[i]<'0'||'9'<s[i]){
            flag = false;
        }
    }
    if(s[a]!='-')flag = false;
    REP(i,b){
        if(s[i+a+1]<'0'||'9'<s[i+a+1]){
            flag = false;
        }
    }
    if(flag){
        put("Yes");
    }else{
        put("No");
    }
    return 0;
}


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

using namespace std;

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

    for (int i = 1; i <= n; i++) {
        string num_str = to_string(i);
        int sum = 0;
        for (int j = 0; j < num_str.size(); j++) {
            sum = sum + (int)(num_str[j] - '0');
        }

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

    cout << ans;
}

Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <limits>
#include <cmath>


using namespace std;

//  ||
// \

int main() {
	string s;
	cin >> s;
	if(s <= "2019/04/30") {
		cout << "Heisei" << endl;
	}
	else {
		cout << "TBD" << endl;
	}

    return 0;
}

Measured memory_bytes: 256
"use strict";

const main = arg => {
  const input = arg.trim().split("\n");

  const A = parseInt(input[0].split(" ")[0]);
  const B = parseInt(input[0].split(" ")[1]);
  console.log(A * B);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

Measured memory_bytes: 29620
unittest
{
	assert( [ "0 0 0 1" ].parse.expand.solve == "-1 1 -1 0" );
	assert( [ "2 3 6 6" ].parse.expand.solve == "3 10 -1 7" );
	assert( [ "31 -41 -59 26" ].parse.expand.solve == "-126 -64 -36 -131" );
}



import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto xyxy = input.front.split.to!( long[] );
	return tuple( xyxy );
}

auto solve( long[] xyxy )
{
	auto xy1 = xyxy[ 0 .. 2 ];
	auto xy2 = xyxy[ 2 .. $ ];
	
	// xy1からxy2への距離を計算
	auto dx12 = xy2[ 0 ] - xy1[ 0 ];
	auto dy12 = xy2[ 1 ] - xy1[ 1 ];
	
	// xy2からxy3への距離を計算（反時計回りで90度回転）
	auto dx23 = -dy12;
	auto dy23 = dx12;
	
	// xy3の座標を計算
	auto xy3 = [ xy2[ 0 ] + dx23, xy2[ 1 ] + dy23 ];
	
	// xy3からxy4への距離を計算（反時計回りで90度回転）
	auto dx34 = -dy23;
	auto dy34 = dx23;
	
	// xy4の座標計算
	auto xy4 = [ xy3[ 0 ] + dx34, xy3[ 1 ] + dy34 ];
	
	return ( xy3 ~ xy4 ).map!( to!string ).join( " " );
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, M) = listOfLong()
    val ans =
        if (N == 1L && M == 1L) 1L
        else if (N == 1L && M > 1) M - 2
        else if (N > 1 && M == 1L) N - 2
        else (N - 2) * (M - 2)
    println(ans)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt(d: Int = 0) = listOfString().map { it.toInt() + d }
fun listOfLong(d: Long = 0) = listOfString().map { it.toLong() + d }


Measured memory_bytes: 37864
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#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;
  set<int> st[3];
  for(int i = 0;i < 3;i++){
    int x;
    cin >> x;
    for(int j = 0;j < x;j++){
      int t;
      cin >> t;
      st[i].insert(t);
    }
  }
  int ans = 0;
  for(int i = 1;i <= N;i++){
    if(((!st[0].count(i)) && st[2].count(i)) || (st[1].count(i) && st[2].count(i))){
      ans++;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3104
import collections
n = int(input())
x = map(int, input().split())
a_list = list(x)

# n = 5
# a_list = [1,1,3,3]

r_list = collections.Counter(a_list)
y = []
for i in range(1,(n+1)):
    if (i in r_list):
        y.append(r_list[i])
    else:
        y.append(0)

r_list2 = map(str, y)
r_list2 = list(r_list2)
ans = "\n".join(r_list2)
print(ans)

# r_list = map(a_list.count, range(n+1))
#r_list = list(r_list_v)

Measured memory_bytes: 44192
#include <stdio.h>

int main(void)
{
    int x, y;

    while(1) {
        scanf("%d", &x);
        if(x == 0) break;
        y = 1000-x;
        int cnt[6] = {0};
    
        while(y > 0) {
            if(y >= 500) {
                y -= 500;
                cnt[0]++;
            } else if(y >= 100) {
                y -= 100;
                cnt[1]++;
            } else if(y >= 50) {
                y -= 50;
                cnt[2]++;
            } else if(y >= 10) {
                y -= 10;
                cnt[3]++;
            } else if(y >= 5) {
                y -= 5;
                cnt[4]++;
            } else if(y >= 1) {
                y -= 1;
                cnt[5]++;
            } else {
                break;
            }
        }
    
        printf("%d\n", cnt[0]+cnt[1]+cnt[2]+cnt[3]+cnt[4]+cnt[5]);
    }

    return (0);
}

Measured memory_bytes: 1028
import math

while True:
    x = int(input())
    h = int(input())
    if x == 0 and h == 0:
        break

    x = float(x)
    h = float(h)
    y = math.sqrt(h**2 + x**2/4.0)
    print(x**2 + 2.0*x*y)



Measured memory_bytes: 5668
from collections import defaultdict
n = int(input())
S = [input() for _ in range(n)]
d = defaultdict(int)
for s in S:
    d[s] += 1
m = max(d.values())
items = d.items()
a = sorted([c[0] for c in items if c[1] == m])
[print(i) for i in a]


Measured memory_bytes: 107472
#include <bits/stdc++.h>
using namespace std;
//解説AC　難しい
int main() {
  int n; cin >>n;
  vector<long long>a(n+1);
  map<long long ,long long>mp;
  for(int i=0;i<n;i++){
    cin>>a[i];
    mp[a[i]]++;
  }
  if(mp.size()==1){
    if(a[0]==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
  }else if(mp.size()==2){
    long long atai=0;
    long long kazu=0;
    auto begin=mp.begin(),end=mp.end();
    for(auto iter=begin;iter!=end;iter++){
      atai=iter->first;
      kazu=iter->second;
      if(atai==0&&kazu*3==n){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
    cout<<"No"<<endl;
    return 0;
  }else if(mp.size()==3){
    long long atai=0;
    long long kazu=0;
    vector<long long>b(3,0);
    int count =0;
    auto begin=mp.begin(),end=mp.end();
    for(auto iter=begin;iter!=end;iter++){
      atai=iter->first;
      kazu=iter->second;
      b[count]=atai;
      count++;
      if(kazu*3!=n){
        cout<<"No"<<endl;
        return 0;
      }
    }
    if((b[0]^b[1]^b[2])==0){
      cout<<"Yes"<<endl;
      return 0;
    }else{
      cout<<"No"<<endl;
      return 0;
    }
  }else{
    cout<<"No"<<endl;
    return 0;
  }
}

Measured memory_bytes: 8652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;

public class Main {

    public static void main(String args[]) throws IOException {
    	
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] inputArray = br.readLine().split(" ");
        
        Stack<Integer> stack = new Stack<Integer>();
        int a = 0;
        int b = 0;
        
        for (int i = 0; i < inputArray.length; i++) {
            if (inputArray[i].equals("+")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b + a);
                continue;
            }
            
            if (inputArray[i].equals("-")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b - a);
                continue;
            }
            
            if (inputArray[i].equals("*")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b * a);
                continue;
            }
            
            stack.push(Integer.parseInt(inputArray[i]));
        }
        System.out.println(stack.pop());
    }
}


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

int main() {
    int n,k,q;
    cin >> n >> k >> q;
    vector<int> ans(n,k);

    int a;
    rep(i,q) {
        cin >> a;
        ans[a-1]++;
    }

    rep(i,n) {
        if (ans[i] > q) {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
        
    }
    return 0;
}

Measured memory_bytes: 3728
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)

int main()
{
    long long n;
    long long a,b;
    cin >> n >> a >> b;
    long long ans = (n / (a + b) * a);
    long long rest = (n % (a + b));
    if (rest <= a)
    {
        ans += rest;
    }else
    {
        ans += a;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n=int(input())
s=input().split()
num=[]
for i in range(n):
    num.append(0)
for i in range(n):
    num[int(s[i])-1]+=1
c=0
for i in range(n):
    c+=(num[i]*(num[i]-1))//2
for i in range(n):
    print(c-num[int(s[i])-1]+1)

Measured memory_bytes: 22300
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n;
	string s;
	cin >> n;
	cin >> s;
	for (int i = 0; i < s.size(); i++)
	{
		s[i] += n;
		if (int(s[i]) > 90)
		{
			s[i] -= 26;
		}
	}
	cout << s << endl;
	return  0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int ans=inf;
bool b[400];
int n,m;
int a[400][400];

void f(){
 
  map<int,int> mp;

  rep(i,n){
    rep(j,m){
      if(!b[a[i][j]]) continue;
      mp[a[i][j]]++;
      break;
    }
  }
  int ret=-1,res=-1;

  for(auto s :mp){
    if(s.S>ret){
      ret=s.S;
      res=s.F;
    }
  }
  
//  cout<<ret<<' '<<res<<endl;
  if(ret==-1) return;

  ans=min(ans,ret);
  b[res]=false;
  f();
}



main(){
  cin>>n>>m;
  rep(i,n){
    rep(j,m){
      cin>>a[i][j];
    }
  }

  rep(i,m+1){
    b[i]=true;
  }

  f();

  cout<<ans<<endl;
}


Measured memory_bytes: 3584