akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			int n = Integer.parseInt(br.readLine());

			if(n == 0){
				break;
			}

			String[] input = new String[n];

			for(int i = 0; i < n; i++){
				input[i] = br.readLine();
			}

			String names[] = new String[n];
			for(int i = 0; i < n; i++){
				//前半　最初の母音抽出　後半　母音除去
//				names[i] = names[i].replaceAll("[^aeiou].*", "") + names[i].replaceAll("[aeiou]", "");
//				//あとで処理をしやすいように余計な文字をたくさん追加しておく
//				names[i] += "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

				names[i] = ""+input[i].charAt(0);
				for(int j = 0; j < input[i].length() - 1; j++){
					if(input[i].substring(j, j + 1).matches("[aeiou]")){
						names[i] += input[i].charAt(j + 1);
					}
				}
				//あとで処理をしやすいように余計な文字をたくさん追加しておく
				names[i] += "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

//				System.out.println(names[i]);
			}

			//比較は素朴にやる

			for(int i = 1; i <= 50; i++){
				boolean same = false;
				for(int j = 0; j < n; j++){
					for(int k = j + 1; k < n; k++){
//						int len1 = Math.min(i, names[j].length());
//						int len2 = Math.min(i, names[k].length());
//						//どちらか一方の文字列がより短ければ異なるということ
//						if(len1 != len2){
//							continue;
//						}

						if(names[j].substring(0, i).equals(names[k].substring(0, i))){
							same = true;
							break;
						}
					}

					if(same){
						break;
					}
				}

				if(!same){
					System.out.println(i);
					break;
				}
				else if(i == 50){
					System.out.println(-1);
				}
			}


		}
	}

}



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

int main() {
  int n, tmp, index, count = 0;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }

  // sort
  for (int i = 0; i < n - 1; ++i) {
    index = i;
    for (int j = i; j < n; ++j) {
      if (a[j] < a[index]) {
        index = j;
      }
    }
    // swap
    tmp = a[i];
    a[i] = a[index];
    a[index] = tmp;
    if (index != i) count++;
  }
  for (int i = 0; i < n; ++i) {
    cout << a[i] << ((i == n - 1) ? '\n' : ' ');
  }
  cout << count << '\n';
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
vector<ii> vet;
vector<int>vet2;
map<int,int> mapa1;

int main(){
	int n,val;
	cin >> n;
	for(int i = 0;i<n;i++){
		cin >> val;
		mapa1[val]++;
	}
	
	for(auto it: mapa1){
		vet2.push_back(it.first);
		if(it.second !=1)
			vet.push_back({it.first,it.second-1});
	}
	
	int l = vet.size()-1;
	for(int i = 0;i<vet.size();i++){
		while(l>i and vet[i].second){
			while(vet[l].second == 0 and l>i){
				l--;
			}
			if(vet[l].second >0){
				vet[i].second--;
				vet[l].second--;
			}
		}
		if(l == i and vet[i].second>=2){
			while(vet[i].second >=2){
				vet[i].second-=2;
			}
		}
	}
	bool f = 0;
	for(auto it:vet){
		if(it.second){
			f = 1;
		}
	}
	int ans = vet2.size();
	if(f)
		ans-=1;
	cout<<ans;
		    	
}

Measured memory_bytes: 5628
#include <stdio.h>
#include <iostream>
#include <map>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long Int;

int n, m, x[6000], u[6000], v[6000];
map<string, int> of;

int main() {
    cin >> n;
    rep (i, n) {
        string s;
        cin >> s >> x[i];
        of[s] = i;
    }
    cin >> m;
    rep (i, m) {
        string s, t;
        cin >> s >> t;
        u[2*i] = v[2*i+1] = of[s];
        u[2*i+1] = v[2*i] = of[t];
    }
    rep (_, n) rep (i, m*2) x[u[i]] = min(x[u[i]], x[v[i]]);
    cout << accumulate(x, x+n, 0) << endl;
    return 0;
}

Measured memory_bytes: 1816
from sys import stdin
import fractions
import bisect

a,b = [int(x) for x in stdin.readline().rstrip().split()]

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

ali = set(prime_factorize(a))
bli = set(prime_factorize(b))

ali = list(ali)
bli = list(bli)

point = 0
for i in range(len(ali)):
    if ali[i] in bli:
        point += 1
print(point+1)

Measured memory_bytes: 5340
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


signed main(){
    ll k,a,b;
    cin>>k>>a>>b;
    if(k<=a) cout<<k+1<<endl;
    else{
        ll x=k-(a-1);   
        if(x%2==1) cout<< max(k+1,b+(b-a)*(x/2-1)+1)<<endl;
        else cout<<max(b+(b-a)*(x/2-1),k+1)<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
let read_int_list () =
    read_line ()
    |> Str.split (Str.regexp " ")
    |> List.map int_of_string

let () =
    let [n; _; x] = read_int_list () in
    let a = read_int_list () in
    let count_lesser =
        List.filter (fun n -> n < x) a
        |> List.length
    in
    let count_greater =
        List.filter (fun n -> n > x) a
        |> List.length
    in
    print_endline (string_of_int (min count_lesser count_greater))


Measured memory_bytes: 384
import java.util.*;

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

        int N = sc.nextInt();

        ArrayList<Integer> arr = new ArrayList<>();

        for(int i=0;i<2*N;i++){
            arr.add(sc.nextInt());
        }

        Collections.sort(arr,Collections.reverseOrder());

        int total_meals=0;
        for(int i=0;i<2*N;i+=2){
            total_meals +=Math.min(arr.get(i), arr.get(i+1));
        }
        System.out.println(total_meals);


    }
}


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


int main() {
  int N, M;
  cin >> N >> M;
  
  bool ans = false;
  if(N == M){
    ans = true;
  }
  
  if(ans){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
int dp[100000];

int main(){
  int n;cin>>n;
  int h[100000];
  REP(i,n) cin>>h[i];
  REP(i,n){
    if(i==0) dp[0]=0;
    else if(i==1) dp[1]=abs(h[1]-h[0]);
    else dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }

  cout<<dp[n-1];
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    int d = 0;
    int cnt = 1;
    
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    cin >> a;
    
    rep(i, n) {
        d += a[i];
        if (d <= x) ++cnt;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3664
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def hadamard(n):
        if mem[n] != None:
            return mem[n]
        h = hadamard(n-1)
        res = [[j for j in i] for i in h]
        res_ = [[j for j in i] for i in h]
        for i in range(len(res)):
            res[i] += [j for j in h[i]]
            res_[i] += [j^1 for j in h[i]]
        res += res_
        mem[n] = res
        return res

    n,m = LI()
    f = 0
    if m < n:
        n,m = m,n
        f = 1
    h,w = 1<<n, 1<<m
    mem = defaultdict(lambda : None)
    mem[0] = [[0]]
    s = hadamard(m)[:h]
    if f:
        s = [[s[j][i] for j in range(h)] for i in range(w)]
        h,w = w,h
    for x in range(w):
        for y in range(h-1)[::-1]:
            s[y+1][x] ^= s[y][x]
    for y in range(h):
        for x in range(w-1)[::-1]:
            s[y][x+1] ^= s[y][x]
    ans = [i[1:] for i in s[1:]]
    for i in ans:
        print(*i,sep="")
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 97372
n,m = map(int,input().split())
h = list(map(int,input().split()))

l = list()
for i in range(n):
  l += [1]
  
for i in range(m):
  a,b = map(int,input().split())
  if h[a-1]<h[b-1]:
    l[a-1]=0
  elif h[a-1]>h[b-1]:
    l[b-1]=0
  else:
    l[a-1]=l[b-1]=0

print(sum(l))

Measured memory_bytes: 20128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s-1);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int n; cin >> n;
    ll x[n], y[n], h[n];

    REP(i, n) cin>>x[i]>>y[i]>>h[i];

    REP(cx, 101) {
        REP(cy, 101) {
            bool f = true;
            ll H = -1;
            REP(i, n) {
                if (h[i] == 0) continue;
                H = h[i] + (ll)abs(cx - x[i]) + (ll)abs(cy - y[i]);
                break;
            }
            if (H != -1) {
                REP(i, n) {
                    ll h2 = H - (ll)abs(cx - x[i]) - (ll)abs(cy - y[i]);
                    if (!((h2 < 0 && h[i] == 0) || h2 == h[i])) {
                        f = false;
                        break;
                    }
                }
                if (f) {
                    cout << cx << " " << cy << " " << H << endl;
                    return 0;
                }
            } else {
                REP (i, n) {
                    f = true;
                    H = (ll)abs(cx - x[i]) + (ll)abs(cy - y[i]);
                    if (H == 0) continue;
                    REP(j, n) {
                        ll h2 = H - (ll)abs(cx - x[j]) - (ll)abs(cy - y[j]);
                        if (!((h2 < 0 && h[j] == 0) || h2 == h[j])) {
                            f = false;
                            break;
                        }
                    }
                    if (f) {
                        cout << cx << " " << cy << " " << H << endl;
                        return 0;
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 256
import { readFileSync } from "fs";

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { cin, nCin, biCin } = (() => {
  const inputs = readFileSync("/dev/stdin", "utf-8").split(/[\n|\s]+/);
  let count = 0;
  const cin = () => inputs[count++];
  return { cin: cin, nCin: () => Number(cin()), biCin: () => BigInt(cin()) };
})();

const range = (n: number | bigint) => [...Array(Number(n))].map((_, i) => i);

type Color = "Black" | "White";
type PickData = {
  index: number;
  isPicked: boolean;
};

{
  const [H, W, K] = [nCin(), nCin(), nCin()];

  const cnt = (() => {
    const css: Color[][] = range(H).map(() =>
      cin()
        .split("")
        .map((c) => (c === "#" ? "Black" : "White") as Color)
    );

    const getBlackCnt = (hPicks: PickData[], wPicks: PickData[]) =>
      hPicks
        .filter(({ isPicked }) => isPicked)
        .map(({ index }) => {
          const cs = css[index];
          return wPicks
            .filter(({ isPicked }) => isPicked)
            .map(({ index }) => (cs[index] === "Black" ? 1 : 0) as number)
            .reduce((acc, x) => acc + x, 0);
        })
        .reduce((acc, x) => acc + x, 0);

    const initialBlackCnt = getBlackCnt(
      range(H).map((i) => ({ index: i, isPicked: true })),
      range(W).map((j) => ({ index: j, isPicked: true }))
    );

    const wPickFn = (n: number, hPicks: PickData[], wPicks: PickData[]): number =>
      n >= W
        ? (() => {
            const hCnt = getBlackCnt(
              range(H).map((i) => ({ index: i, isPicked: true })),
              wPicks
            );
            const wCnt = getBlackCnt(
              hPicks,
              range(W).map((j) => ({ index: j, isPicked: true }))
            );
            const hwCnt = getBlackCnt(hPicks, wPicks);

            return initialBlackCnt - (hCnt + wCnt - hwCnt);
          })() === K
          ? 1
          : 0
        : wPickFn(n + 1, hPicks, wPicks) +
          wPickFn(
            n + 1,
            hPicks,
            wPicks.map(({ index, isPicked }) =>
              index === n ? { index: index, isPicked: true } : { index: index, isPicked: isPicked }
            )
          );

    const hPickFn = (n: number, hPicks: PickData[]): number =>
      n >= H
        ? wPickFn(
            0,
            hPicks,
            range(W).map((j) => ({ index: j, isPicked: false }))
          )
        : hPickFn(n + 1, hPicks) +
          hPickFn(
            n + 1,
            hPicks.map(({ index, isPicked }) =>
              index === n ? { index: index, isPicked: true } : { index: index, isPicked: isPicked }
            )
          );

    return hPickFn(
      0,
      range(H).map((i) => ({ index: i, isPicked: false }))
    );
  })();

  console.log(cnt);
}


Measured memory_bytes: 40540
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)

int n,a[11][5];

void solve()
{
    while(cin>>n,n){
        REP(i,n)REP(j,5)cin>>a[i][j];
        int ans=0;bool flag=1;
        while(flag){
            flag=0;
            REP(i,n){
                int now=a[i][0],cnt=1,idx=0;
                rep(j,1,5){
                    if(a[i][j]==a[i][j-1])cnt++;
                    else if(cnt<3)now=a[i][j],cnt=1,idx=j;
                    else break;
                }
                if(cnt>=3&&a[i][idx]!=0){
                    ans+=cnt*a[i][idx];
                    flag=1;
                    rep(j,idx,idx+cnt)a[i][j]=0;
                }
            }
            REP(i,5)REP(j,n)if(a[j][i]==0){
                for(int k=j;k>0;k--)swap(a[k][i],a[k-1][i]);
            } 
        }
        cout<<ans<<endl;
    }
}

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


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

int main() {
  int n;
  cin >> n;
  map<ll , ll> m;
  for (int i = 0; i < n; i++) {
    ll a;
    cin >> a;
    m[a]++;
  }
  ll ans = 0;
  for (auto b : m) {
    if (b.second % 2 == 1) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6528
/**
 * Author: AcFunction
 * Date:   2019-02-24 19:56:49
 * Email:  3486942970@qq.com
**/

#include <bits/stdc++.h>
#define ll long long
#define int ll 
using namespace std;
int n, m, q, a[100100], b[100100]; 
int find1(int x) {
  int l = 1, r = n, ret = -1; 
  while(l <= r) {
    int mid = (l + r) >> 1;
    if(a[mid] <= x) l = mid + 1, ret = a[mid]; 
    else r = mid - 1; 
  } return ret; 
}
int find2(int x) {
  int l = 1, r = n, ret = -1; 
  while(l <= r) {
    int mid = (l + r) >> 1;
    if(a[mid] >= x) r = mid - 1, ret = a[mid]; 
    else l = mid + 1; 
  } return ret; 
}
int find3(int x) {
  int l = 1, r = m, ret = -1; 
  while(l <= r) {
    int mid = (l + r) >> 1;
    if(b[mid] <= x) l = mid + 1, ret = b[mid]; 
    else r = mid - 1; 
  } return ret;
}
int find4(int x) {
  int l = 1, r = m, ret = -1; 
  while(l <= r) {
    int mid = (l + r) >> 1;
    if(b[mid] >= x) r = mid - 1, ret = b[mid]; 
    else l = mid + 1; 
  } return ret; 
}
signed main() {
   cin >> n >> m >> q; 
  for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= m; i++) cin >> b[i];
  sort(a + 1, a + n + 1);
sort(b + 1, b + m + 1); 
  for(int i = 1; i <= q; i++) {
    int x, ans = 900000000000000; cin >> x; 
    int t1 = find1(x), t2 = find2(x), t3 = find3(x), t4 = find4(x); 
    if(t1 != -1 && t3 != -1) ans = min(ans, x - min(t1, t3)); 
    if(t2 != -1 && t4 != -1) ans = min(ans, max(t2, t4) - x); 
    if(t1 != -1 && t4 != -1) ans = min(ans, min(x - t1 + t4 - t1, t4 - x + t4 - t1)); 
    if(t2 != -1 && t3 != -1) ans = min(ans, min(x - t3 + t2 - t3, t2 - x + t2 - t3)); 
    cout << ans << endl;
  }
  return 0; 
}

Measured memory_bytes: 2944
#include <iostream>
#include <cstring>
using namespace std;
int main() {
  int N; cin>>N;
  char str[4];
  sprintf(str, "%d", N);
  int n = str[strlen(str) - 1] - '0';
  if (n==2||n==4||n==5||n==7||n==9) {
    cout<<"hon";
  } else if (n==0||n==1||n==6||n==8) {
    cout<<"pon";
  } else {
    cout<<"bon";
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  st s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  rep(i,26){
    if(s1[0]==abc[i]){
      cout << ABC[i];
    }
  }
  rep(i,26){
    if(s2[0]==abc[i]){
      cout << ABC[i];
    }
  }
  rep(i,26){
    if(s3[0]==abc[i]){
      cout << ABC[i] << endl;
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
using namespace std;
#define MAX_N 1000
int x[MAX_N], y[MAX_N], X[MAX_N][MAX_N], dist[MAX_N];
int A, B, N;
int main() {
	while (true) {
		cin >> A; if (A == 0) { break; } 
		for (int i = 0; i < A; i++) { cin >> x[i] >> y[i]; }
		cin >> B; 
		for (int i = A; i < A + B; i++) { cin >> x[i] >> y[i]; }N = A + B;
		for (int i = 0; i < N; i++) { 
			for (int j = 0; j < N; j++) { 
				if (x[i] < x[j] && y[i] < y[j]) { X[i][j] = 1; }
				else { X[i][j] = 0; }
			} 
		}
		queue<int>Q; int res = 0; for (int i = 0; i < N; i++) { dist[i] = 1; Q.push(i); }
		while (!Q.empty()) {
			int a1 = Q.front(); Q.pop();
			for (int i = 0; i < N; i++) {
				if (X[a1][i] == 1 && dist[a1] + 1 > dist[i]) { dist[i] = dist[a1] + 1; Q.push(i); }
			}
		}
		for (int i = 0; i < N; i++) { if (res < dist[i]) { res = dist[i]; } }cout << res << endl;
	}
}

Measured memory_bytes: 1940
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
#define ld long double
#define ft first
#define sd second
using namespace std;

const int N = 2e5 + 9;

ll fact[N], ifact[N], inv[N], f[N];
ll ncr(int n, int r) {
    // cout << "f:" << n << " " << r << "\n";
    if(n < 0 || r < 0 || r > n) return 0;
    // cout << "f:" << n << " " << r << " " << fact[n] << " " << ifact[r] << " " << ifact[n-r] << "\n";
    return fact[n] * ifact[r] % mod * ifact[n-r] % mod;
}

bool par[N];
pair<int, int> a[N];


signed main() {

    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, m, k; cin >> n >> m >> k;
    fact[0] = 1;
    for(int i = 1; i < N; i++) {
        fact[i] = fact[i-1] * i % mod;
    }
    inv[1] = 1;
    for(int i = 2; i < N; i++) {
        inv[i] = (mod - mod / i * inv[mod % i] % mod) % mod;
    }
    ifact[0] = 1;
    for(int i = 1; i < N; i++) {
        ifact[i] = ifact[i-1] * inv[i] % mod;
    }
    for(int i = 1; i <= k; i++) {
        cin >> a[i].ft >> a[i].sd;
    }
    k++;
    a[k].ft = n; a[k].sd = m;
    sort(a + 1, a + k + 1);
    for(int i = 1; i <= k; i++) {
        f[i] = ncr(a[i].ft+a[i].sd-2, a[i].ft-1);
        for(int j = 1; j < i; j++) {
            f[i] = (f[i] - f[j] * ncr(a[i].ft-a[j].ft + a[i].sd-a[j].sd, a[i].ft-a[j].ft) % mod + mod) % mod;
        }
    }
    cout << f[k] << "\n";


    
    return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
const int INF = 1001001001;
// << fixed << setprecision(0) <<
// sort(ALL(),greater<int>());


int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  REP(i,n) {
    cin >> d[i];
  }
  int ans=0;
  sort(ALL(d));
  for(int i=d[0];i<=d[n-1];i++) {
    auto iter = lower_bound(ALL(d),i);
    if(iter-d.begin()==n/2) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static final int BIG_NUM = 2000000000;
	public static final int MOD = 1000000007;

	public static ADJ[] edge;
	public static boolean visited[];
	public static int go_time[];
	public static int back_time[];
	public static int current_time;

	public static void main(String[] args) {

		Scanner sc = new  Scanner(System.in);

		int V = sc.nextInt();
		edge = new ADJ[V];

		for(int i = 0; i < V; i++){
			edge[i] = new ADJ();
		}

		visited = new boolean[V];
		for(int i = 0; i < V; i++){
			visited[i] = false;
		}

		go_time = new int[V];
		back_time = new int[V];

		int node_id,num,tmp_to;

		for(int loop = 0; loop < V; loop++){
			node_id = sc.nextInt();
			node_id--;

			num = sc.nextInt();

			for(int i = 0; i < num; i++){
				tmp_to = sc.nextInt();
				tmp_to--;
				edge[node_id].to.add(tmp_to);
			}
		}

		current_time = 1;

		for(int i = 0; i < V; i++){
			if(visited[i])continue;
			visited[i] = true;
			dfs(i);
		}

		StringBuilder ans = new StringBuilder();

		for(int i = 0; i < V; i++){
			ans.append(Integer.toString(i+1)).append(" ").append(Integer.toString(go_time[i])).
				append(" ").append(Integer.toString(back_time[i])).append("\n");
		}

		System.out.print(ans.toString());
	}

	public static void dfs(int node_id){

		go_time[node_id] = current_time++;
		int next_node;

		for(int i = 0; i < edge[node_id].to.size(); i++){

			next_node = edge[node_id].to.get(i);
			if(visited[next_node])continue;

			visited[next_node] = true;
			dfs(next_node);
		}
		back_time[node_id] = current_time++;
	}

}

class ADJ{
	ArrayList<Integer> to;

	ADJ(){
		to = new ArrayList<Integer>();
	}
}


Measured memory_bytes: 27976
import java.util.Scanner;

public class Main {
	static int[][] points;
	static double sum;
	static double con;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		points = new int[N][2];
		int[] perm = new int[N];

		for (int i = 0; i < N; i++) {
			points[i][0] = sc.nextInt();
			points[i][1] = sc.nextInt();
			perm[i] =i;
		}

		Main main = new Main();

		main.permutation(perm);

		System.out.println(sum / con);
	}

	public void permutation(int[] seed) {
        int[] perm = new int[seed.length];
        boolean[] used = new boolean[seed.length];
        buildPerm(seed, perm, used, 0);
    }

	public void buildPerm(int[] seed, int[] perm, boolean[] used, int index) {
        if (index == seed.length) {
            procPerm(perm);
            return;
        }

        for (int i = 0; i < seed.length; ++i) {
            if (used[i]) continue;
            perm[index] = seed[i];
            used[i] = true;
            buildPerm(seed, perm, used, index + 1);
            used[i] = false;
        }
    }

	public void procPerm(int[] perm) {
		con++;
		for (int i = 1; i < perm.length; i++) {
			sum += Math.sqrt(Math.pow(points[perm[i - 1]][0] - points[perm[i]][0], 2) + Math.pow(points[perm[i - 1]][1] - points[perm[i]][1], 2));
		}
        return;
    }

}

Measured memory_bytes: 37292
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = 0;
		String[] Test_String;
		int[] Test_Score;
		String input_n = "";
		String input_test = "";
		boolean judge_n = true;
		boolean judge_test = true;
		double m = 0.0;
		double V = 0.0;
		int MAX = 1000;
		double[] SD = new double[MAX];
		int data_count = 0;

		out: while (true) {
			input_n = sc.nextLine();
			n = Integer.parseInt(input_n);
			if (n == 0) {
				break out;
			}
			if (n < 0 || n > 1000) {
				judge_n = false;
				break out;
			}

			input_test = sc.nextLine();
			Test_String = input_test.split(" ");

			if (Test_String.length != n) {
				judge_test = false;
				break out;

			}
			// 始:平均値を求める
			m = 0.0;
			Test_Score = new int[n];
			for (int i = 0; i < n; i++) {
				Test_Score[i] = Integer.parseInt(Test_String[i]);
				m += Test_Score[i];
			}
			m = m / n;
			// 終:平均値を求める

			V = 0.0;

			for (int j = 0; j < n; j++) {
				V += ((double) (Test_Score[j] - m))
						* ((double) (Test_Score[j] - m));

			}
			V = V / n;
			SD[data_count] = Math.sqrt(V);
			data_count++;
		}// out:whileここまで

		if (judge_n == true && judge_test == true) {

			for (int k = 0; k < data_count; k++) {
				System.out.printf("%.5f", SD[k]);
                System.out.println();
			}
		}
	}
}



Measured memory_bytes: 28648
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	long long n, m, i, j, k, MOD = 1000000007;
	cin >> n >> m;
	vector<string> s(n);
	for (i = 0; i < n; i++) cin >> s[i];
	vector<vector<long long>> dp(n, vector<long long>(m, 0));

	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			if (s[i][j] == '#') continue;
			if ((i == 0) && (j == 0)) dp[i][j] = 1;
			else {
				if (i > 0) dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
				if (j > 0) dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD;
			}
		}
	}

	cout << dp[n - 1][m - 1] << "\n";

	return 0;
}




Measured memory_bytes: 9600
import java.util.Map.Entry;
import java.io.*;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int N = sc.nextInt();
		int sum = 0;
		int max = 0;
		for(int i = 0; i < N; i++){
			int p = sc.nextInt();
			sum += p;
			max = Math.max(max, p);
		}
		sum -= max / 2;
		System.out.println(sum);
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define ull unsigned long long
#define f first
#define s second
using namespace std;
const int inf=1e9;
int main(){
    ios::sync_with_stdio(0),cin.tie(0);
    ull f=1;
    int n;
    cin >> n;
    bool s[n],t[n];
    ull u[n],v[n],ans[n][n];
    for(int i=0;i<n;i++)cin >> s[i];
    for(int i=0;i<n;i++)cin >> t[i];
    for(int i=0;i<n;i++)cin >> u[i];
    for(int i=0;i<n;i++)cin >> v[i];
    memset(ans,0,sizeof ans);
    for(int k=0;k<64;k++){
        bool m[n][n],r[n]={0},c[n]={0},av[n][n];
        int rw[n]={0},cl[n]={0};
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                av[i][j]=0;
                bool p=(f<<k)&u[i];
                bool q=(f<<k)&v[j];
                p=p^s[i],q=q^t[j];
                if(p and q){
                    if(s[i]==t[j])m[i][j]=1^s[i],r[i]=1,c[j]=1;
                    else{
                        cout << -1;
                        return 0;
                    }
                }
                else if(p){
                    m[i][j]=1^s[i],r[i]=1;
                    if(m[i][j]==t[j])c[j]=1;
                }
                else if(q){
                    m[i][j]=1^t[j],c[j]=1;
                    if(m[i][j]==s[i])r[i]=1;
                }
                else{
                    if(s[i]==t[j])m[i][j]=s[i],r[i]=1,c[j]=1;
                    else rw[i]++,cl[j]++,av[i][j]=1;
                }
            }
        }
        while(1){
            int mr=inf,rn=n,mc=inf,cn=n;
            for(int i=0;i<n;i++){
                if(!r[i]){
                    if(rw[i]<mr)mr=rw[i],rn=i;
                }
                if(!c[i]){
                    if(cl[i]<mc)mc=cl[i],cn=i;
                }
            }
            if(rn==n and cn==n)break;
            if(mr==0 or mc==0){
                cout << -1;
                return 0;
            }
            if(mr<mc){
                r[rn]=1;
                for(int i=0;i<n;i++){
                    if(av[rn][i]){
                        m[rn][i]=s[rn];
                        av[rn][i]=0;
                        cl[i]--;
                        break;
                    }
                }
            }
            else{
                c[cn]=1;
                for(int i=0;i<n;i++){
                    if(av[i][cn]){
                        m[i][cn]=t[cn];
                        av[i][cn]=0;
                        rw[i]--;
                        break;
                    }
                }
            }
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(m[i][j])ans[i][j]+=(f<<k);
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++)
            cout << ans[i][j] <<  " ";
        cout << '\n';
    }
}

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

using namespace std;

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

	string s;
	int n;

	cin >> s;
	n = s.length();

	string a = s.substr(0,(n/2));
	string b = s.substr(n/2+1);
	if(a==b)
	{
		cout << "Yes" << '\n';
	}
	else
	{
		cout << "No" << '\n';
	}
	
    return 0;
}

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

int main() {
	long int n,min=1000000001,dammy,max=-1000000000;
	int fst=0;
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> dammy;
		if (fst==1&&max < dammy - min) max = dammy - min;
		if (min > dammy) min = dammy;
		fst=1;
	}
	cout << max << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<string> vs;
typedef vector<vs> table;
typedef vector<vl> v2;
typedef vector<v2> v3;
typedef vector<v3> v4;


const ll e5 = 1 << 20;
const ll mods[] = {998244353, 1000000007, 1000000009};
const ll bases[] = {997, 1009, 1013};
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

ll n,m;
graph g;
vl used;
ll min_num = INF;
vl tans;

int main(){
  cin >> n >> m;
  for(ll i = 0;i < m;i++){
    ll a,b;
    cin >>  a >> b;
    g[a][b] = 1;
  }
  for(ll i = 1;i <= n;i++){
    used = vl(n+1);
    queue<ll> q;
    for(auto y : g[i]){
      used[y.first] = i;
      q.push(y.first);
    }
    bool flag = false;
    while(!q.empty()){
      ll x = q.front();
      q.pop();
      if(x == i){
        flag = true;
      }
      for(auto y : g[x]){
        if(used[y.first]) continue;
        used[y.first] = x;
        q.push(y.first);
      }
    }
    if(flag){
      vl ans;
      ans.push_back(i);
      ll x = used[i];
      while(x != i){
        ans.push_back(x);
        x = used[x];
      }
      if(ans.size() < min_num){
        min_num = ans.size();
        tans = ans;
      }
    }



  }
  if(tans.size() == 0) cout << -1 << endl;
  else{
    cout << tans.size() << endl;
    for(ll i = 0;i < tans.size();i++){
      cout << tans[i] << endl;
    }    
  }


}


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

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  string s1, s2, s3 ;
  cin >> s1 >> s2 >> s3 ;
  
  transform(s1.begin(),s1.end(),s1.begin(),::toupper) ;
  transform(s2.begin(),s2.end(),s2.begin(),::toupper) ;
  transform(s3.begin(),s3.end(),s3.begin(),::toupper) ;
  
  cout << s1.at(0)<<s2.at(0)<<s3.at(0)<<endl ;
  
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

Measured memory_bytes: 256
#include<stdio.h>

int main(){ int aa, bb, cc;
	scanf ("%d %d %d", &aa, &bb, &cc);
	if (aa <= bb && bb <= cc) { printf ("%d %d %d\n", aa, bb, cc); return 0; }
	if (aa <= cc && cc <= bb) { printf ("%d %d %d\n", aa, cc, bb); return 0; }
	if (bb <= aa && aa <= cc) { printf ("%d %d %d\n", bb, aa, cc); return 0; }
	if (bb <= cc && cc <= aa) { printf ("%d %d %d\n", bb, cc, aa); return 0; }
	if (cc <= aa && aa <= bb) { printf ("%d %d %d\n", cc, aa, bb); return 0; }
	if (cc <= bb && bb <= aa) { printf ("%d %d %d\n", cc, bb, aa); return 0; }
	
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  if(n % 10 == 3){
    cout << "bon" << endl;
    return 0;
  } else if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) {
    cout << "pon" << endl;
    return 0;
  } else {
    cout << "hon" << endl;
    return 0;
  }
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
using namespace std;
#define MOD 1000000007
#define PI 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define each(i, v) for (auto i : v)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
#define fi first
#define se second
#define setp(x) setprecision(x)
#define mset(m, v) memset(m, v, sizeof(m))
static const int INF = 0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }

//static const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//#define int ll

int main() { 
        string s[3];
        rep(i, 3) cin >> s[i];
        char t[3];
        rep(i, 3) {
                t[i] = 'A' + s[i][0] - 'a';
        }
        rep(i ,3) cout << t[i];
        cout << endl; 
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return 1; }return 0; }
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
const ll INF =1LL << 62;

ll dp[100001];
int main(){
	int n; cin >>n;
	vector<int> h(n);
	cinf(n,h);
	for(int i=0;i<100002;i++){
		dp[i]=INF;
	}
	dp[0]=0;
	for(int i=1;i<n;i++){
		chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
		if(i>1)
			chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout << dp[n-1]<< endl;
}


Measured memory_bytes: 1408
#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>;
const int  mx = 100005;
vector<int> p;
vector<int> e[mx];
int visited[mx] ={0};
void rec(vector<int> *pos,vector<int> *val,int cur) {
    visited[cur] = 1;
    pos->push_back(cur); val->push_back(p[cur]);
    for(int u : e[cur]) {
        if(visited[u]) continue;
        rec(pos,val,u);
    }
}
int main() {
    int ans = 0;
    int n, m; cin >> n >> m;
    p.resize(n+1);
    rep(i, n) cin >> p[i+1];
    rep(i, m) {
        int x, y; cin >> x >> y;
        e[x].push_back(y);
        e[y].push_back(x);
    }
    for(int i=1;i<=n;i++) {
        if(visited[i]) continue;
        vector<int> pos;
        vector<int> val;
        rec(&pos,&val,i);
        int y = pos.size();
        //printf("y:%d\n",y);
        sort(pos.begin(), pos.end()); sort(val.begin(), val.end());
        while(!pos.empty()||!val.empty()) {
            int pp = pos.back(); int vv = val.back();
            if(pp < vv) val.pop_back();
            else if(pp == vv) {
                pos.pop_back(); val.pop_back();
                ans++;
            }else{
                pos.pop_back();
            }
        }
    }
    cout << ans;
}


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

int main(){
  int N,p[11],temp=0,discount=0;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>p[i];
    if(p[i]>temp){
      temp=p[i];
      discount=i;
    }
  }
  temp=0;
  for(int i=0;i<N;i++){
  	if(i!=discount)temp+=p[i];
  	if(i==discount)temp+=p[i]/2;
  }
  cout<<temp<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<deque>
#include<iterator>
#include<list>
#include<queue>
#include<stack>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<math.h>
#include<utility>
#include<functional>
const int MOD = 1e9 + 7;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    int sum = 0;
    for (int i = 0; i < 3; i++) {
        int a;
        cin >> a;
        sum += a;
    }
    if (sum >= 22) {
        cout << "bust" << endl;
    }
    else {
        cout << "win" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, m;
    cin >> n >> m;
    VVI to(n), from(n);
    VI cnt(n);
    REP(i,m){
        int u = in() - 1, v = in() - 1;
        to[u].push_back(v);
        from[v].push_back(u);
        cnt[v]++;
    }

    VI ord;
    queue<int> que;
    REP(i,n){
        if (cnt[i] == 0) que.push(i);
    }
    while (!que.empty()){
        int x = que.front();
        que.pop();
        ord.push_back(x);
        for (int next : to[x]){
            cnt[next]--;
            if (cnt[next] == 0) que.push(next);
        }
    }

    VI dp(n);
    REP(i,n){
        for (int next : to[ord[i]]){
            dp[next] = max(dp[next], dp[ord[i]] + 1);
        }
    }

    int ans = *max_element(ALL(dp));
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 12540
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		StringBuilder output = new StringBuilder();
		
		while(true) {
			int H = scan.nextInt();
			int W = scan.nextInt();
			
			if (H == 0 && W == 0)
				break;
			
				for (int i = 0; i < H/2; i++) {
						for (int j = 0; j < W/2; j++) {
							output.append("#").append(".");
						}
						if (W%2 == 1) {
							output.append("#");
						}
						output.append('\n');
						for (int j = 0; j < W/2; j++) {
							output.append(".").append("#");
						}
						if (W%2 == 1) {
							output.append(".");
						}
						output.append('\n');
				}
			if (H%2 == 1) {
				for (int l = 0; l < W/2; l++) {
					output.append("#").append(".");
				}
				if (W%2 == 1) {
					output.append("#");
				}
				output.append('\n');
			}
			output.append('\n');
		}
		System.out.print(output);
	}

}

Measured memory_bytes: 19728
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rlcfpoj(x) scanf("%I64d",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define plcfpoj(x) printf("%I64d",x)
#define lfd() printf("\n")
#define sp() printf(" ")
#define inrep(x) int x;scanf("%d",&x);while(x--)
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
int n,u,v;
vector<int> ga[100100];
int dist[100100];
int cnt[100100];
int pr[100100];
void dfs(int u,int p){
	pr[u]=p;
	cnt[u]=1;
	for(int i=0;i<ga[u].size();i++){
		int v=ga[u][i];
		if(v==p)
			continue;
		dist[v]=dist[u]+1;
		dfs(v,u);
		cnt[u]+=cnt[v];
	}
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<n;i++){
		cin>>u>>v;
		ga[u].push_back(v);
		ga[v].push_back(u);
	} 
	dfs(1,0);
	int up=(dist[n]-1)/2;
	int c=n;
	while(up--){
		c=pr[c];
	}
	int s=cnt[c],f=n-cnt[c];
	if(f>s)
		cout<<"Fennec"<<endl;
	else
		cout<<"Snuke"<<endl;
	return 0;
}


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


string s;

main(){
  cin>>s;
  rep(i,s.size()-1){
    if(s[i]==s[i+1]){
      cout<<"Bad"<<endl;
      return 0;
    }
  }

  cout<<"Good"<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner


object Main {
  def read() = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val str = sc.next()
    (n, str)
  }

  case class PairString(x: String, y: String) {
    def numContainedBoth(): Int = x.distinct.intersect(y.distinct).length
  }

  def main(args: Array[String]): Unit = {
    val (n, str) = read()
    val result =
      (1 until n) //Yの始まるindex
        .map(i => PairString(str.substring(0, i), str.substring(i, n))) // (X,Y)の全体
        .map(pair => pair.numContainedBoth())
        .max

    println(result)
  }
}

Measured memory_bytes: 27068