akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
  int N;
  cin>>N;
  int a,b;
  vector<int> G[N];
  for(int i=0;i<N-1;++i){
    cin>>a>>b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  long long c;
  vector<long long> v;
  for(int k=0;k<N;++k){
    cin>>c;
    v.push_back(c);
  }
   std::sort(v.begin(), v.end() );
   long long ans=0;
   for(int j=0;j<N-1;++j){
     ans+=v[j];
   }
   cout<<ans<<"\n";
   int used[N]={};
   used[0]=1;
   int order[N]={};
   order[0]=0;
   queue<int> que;
   que.push(0);
   int counter=1;
   int num;
   while (que.size()){
     num=que.front();
     que.pop();
     for(int i=0;i<G[num].size();++i){
       int target=G[num][i];
       if(used[target]==0){
         used[target]=1;
         order[target]=counter;
         counter+=1;
         que.push(target);
       }
     }
   }
   for(int i=0;i<N;++i){
     cout<<v[N-1-order[i]]<<" ";
   }
return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
using P = pair<int,int>;
typedef long long ll;
 
int main() {
    
    int n,m;
    cin>>n>>m;
    vector<int> k(m);
    vector<vector<int>> s(m,vector<int>(n));
    vector<int> p(m);
    rep(i,m) {
        cin>>k.at(i);
        rep(j,k.at(i)) {
            cin>>s[i][j];
        }
    }
    rep(i,m)    cin>>p.at(i);

    //スイッチn個についてbit全探索
    int ans=0;
    vector<int> t(n);
    for(int bit=0; bit <(1<<n); ++bit) {
        for(int i=0;i<n;i++) {
            if(bit & (1<<i))    t[i]=true;
            else    t[i]=false;
        }
        rep(i,m) {
            int res=0;
            rep(j,k[i]) {
                if(t[s[i][j]-1]==true)  res++;
            }
            if(res%2!=p[i]) break;
            if(i==m-1)  ans++;
        }
    }

    cout<<ans<<endl;

 return 0;
}

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

using namespace std;

int main() {
  string c;
  cin >> c;
  if(c[0] == 'a' || c[0] == 'i' || c[0] == 'u' || c[0] == 'e' || c[0] == 'o') {
    cout << "vowel" << endl;
  }else {
    cout << "consonant" << endl;
  }

  return 0;
}


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

int main(){
    string s, t;
    cin >> s >> t;

    for(int i = 0; i < s.size(); i++){
        s.insert(s.begin(), s[s.size() - 1]);
        //cout << "s:" << s << endl;
        s.erase(s.end() - 1);
        //cout << "s:" << s << endl;
        if(s == t){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

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

namespace ABC049B___たてながThin
{
    class Program
    {
        static int multipleHeight = 2;

        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int h = int.Parse(input[0]);
            int w = int.Parse(input[1]);

            List<string> pixel = new List<string>();

            for (int index = 1; index <= h; index++)
            {
                pixel.Add(Console.ReadLine());
            }

            foreach (string v in pixel)
            {
                for (int index =1; index<= multipleHeight;index++)
                {
                    Console.WriteLine(v);
                }
                
            }

        }
    }
}


Measured memory_bytes: 13268
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np


# なんこか入力
l,r = map(int, input().split())

if r-l >= 2019:
    r = l+2019
else:
    r = l + (r-l) % 2019

answer = 9999
for j in range(l,r+1):
    for i in range(l,j):
        a = i % 2019
        b = j % 2019
        answer = min(answer,(a*b)%2019)

print(answer)


Measured memory_bytes: 12424
#include <iostream>
#include <algorithm>
#include <limits.h>
using namespace std;
typedef long long ll;
const int MAX = (1 << 10) - 1;
int N;
int F[100];
int P[100][11];
ll ans = LLONG_MIN;
int main(void) {
	cin >> N;
	for (int n = 0; n < N; ++n) {
		for (int c = 10; c > 0; --c) {
			int num; cin >> num;
			F[n] += num << c - 1;
		}
	}
	for (int n = 0; n < N; ++n) {
		for (int p = 0; p < 11; ++p) {
			cin >> P[n][p];
		}
	}
	for (int a = 1; a <= MAX; ++a) {
		ll score = 0LL;
		for (int n = 0; n < N; ++n) {
			if (a == 1024) {
				int kk = 0;
			}
			int count = 0;
			int t = a & F[n];
			for (int k = 0; k < 10; ++k) {
				if (t >> k & 1) ++count;
			}
			score += P[n][count];
		}
		if (ans == 0) {
			int ii = 0;
		}
		ans = max(ans, score);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
ac = [0] * N
wa = [0] * N

for _ in range(M):
  p_str, s = map(str, input().split())
  p = int(p_str)
  if ac[p-1] == 1:
    continue
  if s == 'AC':
    ac[p-1] = 1
  if s == 'WA':
    wa[p-1] += 1

result = [x * y for (x, y) in zip(ac, wa)]
AC = sum(ac)
WA = sum(result)

print(AC, WA)


Measured memory_bytes: 5528
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;


int main() {
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 1; i < (int)s.size(); i += 2) {
		if (s[i] == 'g')
			++ans;
	}
	for (int i = 0; i < (int)s.size(); i += 2) {
		if (s[i] == 'p')
			--ans;
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 512
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).rbegin(), (x).rend())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
#define SP << " " <<
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
//#define MOD  1000000007
#define MOD  2
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
struct Comb {
    ll p;
    vector<vector<ll>> com;
    Comb(ll _p) : p(_p), com(p, vector<ll>(p)) {
        init(p);
    }
    void init(ll p) {
        com[0][0] = 1;
        reps(i,1,p) {
            com[i][0] = 1;
            repr(j,i,1) {
                com[i][j] = (com[i-1][j-1] + com[i-1][j]) % p;
            }
        }
    }
    ll c(ll n, ll k) {
        ll ret = 1;
        while (n > 0) {
            int ni = n % p;
            int ki = k % p;
            ret *= com[ni][ki];
            ret %= p;
            n /= p;
            k /= p;
        }
        return ret;
    }
};
//--MAIN-----------------------------------
void Main() {
    ll N;
    cin>>N;
    string S; cin>>S;
    rep(i,N) S[i]-=1;

    ll ct=0;
    Comb comb(2);
    rep(i,N) if(S[i]=='1') ct^=comb.c(N-1,i);
    if(ct==1) {cout<< 1 <<"\n"; return;}
    rep(i,N) if(S[i]=='1') {cout<< 0 <<"\n"; return;}
    ct=0;
    rep(i,N) if(S[i]=='2') ct^=comb.c(N-1,i);
    if(ct==1) {cout<< 2 <<"\n"; return;}
    cout<< 0 <<"\n";

}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 1948
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <assert.h>
using namespace std;
#define int long long

signed main() {
	int N;
	cin >> N;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			if (i * j == N) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<stdlib.h>

int *L, *R;  // left(child), right(child).

void preorder(int i)
{
    if(i < 0) return;
    cout << " " << i;
    preorder(L[i]);
    preorder(R[i]);
}

void inorder(int i)
{
    if(i < 0) return;
    inorder(L[i]);
    cout << " " << i;
    inorder(R[i]);
}

void postorder(int i)
{
    if(i < 0) return;
    postorder(L[i]);
    postorder(R[i]);
    cout << " " << i;
}

int main()
{
    int *P;  // parent.
    int i, n, l, r;
    cin >> n;
    P = new int [n]; L = new int [n]; R = new int [n];
    if(P == NULL || L == NULL || R == NULL) exit(EXIT_FAILURE);

    // initialize.
    for(i = 0; i < n; i++){ P[i] = -1; }
    // input.
    while(cin >> i >> l >> r){
        L[i] = l; R[i] = r;
        if(l >= 0) P[l] = i;
        if(r >= 0) P[r] = i;
    };

    i = 0;
    while(P[i] >= 0){ i++; };  // i is root.

    cout << "Preorder" << endl;  preorder(i);  cout << endl;
    cout << "Inorder" << endl;   inorder(i);   cout << endl;
    cout << "Postorder" << endl; postorder(i); cout << endl;

    delete [] P; delete [] L; delete [] R;
    return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a,b,k;
  cin>>a>>b>>k;
  if(a<=k){
    k=k-a;
    a=0;
    if(b<=k){
      b=0;
    }
    else{
      b=b-k;
    }
  }
  else{
    a=a-k;
  }
  cout<<a<<" "<<b<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
  ll n, a, b, ans=0;
  cin >> n >> a >> b;
  ans += n/(a+b)*a;
  ans += min(n%(a+b), a);  
  cout << ans << endl;
  
  return 0; 
}

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

namespace abc153_c
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] NK = Console.ReadLine().Split(' ');
            long N = long.Parse(NK[0]); //攻撃モンスターの体力を1減らす
            long K = long.Parse(NK[1]); //必殺技モンスターの体力を0にする

            long[] H = new long[N];



            string[] input = Console.ReadLine().Split(' ');

            for (int i = 0; i < N; i++)
            {
                H[i] = long.Parse(input[i]);
            }

            Array.Sort(H); //並び替え

            long ans = 0; //攻撃回数の最小値

            //必殺技の回数を引いた数だけans+
            for (int i = 0; i < N - K; i++)
            {
                ans += H[i];
            }

            Console.WriteLine(ans);

            Console.Read();
        }
    }
}


Measured memory_bytes: 37504
n,u,v = map(int,input().split())

import queue

dist_t = [0] * n
dist_a = [0] * n

elb_t = [0] * n
elb_a = [0] * n

ab = [[] for j in range(n)]

for i in range(n-1):
    a,b = map(int,input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)

u -= 1
v -= 1

q = queue.Queue()

q.put(u)
elb_t[u] = 1
dist_t[u] = 0

while not q.empty():
    tmp = q.get()
    for i in range(len(ab[tmp])):
        idx = ab[tmp][i]
        if elb_t[idx] != 1:
            if dist_t[idx] != 0:
                dist_t[idx] = min(dist_t[idx], dist_t[tmp] + 1)
            else:
                dist_t[idx] = dist_t[tmp] + 1
            elb_t[idx] = 1
            q.put(idx)

q = queue.Queue()

q.put(v)
elb_a[v] = 1
dist_a[v] = 0

while not q.empty():
    tmp = q.get()
    for i in range(len(ab[tmp])):
        idx = ab[tmp][i]
        if elb_a[idx] != 1:
            dist_a[idx] = dist_a[tmp] + 1
            elb_a[idx] = 1
            q.put(idx)

ans = 0

for i in range(n):
    if dist_a[i] > dist_t[i]:
        ans = max(ans,dist_a[i]-1)

print(ans)

Measured memory_bytes: 31532
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [[input().split()] for _ in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n=n0()
a=n1()
b=n1()
c=n1()

a.sort()
b.sort()
c.sort()

from bisect import bisect_left,bisect_right
b2=[]
for i in b:
    b2.append(bisect_left(a,i))

import itertools
b3=list(itertools.accumulate(b2))
    
ans=0
for i in c:
    t=bisect_left(b,i)
    if t>0:
        ans+=b3[t-1]
    
print(ans)

Measured memory_bytes: 112996
#include <stdio.h>

int main() {
  char s[3][101];
  scanf("%s %s %s", s[0], s[1], s[2]);

  char  t=s[0][0], tmp, a=1, b=0, c=0;
  while (1) {
    if (t=='a') {
      t=s[0][a++];
      tmp='a';
    } else if (t=='b') {
      t=s[1][b++];
      tmp='b';
    } else {
      t=s[2][c++];
      tmp='c';
    }

    if (t=='\0') {
      printf("%c\n", tmp-32);
      return 0;
    }
  }
}

Measured memory_bytes: 128
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val (n, k) = (0 until 2).map { sc.nextInt() }
    var count = 0
    repeat(n) {
        val h = sc.nextInt()
        if (h >= k) {
            count++
        }
    }
    println(count)
}

Measured memory_bytes: 49548
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define EPS (1e-10)
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	int x = 0;
	int tmp = 0;
	for (int i = 1; i <= n; i++) {
		x += i;
		if (x >= n) {
			tmp = i;
			break;
		}
	}
	int y = x - n;
	for (int i = 1; i <= tmp; i++) {
		if (i != y) {
			cout << i << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
	int n,x;
	cin >> n;

	for (int i = 3; i <= n; i++)
	{
		x = i;
		if (x % 3 == 0)
		{
			cout << " " << i;
			continue;
		}


		while (x)
		{
			int flag = 0;
			if (x % 10 == 3)
			{
				cout << " " << i;
				break;
			}
			x /= 10;
		}
	}

	cout << endl;
	return 0;
}


Measured memory_bytes: 3092
#include<stdio.h>
int main(void){
	int i,j,q,f,e,co=0;
	char str[1000],re[100],rep[1000],letter,ans[1000][1000];
	
	scanf("%s",&str);
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%s %d %d",&re,&f,&e);
		if(re[2]=='p'){
			scanf("%s",&rep);
			for(j=0;j<e-f+1;j++){
				str[j+f]=rep[j];
			}
		}
		else if(re[2]=='v'){
			for(j=0;j<(e-f+1)/2;j++){
				letter=str[f+j];
				str[f+j]=str[e-j];
				str[e-j]=letter;
			}
		}
		else{
			co++;
			for(j=0;j<e-f+1;j++){
				
				ans[co-1][j]=str[j+f];
			}
		}
	}
	for(i=0;i<co;i++){
		for(j=0;j<1000;j++){
			if(ans[i][j]=='\0')break;
			printf("%c",ans[i][j]);
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2652
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(const auto& x : c )cout << x << " "; cout << "\n";
#define PI acos(-1LL)


#ifdef LOCAL
string to_string(const string& s){
    return '"' + s + '"';
}
string to_string(const char* s) {
    return to_string((string) s);
}
string to_string(bool b) {
    return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename T>
string to_string(T v){
    bool first = true;
    string res = "{";
    for(const auto& x: v){
        if(!first) res+=", ";
        first = false;
        res+=to_string(x);
    }
    res+="}";
    return res;
}
void bug() { cerr << endl; }
template<typename Head, typename... Tail>
void bug(Head H, Tail... T) {
    cerr << " " << to_string(H);
    bug(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__);
#else
#define debug(...) 11;
#endif

const int M = 1000000007;
const int N = 2e6 + 5;
const long long INF = 2e18 + 12;

void solve(){
    int x;
    cin >> x ;
    cout << (x^1) << endl;
}
signed main(){
    FAST
#ifdef TIMER
    clock_t start;
    double duration;
    start = clock();
#endif
    int tc = 1;
//    TODO: check for tc
//    cin >> tc;
    for (int tt = 1; tt <= tc; tt++) {
        solve();
    }
#ifdef TIMER
    duration = (clock() - start) / (double) CLOCKS_PER_SEC;
    cerr <<"\n\nTotal time elapsed: "<< duration <<"sec\n";
#endif
}


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

const int inf = 1<<29;

int main()
{
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  s += '0';

  int n = s.size();
  vector< vector<int> > dp(n+1, vector<int>(2, inf));
  dp[0][0] = 0;

  for(int i = 0; i < n; i++) {
    for(int a = 0; a < 10; a++) {
      for(int j = 0; j < 2; j++) {
        int d = s[i] - '0';
        int aa = a - j;
        int b = aa - d;
        int nj = 0;
        if(b < 0) {
          b += 10;
          nj = 1;
        }
        dp[i+1][nj] = min(dp[i+1][nj], dp[i][j] + a + b);
      }
    }
  }

  cout << dp[n][0] << endl;
}

Measured memory_bytes: 55940
#include <iostream>
#include <vector>
#include <map>
#include <cmath>

using namespace std;
#define INF 1e9
int Eq[27], Zero[27];
vector<int> TC, hash, zr;
typedef map<int, map<int, int> > DIC;
int check(int s, int e){
	int i,sum=0;
	for(i=s;i<e;i++) sum += hash[i] * TC[i-s];
//	for(i=0;i<int(TC.size());i++) cout << TC[i] << " ";
//	cout << "= " << sum << endl;
	return sum;
}

void solve2(int s, int e, int mask, DIC &ret){
	int i, j;
	if(e-s == TC.size()){
		ret[check(s, e)][mask] ++;
		return;
	}
	for(i=0;i<=9;i++){
		if(!i && zr[s + TC.size()]) continue;
		if((mask >> i) & 1) continue;
		TC.push_back(i);
		solve2(s, e, mask | (1 << i), ret);
		TC.pop_back();
	}
}
int solve1(){
	int i, j, sum = 0;
	if(hash.size() <= 5){
		DIC ret;
		solve2(0, hash.size(), 0, ret);
		for(map<int, int>::iterator it=ret[0].begin();it!=ret[0].end();++it) sum += (*it).second;
	}else{
		DIC ret1, ret2;
		solve2(0, hash.size()/2, 0, ret1);
		solve2(hash.size()/2, hash.size(), 0, ret2);
//		cout << ret1.size() << "*" << ret2.size() << endl;
		for(DIC::iterator it1=ret1.begin();it1!=ret1.end();++it1){
			for(map<int, int>::iterator it2=ret2[-(*it1).first].begin();it2!=ret2[-(*it1).first].end();++it2){
				for(map<int, int>::iterator it3=(*it1).second.begin();it3!=(*it1).second.end();++it3){
					if(((*it3).first & (*it2).first) == 0) sum += (*it3).second * (*it2).second;
				}
			}
		}
	}
	return sum;
}

main(){
	int n, i;
	char buf[10];
	while(cin>>n,n){
		for(i=0;i<26;i++){
			Eq[i] = INF;
			Zero[i] = 0;
		}
		hash.clear();
		zr.clear();
		TC.clear();
		while(n--){
			cin>>buf;
			if(buf[1]) Zero[buf[0]-'A'] = 1;
			char *p = buf;
			while(*++p);
			for(i=0;buf<p--;i++){
				Eq[*p-'A'] = (Eq[*p-'A']==INF?0:Eq[*p-'A']) + pow(10, i) * (n?1:-1);
			}
		}
		for(i=0;i<26;i++){
			if(Eq[i]!=INF){
				hash.push_back(Eq[i]);
				zr.push_back(Zero[i]);
			}
		}
		cout << solve1() << endl;
	}
	return 0;
}

Measured memory_bytes: 10896
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

# input
inputs = []
lc = 0
hh = {}
while l = $stdin.gets do
  if lc == 0
  else
    tmp = l.chomp.split(" ").map(&:to_s)
    if hh[tmp[0]] == nil
      hh[tmp[0]] = [[tmp[1].to_i, lc]]
    else
      hh[tmp[0]] << [tmp[1].to_i, lc]
    end
    inputs << tmp[0]
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end


inputs = inputs.uniq.sort

# body
if $debugFlag
  p hh
  p inputs
end

inputs.each do |x_i|
  hh[x_i].sort_by!{|x| x[0]}.reverse!
  hh[x_i].each do |y_j|
    puts y_j[1]
  end
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<pair<ll,ll>> q;
    rep(i,n) {
        ll a;
        cin >> a;
        q.emplace(a,1);
    }
    rep(i,m) {
        ll b, c;
        cin >> b >> c;
        q.emplace(c,b);
    }
    ll ans = 0;
    rep(i,n) {
        auto p = q.top();
        q.pop();
        ans += p.first;
        if (p.second > 1) {
            q.emplace(p.first, p.second-1);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7464
{-# LANGUAGE BangPatterns #-}

import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = do
  s <- getLine
  putStrLn $ solve s

solve (x:xs) = if isBad x xs then "Bad" else "Good"

isBad c (x:xs) = if c == x then True else isBad x xs
isBad _ []     = False

-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . C.readInteger) . C.words <$> C.getLine

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

Measured memory_bytes: 380
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;



void solve() {
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << fixed << setprecision(10) << w*h/2.000 << " ";
    if(x == w/2 && y == h/2) cout << 1 << endl;
    else cout << 0 << endl;
}

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

    solve();
    return 0;
}

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

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

# list X をソート O(Mlog(M)) する
# 駒を置いて残る目的地 (X_i, ..., X_j) に対して、訪れない区間の長さ最大化する
# 駒２個目以降をおくたびに、訪れないで済む区間が一つ増える
N, M = map(int, readline().split())

if N >= M:
    print(0)
    sys.exit()

X = list(map(int, readline().split()))
X.sort()

L = []
for i in range(M-1):
    L.append(X[i+1] - X[i])

L.sort(reverse=True)

res = X[M-1] - X[0] - sum(L[:N-1])

print(res)







Measured memory_bytes: 18948
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
const int mod=1000000007;
long long dp[N][2];
vector<int>e[N];
void dfs(int u,int f)
{
	dp[u][0]=dp[u][1]=1;
	for(int i=0;i<e[u].size();i++)
	{
		int v=e[u][i];
		if(v!=f)
		{
			dfs(v,u);
			dp[u][0]=dp[u][0]*dp[v][1]%mod;
			dp[u][1]=dp[u][1]*(dp[v][0]+dp[v][1])%mod;
		}
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	dfs(1,0);
	printf("%d\n",(dp[1][0]+dp[1][1])%mod);
	return 0;
}


Measured memory_bytes: 14208
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int a, b, c, N, p[1123], m[1123], k[1123], r[1123];
int ans[312];

int main()
{
	while (true)
	{
		a = b = c = N = 0;
		memset(p, 0, sizeof(p));
		memset(m, 0, sizeof(m));
		memset(k, 0, sizeof(k));
		memset(r, 0, sizeof(r));
		memset(ans, 0, sizeof(ans));

		in >> a >> b >> c;
		if (a == 0 && b == 0 && c == 0) { break; }
		in >> N;
		rep(i, N) { in >> p[i] >> m[i] >> k[i] >> r[i]; }
		std::fill_n(ans, 1 + a + b + c, 2);

		rep(i, N)
		{
			if (r[i] == 1)
			{
				ans[p[i]] = 1;
				ans[m[i]] = 1;
				ans[k[i]] = 1;
			}
		}
		rep(i, N)
		{
			if (r[i] == 0)
			{
				if (ans[m[i]] == 1 && ans[k[i]] == 1) { ans[p[i]] = 0; }
				if (ans[p[i]] == 1 && ans[k[i]] == 1) { ans[m[i]] = 0; }
				if (ans[p[i]] == 1 && ans[m[i]] == 1) { ans[k[i]] = 0; }
			}
		}

		rep(i, a + b + c) { out << ans[i + 1] << std::endl; }
	}
	return 0;
}

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

int find_min_index(int a[], int n){
  int i, min;
  for(i = 0; i < n; i++){
    if(a[i] != 0) min = i;
  }
  for(i = 0; i < n; i++){
    if(a[i] == 0) continue;
    if(a[i] < a[min]) min = i;
  }
  return min;
}

int main(){
  int n, i, min_index;
  cin >> n;
  int a[n] = {};
  for(i = 0; i < n; i++){
    cin >> a[i];
  }
  while(true){
    int flag = 1;
    min_index = find_min_index(a, n);
    for(i = 0; i < n; i++){
      if(i == min_index) continue;
      a[i] %= a[min_index];
      if(a[i]) flag = 0;
    }
    if(flag){
      cout << a[min_index] << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define MAX 100005
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

bool Is_Prime(int n){
  if(n==1) return false;
  for(int i=2;i*i<n;i++){
    if(n%i==0){
      return false;
    }
  }
  return true;
}

signed main(){
    int n,x;
    while(cin>>n>>x,n){
      vector<int> v(n);
      rep(i,n)cin>>v[i];
      vector<int> dp(x+1);
      dp[0]=1;
      rep(j,n){
        loop(i,1,x+1){
          if(i-v[j]>=0&&dp[i-v[j]]==1){
            dp[i]=1;
          }
        }
      }
      for(int i=x;i>0;i--){
        if(dp[i]==1&&Is_Prime(i)){
          cout<<i<<endl;
          goto at;
        }
      }
      cout<<"NA"<<endl;
      at: ;
    }

  return 0;
}

Measured memory_bytes: 16700
#include<iostream>
#include<iterator>
#include<algorithm>
#include<math.h>
#include<vector>
#include<stack>
#include<string.h>
#include<map>
#include<bitset>
#include<set>
#include<deque>
#include<queue>
#include<list>
#define ln 106
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    
    if((a==b &&  a!=c) || (a==c &&  a!=b) || (b==c &&  a!=b)){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define tam 120004
#define offset 320000
#define se second
#define fi first
#define pitem item*
#define ptr tre*
#define forr(i,p,n) for(ll i=p;i<n;i++)
using namespace std;
typedef long long ll;
const ll MOD=1000000007 ;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;

int main()
{
    string txt;
    cin>>txt;
    int n=15-txt.size();
    forr(i,0,txt.size())
    {
        if (txt[i]=='o')
            n++;
    }
    if (n>=8)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;

int main()
{
  int n;
  cin >> n;
  vector<int> x, y;
  rep(i, n)
  {
    int v;
    cin >> v;
    x.push_back(v);
  }
  rep(i, n)
  {
    int v;
    cin >> v;
    y.push_back(v);
  }
  double p1 = 0;
  rep(i, n)
  {
    p1 += abs(x[i] - y[i]);
  }
  printf("%.6f\n", p1);

  double p2 = 0;
  rep(i, n) {
    p2 += pow(abs(x[i] - y[i]),2);
  }
  printf("%.6f\n", sqrt(p2));

  double p3 = 0;
  rep(i, n) {
    p3 += pow(abs(x[i] - y[i]),3);
  }
  printf("%.6f\n", cbrt(p3));

  double p_inf = 0;
  rep(i, n) {
    p_inf = max(p_inf, (double)abs(x[i]-y[i]));
  }
  printf("%.6f\n", p_inf);

  return 0;
}


Measured memory_bytes: 3404
PROGRAM ATCODER

implicit none
integer(16) :: n,t(1:5),ans=5

read*, n,t(1:5)

ans = ans + n/minval(t)

if ( mod(n,minval(t)) == 0 ) then
  ans = ans - 1
end if

print'(i0)', ans

contains

END PROGRAM ATCODER

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
int main(){

  int i, j, N, minj, K,count=0;
  int *A;
  scanf("%d",&N);
  A = (int *)malloc(sizeof(int)*N);

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

  for(i=0; i<=N-1; i++){
    minj = i;
      for(j=i; j<=N-1; j++){
        if (A[j] < A[minj])
          minj = j;
      }
      if(i != minj) count++;
    K = A[i];
    A[i] = A[minj];
    A[minj] = K;
      }
  printf("%d",A[0]);
  for(i=1;i<=N-1;i++){
  printf(" %d",A[i]);
  }
  printf("\n%d\n",count);
  return 0;
}


Measured memory_bytes: 2088
/*....Abhilash's coding template....*/
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define pb push_back
#define pob pop_back
#define mp make_pair
#define in insert
#define ff first
#define ss second
#define all(a) (a).begin(),(a).end()
#define vll vector<ll>
#define fl(i,a,b) for(ll i=a;i<=b;i++)
#define flr(i,a,b) for(ll i=a;i>=b;i--)
#define print(v) for(auto i=v.begin();i!=v.end();i++){cout<<*i<<" ";}cout<<"\n";
#define tr(c,i) for(decltype((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define test() ll te; cin >> te; while(te--)
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define PI 3.14159265
#define MOD 1000000007
#define M 998244353
#define node pair<ll , pair<ll,ll> >
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

int main()
{
    string a,b; ll n;cin>>n>>a>>b;
    fl(i,0,n-1)
    {
        cout<<a[i]<<b[i];
    }
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int ans = t.length();

        for(int i = 0; i <= s.length()-t.length(); i++){
            int different = 0;
            for(int j = 0; j < t.length(); j++){
                if(t.charAt(j) != s.charAt(i+j)){
                    different++;
                }
            }
            ans = Math.min(ans,different);
        }
        System.out.println(ans);
    } 
}

Measured memory_bytes: 35572
#include<bits/stdc++.h>
#define lli long long int 
using namespace std;
lli funMaxHappinness(lli n,lli happiness[][3],lli dp[][3],lli index){
	if(n==1){
		dp[n][0] = happiness[n-1][0];
		dp[n][1] = happiness[n-1][1];
		dp[n][2] = happiness[n-1][2];

		if(index==0) return max(dp[n][1],dp[n][2]);
		else if(index==1) return max(dp[n][0],dp[n][2]);
		else if(index==2) return max(dp[n][0],dp[n][1]);
	}
	if(dp[n][0]!=-1){

		if(index==0) return max(dp[n][1],dp[n][2]);
		else if(index==1) return max(dp[n][0],dp[n][2]);
		else if(index==2) return max(dp[n][0],dp[n][1]);	
	}
	dp[n][0] = funMaxHappinness(n-1,happiness,dp,0)+happiness[n-1][0];
	dp[n][1] = funMaxHappinness(n-1,happiness,dp,1)+happiness[n-1][1];
	dp[n][2] = funMaxHappinness(n-1,happiness,dp,2)+happiness[n-1][2];
	if(index==0) return max(dp[n][1],dp[n][2]);
	else if(index==1) return max(dp[n][0],dp[n][2]);
	else if(index==2) return max(dp[n][0],dp[n][1]);	
}

int main(){
	lli n;
	cin>>n;
	lli a[n][3];
	for(lli i=0;i<n;i++){
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	}
	lli dp[n+1][3];
	for(lli i=0;i<=n;i++) dp[i][0]=-1,dp[i][1]=-1,dp[i][2]=-1;
		dp[0][0] = 0;
		dp[0][1] = 0;
		dp[0][2] = 0;
	dp[n][0] = funMaxHappinness(n-1,a,dp,0)+a[n-1][0];
	dp[n][1] = funMaxHappinness(n-1,a,dp,1)+a[n-1][1];
	dp[n][2] = funMaxHappinness(n-1,a,dp,2)+a[n-1][2];
	cout<<max(max(dp[n][0],dp[n][1]),dp[n][2]);
	return 0;
}

Measured memory_bytes: 11136
#include<stdio.h>
#include<math.h>


int main(void){
    long long int N;
    long long int n;
    
    int max= 0;
    int keta = 0;
    int count = 0;
    scanf("%lld",&N);
    //printf("%lld\n",N);
    n = N;
    while(n != 0){
        if(n%10==9){
            count++;
        }
        keta ++; 
        max = n;
        n = n/10;
        
    }
    //printf("%d",count);
    /*
    for(long long int i=N;i>=N-20;i--){
        long long int n = i;
        int sum = 0;
        while(n != 0){
            sum += n%10;
            n = n/10;
        }
        if(sum>max){
            max = sum;
        }
    }
    */
    int ans = (keta-1)*9+max-1;
    if(count  == keta){
        ans ++;
    }
    double a = (int)(max+1)*pow(10,keta-1)-1;
    long long int b = (long long int)a;
    //printf("%lld",b);
    if(b==N){
        ans++;
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
import Control.Applicative
import Data.List

main = do _ <- getLine
          cards <- map words . lines <$> getContents
          putStrLn . unwords . map show $ solve cards

solve :: [[String]] -> [Int]
solve cards = map sum . transpose $ map judge cards

judge :: [String] -> [Int]
judge (t:h:_) | t == h = [1,1]
              | t > h = [3,0]
              | otherwise = [0,3]

Measured memory_bytes: 4216
N, M = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(M)]

class UnionFind:
    def __init__(self, size):
        self.rank = [-1]*(size+1)
        self.number = [1]*(size+1)
        
    def find(self, x):
        while self.rank[x] >= 0:
            x = self.rank[x]
        return x
    
    def union(self, a, b):
        if a == b:
            return
        if self.rank[a] == self.rank[b]:
            self.rank[b] = a
            self.rank[a] -= 1
            self.number[a] += self.number[b]
        elif self.rank[a] < self.rank[b]:
            self.rank[b] = a
            self.number[a] += self.number[b]
        else:
            self.rank[a] = b
            self.number[b] += self.number[a]
            
p = N * (N - 1) // 2
ans = [p]
uf = UnionFind(N)

for a, b in ab[::-1]:
    ar = uf.find(a)
    br = uf.find(b)
    
    if ar != br:
        p -= uf.number[ar] * uf.number[br]
        uf.union(ar, br)
    ans.append(p)

print(*ans[::-1][1:], sep='\n')

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

#define fi first
#define se second
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const long long N = 200200;
const long long Q = 100000001;
const long long mod = 1e9 + 7;
const long long MAGIC = 30;

using namespace std;

int n;
int a[N];

void solve()
{
        cin >> n;
        for(int i = 1; i <= n; i++){
                int x;
                cin >> x;
                a[x] = i;
        }
        int ans = 0;
        for(int i = 1; i <= n; i++){
                int j = 1;
                while(i + j <= n && a[i + j] > a[i + j - 1]){
                        j++;
                }
                ans = max(ans, j);
                i += j - 1;
        }
        cout << n - ans << "\n";
}

bool mtest = false; int main()
{
        //fin("input.txt");
        //fout("output.txt");
        //fin("maze.in");
        //fout("maze.out");
        ios_base::sync_with_stdio(0);
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> pipii;
typedef priority_queue<int, vector<int>, greater<int>> minpq;
typedef priority_queue<int> maxpq;
const long double PI = 3.14159265358979323846264338327950;
const int mod = 1000000007;



int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    char c;
    cin>>c;
    if('A'<=c && c<='Z'){
        cout<<'A'<<endl;
    }
    else{
        cout<<"a"<<endl;
    }
    
}


Measured memory_bytes: 3648
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int x;
    scanf("%d", &x);
    int a = 0 , b = 0,c = 0;
    while(x % 2 == 0){
      x /= 2;
      a++;
      if(a == 3){
        break;
      }        
    }
    while(x % 3 == 0){
      x /= 3;
      b++;
      if(b == 2){
        break;
      }        
    }
    while(x % 5 == 0){
      x /= 5;
      c++;
      if(c == 1){
        break;
      }        
    }
  
    int iAns = 360;
    while(a > 0){
      iAns /= 2;
      a--;       
    }
    while(b > 0){
      iAns /= 3;
      b--;       
    }
    while(c > 0){
      iAns /= 5;
      c--;       
    }
  
    printf("%d", iAns);
    return 0;
}


Measured memory_bytes: 3212
#include<stdio.h>
#include<string.h>
int main(void){
    char r[100];
    while(scanf("%s",r)!=EOF){
        int i,j,work,a[100],b,c;
        char w;
        b=strlen(r);
        for(i=0;i<b/2;i++){
            w=r[i];
            r[i]=r[b-i-1];
            r[b-i-1]=w;
        }
        for(i=0;i<b;i++){
            if(r[i]=='I')a[i]=1;
            else if(r[i]=='V')a[i]=5;
            else if(r[i]=='X')a[i]=10;
            else if(r[i]=='L')a[i]=50;
            else if(r[i]=='C')a[i]=100;
            else if(r[i]=='D')a[i]=500;
            else if(r[i]=='M')a[i]=1000;
        }
        work=a[0];
        for(i=1;i<b;i++){
            if(a[i]<a[i-1])work-=a[i];
            else work+=a[i];
        }
        printf("%d\n",work);
    }
    return 0;
}

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

int main(void)
{
	ll n;
	cin >> n;
	ll a=n%10;
	n=n/10;
	if(a == 7)
		cout << "Yes\n";
	else
	{
		a=n%10;
		n=n/10;
		if(a == 7)
			cout << "Yes\n";
		else
		{
			a=n%10;
			n=n/10;
			if(a == 7)
				cout << "Yes\n";
			else
				cout << "No\n";
		}
	}



	return 0;
}

Measured memory_bytes: 3644
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const a = parseInt(args[0][0], 10)
	const b = parseInt(args[0][1], 10)
	if (b >= a) console.log(a)
	else console.log(a - 1)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

main() {
    int N; cin >> N;
    string S; cin >> S;
    int ans=0;
    rep(i,N-1){
        map<char,int> m,m2;
        int tmp=0;
        for(int j=0;j<i+1;j++){
            m[S[j]]++;
        }
        for(int j=i+1;j<N;j++){
            m2[S[j]]++;
        }
        for(auto p:m){
            if(m2[p.first]>0)
            tmp++;
        }
        ans=max(ans,tmp);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    ArrayList<String[]> list = new ArrayList<String[]>();
    while(true) {
        String line = sc.nextLine();
        String[] linesp = line.split(" ");
        if(linesp[0].equals("0") && linesp[1].equals("0")) {
            break;
        }
        list.add(linesp);
    }
    for(int i = 0; i < list.size(); i++) {
        int h = Integer.parseInt(list.get(i)[0]);
        int w = Integer.parseInt(list.get(i)[1]);
        for(int j = 0; j < h; j++) {
            for(int k = 0; k < w; k++) {
                if(j == 0 || j == h - 1) {
                    System.out.print("#");
                } else if(j > 0 && j < h - 1) {
                    if(k == 0 || k == w - 1) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
            }
            System.out.println("");
        }
        System.out.println("");
    }
  }
}


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

#define MOD 1000000007

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

int N;
char S[3001];
mint dp[3002][3002];

int main() {
    scanf("%d %s", &N, S);
    for (int i = 0; i <= N - 1; i++) {
        dp[0][i] = 1;
    }
    for (int i = 0; i + 1 < N; i++) {
        for (int j = 0; j <= N - 1 - i; j++) {
            int k = (N - 1 - i) - j;
            if (S[i] == '<') {
                dp[i + 1][0] += dp[i][j];
                dp[i + 1][j] -= dp[i][j];
            } else {
                dp[i + 1][j] += dp[i][j];
                dp[i + 1][j + k] -= dp[i][j];
            }
        }
        for (int j = 0; j <= N; j++) {
            dp[i + 1][j + 1] += dp[i + 1][j];
        }
    }
    printf("%d\n", dp[N - 1][0].n);
    return 0;
}


Measured memory_bytes: 35456
h, w, k = map(int, input().split())
s = ["".join(input().split()) for _ in range(h)]

ans = [[0]  * w for _ in range(h)]

coord_s = [[] for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            coord_s[i].append(j)

p = 0
for i in range(h):
    prev = -1
    p += 1
    for j in range(len(coord_s[i])):
        y = coord_s[i][j]
        while True:
            ans[i][y] = p
            y -= 1
            if y == -1 or y == prev:
                break
        prev = coord_s[i][j]

        if j == len(coord_s[i]) - 1:
            y = coord_s[i][j]
            while True:
                ans[i][y] = p
                y += 1
                if y == w:
                    break

        p += 1

nonzeros = []
for i in range(h):
    if sum(ans[i]) != 0:
        nonzeros.append(i)

from bisect import bisect_left
for i in range(h):
    for j in range(w):
        if ans[i][j] == 0:
            idx = bisect_left(nonzeros, i)
            if idx < len(nonzeros):
                ans[i][j] = ans[nonzeros[idx]][j]
            if idx == len(nonzeros):
                ans[i][j] = ans[nonzeros[-1]][j]


sets = []
for i in range(h):
    for j in range(w):
        sets.append(ans[i][j])
sets = list(set(sets))
sets.sort()

d = dict()
for i in range(len(sets)):
    d[sets[i]] = i + 1

for i in range(h):
    for j in range(w):
        ans[i][j] = d[ans[i][j]]


for i in range(h):
    _ans = ''
    for j in range(w):
        _ans += str(ans[i][j]) + ' '
    print(_ans[:-1])


Measured memory_bytes: 25820
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x;
  cin >> x;
  bool h = false;
   for(int i = -150; i <= 150; i++) {
     for(int j = -150; j <= 150; j++) {
       if(pow(i,5) - pow(j,5) == x) {
         cout << i << " " << j << endl;
         h = true;
         break;
      }
       if (h) break;
    }
  }
}

Measured memory_bytes: 4024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 10000000000
#define FOR(i,a,n) for(i=a;i<n;i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
int n,a,b;
ll h[100000];
int check(ll t){
	int i,d=a-b;
	ll k=b*t;
	FOR(i,0,n){
		if(h[i]>k){
			t-=((h[i]-k+d-1)/d);
		}
	}
	return t>=0;
}
int main(void)
{
	int i;
	ll l=0,r=INF,mid;
	scanf("%d%d%d",&n,&a,&b);
	FOR(i,0,n) scanf("%lld",&h[i]);
	FOR(i,0,100){
		mid=(l+r)/2;
		if(check(mid)) r=mid;
		else l=mid+1;
	}
	printf("%lld\n",r);
	return 0;
}

Measured memory_bytes: 896
use std::io;

fn read_i32_exn() -> i32 {
    let mut n = String::new();
    io::stdin().read_line(&mut n).expect("Failed to input");
    (*n).trim().parse::<i32>().unwrap()
}

fn main() {
    let mut v: Vec<i32> = Vec::new();
    let n = read_i32_exn();
    for i in 0..n {
        v.push(read_i32_exn());
    }
    v.sort_by(|a, b| b.cmp(a));
    v[0] = v[0] / 2;
    let ans: i32 = (*v).iter().sum();
    println!("{}", ans);
}


Measured memory_bytes: 4352
#ifdef _DEBUG
#include ".vscode/debug_print.hpp"
#else
#define debug(...)
#endif
#include <bits/stdc++.h>

using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1050000000;
constexpr long long INF64 = 4000000000000000000;
constexpr int MOD7        = 1000000007;
constexpr int MOD53       = 998244353;
constexpr long double PI  = 3.14159265358979323846;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

void vprint() { std::cout << '\n'; }
template <class H, class... T> void vprint(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << '\n';
    vprint(std::forward<T>(args)...);
}
template <class T> void vprint(std::vector<T> &v) {
    for (auto &&i : v) {
        std::cout << i << '\n';
    }
}

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

    int N;
    scan(N);
    vector<int> x(N);
    scan(x);
    ll ans = INF64;
    ll now = 0;
    for (size_t i = 1; i < 101; i++) {
        now = 0;
        for (size_t j = 0; j < N; j++) {
            now += (i - x[j]) * (i - x[j]);
        }
        chmin(ans, now);
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 256