akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
namespace Lesson04
{
    class MainClass
    {

        public static List<string[]> getinputdata (){

            List<string[]> list_temp = new List<string[]>();
            string strdata = Console.ReadLine ();

            while (strdata!=null) {

                string[] s_temp = strdata.Split (' ');

                list_temp.Add (s_temp);

                strdata = Console.ReadLine ();

            }

            return list_temp;
        }


        public static void Main (string[] args)
        {
            List<string[]> arr_result = new List<string[]>();
            arr_result = getinputdata ();

            int a = int.Parse(arr_result[0][0]);
            int b = int.Parse(arr_result[0][1]);

            if (a == b)
            {
                Console.WriteLine("a == b");
            }else if (a > b)
            {
                Console.WriteLine("a > b");
            }else if (a < b)
            {
                Console.WriteLine("a < b");
            }



        }
    }
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

ll f(ll N, ll b) {
  ll res = 0;
  while (N > 0) {
    res += N % b;
    N /= b;
  }
  return res;
}

ll solve_small(ll N, ll S) {
  for (int b = 2; b <= 1000000; b++) {
    if (f(N, b) == S) 
      return b;
  }
  return -1;
}

ll solve_large(const ll N, const ll S) {
  ll ans = -1;
  for (ll p = 1; p <= 1000000; p++) {
    ll b = (N - S) / p + 1;
    if (b >= 2) {
      if (f(N, b) == S && (ans == -1 || ans > b)) {
        ans = b;
      }
    }
  }
  return ans;
}

int main2() {
  ll N, S;
  cin >> N >> S;

  if (N < S) {
    cout << -1 << endl;
    return 0;
  }
  if (N == S) {
    cout << (N+1) << endl;
    return 0;
  }

  ll ans = solve_small(N, S);
  if (ans != -1) {
    cout << ans << endl;
    return 0;
  }

  ans = solve_large(N, S);
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,int>;
using ll=long long;

int main() {
  string S;
  cin >> S;
  int m=0;
  for (int i=0; i<S.size()-1; i++) {
    if (S[i]!=S[i+1]) {m++;}
  }
  cout << m << endl;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  int n, max = -INT_MAX, min = INT_MAX, in;
  long long sum = 0;
 
  cin >> n;
  for(int i = 0 ; i < n ; i++){
    cin >> in;
    max = std::max(max, in);
    min = std::min(min, in);
    sum += in;
  }
  cout << min << " " << max << " " << sum << endl;
 
  return 0;
}

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

int main() {
  // 入力
  int r, g;
  cin >> r;
  cin >> g;
  
  // (r + x) / 2 = g
  // r + x = 2 * g
  // x = 2 * g - r
  cout << 2 * g - r;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n; 
	while (cin >> n) {
		if (!n)return 0;
		char s[100]; cin >> s;
		pair<int, int>sw[101];
		for (int i = 1; i <= n; i++) {
			cin >> sw[i].first >> sw[i].second;
			sw[i].first--;
			sw[i].second--;
		}
		for (int i = n; i >= 1; i--) {
			char tmp = s[sw[i].first];
			s[sw[i].first] = s[sw[i].second];
			s[sw[i].second] = tmp;
			for (int j = 0; j < max(sw[i].second - sw[i].first, sw[i].first - sw[i].second); j++) {
				if (s[sw[i].first] == 'z')s[sw[i].first] = 'a';
				else s[sw[i].first]++;
				if (s[sw[i].second] == 'z')s[sw[i].second] = 'a';
				else s[sw[i].second]++;
			}
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 3096
#include<stdio.h>

int main(void)
{
    int n,i,j,sum,max;
    int a[5000];

    while(scanf("%d",&n),n){

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

        max=a[0];

        for(i=0;i<n;i++){
            sum=0;
            for(j=i;j<n;j++){
                sum+=a[j];
                if(max<sum){
                    max=sum;
                }
            }
        }

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

    }
    return 0;
}

Measured memory_bytes: 620
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;

int main()
{
    int N, W;
    cin >> N >> W;
    vector<pair<int, int>> A(N, pair<int, int>(0, 0));
    for (int i = 0; i < N; i++)
    {
        cin >> A[i].first >> A[i].second;
    }
    vector<vector<int>> dp(N + 1, vector<int>(W + 1, 0));
    for (int i = 1; i <= N; i++)
    {
        for (int j = 0; j <= W; j++)
        {
            if (j >= A[i - 1].second)
            {
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - A[i - 1].second] + A[i - 1].first);
            }
            else
            {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    cout << dp[N][W] << endl;

    return 0;
}


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

using namespace std;

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    for(int i=0;i<s.length()/2;i++){
        if(s[i] != s[s.length()-1-i])cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#define N 200002
using namespace std;

int a[N], b[N];

int read()
{
	char c;
	while((c = getchar()) < 48 || c > 57);
	int x = c - 48;
	while((c = getchar()) > 47 && c < 58) x = x * 10 + c - 48;
	return x;
}

void write(int x)
{
	if(x < 10){
		putchar(x + 48);
		return;
	}
	write(x / 10);
	putchar(x % 10 + 48);
}

int main() 
{
	int n, i, x, y;
	
	n = read();
	for(i = 0; i < n; i++){
		a[i] = b[i] = read();
	}
	sort(b, b + n);
	x = b[(n >> 1) - 1], y = b[n >> 1];
	if(x == y){
		for(i = 0; i < n; i++){
			write(x), putchar(10);
		}
		return 0;
	}
	for(i = 0; i < n; i++){
		if(a[i] >= y) write(x);
		else write(y);
		putchar(10);
	}
			
	return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
const int maxn=605;
struct node
{
    int to;
    bool f;
    node(int _to=0,bool _f=0)
    {
        to=_to;
        f=_f;
    }
};
vector<node>G[maxn];
int n,m;
double cal()
{
    double f[maxn];
    f[n]=0;
    for(int i=n-1;i>=1;i--)
    {
        f[i]=0;
        int Len=G[i].size();
        int len=Len;
        for(int j=0;j<len;j++)
            if(G[i][j].f==0)
                Len--;
        for(int j=0;j<len;j++)
        {
            node &e=G[i][j];
            if(e.f==0)
                continue;
            f[i]+=f[e.to]+1;
        }
        f[i]/=Len;
    }
    return f[1];

}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int x,y;scanf("%d%d",&x,&y);
        G[x].push_back(node(y,1));
    }
    double f[maxn],ans=cal();
    f[n]=0;
    for(int i=n-1;i>=1;i--)
    {
        f[i]=0;
        int len=G[i].size();
        double mx=0;
        int id=0;
        for(int j=0;j<len;j++)
        {
            node &e=G[i][j];
            f[i]+=f[e.to]+1;
            if(f[e.to]>mx)
            {
                mx=f[e.to];
                id=j;
            }
        }
        f[i]/=len;
        if(len>1)
        {
            G[i][id].f=0;
            ans=min(ans,cal());
            G[i][id].f=1;
        }
    }
    printf("%.10f\n",ans);
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H, W;
  cin >> H >> W;
  vector<string> grid(H);
  int init_walls = 0;
  REP(i, H) {
    cin >> grid[i];
    assert(grid[i].size() == size_t(W));
    REP(j, W) {
      if (grid[i][j] == '#') {
        init_walls++;
      }
    }
  }
  vector<vector<bool>> visited(H, vector<bool>(W));
  deque<tuple<int, int, int>> q;
  q.emplace_back(0, 0, 1);
  visited[0][0] = true;
  while (q.size()) {
    vector<int> dx = {1, -1, 0, 0};
    vector<int> dy = {0, 0, 1, -1};
    auto [r, c, d] = q.front();
    q.pop_front();
    if (r == H - 1 && c == W - 1) {
      int ans = H * W - d - init_walls;
      cout << ans << endl;
      return 0;
    }
    REP(i, 4) {
      int r2 = r + dx[i];
      int c2 = c + dy[i];
      if (r2 < 0 || r2 >= H || c2 < 0 || c2 >= W) continue;
      if (grid[r2][c2] == '#') continue;
      if (visited[r2][c2]) continue;
      visited[r2][c2] = true;
      q.emplace_back(r2, c2, d + 1);
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a[101][2],b,c,d,n,m,p,q,x,y,k,h,w,sum,mi,ma,ans,l,r,res;
string s;
typedef vector<int> VI;
typedef vector<pair<int,int> > VP;

int main(){
    cin>>n;
    rep(j,2)rep(i,n)cin>>a[i][j];
    rep(i,n-1)a[i+1][0]+=a[i][0];
    rep(i,n-1)a[n-2-i][1]+=a[n-1-i][1];
    rep(i,n)if(a[i][0]+a[i][1]>ma)ma=a[i][0]+a[i][1];
    p(ma);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;
ll mod = 1e9+7;

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<ll> sum(n+3,0);
    vector<vector<ll> > dp(n+1,vector<ll>(n+3,0) );
    for(int i=0;i<=n;i++)dp[1][i] = 1;
    for(int i=2;i<=n;i++){
	sum[0] = 0;
	for(int j=1;j<n-i+3;j++) sum[j] = (sum[j-1] + dp[i-1][j-1] )% mod;
	if(s[i-2]=='<'){
	   // for(int j=0;j<n-i+1;j++)for(int k=j+1;k<n-i+2;k++)dp[i][j]=(dp[i][j]+dp[i-1][k])%mod;
	    for(int j=0;j<n-i+1;j++) dp[i][j] = (sum[n-i+2] - sum[j+1] + mod ) %mod;
	}else{
	   // for(int j=0;j<n-i+1;j++)for(int k=0;k<j+1;k++)dp[i][j]=(dp[i][j]+dp[i-1][k])%mod;
	    for(int j=0;j<n-i+1;j++) dp[i][j]  = sum[j+1];
	}
    }
    cout<<dp[n][0]<<endl;
    return 0;
}


Measured memory_bytes: 70784
n,k = map(int,input().split())
a = list(map(int,input().split()))
dp = [False]*(k+1)
#i = a[0]
for i in range(0,k+1):
  for j in range(n):
    if i-a[j] < 0:
      break
    if dp[i-a[j]] == False:
      dp[i] = True
      break
print(["Second","First"][dp[k]])

Measured memory_bytes: 43116
#include <iostream>
#include <algorithm>
#include <iterator>

#include <vector>
#include <queue>
#include <unordered_map>

using namespace std;

int main(){
    int N;
    cin>>N;
    vector<uint64_t > H(N, 0);
    for(int i=0; i<N; i++){
        cin >> H[i];
    }

    int answer = 0;
    int tmp=0;
    for(int i=0; i<N-1; i++){
        if(H[i+1]<=H[i]){
            tmp++;
        }else{
            tmp=0;
        }
        answer=max(answer,tmp);
    }
    cout<<answer<<endl;
    return 0;
}


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

class Amondai {
    static void Main()
    {
        var line = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var all=line[0];
        var shinbunX = line[1];
        var shinbunY = line[2];
        var shinbunXy = shinbunX + shinbunY;
        var min = all < shinbunXy ? shinbunXy-all : 0;
        var max = Math.Min(shinbunX,shinbunY);
        Console.WriteLine($"{max} {min}");
    }
}

Measured memory_bytes: 13268
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

#椅子はば
x = int(arr_data[0][0])
y = int(arr_data[0][1])
z = int(arr_data[0][2])

#print(x, y, z)

hasi = y + z

naka = y + z 

#座れる人数初期値
cnt = 0

#はしに座れる人数
#cnt+=x//(hasi)
#print(cnt)


if x >= hasi * 2:
    
    cnt += 2
    #残り
    x -= hasi * 2
    
elif x >= hasi:
    
    cnt += 1
    #残り
    x -= hasi



x-=z
#中に座れる人数
cnt += x // naka

print(cnt)





Measured memory_bytes: 3064
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Double> a = new ArrayList<>();
        double max = 0;
        for (int i = 0; i < n; i++) {
            double k = sc.nextDouble();
            max += k;
            a.add(k);
        }
        double average = max / n;
        double min = max;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (Math.abs(average - a.get(i)) < min) {
                min = Math.abs(average - a.get(i));
                ans = i;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23252
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.IO;

class Program
{
    static void Main(string[] args)
    {
        var tmp = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        var K = tmp[0];
        var X = tmp[1];

        var ansArray = new int[2 * K - 1];
        var totalNum = 2 * K - 1;
        var firstElement = X - K + 1;

        for (var i = 0; i < totalNum; i++)
        {
            ansArray[i] = firstElement + i;
        }

        Console.WriteLine(string.Join(" ", ansArray));
    }
}


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

int main(){
	
	
	int n;
	int b[10];
	
	cin>>n;
	while(n>0){
		stack<int> s1,s2;
		int f=0;
		for(int i=0;i<10;i++)
			cin>>b[i];
		for(int i=0;i<10;i++){
			if(s1.empty())
			s1.push(b[i]);
			else if(s1.top()<b[i])
			s1.push(b[i]);
			else if(s2.empty())
			s2.push(b[i]);
			else if(s2.top()<b[i])
			s2.push(b[i]);
			else
				f=1;
		}
		if(f==0)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
		n--;
			
	}
}

Measured memory_bytes: 1192
let dp = ref [ 1; 1 ]

let rec fib num =
  match num with
  | 0 -> List.nth !dp 0
  | 1 -> List.nth !dp 1
  | num ->
    try
      List.nth !dp num
    with Failure "nth" ->
      let x = fib (num - 2) + fib (num - 1) in
      dp := !dp @ [x];
      x


let () =
  let n = read_int () in
  fib n
  |> string_of_int
  |> print_endline



Measured memory_bytes: 2224
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  int a, b, c;
  cin >> a >> b;
  c = max(a + b, a - b);
  cout << max(c, a * b) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cmath>
#define ll long long
using namespace std;

int main(){
	int a,b;
	string s;
	
	cin>>a>>b;
	cin>>s;
	int flag=1;
	for (int i=0;i<a;i++){
		if (!(s[i]>='0'&&s[i]<='9')){
			flag=0;
			break;
		}
	}
	
	if (s[a]!='-') flag=0;
	
	if (flag){
		for (int i=0;i<b;i++){
			if (!(s[a+1+i]>='0'&&s[a+1+i]<='9')){
				flag=0;
				break;
			}
		}
	}
	if (flag) cout<<"Yes";
	else cout<<"No";
	
}

Measured memory_bytes: 256
/*
 * atcoder/abc113_2nd/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

template <class T>
int numDigits(T number)
{
    int digits = 0;
    if (number < 0) digits = 1;
    while (number) {
        number /= 10;
        digits++;
    }
    return digits;
}

string zeroPadding (ll num, int digits) {
  int d = numDigits<ll>(num);
  if (d >= digits) return to_string(num);
  return string(digits-d, '0').append(to_string(num));
}

struct City {
  ll n, p, y;
  string id;
  void setid(ll n) {
    id = zeroPadding(p, 6) + zeroPadding(n, 6);
  }
  bool operator<(const City& o)const{
    return p == o.p ? y < o.y : p < o.p;
  }
};

bool comp(const City& lh, const City& rh) {
     return lh.n < rh.n;
}

int N, M;
ll p, y;
vector<City> C;

void solve() {
  cin >> N >> M;
  loop(m,0,M) {
    cin >> p >> y;
    C.push_back((City){ m, p, y });
  }
  sort(C.begin(), C.end());
  int p = -1;
  int idx = 0;
  for (auto&& c: C) {
    if (p != c.p) {
      idx = 1;
      p = c.p;
    }
    else idx++;
    c.setid(idx);
  }
  sort(C.begin(), C.end(), comp);
  for (auto &&c: C) {
    cout << c.id << endl;
  }
}
int main() {
  // cout.precision(15);
  // cout << fixed << double

  solve();

  return 0;
}


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

using namespace std;
#define pb push_back
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef set<char> setc;
typedef set<int> seti;

void solve(){
	//write solution here
	int a,b,c;
	cin>>a>>b>>c;
	if(b-a!=c-b){
		cout<<"NO"<<endl;
	}
	else{
		cout<<"YES"<<endl;
	}
}

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

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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int N, M; cin >> N >> M;
    int sum = 0;
    vector<int> A;
    REP(i, N) {
        int tmp; cin >> tmp;
        A.push_back(tmp);
        sum += tmp;
    }
    int cnt = 0;
    for (auto x: A){
        if (4*M*x >= sum) cnt++;
    }
    if (cnt >= M) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

namespace _0025
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                string line = RSt();
                if (line == String.Empty || line == null) break;
                int[] a = Array.ConvertAll(line.Trim().Split(' '), e => int.Parse(e));

                string line2 = RSt();
                if (line2 == String.Empty || line2 == null) break;
                int[] b = Array.ConvertAll(line2.Trim().Split(' '), e => int.Parse(e));

                int hit = 0;
                int blow = 0;
                for (int i = 0 ; i < a.Count() ; i++)
                {
                    if (a.Contains(b[i]))
                    {
                        if (a[i] == b[i]) hit++;
                        else blow++;
                    }
                }
                Console.WriteLine("{0} {1}", hit, blow);
            }

        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine()); }
        static long RLong() { return long.Parse(Console.ReadLine()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



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

int main() {
  int n,k; cin >> n >> k;
  int ans = 1;
  while (true){
    n /= k;
    if (n>0) ans++;
    else break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
S = input()
N = len(S)+1
l = [0]
r = [0]

for i in range(N-1):
    if S[i] == '<':
        l.append(l[-1]+1)
    else:
        l.append(0)
    if S[-1-i] == '>':
        r.append(r[-1]+1)
    else:
        r.append(0)

r = r[::-1]
ans = [max(l[i], r[i]) for i in range(N)]
print(sum(ans))

Measured memory_bytes: 116044
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;

bool HD(char c){
  if(c == 'H') return 1;
  if(c == 'D') return 0;
}

int main(){
  char a,b;
  cin >> a >> b;
  if(HD(a)^HD(b)) cout << "D" << endl;
  else cout << "H" << endl;
}

Measured memory_bytes: 256
N = int(input())
D = list(map(int, input().split()))
M = 998244353
from collections import Counter

if D[0] != 0:
    print(0)
    exit(0)

cd = Counter(D)
if cd[0] != 1:
    print(0)
    exit(0)

tmp = sorted(cd.items(), key=lambda x: x[0])

prev = -1
for i, _ in tmp:
    if i == prev + 1:
        prev = i
    else:
        print(0)
        exit(0)


ans = 1
# print(tmp)
# print(cd)
# for kx in range(2, max(D)+1):
for kx in range(2, len(tmp)):
    # print(kx)
    __, p = tmp[kx-1]
    _, v = tmp[kx]
    # p = cd[kx-1]
    # v = cd[kx]
    # print("{}^{}".format(p, v))
    while v > 0:
        ans *= p
        ans %= M
        v -= 1
# print(cd)

# for kx in range(1, max(D)+1):
#     ans *= pow(cd[kx-1], cd[kx],M)
#     ans %= M

print(ans)

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

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

int main()
{
    int n;
    cin>>n;
    long long int s=0;
    
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                s+=g(i,g(j,k));
            }
        }
    }
    
    cout<<s;
    return 0; 
}


Measured memory_bytes: 3188
fun main(args: Array<String>) = ripPro0408d()

fun ripPro0408d() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val broken = (1..m).map { readLine()!!.toInt() }.toSet()

    val counts = LongArray(n + 1)
    counts[0] = 1

    for (i in 0..n) {
        if (i in broken) continue
        if (i > 0) {
            counts[i] += counts[i - 1]
            counts[i] %= MOD
        }
        if (i > 1) {
            counts[i] += counts[i - 2]
            counts[i] %= MOD
        }
    }
    val answer = counts.last()

    println(answer)
}

private const val MOD = (1e9 + 7).toLong()


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

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

    vector<int> a(n);
    int max = 0;
    for (auto i = 0; i < n; i++) {
        cin >> a[i];
        if(i > 1){
            int tmp = a[i] - a[i - 1];
            if(tmp > max) {
                max = tmp;
            }
        }
    }
    if(k - a[n - 1] + a[0] > max) {
        max = k - a[n - 1] + a[0];
    }
    if(a[1] - a[0] > max) {
        max = a[1] - a[0];
    }

    cout << (k - max) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
ll dp[200000];
const ll INF = 1LL<<60;
int main() {
  int n,k;
  cin >> n >> k;
  vi h(n);
  rep(i,n)cin >> h[i];
  fill(dp,dp+200000,INF);
  dp[0] = 0;
  rep(i,n){
    srep(j,1,k+1){
      if(i-j<0)continue;
      mins(dp[i],dp[i-j]+abs(h[i-j]-h[i]));
    }
  }
  cout<<dp[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 2176
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

void solve() {
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        string s;
        cin >> s;
        int idx = s.length() - 1;
        while (idx > 0) {
            if (s[idx] == 'm') {
                if (idx >= 4 && s.substr(idx - 4, 5) == "dream") idx -= 5;
                else break;
            } else if (s[idx] == 'e') {
                if (idx >= 4 && s.substr(idx - 4, 5) == "erase") idx -= 5;
                else break;
            } else if (s[idx] == 'r') {
                if (idx >= 6 && s.substr(idx - 6, 7) == "dreamer") idx -= 7;
                else if (idx >= 5 && s.substr(idx - 5, 6) == "eraser") idx -= 6;
                else break;
            } else {
                break;
            }
            if (idx == -1) {
                cout << "YES" << endl;
                return 0;
            }
        }
        cout << "NO" << endl;

        solve();

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 512
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
// -fsanitize=undefinedでオーバーフロー検出
#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};


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

    ll a,b,c,d,m,n,maxi=0,f=0,g=0,mini=INF,sum=0;
    ll k;
    string str,stra;
    
    cin>>n>>str>>a;
  a--;
  rep(i,str.length()){
  if(str[i]!=str[a]) cout<<"*";
    else cout<<str[a];
  }
  ln;
    return 0;
}


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

using namespace std;
int main(){
	int n; cin >> n;
	string s; cin >> s;
	int max = 0;
	int cnt = 0;
	for (int i = 0; i < n; i++){
		if (s[i] == 'I'){
			cnt++;
		}else{
			cnt--;
		}
		if (max < cnt) max = cnt;
	}
	cout << max << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;
using namespace std;

#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (int i = (a); i < (b); i++)
#define rrrep(i, a, b) for (int i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl

ll n, cnt, ans, a, b, c, d, tmp, tmpp, m, h, w, x, y, sum, pos, k;
ld doua;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
bool fl;
struct edge
{
    int to, cost;
};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin >> n >> s;
    unordered_map<string, ll> mp;
    string first = "", second = "";
    rep(i, n) first += s[i];
    rrep(i, n, 2 * n) second += s[i];
    for (int bit = 0; bit < (1 << (n)); bit++)
    {
        string red = "", blue = "";
        rep(i, n)
        {
            if (bit & (1 << i))
            {
                red += first[i];
            }
            else
            {
                blue += first[i];
            }
        }
        string match = red + '.' + blue;
        mp[match]++;
    }
    for (int bit = 0; bit < (1 << (n)); bit++)
    {
        string red = "", blue = "";
        rep(i, n)
        {
            if (bit & (1 << i))
            {
                red += second[i];
            }
            else
            {
                blue += second[i];
            }
        }
        reverse(all(red));
        reverse(all(blue));
        string match = blue + '.' + red;
        ans += mp[match];
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 71668
#10000a+5000b+1000c=1000/1000*y & a+b+c=n
n,y=map(int,input().split())
#をみたすa,b,cの組
for i in range(n+1):
  for j in range(n+1):
    k=n-i-j
    if k<0:continue
    s=10000*i+5000*j+1000*k
    if s==y:
      print(i,j,k)
      exit()
      
print(-1,-1,-1)


Measured memory_bytes: 2940
import java.util.Scanner

fun a(sc: Scanner): String {
    if (sc.nextInt() + sc.nextInt() + sc.nextInt() < 22) {
        return "win"
    }
    return "bust"
}

fun b(sc: Scanner): String {
    val s = sc.next()
    val sr = s.reversed()
    val l = s.length
    var ans = 0
    s.forEachIndexed { index, c ->
        if (index * 2 >= l) {
            return ans.toString()
        }
        if (c != sr[index]) ans++
    }
    return "0"
}

fun c(sc: Scanner): String {
    val N = sc.nextInt()
    val arr = (0 until N).map {
        (0 until sc.nextInt()).map {
            Pair(sc.nextInt(), sc.nextInt())
        }
    }
    val ans = (0 until (2.shl(N-1))).map { pat ->
        if (arr.withIndex().all {a ->
            pat shr (a.index) and 1 == 0 ||
            a.value.all {
                ((pat shr (it.first - 1)) and 1) == it.second
            }
        }) {
            (0 until N).count {
                (pat shr it) and 1 == 1
            }
        } else {
            0
        }
    }.max().toString()
    return ans
}

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    println(
//        a(sc)
//        b(sc)
    c(sc)
    )
}

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


int merge(long int a1[], long int a2[], long int a1_size, long int a2_size, long int a[]);
int mergeSort(long int a[], long int number);

int main(void)
{
	long int n, k;
	long int count = 0;
	long int i, j;
	long int work = -1;
	long int a[200000];
	
	scanf("%ld", &n);
	
	for(i = 0; i < n; i++) {
		scanf("%ld", &a[i]);
	}
	
	mergeSort(a, n);
	
	for(i = 0; i < n; i++) {
		if(a[i] == work) {
			printf("NO\n");
			return 0;
		}
		work = a[i];
	}
	
	printf("YES\n");
	
	return 0;
}

int merge(long int a1[], long int a2[], long int a1_size, long int a2_size, long int a[])
{
	long int i = 0, j = 0;
	
	while( (i < a1_size ) || (j < a2_size) ) {
		if( (j >= a2_size ) || ( (i < a1_size) && (a1[i] < a2[j]) ) ) {
			a[i + j] = a1[i];
			i++;
		} else {
			a[i + j] = a2[j];
			j++;
		}
	}
	
	return 0;
}


int mergeSort(long int a[], long int number)
{
	long int m = number / 2, n = number - m;
	long int a1[m];
	long int a2[n];
	int i, j;
	
	if(number > 1) {
		for(i = 0; i < m; i++) {
			a1[i] = a[i];
		}
		for(i = 0; i < n; i++) {
			a2[i] = a[m + i];
		}
		mergeSort(a1, m);
		mergeSort(a2, n);
		merge(a1, a2, m, n, a);
	}
	
	return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
#define ALL(V) V.begin(), V.end()
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}


int Main(int N, VS &S, VI &T, string X)
{
    int ans = 0;
    REP(i, N) {
        if(S[i] == X) {
            REP2(j, i+1, N) {
                ans += T[j];
            }
            return ans;
        }
    }
    return ans;
}

int main(void){
    int N;
    cin >> N;
    VS S(N);
    VI T(N);
    REP(i, N) cin >> S[i] >> T[i];
    string X;
    cin >> X;
    cout << Main(N, S, T, X) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  string s;
  cin>>s;
  ll len=s.length();
  vector<ll> num(len);
  for(ll i=0;i<len;i++){
    num[i]=s.at(i)-48;
    //cout<<num[i]<<endl;
  }
  ll ans=0;
  for(ll bit=0;bit<(1<<len-1);bit++){
    ll res=0;
    ll tmp=num[0];
    for(ll i=0;i<len-1;i++){
      if(bit&(1<<i)){
        res+=tmp;
        
        tmp=num[i+1];
      }else{
        tmp=tmp*10;
        //cout<<tmp<<endl;
        tmp+=num[i+1];
      }
    }
    res+=tmp;
    ans+=res;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3568
"use strict"

function main(input) {
  const abc = 'abcdefghijklmnopqrstuvwxyz' // 0-25
  const alfabets = abc.split('')
  input = input.split('').sort()

  let cnt = -1;
  for (let i = 0; i < input.length; i++) {

    let index = -1;
    for (let j = 0; j < alfabets.length; j++) {
      if (input[i] == alfabets[j]) {
        index = j
      }
    }
    if (index != cnt && index != cnt + 1) {
      console.log(alfabets[cnt + 1])
      return
    } else {
      cnt = index
    }
  }
  if (cnt == 24) {

    console.log('z')

  } else {
    console.log('None')
  }
}
main(require("fs").readFileSync("/dev/stdin", "utf8"))

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc153() {
	ll h, n;
	string ans;

	cin >> h >> n;

	V a(n);
	ll sum = 0;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}

	if (h <= sum) {
		ans = "Yes";
	}
	else {
		ans = "No";
	}

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

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

	solve_abc153();

	return 0;
}

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

using namespace std;

int main() {

	int n;
	cin >> n;
	vector<int> p(n+1, 0);
	for (int i = 0; i < n; i++) {
		cin >> p[i] >> p[i + 1];
	}
	vector<vector<int>> m(n + 1, vector<int>(n + 1, 0));
	for (int i = 1; i <= n; i++) {
		m[i][i] = 0;
	}

	for (int l = 2; l <= n; l++) {
		for (int i = 1; i <= n - l + 1; i++) {
			int j = i + l - 1;
			m[i][j] = INT_MAX;
			for (int k = i; k <= j - 1; k++) {
				m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
			}
		}
	}
	cout << m[1][n] << endl;
}


Measured memory_bytes: 3188
// Created by ...Lusifer
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void solveTest(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int cnt=0;
	while(1){
		for(int i=0;i<n;i++){
			if(a[i]%2!=0){
				cout<<cnt<<endl;
				return;
			}
			else {
				a[i]/=2;
			}
		}
		cnt++;
	}
	return ;
}
 
int main(){
	fastio();

	int t=1;
	//cin>>t;
	while(t--){
		solveTest();
 
	}
	return 0;
}

Measured memory_bytes: 256
/* basic header */
#include <bits/stdc++.h>
/* define */
#define ll long long
#define dou double
#define pb emplace_back
#define mp make_pair
#define sot(a,b) sort(a+1,a+1+b)
#define rep1(i,a,b) for(int i=a;i<=b;++i)
#define rep0(i,a,b) for(int i=a;i<b;++i)
#define eps 1e-8
#define int_inf 0x3f3f3f3f
#define ll_inf 0x7f7f7f7f7f7f7f7f
#define lson (curpos<<1)
#define rson (curpos<<1|1)
/* namespace */
using namespace std;
/* header end */

int n;
vector<pair<ll, ll>> v;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        pair<ll, ll> p; scanf("%lld%lld", &p.first, &p.second);
        if (p.first || p.second) v.pb(p);
    }
    n = (int)v.size();
    sort(v.begin(), v.end(), [&](pair<ll, ll> a, pair<ll, ll> b) {
        return atan2(a.second, a.first) < atan2(b.second, b.first);
    });
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        int j = i; ll x = 0, y = 0;
        for (int k = 0; k < n; k++) {
            x += v[j].first; y += v[j].second;
            ans = max(ans, x * x + y * y);
            if (++j == n) j = 0;
        }
    }
    printf("%.15f\n", sqrt(ans));
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int sum = a+b;
  if(sum%2 == 0){
    cout<<sum/2<<endl;
    return 0;
  }else{
    cout<<(sum/2+1)<<endl;
    return 0;
  }
}


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

int main()
{
    int a,b;
    cin >> a >> b;
    int ans = 0;
    if(a >=10 || b>=10){
        ans = -1;
    }else{
        ans = a*b;
    }
  
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
H, W = gets.split.map(&:to_i)
M = H.times.map{gets.chomp}

ch = H.times.reject{|y| W.times.all?{|x| M[y][x] == '.'} }
cw = W.times.reject{|x| H.times.all?{|y| M[y][x] == '.'} }


ch.each do |y|
  puts cw.map{|x| M[y][x] }.join
end


Measured memory_bytes: 1916
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
    int n;
    int m;
    int p[110]={};
    int cnt = 0;

    cin >> n >> m;

    for(int i = 0;i < n;i++){
        cin >> p[i];
        m -= p[i];
    }
    sort(p,p+n);

    cnt = n;
    cnt += m/p[0];
    
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
using namespace std;
#define MAX_N 100000
int  n, i,  j, ans, c[MAX_N];

int sort(const void *a, const void *b){
  return *(int*)a - *(int*)b;
}

int main(){
  while(1){
    scanf("%d", &n);
    if(n == 0) break;
    for(i = 0; i < n; i++) {
      scanf("%d", &c[i]);
      if(i % 2 == 1 && c[i] != c[i - 1]){
	for(j = i - 1; j >= 0; j--){
	  if(c[i] == c[j]) break;
	  c[j] = c[i];
	}
      }
    }
      ans = n;
      for(i = 0; i < n; i++) ans -= c[i];
      printf("%d\n", ans);
  }
  return 0;
}

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

int main() {
  int A,B,answer;
  cin >> A;
  cin >> B;
  if (A+B==3) answer = 3;
  if (A+B==4) answer = 2;
  if (A+B==5) answer = 1;
  cout << answer << endl;
}

Measured memory_bytes: 256
def years():
  A=list(map(int,input().split()))
  c=0
  a=A[0]
  b=A[1]
  
  if b<=1 or (b%2!=0) or a<0:
    return
  
  
  if a>=13:
    print(b)
    
  if a>=6 and a<=12:
    b=b/2
    print(int(b))
    
  if a<=5:
    print(c)
    
    
if __name__=="__main__":
  years()

Measured memory_bytes: 3064
#include <fstream>
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

int main() {
  string str;
  getline(cin, str);
  for (int i = 0; i < str.size(); i++) {
    str[i] = toupper(str[i]);
  }
  cout << str << endl;
}

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

using namespace std;

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

    string s;
    cin >> s;

    int n = s.size();
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'h' && i + 1 < n && s[i + 1] == 'i')
            ++i;
        else {
            cout << "No" << "\n";
            return 0;
        }
    }
    cout << "Yes" << "\n";
    return 0;
}


Measured memory_bytes: 888
# -*- coding: utf-8 -*-
def solve():
    N, L = map(int, input().split())
    if L*(L+N-1) <= 0:
        return sum(L+i for i in range(N))
    elif L > 0:
        return sum(L+i for i in range(N)) - L
    else:
        return sum(L+i for i in range(N)) - ((L+N-1))

if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 3060
S = input()
res  = 'WA'
if S[0] == "A":
    counter = 0
    if len(S) > 4:   
        for i  in S[2:-1]:
            if i =='C':
                counter += 1
    else:
        if S[2] =='C':
            counter =1
    if counter == 1:
        low = 0
        big = 0
        for i in S:
            if i.islower():
                low += 1
            else:
                big += 1
        if big == 2:
            res = 'AC'
print(res)

Measured memory_bytes: 3064
#ifndef _TEMPLATE_ROOT
#define _TEMPLATE_ROOT
#include "bits/stdc++.h"
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define repl(i, a, b) for(ll i = a; i < (b); ++i)
#define repd(i, a, b) for(int i = a; i >= (b); --i)
#define repdl(i, a, b) for(ll i = a; i >= (b); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
#endif
#ifndef _TEMPLATE_IO
#define _TEMPLATE_IO

template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void writef(T ...tail) { write(tail...); cout << flush; }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  if (v.size()) {
    rep(i, 0, sz(v) - 1)
      out << v[i] << " ";
    out << v.back();
  }
  return out;
}
#endif
using namespace std;

int h, w, m;
map<pair<int, int>, int> occ;
int cnt_x[300005], cnt_y[300005];
int x[300005], y[300005];

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

  read(h, w, m);
  rep(i, 0, m) {
    read(x[i], y[i]);
    cnt_x[x[i]]++;
    cnt_y[y[i]]++;
    occ[{x[i], y[i]}]++;
  }
  
  int ans = 0;
  rep(i, 0, m) {
    chmax(ans, cnt_x[x[i]] + cnt_y[y[i]] - 1);
  }
  
  // check max + max
  int xmax = *max_element(cnt_x, cnt_x + 300005);
  int ymax = *max_element(cnt_y, cnt_y + 300005);

  vector<int> xid, yid;
  rep(i, 0, 300005) if (cnt_x[i] == xmax) xid.push_back(i);
  rep(i, 0, 300005) if (cnt_y[i] == ymax) yid.push_back(i);
  if (1ll * sz(xid) * sz(yid) <= m) {
    for (int x : xid) for (int y : yid)
      chmax(ans, cnt_x[x] + cnt_y[y] - occ[{x, y}]);
  } else {
    chmax(ans, xmax + ymax);
  }

  write(ans);
}



Measured memory_bytes: 30856
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N;cin>>N;
	vector<int> cnt(N,0);
	vector<ip> edge(N-1);
	vector<vector<int>> G(N,vector<int>());
	rep(i,N-1){
		int a,b; cin>>a>>b;
		--a; --b;
		++cnt[a]; ++cnt[b];
		edge[i] = make_pair(a, b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int color = 0;
	int root = 0;
	rep(i,N){
		if(cnt[i]>color){
			color = cnt[i];
			root = i;
		}
	}
	queue<int> Q;
	map<ip,int> ans;
	vector<int> al(N,inf);
	Q.push(root);
	al[root] = 0;
	while(!Q.empty()){
		int f = Q.front();
		Q.pop();
		int col = 0;
		rep(i,G[f].size()){
			int t = G[f][i];
			if(al[t] == inf){
				++col;
				if(col == al[f])++col;
				ans[make_pair(f, t)] = col;
				al[t] = col;
				Q.push(t);
			}
		}
	}
	cout<<color<<endl;
	rep(i,N-1){
		cout<<max(ans[edge[i]], ans[make_pair(edge[i].second, edge[i].first)])<<endl;
	}
}

Measured memory_bytes: 20096
import java.io.*;
public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(in.readLine());
		
		int[] a = new int[n];
		for (int i = 0; i < a.length; i++) a[i] = Integer.parseInt(in.readLine());
		
		long c = 0;
		for (int i = 0; i < a.length - 1; i++) {
			if(a[i] % 2 == 0) {
				c += a[i] / 2;
				a[i] = 0;
			}
			else {
				if(a[i + 1] > 0) {
					c += (a[i] + 1) / 2;
					a[i] = 0;
					a[i+1]--;
				}
				else {
					c += (a[i] - 1) / 2;
					a[i] = 1;
				}
			}
		}
		
		c += a[a.length -1]/2;
		
		System.out.println(c);
	}
}


Measured memory_bytes: 30600
#include <bits/stdc++.h>
#define re return
#define ll long long
#define ull unsigned ll
#define ld long double
#define f first
#define s second
#define pi acos(-1)
#define oo (ll)1e9
#define OO 1e18
#define EPS 1e-7
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn=105;

int main()
{
    IO;
    int a,b,c;
    cin >> a >> b >> c;
    cout<<max(a+(b*10)+c,max((a*10)+b+c,a+b+(c*10)))<<"\n";
    re 0;
}

Measured memory_bytes: 256