akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 9e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

vector<int> a[100010];
vector<int> visit(100010, 0);
ll res = inf;
void dfs(int u, ll cnt){
    //cout << u sp cnt sp res << endl;
    if(u == 1){
        chmin(res, cnt);
        return;
    }
    visit[u] = 1;
    for(auto const& e : a[u]){
        if(visit[e]) continue;
        dfs(e, cnt+1);
    }
}

class BTrained {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n, ina;
	    in >> n;
	    for(int i=0; i<n; i++){
	        in >> ina;
	        ina--;
	        a[i].push_back(ina);
	    }

	    dfs(0, 0LL);

	    if(res == inf) out << -1 << endl;
	    else out << res << endl;
	}
};


int main() {
	BTrained solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
#define N 100000
using namespace std;
vector<vector<int>> adj(N);
vector<int> dp(N,0);
vector<bool> vis(N,false);
void dfs(int r){
    vis[r] = true;
    for(int c:adj[r]){
        if(!vis[c]){
            dfs(c);
        }
        dp[r] = max(dp[r],dp[c]+1);
    }
}
int longest_path(int n){
    for(int i=0;i<n;i++){
        if(!vis[i]){
            dfs(i);
        }
    }   
}
int main(){
    int n,m,u,v;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>u>>v;
        u--;v--;
        adj[u].push_back(v);
    }
    longest_path(n);
    cout<<*max_element(dp.begin(),dp.end())<<endl;
    return 0;
}

Measured memory_bytes: 8192
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
const int nmax = 2100;
int N, K, Q;
int A[nmax];
int ans;
int main()
{
    cin >> N >> K >> Q;
    for(int i =0 ; i< N ; ++i)
    {
        cin >> A[i];
        ans = max(A[i], ans);
    }
    
    for(int i = 0; i < N; ++i)
    {
        vector<int> l,r;
        int L = 0;
        A[N] = A[i]-1;
        for(int j = 0; j <= N; ++j)
        {
             if(A[j]< A[i])
             {
              if(l.size() < K)
              {
                l.clear();
                continue;
              }
              sort(l.begin(), l.end());
              for(int z= 0 ; z <= l.size() - K; ++z)
                  r.push_back(l[z]);
              l.clear();
             }else l.push_back(A[j]);
        }
        if(r.size() < Q) continue;
        sort(r.begin(), r.end());
        ans = min(ans, r[Q-1] - A[i]); 
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
using System;

namespace ITP1_4_D
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] strs = Console.ReadLine().Split(' ');
            int min = int.MaxValue;
            int max = int.MinValue;
            long sum = 0;
            for (int i = 0; i < n; i++)
            {
                int a = int.Parse(strs[i]);
                min = a < min ? a : min;
                max = a > max ? a : max;
                sum += a;
            }
            Console.WriteLine("{0} {1} {2}", min, max, sum);
        }
    }
}

Measured memory_bytes: 9852
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

const int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n, m;
    cin >> n >> m;
    vi s(m), c(m);
    rep(i, m) cin >> s[i] >> c[i];
    rep(i, m) s[i]--;

    for (int i = 0; i < 1000; i++) {
        string nd = to_string(i);
        if (nd.size() != n) continue;
        bool f = true;
        rep(j, m) {
            char cc = c[j] + '0';
            if (nd[s[j]] != cc) f = false;
        }
        if (f) { cout << i << endl; exit(0); }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque
N,M = list(map(int,input().split()))
map1 = [[] for i in range(N+1)]

sirusi = [0]*(N+1)

for i in range(M):
    a,b = list(map(int,input().split()))
    
    map1[a].append(b)
    map1[b].append(a)
    
d = deque([1]+map1[1])
visited = [0]*(N+1)
visited[1] = 1
# print(map1)
while d:
    D = d.popleft()
    for i in map1[D]:
        if visited[i] == 1:
            continue
        visited[i] = 1
        d.append(i)
        sirusi[i] = D
        
print("Yes")
for i in range(2,N+1):
    print(sirusi[i])
        

Measured memory_bytes: 34996
// copied by Nurstan Duisengaliev
// skatal
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) (int)x.size()
 
using namespace std;
//using namespace __gnu_pbds;

//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;                         

const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;

void solve () {
	char c;
	cin >> c;
	if (c <= 'Z') {
		cout << "A";
	}
	else cout << "a";
}   	
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//    cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

Measured memory_bytes: 3608
#import numpy as np
#import collections
#import math

#f = open('./input_C.txt')
#f = open('./input_C2.txt')

#K=int(f.readline())

K = int(input())

if K%7 == 0:
    L = 9*(K//7)
else:
    L = 9*K

#def CalcAmariSub(n,L,amari):
#    p=10000
#    if n <= p:
#        amari = (amari*(10**p))%L
#        return 0, amari
#    else:
#        amari = (amari*(10**p))%L
#        return n-p, amari
#
#def CalcAmari(n,L):
#    amari = 1
#    while n !=0:
#        n,amari = CalcAmariSub(n,L,amari)
#    return amari

ans = -1
amari = 1
for n in range(1,2*10**8):
    amari = (10*amari)%L
    if amari == 1:
        ans = n
        break

print(ans)

Measured memory_bytes: 63160
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(a==b)
  {
    cout<<a+b<<endl;
  }
  else
  {
      int c=max(a,b);
      cout<<c+(c-1)<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

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

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	ll a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	if (v <= w)cout << "NO" << endl;
	else
	{
		ll c = abs(a - b);
		ll x = v - w;
		if (c <= t * x)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

Measured memory_bytes: 3592
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

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

using namespace std;
typedef pair<int, int> pii;

int n,s[110]={0};
int x=10000,sum=0;

signed main() {
	cin>>n;
    rep(i,n){
        cin>>s[i];
        sum+=s[i];
        if(s[i]%10!=0){
            x=min(x,s[i]);
        }
    }
	
    if(sum%10!=0){
        cout<<sum<<endl;
    }
    else{
        if(x!=10000){
            cout<<sum-x<<endl;
        }
        else{
            cout<<0<<endl;
        }
    }
	
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python
# -*- coding: utf-8 -*-

from collections import deque

N = int(input())

item = ["3","5","7"]

d = deque([])
Order = 3
for _ in range(0,Order):
    d.append(item[0])

cand = []
cand.append("".join(list(d)))

while True:

    if d == deque([]):
        Order += 1
        for _ in range(0,Order):
            d.append(item[0])

    now = d.pop()

    if now == item[0]:
        d.append(item[1])
        while len(d) < Order:
            d.append(item[0])
        cand.append("".join(list(d)))
#        print("".join(list(d)))
    elif now == item[1]:
        d.append(item[2])
        while len(d) < Order:
            d.append(item[0])
        cand.append("".join(list(d)))
#        print("".join(list(d)))
    elif now == item[2]:
        continue

    # 終了条件
    if int("".join(list(d))) > N:
        break

if int(cand[-1]) > N:
    del cand[-1]

cnt = 0
for Num in cand:
    if Num.count("3") != 0 and Num.count("5") != 0 and Num.count("7") != 0:
        cnt += 1

print(cnt)

Measured memory_bytes: 5548
S = list(input())
L = len(S)

to = -1
ans = 0
for i in range(L-1,-1,-1):
  if S[i] == 'W':
    to = max(to,i)
  else:
    if to == -1:
      continue
    else:
      ans += to - i
      to -= 1
      
print(ans)

Measured memory_bytes: 4840
def solve(string):
    n, k, s = string.split()
    n, k = map(int, [n, k])
    ans = n - 1 - s.count("RL") - s.count("LR")
    return str(min(ans + 2 * k, n - 1))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Measured memory_bytes: 3316
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
#include <bitset>
using namespace std;
#define N (1000000000+7)
//#define N 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
 
const int inf = (int)1e9; 

int main(void){
    int n;
    cin>>n;
    vector<P>v;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        ll num = 0;
        ll len = 9;
        for(int j=0;j<s.length();j++){
            if(s[j]!='.'){
                num*=10;
                num+=s[j]-'0';
            }
            else{
                len = 9-(s.length()-1-j);
            }
        }
        int t=0,f=0;
        while(len){
            --len;
            num*=10;
        }
        while(num%2==0){
            num/=2;
            t++;
        }
        while(num%5==0){
            num/=5;
            f++;
        }
        t = min(t, 18);
        f = min(f, 18);
        v.push_back(P(t,f));
    }
     sort(v.begin(), v.end());
        ll ans = 0;
        vector<vector<ll>> memo;
        memo.assign(20, vector<ll>(20, 0));
        for (int i = 0; i < n; ++i) {
            for (int j = 18 - v[i].first; j <= 18; ++j)
                for (int k = 18 - v[i].second; k <= 18; ++k) ans += memo[j][k];
            ++memo[v[i].first][v[i].second];
        }
        cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;

int main() {
    ll N, s = 0;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        s += i;
        if (s >= N) {
            for (int j = 1; j <= i; j++) {
                if (j == s - N) continue;
                cout << j << "\n";
            }
            return 0;
        }
    }
}

Measured memory_bytes: 256
from collections import Counter
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
A = list(map(int, input().split()))
C = Counter(A)
tot = sum(A)
Q = int(input())
ans = [-1] * Q
for i in range(Q):
    b, c = map(int, input().split())
    x = C[b]
    C[b] = 0
    C[c] += x
    tot -= x * b
    tot += x * c
    ans[i] = tot

print(*ans, sep="\n")

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

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

    long long N;
    cin >> N;
    int h, n;
    for (h = 1; h <= 3500; ++h) {
        for (n = 1; n <= 3500; ++n) {
            long long a = 4 * h * n - N * n - N * h;
            long long b = N * h *n;
            // if (4 * h * n - N * n - N * h <= 0) continue;
            if (a > 0 && b % a == 0) {
                long long w = b / a;
                printf("%d %d %lld", h, n, w);
                return 0;
            };
        }
    }
    return 0;
}


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

long long N;
int main(){
    cin>>N;
    string S;
    while(N>0){
        N--;
        
        S.push_back('a'+N%26);
        if(N==0)break;
        N/=26;

    }
    reverse(S.begin(),S.end());
    cout<<S<<endl;
    return 0;
}

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

int main(){
    int c[3][3];
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin >> c[i][j];
        }
    }

    string ans = "No";
    int a[3], b[3];
    a[0] = 0;
    b[0] = c[0][0];
    b[1] = c[0][1];
    b[2] = c[0][2];

    if(c[1][0] - b[0] == c[1][1] - b[1]  &&  c[1][0] - b[0] == c[1][2] - b[2]  &&  c[2][0] - b[0] == c[2][1] - b[1]  &&  c[2][0] - b[0] == c[2][2] - b[2] ){
        ans = "Yes";
    }

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

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

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

    for (int i = a; i <= b; i++) {
        if (i%k == 0) {
            cout << "OK\n";
            return 0;
        }
    }
    cout << "NG\n";
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main() {
	int n;
	int a[100001]={};
	int b[100000]={};
	long long ans=0;
	scanf("%d", &n);
	for (int i = 0; i < n + 1; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &b[i]);
	}
	for (int i = 0; i < n; i++) {
		if(a[i]<=b[i]){
			if (a[i]+a[i+1]>b[i]) {
				ans+=b[i];
				a[i+1]-=b[i]-a[i];
			} else {
				ans+=a[i]+a[i+1];
				a[i]=a[i+1]=0;
			}
		}else{
			ans+=b[i];
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <cmath>

using namespace std;

double dist(double x1, double y1, double x2, double y2){
	return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}

int main(){

	double x[3], y[3];
	int n;

	cin >> n;
	while(n-- > 0){
		for(int i = 0; i < 3; i++){
			cin >> x[i] >> y[i];
		}

		double a = x[1] - x[0];
		double b = y[1] - y[0];
		double c = x[2] - x[1];
		double d = y[2] - y[1];
		double e = x[1]*x[1] - x[0]*x[0] + y[1]*y[1] - y[0]*y[0];
		double f = x[2]*x[2] - x[1]*x[1] + y[2]*y[2] - y[1]*y[1];

		double p = (e*d - f*b) / (2 * (a*d - b*c));
		double q = (e*c - f*a) / (2 * (b*c - a*d));

		double r = dist(x[0], y[0], p, q);

		cout.setf(ios::fixed);
		cout.precision(3);
		cout << p << ' ' << q << ' ' << r << endl;
	}

	return 0;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;
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 ll INF = 1e16;

int main(){
    ll l,r;
    cin >> l >> r;
    if(r-l>=2018){
        cout << 0 << endl;
        return 0;
    }
    int L = l % 2019;
    int R = r % 2019;
    if(R<L){
        cout << 0 << endl;
        return 0;
    }
    ll m = INF;
    for(int i=L;i<=R;i++){
        for(int j=i+1;j<=R;j++){
            ll res = i*j;
            res %=2019;
            m=min(m,res);
        }
    }
    cout << m << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

constexpr int MAX = 200;
bool grid[2 * MAX][2 * MAX];

struct Cor {
    // constructer
    Cor(int x, int y) : x_(x), y_(y) {}

    // field
    int x_;
    int y_;
};

int check_x(int x, int y) {
    int count = 0;
    int empty_count = 0;
    for (int xx = x; xx < 2 * MAX; ++xx) {
        if (grid[y][xx] == true) {
            count = xx;
        }
    }
    return count - x;
}

int check_y(int x, int y) {
    int count = 0;
    for (int yy = y; yy < 2 * MAX; ++yy) {
        if (grid[yy][x] == true) {
            count = yy;
        }
    }
    return count - y;
}

int main (int argc, char *argv[]) {
    int N, n, d;
    vector<Cor> cs;
    int dx[4] = {-1, 0, 1, 0};
    int dy[4] = {0, -1, 0, 1};
    
    // input
    while (cin>>N, N) {
        // init
        for (int i = 0; i < 2 * MAX; ++i) {
            for (int j = 0; j < 2 * MAX; ++j) {
                grid[i][j] = false;
            }
        }

        // cout<<"---solve---"<<endl;
        //solve
        grid[200][200] = true;
        cs.push_back(Cor(200, 200));
        for (int i = 0; i < N-1; ++i) {
            cin>>n>>d;
            int nx = cs[n].x_ + dx[d];
            int ny = cs[n].y_ + dy[d];
            grid[ny][nx] = true;
            cs.push_back(Cor(nx, ny));
        }

        // print
        // for (int i = 180; i < 1.2 * MAX; ++i) {
        //     for (int j = 180; j < 1.2 * MAX; ++j) {
        //        cout<<grid[i][j]<<" ";
        //     }
        //     cout<<endl;
        // }
        // cout<<endl;

        // ans
        int max_x = 200;
        int min_x = 200;
        int max_y = 200;
        int min_y = 200;
        // cout<<"--check---"<<endl;
        // check x
        for (int y = 0; y < 2 * MAX; ++y) {
            for (int x = 0; x < 2 * MAX; ++x) {
                if (grid[y][x] == true) {
                    max_x = max(max_x, x);
                    min_x = min(min_x, x);
                    max_y = max(max_y, y);
                    min_y = min(min_y, y);
                }
            }
        }
        // // check y
        // for (int x = 0; x < 2 * MAX; ++x) {
        //     for (int y = 0; y < 2 * MAX; ++y) {
        //         if (grid[y][x] == true) {
        //             int tmp = check_y(x, y);
        //             y += tmp;
        //             max_y = max(max_y, tmp);
        //         }
        //     }
        // }

        // ans
        // cout<<"---ans---"<<endl;
        cout<<max_x - min_x + 1<<" "<<max_y - min_y + 1<<endl;

        // clear
        cs.clear();
    }


    return 0;
}

Measured memory_bytes: 3092
#include <stdio.h>
#include <stdlib.h>
int main(void){
	int n,ans=0,i,a,b;
	scanf("%d",&n);
	scanf("%d",&b);
	for(i=1;i<n;i++){
		scanf("%d",&a);
		if(b==a){
			ans++;
			b = 0;
		}else	b = a;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
// ~/BAU/ACM-ICPC/Teams/Rampage/MMZA
// ~/sudo apt-get verdict Accepted
// practice...
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<pair<int, int>> vp;
typedef vector<vector<pair<int, int>>> vvp;
typedef unsigned long long ull;
typedef long double ld;
const int Mod = 1000000007;
int main()
{
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
//.\a.exe
int n;
scanf("%d",&n);
for(int i=0;i<=n;i++){
    
    for(int j=0;j<=n;j++)
    {
        if(i*4+j*7==n)
        {

            puts("Yes");
            return 0;
        }
    }
}
puts("No");
    return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read():
    N, M = map(int, input().strip().split())
    parents = [list() for i in range(N)]
    n_children = [0 for i in range(N)]
    for i in range(M):
        x, y = map(int, input().strip().split())
        n_children[x-1] += 1  # x -> E_out[x]
        parents[y-1].append(x-1)   # E_in[x] -> x
    return N, M, n_children, parents


def solve(N, M, n_children, parents):
    dp = [0 for i in range(N)]
    q = deque()
    r = deque()
    for x in range(N):
        if n_children[x] == 0:
            q.append(x)
    while q:
        x = q.pop()
        r.append(x)
        for parent in parents[x]:
            n_children[parent] -= 1
            if n_children[parent] == 0:
                q.append(parent)
    
    while r:
        x = r.pop()
        for y in parents[x]:
            dp[x] = max(dp[x], dp[y]+1)
    return max(dp)


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 23840
#include<stdio.h>
#include<iostream>
using namespace std;

int W,a,b;
int main(){
    cin >> W >> a >> b;
    if( a+W < b ) cout << b-(a+W) << endl;
    else if( b+W < a ) cout << a - (b+W) << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb push_back;
#define sp " ";
#define INF 100000000
void vout(vector<int> v){
    for(unsigned int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    int a,b;
    cin>>a>>b;
    out(a*b);
}

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

using namespace std;
using ll = long long;
using vs = vector<string>;
using pll = pair<ll,ll>;
using vpl = vector<pll>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ld = long double;
using vd = vector<ld>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;

#define R(a,i) for(ll a=0; a < (i); (a)++)
#define FOR(a,i,j) for(ll a=(i); a < (j); (a)++)
#define RD(a,i) for(ll a=(i)-1; (a) >= 0; (a)--)
#define FORD(a,i,j) for(ll a=(j)-1; (a) >= (i); (a)--)

#define xx first
#define yy second
#define pb push_back

#define all(X) begin(X),end(X)
#define sz(X) (X).size()

const ll oo = 0x3f3f3f3f3f3f3f3f;
const ld eps = 1e-9;

#define DBG 0
#define TR(X) {if(DBG) cerr << (#X) << " = " << (X) << "\n";}
#define hline {if(DBG) cerr << "----------------------------------------------------------------------" << "\n";}
#define PK(X) {if(DBG) cerr << (X) << "\n";}

ld all;
ll lall;

vvvd mem(302, vvd(302, vd(302, -100)));

ld rek(ll p1, ll p2, ll p3) {
	if( mem[p1][p2][p3] < 0 ) {
		ld p0 = all - (p1 + p2 + p3);
		if(abs(p0 - all) < eps)
			return 0.0;

		ld res = 0.0;
		if(p3 > 0) {
			res += (p3 / all) * (1 + rek(p1, p2 + 1, p3 -1 ));
		}
		if(p2 > 0) {
			res += (p2 / all) * (1 + rek(p1 + 1, p2 - 1, p3 ));
		}
		if(p1 > 0) {
			res += (p1 / all) * (1 + rek(p1 - 1, p2, p3 ));
		}

		mem[p1][p2][p3] = (res + (p0 / all)) / (1 - (p0 / all));
	}
	hline;
	TR(p1);
	TR(p2);
	TR(p3);
	TR(mem[p1][p2][p3]);
	return mem[p1][p2][p3];
}

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

	ll N;
	cin >> N;

	ll a[4] = {0};
	FOR(i,0,N){
		ll ai;
		cin >> ai;
		all ++;
		lall ++;

		a[ai]++;
	}

	cout << fixed << setprecision(9);
	cout << rek(a[1], a[2], a[3]) << endl;
}


Measured memory_bytes: 437888
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 9223372036854775807
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=1e5 ;
int main()
{
    fast ;
    string s,t ; cin>>s>>t ;

    ll ans=0 ;
    for(ll i=0;i<s.length();i++)
    {
        if(s[i]!=t[i]) ans++ ;
    }
    cout<<ans ;



}




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

using namespace std;

map<int, int> mp;

int main() {
    if (fopen("A.inp", "r"))
    freopen("A.inp", "r", stdin),
    freopen("A.out", "w", stdout);
    int n; cin >> n;
    long long res = 0;
    for (int i = 1; i <= n; i++) {
        int x; cin >> x;
        if (mp.count(i - x))
            res += mp[i - x];
        mp[x + i]++;
    }
    cout << res;
}


Measured memory_bytes: 13004
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  int ans = 0;
  for(int i=A;i<=B;i++){
    string s = to_string(i);
    if(s.at(0)==s.at(4) && s.at(1)==s.at(3)){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,a,x=0;
  cin >> N;  
  vector<int> b(101,0);
  
  for(int i=0;i<N;i++){
    cin >> a;
  	b.at(a)=1;
  }   
   
  for(int i=0;i<101;i++)  x+=b.at(i);
        
  cout << x << endl; 
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    char m;
    int a,c,d;
    scanf("%d %c %d",&a,&m,&c);
    if(m=='+')
    {
        d=a+c;

    }
    else
    {
        d=a-c;
    }
     printf("%d\n",d);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = (int)1e9 + 7;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,k;
    cin>>n>>k;
    ll a[n+1], dp[n+1][k+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    dp[0][0] = 1;
    for(int i=1;i<=k;i++){
        dp[0][i] = 0;
    }
    for(int i=1;i<=n;i++){
        vector<int> sum(k+1);
        sum[0] = dp[i-1][0];
        for(int j=1;j<=k;j++){
            sum[j] = (sum[j-1] + dp[i-1][j])%mod;
        }
        for(int j=0;j<=k;j++){
            if(j <= a[i]){
                dp[i][j] = sum[j];
            }
            else{
                dp[i][j] = (sum[j] - sum[j-a[i]-1] + mod)%mod;
            }
        }
        sum.clear();
    }
    cout<<dp[n][k]<<"\n";
}

Measured memory_bytes: 79608
n = parse(Int,readline())
a = map(x->parse(Int,x),split(readline()))
sort!(a)
m = div(a[n],2)
x = max(1,searchsortedlast(a,m))
y = min(n-1,searchsortedfirst(a,m))
println(a[n], ' ', m-a[x] < a[y]-m ? a[x] : a[y])


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

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<int>A(N+1);
    for (int i = 1; i <= N; ++i) {
        cin >> A[i];
    }
    vector<int>X(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> X[i];
    }
    vector<pair<int, ll>> boundary; // 区間 [ ) の左, 答え
    boundary.reserve(N);
    ll sum = 0;
    for (int i = N; i > 0; i -= 2) {
        sum += A[i];
    }
    for (int i = 1; i <= (N-1)/2; ++i) {
        int b = A[N-i] + A[N-2*i];
        b = b / 2 + 1;
        b *= -1;
        boundary.push_back({b, sum});
        sum -= A[N-2*i];
        sum += A[N-i];
    }
    boundary.push_back({1, sum});
    for (int i = 0; i < Q; ++i) {
        pair<int, ll> p = {X[i]*-1, -1};
        auto iter = upper_bound(boundary.begin(), boundary.end(), p);
        p = *iter;
        cout << p.second << "\n";
    }
    return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

class Main {

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

		int m, n;
		int a1, a2, a3, a4;
		int c;
		int a[][];
		
		n = scan.nextInt();
		m = scan.nextInt();
		a = new int[n + 1][m + 1];
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				a1 = scan.nextInt();
				a[i][j] = a1;
				a[n][j] += a1;
				a[i][m] += a1;
			}
			a[n][m] += a[i][m];
		}
		
		for(int i = 0; i <= n; i++){
			for(int j = 0; j <= m; j++){
				System.out.print(a[i][j]);
				if(j != m){
					System.out.print(" ");
				}
			}
			System.out.println();
		}
			
	}
}	

Measured memory_bytes: 45712
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>

using namespace std;

int main(void)
{
    string s[60], X;
    long long N, t[60], i, sum=0, judge=0;

    cin >> N;

    for(i=1; i<=N; i++){
        cin >> s[i] >> t[i];
    }

    cin >> X;

    for(i=1; i<=N; i++){
        if(judge == 1){
            sum += t[i];
        }

        if(s[i] == X){
            judge = 1;
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000

int partition(int [],int , int);
int main(){
  int A[MAX],n,i,same;
    scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
    same=partition(A,0,n-1);
    for(i=0;i<n;i++){
      if(i==same){
        printf("[%d] ",A[same]);
        continue;
      }
      if(i==n-1  )printf("%d\n",A[i]);
      else printf("%d ",A[i]);
    }
    return 0;
      }

int partition(int A[],int p,int r)
{
  int x,i,j,a;

  x=A[r];
  i=p-1;

  for(j=p;j<r;j++){
    if(A[j]<=x){
      i=i+1;
      a=A[j];
      A[j]=A[i];
      A[i]=a;
    }
  }
    a=A[i+1];
    A[i+1]=A[r];
    A[r]=a;

    return i+1;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  vi32 v(5); cin >> v;
  sort(all(v));
  reverse(all(v));
  cout << v << '\n';
}



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

#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define out(a) cout << a << endl
#define PRINT(V) for (auto v : (V)) cout << v << " "

const int MOD = 1000000007;
const double PI = acos(-1.0);

int solve() {
    string S, T;
    cin >> S >> T;
    rep(i, S.size()){
        if(S.at(i) != T.at(i)) return 0;
    }
    return 1;
}
int main() {
    INCANT;
    if(solve()) out("Yes");
    else out("No");
    return 0;
}




Measured memory_bytes: 3644
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <limits>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;
constexpr ll INF = std::numeric_limits<ll>::max()>>2;

ll A, B, Q;
ll ss[100010], ts[100010];

int lower_bound( ll *arr, ll sz, ll x )
{
  int lb = -1, rb = sz;

  while( rb-lb > 1 )
  {
    int mid = (lb+rb)/2;

    if( arr[mid] >= x )
      rb = mid;
    else
      lb = mid;
  }

  return rb;
}

int main()
{
  scanf( "%lld%lld%lld", &A, &B, &Q );
  rep( i, A )
    scanf( "%lld", ss+i+1 );
  ss[0] = -INF, ss[A+1] = INF;
  rep( i, B )
    scanf( "%lld", ts+i+1 );
  ts[0] = -INF, ts[B+1] = INF;

  rep( i, Q )
  {
    ll x;
    scanf( "%lld", &x );

    int si = lower_bound( ss, A+2, x );
    int ti = lower_bound( ts, B+2, x );

    ll ans = INF;

    for( int a = si-1; a <= si+1; ++a ) for( int b = ti-1; b <= ti+1; ++b )
    {
      ans = std::min( ans, llabs(x-ss[a])+llabs(ss[a]-ts[b]) );
      ans = std::min( ans, llabs(x-ts[b])+llabs(ss[a]-ts[b]) );
    }

    printf( "%lld\n", ans );
  }

  return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int n;
string s;

inline bool nat(int l, int r)
{
    if(l==0 || r==0) return true;

    if(l%3==1) return true;
    else if(l%3==2)
    {
        if(r%3==1) return false;
        else return true;
    }
    else
    {
        if(r%3==0) return true;
        else return false;
    }
}

int dp[100001][10][10];
int dfs(int now, int l, int r)
{
    if(dp[now][l][r]>=0) return dp[now][l][r];

    if(now==n) return 0;

    int ret=n;
    if(s[now-1]-'0'==l)
    {
        //????????????????¶?

        //?¬????????¶?
        if(nat(s[now]-'0',r)) ret=min(ret,dfs(now+1,s[now]-'0',r)+1);
        //?¬????????¶?
        if(nat(l,s[now]-'0')) ret=min(ret,dfs(now+1,l,s[now]-'0'));
    }
    if(s[now-1]-'0'==r)
    {
        //????????????????¶?

        //?¬????????¶?
        if(nat(s[now]-'0',r)) ret=min(ret,dfs(now+1,s[now]-'0',r));
        //?¬????????¶?
        if(nat(l,s[now]-'0')) ret=min(ret,dfs(now+1,l,s[now]-'0')+1);
    }

    return dp[now][l][r]=ret;;
}

int main()
{
    while(cin >>s,(s!="#"))
    {
        n=s.size();
        memset(dp,-1,sizeof(dp));
        printf("%d\n",min(dfs(1,s[0]-'0',0),dfs(1,0,s[0]-'0')));
    }
    return 0;
}

Measured memory_bytes: 50124
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>

using namespace std;

vector<int> p;
int N;
map<int, int> comp;

void get_prime()
{
    for (int i = 2; i <= 100;i++)
    {
        bool f = true;
        for (int j = 2; j <= i / 2; j++)
        {
            if(i % j == 0)
            {
                f = false;
                break;
            }
        }
        if(f == true)
        {
            p.push_back(i);
        }
    }
}

void factoring()
{
    for (int i = 2; i <= N;i++)
    {
        int n = i;
        for (auto d = p.begin(); d != p.end();)
        {
            if(n % *d == 0)
            {
                if(comp.find(*d) == comp.end())
                {
                    comp.insert(make_pair(*d, 1));
                }
                else
                {
                    comp[*d]++;
                }
                n /= *d;
            }
            else
            {
                d++;
            }
        }
    }
}

int cnt(int n)
{
    int c = 0;
    for (auto i = comp.begin(); i != comp.end();i++)
    {
        if(i->second >= n)
        {
            c++;
        }
    }
    return c;
}

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

    int ans = cnt(74) + cnt(24) * ( cnt(2) - 1) + cnt(14) * (cnt(4) - 1) + (cnt(4) * (cnt(4) - 1) * (cnt(2) - 2) / 2);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
N, Y = map(int, input().split())
for x in range(N+1): #xを1万円札とする
    for y in range(N+1-x): #yを5千円札とする
        z = N-x-y #zを千円札とする
        if 0<=z<=2000 and 10000*x+5000*y+1000*z == Y:
            print(x,y,z)
            sys.exit()
print(-1,-1,-1)        
#変数が多い場合の方程式の探索

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

#define MAX 2000001
#define VMAX 10000

void countingSort(unsigned short *,unsigned short *,int);

int C[VMAX+1];

int main(){
  unsigned short *A, *B;
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=1;i<=n;i++) scanf("%hd",&A[i]);

  countingSort(A,B,n);

  for(i=1;i<n;i++) printf("%d ",B[i]);
  printf("%d\n",B[i]);

  return 0;
}

void countingSort(unsigned short *A,unsigned short *B,int n){
  int i,j;

  for(i=0;i<=VMAX;i++) C[i]=0;
  for(j=1;j<=n;j++) C[A[j]]=C[A[j]]+1;
  for(i=1;i<=VMAX;i++) C[i]=C[i]+C[i-1];
  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]=C[A[j]]-1;
  }
}



Measured memory_bytes: 9564
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(a[k - 1])


Measured memory_bytes: 2940
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n; cin >> n;
  cout << "Christmas";
  for (int i = 25; i > n; i--) {
    cout << " Eve";
  }
  cout << '\n'; 
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

int main() {
  int N,L;
  cin>>N>>L;
  int sum=0;
  
  
  for (int i=1;i<=N;i++) {
    sum+=L+i-1;
  }
  
  if (L+N-1<0) cout<<sum-(L+N-1)<<endl;
  else if (L>0) cout<<sum-L<<endl;
  else cout<<sum<<endl;
}

Measured memory_bytes: 256
N = int(input())
S = list(input())

# ordで文字からunicode数字を返す
# chrでunicode数字から文字を返す

def chr_change(chr, N):
    """ print("chr is", chr)
    print("N is", N)
    print("ord(chr) is ", ord(chr))
     """
    Num_AtoZ = ord("Z") - ord("A")
    if ord(chr) + N > ord("Z"):
        chg_chr = ord(chr) + N - Num_AtoZ -1
    else:
        chg_chr = ord(chr) + N
    #print("chg_chr is", chg_chr)
    return chg_chr


for i in range(len(S)):
    tmp_chr = S[i]
    print(chr(chr_change(tmp_chr, N)), end = "")
print("\n")


Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
 
const long long MOD = 1000000007;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
typedef long long ll;
 
int main(){
    int N;
    cin >> N;
    vec a(N);
    for(int i=0;i<N;i++){
        cin >> a[i];
        a[i]--;
    }

    ll ans = 0;
    for(int i=0;i<N-1;i++){
        if (i < a[i] && a[a[i]] == i){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
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; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_que<int> pque;//これは大きい順
//typedef priority_que<int, vector<int>, greater<int>> pque;//これは小さい順


int main(){
  int n, k;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i,n) cin >> h[i];
  sort(ALL(h));
  ll sum=0;
  if(n<=k) {cout << "0" << endl;}
  else{
    FOR(i,0,n-k) sum += h[i];
    cout << sum << endl;
  }
  

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
using namespace std;

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

template <typename _T>
inline void read(_T &f) {
	f = 0; _T fu = 1; char c = getchar();
	while (c < '0' || c > '9') { if (c == '-') { fu = -1; } c = getchar(); }
	while (c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
	f *= fu;
}

template <typename T>
void print(T x) {
	if (x < 0) putchar('-'), x = -x;
	if (x < 10) putchar(x + 48);
	else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
	print(x); putchar(t);
}

const int N = 2e5 + 5, M = 8e5 + 5;

struct edge_t { int u, v, next, cap, flow; } G[M];

vector <int> adj[N];
queue <int> q;
int head[N], nowhead[N], d[N];
int n, m, s, t, tot = 1;

inline void addedge(int u, int v, int cap) {
	G[++tot] = (edge_t) {u, v, head[u], cap, 0}, head[u] = tot;
	G[++tot] = (edge_t) {v, u, head[v], 0, 0}, head[v] = tot;
}

int bfs() {
	memset(d, 0, sizeof(d));
	d[s] = 1; q.push(s);
	while (!q.empty()) {
		int u = q.front(); q.pop();
		for (int i = head[u]; i; i = G[i].next) {
			int v = G[i].v;
			if (!d[v] && G[i].cap > G[i].flow) {
				d[v] = d[u] + 1;
				q.push(v);
			}
		}
	}
	return d[t];
}

int dfs(int u, int Flow) {
	if (u == t || !Flow) return Flow;
	int f, flow = 0;
	for (int &i = nowhead[u]; i; i = G[i].next) {
		int v = G[i].v;
		if (d[v] == d[u] + 1 && (f = dfs(v, min(Flow, G[i].cap - G[i].flow))) > 0) {
			G[i].flow += f; G[i ^ 1].flow -= f;
			flow += f; Flow -= f;
			if (!Flow) break;
		}
	}
	return flow;
}

int dinic() {
	int ans = 0;
	while (bfs()) {
		memcpy(nowhead, head, sizeof(nowhead));
		ans += dfs(s, 0x7fffffff);
	}
	return ans;
}

int fa[N], vis[N], match[N], cnt;

int main() {
	read(n); s = 0; t = 2 * n;
	for (int i = 1; i < n; i++) {
		read(m);
		for (int j = 1; j <= m; j++) {
			int x; read(x);
			adj[i].push_back(x + n - 1);
			adj[x + n - 1].push_back(i);
			addedge(i, x + n - 1, 1);
		}
	}
	for (int i = 1; i < n; i++) addedge(s, i, 1);
	for (int i = n; i < 2 * n; i++) addedge(i, t, 1);
	if (dinic() != n - 1) {
		puts("-1");
		return 0;
	}
	int rt = 0;
	for (int i = head[n * 2]; i; i = G[i].next) {
		if (G[i].flow == 0) {
			rt = G[i].v;
			break;
		}
	}
	for (int u = 1; u < n; u++) {
		for (int i = head[u]; i; i = G[i].next) {
			int v = G[i].v;
			if (n <= v && v < n * 2 && G[i].flow) match[u] = v;
		}
	}
	q.push(rt); vis[rt] = 1;
	while (!q.empty()) {
		int u = q.front(); q.pop();
		for (auto v : adj[u]) {
			if (!vis[match[v]]) {
				vis[match[v]] = 1;
				fa[match[v]] = u;
				++cnt;
				q.push(match[v]);
			}
		}
	}
	if (cnt != n - 1) {
		puts("-1");
		return 0;
	}
	for (int i = 1; i < n; i++) {
		print(match[i] - n + 1, ' ');
		print(fa[match[i]] - n + 1, '\n');
	}
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}

signed main(){
    int X,Y;
    cin>>X>>Y;

    int ans=X+Y+2;

    int g=gcd(X,Y);

    cout<<ans-(g+1)<<endl;
    return 0;
}

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

const int mod = 1e9+7;
const int INF = 2000000;

int main() {
    string n;
    cin >> n;
    char c = n[n.size()-1];
    if(c == '3') cout << "bon" << endl;
    else if(c == '0' || c=='1' || c=='6' || c=='8') cout << "pon" << endl;
    else cout << "hon" << endl;
}


Measured memory_bytes: 3592
// inputに入力データ全体が入る
function Main(input) {
	var num = input.split(" ");
	for(var n=0; n<num.length; n++){ num[n]=parseInt(num[n]); }
	var output;
	
	if(num[1]%num[0]==0){
		output=num[1]+num[0];
	}else{
		output=num[1]-num[0];
	}
	
	//出力
	console.log(output);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468