akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#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 bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
  int n; cin >> n;
  vector<int> b(n);
  REP(i, n){
    cin >> b[i];
    b[i]--;
  }

  vector<int> ans;

  function<bool(vector<int>)> rec = [&](const vector<int>& v){
    int sz = static_cast<int>(v.size());
    if(sz == 0) return true;

    bool f = false;
    vector<int> nxt;

    for(int i = sz-1; i >= 0; i--){
      if(v[i] == i && !f){
        f = true;
        ans.emplace_back(v[i]);
      }
      else{
        nxt.emplace_back(v[i]);
      }
    }

    reverse(nxt.begin(), nxt.end());

    return f && rec(nxt);
  };

  if(rec(b)){
    for(int i=n-1; i>=0; i--) cout << ans[i] + 1 << endl;
  } else {
    cout << -1 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define hyperspeed ios::sync_with_stdio(false);cin.tie(NULL);
#define ll long long  
#define ull unsigned long long
#define ui unsigned int
#define li long int
#define uli unsigned long int
#define pb push_back
#define ld long double
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
const int MOD = 1e9+7;

void solve() {
    int k,n;
    cin >> k >> n;
    vi v;
    for(int i=0;i<n;i++) {
        int c;
        cin >> c;
        v.pb(c);
    }
    sort(v.begin(),v.end());
    int mx = 0;
    for(int i=1;i<n;i++) {
        mx = max(mx, v[i]-v[i-1]);
    }
    mx = max(mx , (k-(v[n-1]-v[0])));
    cout << k-mx << endl;
}

int32_t main()
{
    hyperspeed
    int test=1;
    // cin >> test;
    while(test--) {
        solve();
    }
    return 0;
}

//--n1m5


Measured memory_bytes: 4276
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  int sz=1<<N;
  vector<int> dp(sz),nx(sz);
  string S;
  cin>>S>>dp;
  auto win=[&](int a,int b){if(a>b){swap(a,b);} return S[b-a-1]=='0'?a:b;};
  for(int i=N;i>0;i--){
    for(int j=0;j<sz;j+=1<<i){
      for(int k=0;k<1<<i;k+=2){
        int idx=j+k;
        nx[idx/2]=win(dp[idx],dp[idx+1]);
        nx[sz/2+idx/2]=win(dp[idx+1],dp[k+2==(1<<i)?j:idx+2]);
      }
    }
    swap(dp,nx);
  }
  for(auto &I:dp){cout<<I<<endl;}
  

  return 0;
}



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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2> 
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main(){
	int n, gw;
	cin >>n >>gw;
	VI v(n), w(n);
	rep(i, n) cin >>v[i] >>w[i];
	
	VI dp( gw+ 50, -1);
	dp[0] = 0;
	rep(i,n) rep(j, gw) if(dp[j] >=0){
		if(j + w[i] <= gw)  dp[j+w[i]] = max(dp[j+w[i]], dp[j] + v[i]);
	}
	rep(i, gw) dp[i+1] = max(dp[i+1], dp[i]);
	cout << dp[gw] <<"\n";
	//for(auto x :dp) printf("%d, ",x); puts("");
	return 0;
}




Measured memory_bytes: 3164
#include<iostream>
#include<list>
#include<vector>
#include<string>
#include<cmath>

using namespace std;

int main(){
  	int size = 3;
  	string s[size] = {};
	for (int i = 0; i < size; i++){
      cin >> s[i];
    }
    
    cout << 'A' << s[1][0] << 'C' << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

vector<int> W;

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

    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> b = a;
    sort(all(b));
    int ans = b[q - 1] - b[0], pos = 0;
    while (pos + q - 1 < n)
    {
        vector<int> v, w;
        int sum = 0, cnt = 0, num = b[pos];
        rep(i, n)
        {
            if (a[i] >= num)
            {
                cnt++;
                w.push_back(a[i]);
                if (a[i] == num)
                    pos++;
            }
            else
            {
                sort(all(w));
                rep(j, cnt - k + 1)
                    v.push_back(w[j]);
                w = W;
                sum += max(cnt - k + 1, 0LL);
                cnt = 0;
            }
        }
        sum += max(cnt - k + 1, 0LL);
        sort(all(w));
        rep(i, cnt - k + 1)
            v.push_back(w[i]);
        if (sum < q)
            break;
        sort(all(v));
        ans = min(ans, v[q - 1] - v[0]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
// clang-format off
#include <bits/stdc++.h>

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

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define pii pair<int, int>
#define vi vector<int>

using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T>& p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T>& vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
using ll = long long;
constexpr ll MOD = 1000000007;

constexpr int MAX = 100000;
ll a[3*MAX];

int main()
{
    int N;
    cin >> N;
    rep(i, 3*N){
        cin >> a[i];
    }
    sort(a, a+3*N);
    ll sum = 0;
    for(int i = 1;i <= N;i++){
        sum += a[3*N-2*i];
    }
    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 2560
s=input().split()

if int(s[2])>int(s[0]):
  if int(s[2])>int(s[1]):
    print("0")
  else:
    if int(s[3])>int(s[1]):
      print(int(s[1])-int(s[2]))
    else:
      print(int(s[3])-int(s[2]))
else:
  if int(s[0])>int(s[3]):
    print("0")
  else:
    if int(s[3])>int(s[1]):
      print(int(s[1])-int(s[0]))
    else:
      print(int(s[3])-int(s[0]))

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

using namespace std;
using ll = long long;


int main()
{
	int n, c, k; cin >> n >> c >> k;
	vector<int> a(n); for(int i = 0; i < n; i++)cin >> a[i];
	sort(a.begin(), a.end());
	int cnt = 0, cur = a[0];
	int res = 1;


	for(int i = 0; i < n; i++) {
		if(cur + k < a[i] || cnt >= c) {
			cnt = 1;
			cur = a[i];
			res++;
	//		cout << a[i] << endl;
		} else {
			cnt++;
		}
	}

	cout << res << endl;
}

Measured memory_bytes: 640
from itertools import permutations


def main(n, a):
    ans = 0
    for i, j in permutations(a, 2):
        ans = max(ans, i - j)

    print(ans)


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    main(n, a)


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

int main(void)
{
    int N, M, k;
    cin >> N >> M;
    vector<vector<int> > s(M);
    for (int i = 0; i < M; ++i) {
        cin >> k;
        s[i].resize(k);
        for (int j = 0; j < k; ++j) {
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    vector<int> p(M);
    for (int i = 0; i < M; ++i) cin >> p[i];

    int ans = 0;
    for (int bit = 0; bit < (1<<N); ++bit) {
        bool ok = true;
        for (int i = 0; i < M; ++i) {
            int counter = 0;
            for (int j = 0; j < s[i].size(); ++j) {
                if (bit & (1<<s[i][j])) counter++;
            }
            if (counter % 2 != p[i]) {
                ok = false;
            }
        }
        if (ok) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

namespace ConsoleApp2
{
    class Program
    {
        static long[,] A;
        static bool[,] map;
        static long count = 0;
        static long N;
        static long[] used;
        static long ans = 1;
        static void Main(string[] args)
        {
            N = long.Parse(Console.ReadLine());
            A = new long[N + 1, N];
            used = new long[N+1];
            for (int i = 1; i <= N; i++)
            {
                used[i] = 1;
            }
            map = new bool[N + 1, N + 1];
            for (int i = 1; i <= N; i++)
            {
                var tmp = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
                for (int j = 1; j < N; j++)
                {
                    A[i, j] = tmp[j - 1];
                }
            }

            if (Solve())
            {
                Console.WriteLine(ans);
            }
            else
            {
                Console.WriteLine(-1);
            }
            
        }

        static bool Solve()
        {
            var que = new Queue<long>();
            for (int i = 1; i <= N; i++)
            {
                map[i, A[i, 1]] = true;
                if (map[A[i, 1],i])
                {
                    que.Enqueue(i);
                    used[i]++;
                    que.Enqueue(A[i, 1]);
                    used[A[i, 1]]++;
                }
                //que.Enqueue(i);
            }

            while (que.Count() > 0)
            {
                ans++;
                var num = que.Count();
                for (int i = 0; i < num; i++)
                {
                    var top = que.Dequeue();
                    var opp = A[top, used[top]];
                    map[top, opp] = true;
                    if (map[opp, top])
                    {
                        if(used[top] < N - 1)
                        {
                            que.Enqueue(top);
                            used[top]++;
                        }
                        if (used[opp] < N - 1)
                        {
                            que.Enqueue(opp);
                            used[opp]++;
                        }
                            
                    }
                }
            }

            for (int i = 1; i <= N; i++)
            {
                if (used[i] != N-1)
                {
                    return false;
                }
            }
            return true;
        }

    }
}


Measured memory_bytes: 39860
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int a,b,c,n;
  while(cin>>a>>b>>c,a||b||c){
    cin>>n;
    int x[n],y[n],z[n],r[n];
    for(int i=0;i<n;i++) cin>>x[i]>>y[i]>>z[i]>>r[i];
    int ok[a+b+c],ng[a+b+c];
    memset(ok,0,sizeof(ok));
    memset(ng,0,sizeof(ng));
    for(int i=0;i<n;i++){
      if(!r[i]) continue;
      x[i]--;y[i]--;z[i]--;
      ok[x[i]]=ok[y[i]]=ok[z[i]]=1;
    }
    for(int i=0;i<n;i++){
      if(r[i]) continue;
      x[i]--;y[i]--;z[i]--;
      int k=ok[x[i]]+ok[y[i]]+ok[z[i]];
      if(k==2){
	if(!ok[x[i]]) ng[x[i]]=1;
	if(!ok[y[i]]) ng[y[i]]=1;
	if(!ok[z[i]]) ng[z[i]]=1;
      }
    }
    for(int i=0;i<a+b+c;i++){
      if(ok[i]) cout<<1<<endl;
      else if(ng[i]) cout<<0<<endl;
      else cout<<2<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3016
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Map;
import java.util.HashMap;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        Map<Integer, Integer> as = new HashMap<>();
        
        int a;
        for (int i = 0; i < n; i++) {
            a = Integer.parseInt(br.readLine());
            if (as.get(a) == null) {
                as.put(a, 1);
            }
            else {
                as.put(a, as.get(a)+1);
            }
        }
        
        int count = 0;
        for (int x : as.values()) {
            if (x % 2 == 1) count++;
        }
        
        System.out.println(count);
    }
}


Measured memory_bytes: 37164
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
using namespace std;
using ll = long long;
const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

mint com(ll N,ll K){
    mint res = 1;
    for(ll i=0;i<K;i++)res*=N-i;
    for(ll i=1;i<=K;i++)res/=i;
    return res;
}

int main(){
    ll N,K;
    cin>>N>>K;
    for(ll i=0;i<K;i++){
        mint res = com(K-1,i)*com(N-K+1,i+1);
        cout<<res<<"\n";
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
 
N=int(input())
print(N+N**2+N**3)

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    string S;
    cin >> S;

    int remainP = 0;
    int ans = 0;
    for (auto c : S) {
        if (c == 'g') {
            if (remainP > 0) {
                ans++;
                remainP--;
            } else {
                remainP++;
            }
        } else if (c == 'p') {
            if (remainP == 0) {
                ans--;
                remainP++;
            } else {
                remainP--;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 512
/*
 * Problem Description: Heaps - Complete Binary Tree
 * Category:
 * Author: Khan
 * Date: 17th October, 2017
 */

#include <iostream>
#define MAXN 100000

using namespace std;

int parent(int i) {return i / 2;}
int leftChild(int i) {return i * 2;}
int rightChild(int i) {return i * 2 + 1;}

int main(int argc, char const *argv[])
{
    //freopen("sample.txt", "r", stdin);
    int H, A[MAXN + 1];
    cin >> H;
    for (int i = 1; i <= H; ++i)
    {
        cin >> A[i];
    }
    for (int i = 1; i <= H; ++i)
    {
        cout << "node " << i << ": key = " << A[i] << ", ";
        if(parent(i) >= 1)
            cout << "parent key = " << A[parent(i)] << ", ";
        if(leftChild(i) <= H)
            cout << "left key = " << A[leftChild(i)] << ", ";
        if(rightChild(i) <= H)
            cout << "right key = " << A[rightChild(i)] << ", ";
        cout << endl;
    }
}

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

template<class T, class E, class C = std::less<T>>
struct SkewHeap {
    using F = function<T(T, E)>;
    using G = function<E(E, E)>;
    using value_type = T;
    using operation_type = E;
private : 
    C compare;
    const F f;
    const G g;
    const E ie;
    int sz;

    struct node_data {
    public : 
        value_type val;
        operation_type add;
        unique_ptr<node_data> left_node, right_node;
        node_data(const value_type &val, const operation_type &add) :
            val(val), add(add), left_node(nullptr), right_node(nullptr) { }
    };

    using node_type = unique_ptr<node_data>;

    node_type root;

public : 
    SkewHeap() : f([](const T &a, const E &b) { return (a + b); }),
                 g([](const E &a, const E &b) { return (a + b); }),
                 ie(E()) { }

    SkewHeap(const F &f, const G &g, const E &ie) : f(f), g(g), ie(ie), root(nullptr), sz(0) { }

    node_type propagate(node_type node) {
        if (node == nullptr) return (move(node));
        if (node->add == ie) return (move(node));
        if (node->left_node) {
            node->left_node->add = g(node->left_node->add, node->add);
        }
        if (node->right_node) {
            node->right_node->add = g(node->right_node->add, node->add);
        }
        node->val = f(node->val, node->add);
        node->add = ie;
        return move(node);
    }

    node_type meld(node_type a, node_type b) {
        if (not a) return b;
        if (not b) return a;
        if (compare((b->val), (a->val))) a.swap(b);
        a = propagate(move(a));
        a->right_node = meld(move(a->right_node), move(b));
        a->left_node.swap(a->right_node);
        return a;
    };

    constexpr int size() const noexcept {
        return size_t(sz);
    }

    constexpr bool empty() const noexcept {
        return (sz == 0);
    }

    void insert(const value_type &x) {
        root = propagate(move(root)); sz++;
        root = meld(move(root), make_unique<node_data>(move(node_data(x, ie))));
    }

    value_type& top() {
        assert(not empty());
        root = propagate(move(root));
        return (root->val);
    }

    value_type pop() {
        const value_type top_value = top(); sz--;
        root = meld(move(root->left_node), move(root->right_node));
        return top_value;
    }

    void add(const operation_type &x) noexcept {
        if (root) root->add = g(root->add, x);
    }

    void meld(SkewHeap &skew) {
        sz += skew.sz; skew.sz = 0;
        root = meld(move(root), move(skew.root));
    }

};

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

    SkewHeap<int, int, greater<int>> skew;

    for (int i = 0; i < n; i++) {
        int e;
        cin >> e;
        skew.insert(e);
    }

    for (int i = 0; i < m; i++) {
        int e = skew.pop();
        skew.insert(e / 2);
    }

    long long ans = 0;
    while (skew.size()) ans += (skew.pop());

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3328
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let mut a: Vec<usize> = (0..n + 1).collect();
    let mut i = 3;
    while i <= n {
        a[i] = 0;
        i += 3;
    }
    i = 5;
    while i <= n {
        a[i] = 0;
        i += 5;
    }
    println!("{}", a.iter().sum::<usize>());
}


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

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11


int main()
{
    char c; cin >> c;
    if(c >= 'A' && c <= 'Z')cout << 'A' << endl;
    else cout << 'a';
}


Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
const int INF = INT_MAX;
const ll MOD = 998244353;

int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    int N;
    cin >> N;
    vint cntA(112345,0);
    repeat(i, N){
        int A;
        cin >> A;
        cntA[A]++;
    }
    int ans = 0;
    bool eveneven=true;
    repeat(i, 112345){
        if(cntA[i]==0) continue;
        ans++;
        if(cntA[i]%2==0){
            eveneven = !eveneven;
        }
    }
    if(!eveneven){
        ans--;
    }
    cout << ans << endl;
    
    return 0;
}



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

int main() {
  int N,r,preN,ret;
  int n = 10;
  int m = 1;
  int sum = 0;
  cin >> N;
  if((N<1)&&(N>100000000))
    cout << "error";
  else{
    preN = N;
    while(1){
      r = N % n;
      N -= r;
      sum += r;
      N /= 10;
      if(N < 10){
        sum += N;
        break;
      }
    }
    ret = preN % sum;
    if(ret == 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define mod 1000000007
#define mem(a,val) memset(a,val,sizeof(a))

using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
	ll x;cin>>x;
	ll amt = 100;
	ll y=0;
	while(amt<x){
		amt = amt + (amt/100);
		y++;
	}
	cout<<y;
	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>

int main(void) {
    int N;
    int count = 0;;
    std::cin >> N;
    std::vector<int>a(N);
    for (int i=0; i < N; i++) {
        std::cin >> a[i];
        if ((i+1) % 2 != 0) {
            if (a[i] % 2 != 0) {
                count++;
            }
        }
    }

    std::cout << count << std::endl;
}

Measured memory_bytes: 3624
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+8
#define EPS 1e-8
#define PB push_back
#define fi first
#define se second
#define ll long long 
#define reps(i,j,k) for(ll i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
int n;
int check(int y,int x,char field[256][256]){
    int res = 0;
    int ny = y;
    int nx = x;
    int tmp=0;
    while(true){
        if(nx < 0 || nx >= n || ny < 0 || ny >= n || field[ny][nx] == '0')break;
        tmp++;
        ny++;
    }
    res = max(res,tmp);
    ny = y;nx= x;tmp = 0;
    while(true){
        if(nx < 0 || nx >= n || ny < 0 || ny >= n || field[ny][nx] == '0')break;
        tmp++;
        nx++;
    }
    res = max(res,tmp);
    ny = y;nx= x;tmp = 0;
    while(true){
        if(nx < 0 || nx >= n || ny < 0 || ny >= n || field[ny][nx] == '0')break;
        tmp++;
        nx++;
        ny++;
    }
    res = max(res,tmp);
    ny = y;nx= x;tmp = 0;
    while(true){
        if(nx < 0 || nx >= n || ny < 0 || ny >= n || field[ny][nx] == '0')break;
        tmp++;
        nx--;
        ny++;
    }
    res = max(res,tmp);
    ny = y;nx= x;tmp = 0;
    return res;
}
int main(){
    while(scanf("%d",&n),n){
        char field[256][256];
        rep(i,n){
            scanf("%s",field[i]);
        }
        int ans = 0;
        rep(i,n){
            rep(j,n){
                if(field[i][j] == '1'){
                    ans = max(ans,check(i,j,field));
                }
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1256
n=int(input())
p=list(map(int,input().split()))
count=0
for i in range(n-2):
  if((p[i]<p[i+1] and p[i+1]<p[i+2])or(p[i]>p[i+1] and p[i+1]>p[i+2])):
    count+=1
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <numeric>

using namespace std;

string S;

int main()
{
    cin >> S;
    int N = S.length();
    int cnt1 = 0;
    int cnt2 = 0;
    for (int i = 0; i < N; i++)
    {
        if(i % 2 == 0)
        {
            if (S[i] == '0')
            {
                cnt1++;
            }
            else
            {
                cnt2++;
            }
        }
        else
        {
            if (S[i] == '0')
            {
                cnt2++;
            }
            else
            {
                cnt1++;
            }
        }        
    }
    cout << min(cnt1, cnt2) << endl;

    return 0;
}

Measured memory_bytes: 760
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
ll w[110],v[110],dp[105][100005];
ll f(ll x,ll y){
	if(y<=-1)return 10000000000;
	if(x==-1&&y!=0)return 10000000000;
	if(x==-1&&y==0)return 0;
	if(dp[x][y]>=0)return dp[x][y];
	dp[x][y]=min(f(x-1,y),f(x-1,y-v[x])+w[x]);
	return dp[x][y];
}

int main(){FIN;
	ll N,W; cin>>N>>W;
	fore(i,0,N){
		cin>>w[i]>>v[i];
	}
	memset(dp,-1,sizeof dp);
	for(int i=100000;i>=0;i--){
		//cout<<f(N-1,i);
		if(f(N-1,i)<=W){cout<<i; break;
		}
	}
	
	return 0;
}


Measured memory_bytes: 82304
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;

    int total = b-a+1;
    int x = c*d/__gcd(c,d);
    int c1 = 0;
    int c2 = 0;
    int c3 = 0;
    if ( a%c == 0 ){
        c1 = (b/c - a/c + 1);
    }
    else{
        c1 = (b/c - a/c);
    }

    if ( a%d == 0 ){
        c2 = (b/d - a/d + 1);
    }
    else{
        c2 = (b/d - a/d);
    }

    if ( a%x == 0 ){
        c3 = (b/x - a/x + 1);
    }
    else{
        c3 = (b/x - a/x);
    }

    cout<<total-c1-c2+c3<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;

#define pi 3.141592653589
#define repeat(i,n) for(int i=0;i<n;i++)

int main()
{
	int a, b, c;
	double S, L, h,fai,nokori;
	cin >> a >> b >> c;
	
	
	fai = c * 2 * pi / 360;
	h = sin(fai)*b;
	S = a * h / 2;
	nokori = sqrt(a*a + b*b - 2 * a*b*cos(fai));
	L = a + b + nokori;
	cout << fixed << setprecision(5) << S << " " << L << " " << h << endl;

	return 0;

}

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

int main()
{
    string s;
    cin>>s;
    int cnt=0;
    REP(i,s.size())if(s[i]=='x')cnt++;
    if(cnt>=8)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}


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

using ll = long long;

#define vl vector<long long>
using pll = pair<long long, long long>;
#define __ << '\n'
#define _ << ' '
#define all(x) (x).begin(), (x).end()

void error()
{
    cout << "-1";
    exit(0);
}

#define flush fflush(stdout)

bool check(ll i, vector<bitset<64>>& a)
{
    ll c_1 = 0;
    ll c_0 = 0;

    for (auto e : a)
    {
        if (e[i] == 1)
            c_1++;
        else
            c_0++;
    }

    if (c_1 < c_0)
        return true;
    else
        return false;
}

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

    ll n;
    ll tmp;
    cin >> n;

    bitset<64> k;
    cin >> tmp;
    k = tmp;

    vector<bitset<64>> a(n);
    for (auto i = 0; i < n; i++)
    {
        cin >> tmp;
        a[i] = tmp;
    }

    bool flag = true;
    bitset<64> answer(0);
    for (ll i = 63; i >= 0; i--)
    {
        if (flag)
        {
            if (k[i] == 0)
            {
                continue;
            } else
            {
                ll bit = check(i, a);
                if (bit == 0)
                    flag = false;
                answer[i] = bit;
            }
        } else
        {
            ll bit = check(i, a);

            answer[i] = bit;
        }
    }


    ll ans = 0;
    for (auto e : a)
    {
        ans += answer.to_ulong() ^ e.to_ulong();
    }

    cout << ans;




    return 0;
}

Measured memory_bytes: 1024
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <bits/stdc++.h>

using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[200010];
    
    for (int i=0; i<n; i++) {
        cin >> a[i];
    }
    sort(a, a+n);
    for (int i=0; i<n-1; i++) {
        if (a[i] == a[i+1]) {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


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

using namespace std;

int main(){
  int h, w;
  cin >> h >> w;

  char s[h][w];
  for(int i=0; i<h; i++){
    string in;
    cin >> in;
    for(int j=0; j<w; j++){
      s[i][j] = in[j];
    }
  }

  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if(s[i][j] == '#'){
        cout << '#';
      } else {
        int n = 0;
        for(int in=i-1; in<=i+1; in++){
          for(int jn=j-1; jn<=j+1; jn++){
            if(!(in == i && jn == j) && in >= 0 && jn >= 0 && in < h && jn < w)
              if(s[in][jn] == '#')
                n++;
          }
        }
        cout << n;
      }
    }
    cout << endl;
  }

  return 0;
}


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

using namespace std;

const int Nmax = 3005;

int n, i, x, y, val[Nmax], dad[Nmax];
bool used[Nmax], down[Nmax], all[Nmax];
vector<int> v[Nmax];

void dfs(int node)
{
    down[node] = 0;
    used[node] = 1;

    for(auto son : v[node])
        if(!used[son])
        {
            dad[son] = node;
            dfs(son);
            if(!down[son] && val[node] > val[son]) down[node] = 1;
        }
}

void dfs2(int node)
{
    all[node] = down[node] || (val[node] > val[dad[node]] && !all[dad[node]]);
    for(auto son : v[node])
        if(son != dad[node]) dfs2(son);
}

int main()
{
  //  freopen("input", "r", stdin);
    cin.sync_with_stdio(false);

    cin >> n;
    for(i=1; i<=n; ++i) cin >> val[i];

    for(i=1; i<n; ++i)
    {
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }

    dfs(1); val[0] = (1<<30);
    dfs2(1);

    for(i=1; i<=n; ++i)
        if(all[i]) cout << i << ' ';

    return 0;
}


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

#define rep(i,n) for(int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false;}

const int MAX_N = 1e5+3;
ll dp[MAX_N][3];

int main() {
  int n;
  cin >> n;
  int a[n][3];
  rep(i,n) cin >> a[i][0] >> a[i][1] >> a[i][2];

  rep(i,n) {
    rep(j,3) {
      rep(k,3) {
	if (j != k) {
	  chmax(dp[i+1][k], dp[i][j] + a[i][k]);
	}
      }
    }
  }
  ll ans = 0;
  rep(i,3) ans = max(dp[n][i], ans);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3712
#include<iostream>
using namespace std;
int main()
{
	int n,m;
	while(cin>>n>>m)
	{
		int l,r,ll=0,rr=100005;
		for(int i=0;i<m;i++)
		{
			cin>>l>>r;
			if(l>ll)
			  ll=l;
			if(r<rr)
			  rr=r;
		}
		cout<<max(rr-ll+1,0)<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll A, B, C, K; cin >> A >> B >> C >> K;
  ll ans = 0;
  ans += min(A,K);
  K -= A;
  if (K > 0)
    K -= B;
  if (K > 0)
    ans -= min(C, K);
  cout<<ans<<endl;
}


Measured memory_bytes: 3596
da=list(map(str,input().split()))
def ju(k):
    if k=='+' or k=='-' or k=='*':
        return False
    else:
        return True

def change(li):
    n=len(li)
    if n==1:
        return li[0]
    ret=[]
    i=0
    while(i<n-2):
        if ju(li[i]) and ju(li[i+1]) and (not ju(li[i+2])):
            x,y=int(li[i]),int(li[i+1])
            if li[i+2]=='+':
                ret.append(str(x+y))
            elif li[i+2]=='-':
                ret.append(str(x-y))
            else:
                ret.append(str(x*y))
            i+=3
        else:
            ret.append(li[i])
            i+=1
    while i<n:
        ret.append(li[i])
        i+=1
    return change(ret)

print(change(da))


Measured memory_bytes: 5672
#include <bits/stdc++.h>
using namespace std;
int main(){
    int H1,H2,M1,M2,K;cin>>H1>>M1>>H2>>M2>>K;
    int ans=H2*60+M2-H1*60-M1;
    if(ans<K)cout<<0;
    else cout<<ans-K;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 1e+5+5;

int n;
int a[N];
int dep[N];
int k;
int lef[N],rig[N];
int dfn[N],R[N],m;
int f[N];
int ans;

void dfs(int x){
	dfn[x]=++m;
	for(int y=lef[x];y;y=rig[y]){
		dep[y]=dep[x]+1;
		dfs(y);
		f[x]=max(f[x],f[y]);
	}
	R[x]=m;
	f[x]++;
	if (f[x]==k&&a[x]!=1){f[x]=0;ans++;}
}

int main(){
	n=get();k=get();
	fo(i,1,n)a[i]=get();
	ans=(a[1]!=1);
	a[1]=1;
	fo(i,2,n){
		rig[i]=lef[a[i]];
		lef[a[i]]=i;
	}
	dfs(dep[1]=1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 6144
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if((b-a) == (c-b)) {
        cout << "YES";
    }
    else {
        cout << "NO";
    }
    
    cout << endl;
    return 0;
}

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

int main() {
    long long X;
    cin >> X;
    for (int i=-1000; i<1000; i++) {
        for (int j=-1000; j<1000; j++) {
            if (pow(i,5)-pow(j,5)==X) {
                cout << i << " " << j;
                return 0;
            }
        }
    }
}


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

#define AMAX 100000

int main(){
  int a[AMAX];
  int n;
  cin >> n;
  int r = n - 1;

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

  int x = a[r];
  int i = -1;

  for(int j = 0; j < r; j++){
    if(a[j] <= x){
      i = i + 1;
      swap(a[i],a[j]);
    }
  }
  swap(a[i+1],a[r]);

  int q = i + 1;

  for(int j = 0; j < n; j++){
    if(j != n-1){
      if(j == q){
        cout << "[" << a[j] << "]" << " " ;
      }else cout << a[j] << " ";
    }else {
      if(j == q){
        cout << "[" << a[j] << "]" << endl;
      }else cout << a[j] << endl;
    }
  }



}

Measured memory_bytes: 1548
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int h,w,i,j;
	string a[123];
	bool r[123],c[123];
	fill(r,r+123,false);
	fill(c,c+123,false);
	cin >> h >> w;
	for(i=0; i<h; ++i){
		cin >> a[i];
		for(j=0; j<w; ++j){
			if(a[i][j] == '#'){
				r[i] = true; c[j] = true;
			}
		}
	}
	for(i=0; i<h; ++i){
		if(!r[i]){
			continue;
		}
		for(j=0; j<w; ++j){
			if(c[j]){
				cout << a[i][j];
			}
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,m;cin>>n>>m;
  int* h=new int[n];
  int* h2=new int[n]{};
  int* a=new int[m];
  int* b=new int[m];
  for(int i=0;i<n;i++) cin>>h[i];
  for(int i=0;i<m;i++){
    cin>>a[i]>>b[i];a[i]--;b[i]--;
  }
  for(int i=0;i<m;i++){
    if(h[a[i]]>h[b[i]]){
      h2[b[i]]=-1;
    }else if(h[a[i]]<h[b[i]]){
      h2[a[i]]=-1;
    }else if(h[a[i]]==h[b[i]]){
      h2[a[i]]=h2[b[i]]=-1;    
    }
  }
  int c=0;
  for(int i=0;i<n;i++){
    if(h2[i]!=-1)c++;
  }
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 5192
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int n;
int data[10][10];
int d;
bool isdistance_int(int i, int j){
  int sum = 0;
  for(int k = 0; k < d; k++){
    sum += (data[i][k] - data[j][k]) * (data[i][k] - data[j][k]);
  }
  int sq = sqrt(sum);
  return (sum == sq*sq);
}
int main(){
  cin >> n >> d;
  REP(i, n) REP(j, d) cin >> data[i][j];
  int cnt = 0;
  REP(i, n){
    FOR(j,i+1, n){
      if(isdistance_int(i,j)) cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
def main():

    num = int(input())
    boss = input().split()

    ans_list = [0] * num
    
    for i_boss in boss:
        #print(f'start for {i_boss}')
        ans_list[int(i_boss)-1] += 1
    a = list(map(lambda  x: str(x), ans_list))
    print('\n'.join(a))


if __name__ == '__main__':
    main()

Measured memory_bytes: 40240
#include<cstdio>
#define MAXN 100000
int Num[MAXN+5],N,Ans=MAXN+MAXN;
int main(){
	scanf("%d",&N);
	for(int i=1;i<N;i++){
		int A=i,B=N-i,K=0;
		if(!Num[A])
			while(A){
				Num[i]+=A%10;
				A/=10;
			}
		K+=Num[i];
		if(!Num[B])
			while(B){
				Num[N-i]+=B%10;
				B/=10;
			}
		K+=Num[N-i];
		if(K<Ans) Ans=K;
	}
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 512
fun main(args: Array<String>) {
    val a = readLine()!!.toInt()

    val b = (a.toDouble() / 1.08).toInt()
    if((b * 1.08).toInt() == a){
        println(b.toInt())
    }else if(((b + 1) * 1.08).toInt() == a){
        println((b+1).toInt())
    }else{
        println(":(")
    }
}


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

int main(){
	int N, K, i;
	cin >> N >> K;
	int A[N+1];
	int B[N];
	for(i=0;i<N;i++){
		cin >> A[i];
	}
	A[N] = -1;
	sort(A, A+N);
	
	// 種類をカウントする
	int tmp = A[0];
	int pointed = 0;
	int arten = 0;
	for(i=1;i<N+1;i++){
		if(tmp != A[i]){
			B[arten] = i - pointed;
			pointed = i;
			tmp = A[i];
			arten++;
		}
	}
	
	sort(B, B+arten);
	int sum = 0;
  	for(i=0;i<(arten-K);i++){
    	sum += B[i]; 
    }

	cout << sum << endl;  

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const bool debug = 0;
//------------------------------//

ll mod = 998244353;
int N;
vector<pii> p;
int cnt[11234];

ll mod_pow(ll x, ll n, ll mod) {
	if (n == 0) return 1;
	ll res = mod_pow(x * x % mod, n / 2, mod);
	if (n & 1) res = res * x % mod;
	return res;
}

int calcn(int x) { // a*(a-1)/2 = xを満たすxを求める
	int l = 1, r = INF;
	while (r - l > 1) {
		int m = (l + r) / 2;
		if ((ll)m * (m - 1) / 2 <= x) l = m;
		else r = m;
	}
	return l;
}

int main() {
	cin >> N;
	p.resize(N);
	REP(i, N) {
		int a, b;
		scanf("%d %d", &a, &b);
		p[i] = pii(a, b);
	}
	sort(ALL(p));
	
	ll ans = (mod_pow(2, N, mod) - 1 - N + mod) % mod;
	
	REP(i, N) cnt[p[i].fi]++;
	REP(i, 11234) { // x=iの線分
		ll now = (mod_pow(2, cnt[i], mod) - 1 - cnt[i] + mod) % mod;
		ans = (ans - now + mod) % mod;
	}
	
	map<pll, int> m; // (傾き, x=0でのy)*1e8
	REP(i, N) {
		REP(j, i) {
			if (p[i].fi == p[j].fi) continue;
			double a = (double)(p[i].se - p[j].se) / (p[i].fi - p[j].fi);
			double b = p[i].se - a * p[i].fi;
			m[make_pair((ll)round(a * 1e8), (ll)round(b * 1e8))]++;
		}
	}
	
	for (map<pll, int>::iterator it = m.begin(); it != m.end(); ++it) {
		int c = calcn(it->se);
		ll now = (mod_pow(2, c, mod) - 1 - c + mod) % mod;
		ans = (ans - now + mod) % mod;
	}
	
	cout << ans << endl;
	
	
	return 0;
}


Measured memory_bytes: 1536
#include <iostream>

int getScore(int h[], int n)
{
	int res = 0;
	int one_count = 0;
	for (int i=0; i<n; i++) {
		if (2 <= h[i] && h[i] <= 9) res += h[i];
		else if (h[i] >= 10) res += 10;
		else { res++; one_count++; }
	}
	if (res >= 22) return 0;
	else {
		while (res<=11 && one_count>0) { res += 10; one_count--; }
		return res;
	}
}

int main()
{
	int hand[100];
	std::string input;
	while (true) {
		getline(std::cin, input);
		int offset = 0;
		int pos;
		int index = 0;
		int h;
		while ( (pos = input.find(' ', offset)) != std::string::npos ) {
			h = std::stoi(input.substr(offset, pos-offset));
			hand[index] = h; index++;
			offset = pos + 1;
		}
		h = std::stoi(input.substr(offset));
		if (h==0) break;
		hand[index] = h;
		std::cout << getScore(hand, index+1) << std::endl;
	}
	return 0;
}



Measured memory_bytes: 3140
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

double dist[1100][1100];
double DP[1100][1100];

int main(){
	
	int N;
	cin >> N;
	
	double x[1100], y[1100];
	for(int i = 0; i < N; i++){
		cin >> x[i] >> y[i];
	}
	
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			double dx = x[j] - x[i];
			double dy = y[j] - y[i];
			dist[i][j] = sqrt(dx * dx + dy * dy);
		}
	}
	
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			DP[i][j] = INF;
		}
	}
	
	DP[0][0] = 0;
	for(int i = 0; i < N; i++){
		for(int j = 0; j <= i; j++){
			DP[i][i + 1] = min(DP[i][i + 1], DP[j][i] + dist[j][i + 1]);
		}
		for(int j = i + 2; j < N; j++){
			DP[i][j] = DP[i][j - 1] + dist[j - 1][j];
		}
	}
	double ans = INF;
	for(int i = 0; i < N; i++){
		ans = min(ans, DP[i][N - 1] + dist[i][N - 1]);
	}
	
	printf("%.8f\n", ans);
	
	return 0;
}


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

int main() {
  int H1, H2, M1, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  M1 += H1 * 60;
  M2 += H2 * 60;
  cout << M2 - M1 - K << endl;
}


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


int main(){
    int x, y;
    cin >> x >> y;
    string ans = "No";
    for(int i=0; i<=100; i++){
        for(int j=0; j<=100; j++){
            if(i+j == x  &&  2*i + 4*j == y){
                ans = "Yes";
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define ll long long

int main()
{
    int N;
    std::cin >> N;

    bool is_contain = false;
    while(true) {
        if(N == 0) {
            break;
        }
        int tmp = N % 10;
        if(tmp == 7) {
            is_contain = true;
            break;
        }
        N = N / 10;
    }

    if(is_contain) {
        std::cout << "Yes" << std::endl;
    }
    else {
        std::cout << "No" << std::endl;
    }
}

Measured memory_bytes: 3624
n = int(input())
l = [int(input()) for _ in range(n)]
s = sum(l)
l2 = [i for i in l if i % 10 != 0]

if s % 10 != 0:
    print(s)
else:
    if l2:
        print(s - min(l2))
    else:
        print(0)



Measured memory_bytes: 3060
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, a, b = map(int, input().split())
    ab = abs(a - b)
    if ab % 2 == 0:
        print(ab // 2)
    else:
        res1 = a + (ab - 1) // 2
        res2 = n - b + 1 + (ab - 1) // 2
        print(min(res1, res2))


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 38256