akhauriyash/Code-Regression huggingface dataset:
import sys
from collections import defaultdict

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	n = int(input())
	dd=defaultdict(lambda :0)
	for i in range(n):
		s = input()
		dd[s]+=1
		
	maxv=0
	mml=[]
	for k in dd.keys():
		if dd[k]==maxv:
			mml.append(k)
		elif dd[k]>maxv:
			maxv=dd[k]
			mml=[k]
		else:
			pass
			
	mml.sort()
	for k in mml:
		print(k)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 97880
import math
N=int(input())
for n in range(1,N+1):
  tmp=0
  for x in range(1,100):
    for y in range(1,100):
      if 4*n-3*x**2-2*x*y-3*y**2<0:continue
      z=0.5*(math.sqrt(4*n-3*x**2-2*x*y-3*y**2)-x-y)
      if z.is_integer() and z>=1:
        tmp+=1
      z=0.5*(math.sqrt(4*n-3*x**2-2*x*y-3*y**2)*(-1)-x-y)
      if z.is_integer() and z>=1:
        tmp+=1
  print(tmp)


Measured memory_bytes: 69904
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    char[] s = sc.next().toCharArray();
    for(int i = 0; i < s.length; i++){
      s[i] = (char)((s[i] - 'A' + n) % 26 + 'A');
  }
  System.out.println(String.valueOf(s));
}
}

Measured memory_bytes: 22868
#![allow(dead_code)]
use crate::scanner::Scanner;
use proconio::fastout;
use std::collections::VecDeque;
#[fastout]
fn main() {
    let mut scan = Scanner::new();
    let n = scan.read::<usize>();
    let m = scan.read::<usize>();
    let mut g = vec![vec![]; n];
    for _ in 0..m {
        let a = scan.read::<usize>() - 1;
        let b = scan.read::<usize>() - 1;
        g[a].push(b);
        g[b].push(a);
    }
    let mut ret = vec![None; n];
    let mut used = vec![false; n];
    let mut que = VecDeque::new();
    que.push_back(0);
    while let Some(v) = que.pop_front() {
        if used[v] {
            continue;
        }
        used[v] = true;
        for &next in &g[v] {
            if let None = ret[next] {
                ret[next] = Some(v);
                que.push_back(next);
            }
        }
    }
    println!("Yes");
    for v in 1..n {
        println!("{}", ret[v].unwrap() + 1);
    }
}
mod scanner {
    use std::io::{stdin, BufReader, Bytes, Read, Stdin};
    use std::str::FromStr;
    pub struct Scanner {
        buf: Bytes<BufReader<Stdin>>,
    }
    impl Scanner {
        pub fn new() -> Scanner {
            Scanner {
                buf: BufReader::new(stdin()).bytes(),
            }
        }
        pub fn read_next<T: FromStr>(&mut self) -> Option<T> {
            let token = self
                .buf
                .by_ref()
                .map(|c| c.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect::<String>();
            token.parse::<T>().ok()
        }
        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_next().unwrap()
        }
        pub fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.read::<T>()).collect()
        }
        pub fn chars(&mut self) -> Vec<char> {
            self.read::<String>().chars().collect()
        }
    }
}



Measured memory_bytes: 12780
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
using namespace std;
using ll=long long;

int main(){
	int n;
	string s="";
	cin>>n;

	if(n==0){
		cout<<"0";
		return 0;
	}
	while(n){
		if(n%2){
			n--;
			s+="1";
		}else{
			s+="0";
		}
		n/=-2;
	}
	reverse(s.begin(),s.end());
	cout<<s;
}

		

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    string s;cin>>s;
    cout<<(s[0]=='7'||s[1]=='7'||s[2]=='7'?"Yes":"No")<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int INF = 1e9;
vector<int> dx = {1,0,-1,0}, dy = {0,1,0,-1};

int h,w;
vector<string> field(100);
vector<vector<int>> d(100,vector<int>(100));

void bfs(){
    rep(i,h)rep(j,w) d[i][j] = INF;
    d[0][0] = 0;
    queue<P> que;
    que.push(P(0,0));
    while(que.size()){
        P p = que.front(); que.pop();
        int x = p.first, y = p.second;
        if(x == h-1 && y == w-1) return;
        rep(i,4){
            int nx = x + dx[i], ny = y + dy[i];
            if(0 <= nx && nx < h && 0 <= ny && ny < w && d[nx][ny] == INF && field[nx][ny] == '.'){
                d[nx][ny] = d[x][y] + 1;
                que.push(P(nx,ny));
            }
        }
    }
    return;
}

int main(){
    cin >> h >> w;
    rep(i,h) cin >> field[i];
    bfs();
    int cnt = 0;
    rep(i,h) rep(j,w) if(field[i][j] == '.') cnt++;
    if(d[h-1][w-1] == INF) cout << -1 << endl;
    else cout << cnt - d[h-1][w-1] -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        string s;
        cin >> s;
        if(s == "Y"){
            cout << "Four" << endl;
            exit(0);
        }
    }
    cout << "Three" << endl;
    return 0; 
}

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

using namespace std;

const long long MOD = 1000000000 + 7;
const string abc = "abacaba";

void solve() {
    int x;
    cin >> x;
    x -= 400;
    x = x/200;
    cout << 8 - x;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // int t;
    // cin >> t;
    // for (int tt = 0; tt < t; tt++) {
        solve();
    // }
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)

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

    int ans = 0;
    char pre = '?';
    REP(i,S.size()) {
        if (pre != S[i]) {
            pre = S[i];
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

func main() {
	r := bufio.NewReaderSize(os.Stdin, 100000)
	s, _, _ := r.ReadLine()

	v := s[0]
	cnt := 0
	for i := 1; i < len(s)-1; i++ {
		//out(i, string(v), string(s[i]), string(s[i+1]))
		if v == s[i+1] {
			v = s[i+1]
			i++
			//	out("NG")
		} else {
			//	out("OK")
			cnt++
		}
	}

	if cnt == 0 {
		out("Second")
	} else if cnt%2 == 0 {
		out("Second")
	} else {
		out("First")
	}
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(a) (a).begin(),(a).end()
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=10000000000000000;

int main(){
    int n;
    cin >> n;
    vector<ll> h(n+1),dp(n+1,INF);
    rep(i,n) cin >> h.at(i+1);
    dp.at(1)=0;
    for (int i=1;i<n;i++){
        dp.at(i+1)=min(dp.at(i+1),dp.at(i)+abs(h.at(i)-h.at(i+1)));
        if (i==n-1) break;
        dp.at(i+2)=min(dp.at(i+2),dp.at(i)+abs(h.at(i)-h.at(i+2)));
    }
    cout << dp.at(n) << endl;
}


Measured memory_bytes: 1792
#region using directives
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Convert;
#endregion

class Program
{
    static void Main()
    {
        int n = ToInt32(ReadLine());
        List<int> a = new List<int>();
        string[] inputArr = ReadLine().Split();

        a.Add(0);
        for (int i = 0; i < n; i++)
            a.Add(ToInt32(inputArr[i]));
        a.Add(0);

        int sum = 0;
        for (int i = 2; i < n+2; i++)
            if (i == 2)
                sum += Math.Abs(a[i]);
            else
                sum += Math.Abs(a[i] - a[i-1]);

        WriteLine(sum);

        for (int i = 2; i < n+1; i++)
        {
            sum -= Math.Abs(a[i] - a[i - 2]);
            sum -= Math.Abs(a[i+1] - a[i]);
            sum += Math.Abs(a[i - 1] - a[i - 2]);
            sum += Math.Abs(a[i+1] - a[i - 1]);
            WriteLine(sum);
        }
    }
}


Measured memory_bytes: 28772
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        String num[] = N.split("");
        int ans = Integer.parseInt(num[N.length()-1]);
        if(ans == 0 || ans == 1 || ans== 6 || ans == 8)
        {
            System.out.println("pon");
        }
        else if(ans == 3)
        {
            System.out.println("bon");
        }
        else
        {
            System.out.println("hon");
        }
    }
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N, K; cin >> N >> K;
	int R = (N-1)*(N-2)/2 - K;
	if (R < 0) { cout << -1 << el; return; }
	cout << R + N-1 << el;
	for (int i = 2; i <= N; i++) {
		cout << 1 << " " << i << el;
		for (int j = i+1; j <= N; j++) {
			if (R > 0) { cout << i << " " << j << el; R--; }
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <class T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <class T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
ll pow2(const int n){return (1LL << n);}
void co() { cout << endl; }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) {
    cout << head << ' ';
    co(forward<Tail>(tail)...);
}
void ce() { cerr << endl; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) {
    cerr << head << ' ';
    ce(forward<Tail>(tail)...);
}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18L+1;
constexpr ll MOD = 1e9L+7;
constexpr ll MOD_N = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

ll h, w;
Vec2<ll> dist;
VecS board;
Vec dx = {2, 1, 0, -1, -2}, dy = {2, 1, 0, -1, -2};

bool in_board(ll x, ll y){
    return x >= 0 && x < h && y >= 0 && y < w && board[x][y] == '.';
}

void dijkstra(ll fx, ll fy) {
    using PP = pair<ll, P>;
    priority_queue<PP, vector<PP>, greater<PP>> que;
    que.push({0, {fx, fy}});
    while (!que.empty()) {
        PP o = que.top();
        P p = o.second;
        // co(p.first, p.second);
        que.pop();
        if (o.first >= dist[p.first][p.second]) continue;
        dist[p.first][p.second] = o.first;
        for (ll i : dx){
            for(ll j : dx){
                ll x = p.first + i;
                ll y = p.second + j;
                if (((!i || !j) && (abs(i) <= 1 && abs(j) <= 1)) && in_board(x, y)) que.push({o.first, {x, y}});
                else if(in_board(x, y))
                    que.push({o.first + 1, {x, y}});
            }
        }
    }
}

int main(void){
    cin >> h >> w;
    ll fx, fy, ex, ey;
    cin >> fx >> fy >> ex >> ey;
    --fx, --fy, --ex, --ey;
    dist.resize(h);
    rep(i, h) dist[i].resize(w, LINF);
    board.resize(h);
    rep(i, h) cin >> board[i];

    dijkstra(fx, fy);
    ll ans = dist[ex][ey];
    if (ans == LINF) ans = -1;
    co(ans);

    return 0;
}


Measured memory_bytes: 16016
#include <bits/stdc++.h>
#define max 2010

using namespace std;

void dfs(int a[],int b[],int n,int now,int w[], int kyori);

int main(void)
{
	int n,k; cin>>n>>k;
	int a[n],b[n];
	for(int i = 1; i < n; i++) cin>>a[i]>>b[i];
	int w[n+1][n+1];
	for(int i = 1; i < n+1; i++){
		for(int j = 1; j < n+1; j++){
			w[i][j] = 0;
		}
	}
	for(int i = 1; i < n ; i++){
		w[a[i]][b[i]] = 1; w[b[i]][a[i]] = 1;
		for(int j = 1; j < n + 1; j++){
			if(w[a[i]][j] != 0 && j != b[i]){
				w[b[i]][j] = w[a[i]][j]+1;
				w[j][b[i]] = w[j][a[i]]+1;
			}
			else if(w[b[i]][j] != 0 && j != a[i]){
				w[a[i]][j] = w[b[i]][j]+1;
				w[j][a[i]] = w[j][b[i]]+1;
			}
		}
	}
	/*
	for(int i = 1; i < n+1; i++){
		for(int j = 1; j < n+1; j++){
			cout<<w[i][j]<<" ";
		}
		cout<<endl;
	}
	*/
	//for(int i = 1; i < n+1; i++) dfs(a,b,n,i,w[i],0);
	
	int ans = max;
	if(k % 2 == 0){
		for(int i = 1; i < n + 1; i++){
			int t = 0;
			for(int j = 1; j < n + 1; j++){
				if(k/2 < w[i][j]) t++;
			}
			if(t < ans) ans = t;
		}
	}
	else{
		for(int i = 1; i < n; i++){
			int t = 0;
			for(int j = 1; j < n+1; j++){
				if(w[a[i]][j] < w[b[i]][j]){
					if(w[a[i]][j] > (k-1)/2) t++;
				}
				else{
					if(w[b[i]][j] > (k-1)/2) t++;
				}
			}
			if(t < ans) ans = t;
		}
	}
	cout<<ans<<endl;
	
	return 0;
}

void dfs(int a[],int b[],int n,int now,int w[], int kyori)
{
	//cout<<"now = "<<now<<", kyori = "<<kyori<<endl;
	//for(int i = 1; i < n + 1; i++) cout<<w[i]<<" ";
	//cout<<endl;
	for(int i = 1; i < n; i++){
		if(a[i] == now && w[b[i]] == -1){
			//cout<<" i = "<< i<<", a[i] = "<<a[i]<<", now = "<<now<<", w[i] = "<<w[i]<<endl;
			w[b[i]] = kyori+1;
			dfs(a,b,n,b[i],w,kyori+1);
		}
		else if(b[i] == now && w[a[i]] == -1){
			w[a[i]] = kyori+1;
			dfs(a,b,n,a[i],w,kyori+1);
		}
	}
}




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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, q, k;
vector<pair<LL, LL>> v[100001];
LL d[100001], INF = 1e15;

void dfs(int node, LL val) {
	if(val >= d[node]) { return; }
	d[node] = val;
	inc(i, v[node].size()) {
		dfs(v[node][i].FI, val + v[node][i].SE);
	}
}

int main() {
	cin >> n;
	inc(i, n - 1) {
		LL a, b, c;
		cin >> a >> b >> c;
		v[a].EB(b, c);
		v[b].EB(a, c);
	}
	
	cin >> q >> k;
	
	inc1(i, n) { d[i] = INF; }
	dfs(k, 0);
	
	inc(i, q) {
		int x, y;
		cin >> x >> y;
		
		cout << d[x] + d[y] << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 14336
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn solve(z:i64, w:i64, mut aa: Vec<i64>) -> i64 {
    use std::cmp::max;

    if aa.len() == 1 {
        return (aa[0] - w).abs()
    }

    max((aa[aa.len()-1] -w).abs(), (aa[aa.len()-1]-aa[aa.len()-2]).abs())
}

fn main() {
    let (_, z, w) = parse_line!(usize, i64, i64);

    let aa = parse_vec!(i64);

    println!("{}", solve(z,w,aa));
}

#[test]
fn solve_test() {
    assert_eq!(solve(100, 100, vec![10,1000,100]), 900);
    assert_eq!(solve(100, 1000, vec![10,100,100]), 900);
    assert_eq!(solve(1,1, vec![1,1,1,1,1]), 0);
    assert_eq!(solve(1,1, vec![1000000000]), 999999999);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
const int N=10010;
typedef long long LL;
int f[N];
int n,m;
int A[N],B[N];
int main(){
#ifdef WK
	freopen("in.txt","r",stdin);
#endif
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)scanf("%d%d",&A[i],&B[i]);
	for(int i=1;i<=n;i++)f[i]=1000000000;
	for(int i=1;i<=m;i++){
		for(int j=A[i];j<=n+A[i];j++){
			if(j>n)f[n]=min(f[n],f[j-A[i]]+B[i]);
			else f[j]=min(f[j],f[j-A[i]]+B[i]);
		}
	}
	printf("%d\n",f[n]);
    return 0;
}

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

#define int long long
#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
int powmod(int a,int l, int md){a%=md; int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
int invmod(int a, int md){return powmod(a,md-2,md);}
typedef long long ll; typedef unsigned long long ull; typedef long double ld;
typedef vector<int> vi; typedef pair<int, int> ii; typedef vector< ii > vii;
#define pb push_back
int __set(int b, int i) {return b|(1LL<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1LL<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return (((a%md)*(b%md))%md+md)%md;}
int addmod(int a, int b, int md) {return ((a%md+b%md)%md+md)%md;}
int submod(int a, int b, int md) {return (((a%md-b%md)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int maxAbsValExpr(vector<int>& x, vector<int>& y) {
    int res = 0, n = x.size(), smallest, cur;
    for (int p : {1, -1}) {
        for (int q : {1, -1}) {
            smallest = p * x[0] + q * y[0] + 0;
            for (int i = 1; i < n; ++i) {
                cur = p * x[i] + q * y[i];
                res = max(res, cur - smallest);
                smallest = min(smallest, cur);
            }
        }
    }
    return res;
}
signed main(void)
{
	IOS;
	int n; cin>>n;
	vi x(n); vi y(n);
	for(int i = 0; i < n; i++)
		cin>>x[i]>>y[i];
	int ans = maxAbsValExpr(x,y);
	cout<<ans<<endl;	
	return 0;
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  std::string s;
  std::cin >> s;
  int64_t ans = 1;
  constexpr int64_t mod = 1000000007;

  int64_t tmp = 2, po = 0;
  for (int64_t i = 1; i < s.size(); i++) {
    po *= 3;
    po %= mod;
    if (s[i] == '1') {
      po += tmp;
      po %= mod;
      tmp *= 2;
    }
    tmp %= mod;
  }
  ans += tmp;
  ans += po;
  ans %= mod;

  tmp = 2;
  for (int64_t i = 2; i < s.size(); i++) {
    tmp *= 3;
    tmp += 2;
    tmp %= mod;
  }
  if (2 <= s.size()) {
    ans += tmp;
  }
  ans %= mod;
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20)
#define int long long
#define double long double
#define gcd __gcd
#define lcm(a, b) (a / gcd(a, b) * b)
#define factorial(a) (a < 2 ? 1 : factorial(a - 1) * a)
#define summation(a) (a < 1 ? 0 : (a * a + a) / 2)
const int INF = 1e18, MOD = 1e9 + 7;

int n, a, q, b, c;
int cnt[111111] = {};

signed main() {
    INCANT;
    cin>>n;
    int res = 0;
    for (int i = 0; i < n; i++) {
        cin>>a;
        cnt[a]++;
        res += a;
    }
    cin>>q;
    for(int i = 0; i < q; i++) {
        cin>>b>>c;
        res += (c - b) * cnt[b];
        cout<<res<<endl;
        cnt[c] += cnt[b];
        cnt[b] = 0;
    }
}

Measured memory_bytes: 4432
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).trim().split('\n');
main();

function main(){
  var queue = [];
  for(var i = 0, len = input.length; i < len; i++){
    var inp = input[i] - 0;
    if(inp){
      queue.push(inp);
    }else{
      console.log(queue.pop());
    }
  }
}

Measured memory_bytes: 7648
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author HussienMoustafa
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        APayment solver = new APayment();
        solver.solve(1, in, out);
        out.close();
    }

    static class APayment {
        public void solve(int testNumber, Scanner s, PrintWriter sout) {
            int n = s.nextInt(), sum = 1000;

            while (true) {
                if (sum >= n) {
                    sout.println(sum - n);
                    break;
                }
                sum += 1000;
            }
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 32852
def solve(n, ps):
    qs = sorted(ps)
    count = sum(p != q for p, q in zip(ps, qs))
    return count == 0 or count == 2


def main():
    n = int(input())
    ps = [int(p) for p in input().split()]
    print("YES" if solve(n, ps) else "NO")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

int count(int x) {
  int ret = 0;
  while(x) {
    ret++;
    x /= 10;
  }
  return ret;
}

int main() {
  kyun;
  int n;
  cin >> n;
  if(count(n) == 1) cout << n;
  else if(count(n) == 2) cout << 9;
  else if(count(n) == 3) cout << n - 99 + 9;
  else if(count(n) == 4) cout << 909;
  else if(count(n) == 5) cout << n - 9999 + 909;
  else cout << 90909;
  hinata;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){

  int n;
  cin >> n;
  vector<ll> s(n+1,0);
  vector<ll> v(n);
  rep(i,n)cin >> v[i];
  rep(i,n)s[i+1] = s[i]+v[i];
  map<ll,ll> mp;
  rep(i,n+1)mp[s[i]]++;
  ll res = 0;
  for(auto iter = mp.begin();iter != mp.end();iter++)res += (*iter).second*((*iter).second-1)/2;
  cout << res << endl;




  return 0;
}

Measured memory_bytes: 15872
import Control.Applicative ((<$>))
import Control.Monad (replicateM)

main :: IO ()
main = do
    n <- readLn
    ds <- replicateM n $ readDice <$> getLine
    putStrLn $ if solve ds then "Yes" else "No"

solve :: [Dice] -> Bool
solve (d:ds) = foldl (\acc d' -> acc && not (judge d d')) True ds

judge :: Dice -> Dice -> Bool
judge d1 d2 =  d1' == d2'
            || d1' == fmap rot d2'
            || d1' == fmap (rot.rot) d2'
            || d1' == fmap (rot.rot.rot) d2'
    where
        d1' = Just d1
        d2' = matchTB (top d1, bottom d1) d2

matchTB :: (String,String) -> Dice -> Maybe Dice
matchTB p d@(Dice t s e w n b)
    | p == (t,b) = Just d
    | p == (b,t) = Just $ goN $ goN d
    | p == (s,n) = Just $ goN d
    | p == (n,s) = Just $ goS d
    | p == (e,w) = Just $ goW d
    | p == (w,e) = Just $ goE d
    | otherwise = Nothing

goE :: Dice -> Dice
goE (Dice t s e w n b) = Dice w s t b n e
goN :: Dice -> Dice
goN (Dice t s e w n b) = Dice s b e w t n
goS :: Dice -> Dice
goS (Dice t s e w n b) = Dice n t e w b s
goW :: Dice -> Dice
goW (Dice t s e w n b) = Dice e s b t n w

rot :: Dice -> Dice
rot (Dice t s e w n b) = Dice t w s n e b

data Dice = Dice
    { top :: String
    , south :: String
    , east :: String
    , west :: String
    , north :: String
    , bottom :: String
    } deriving (Eq)

readDice :: String -> Dice
readDice str = Dice t s e w n b
    where (t:s:e:w:n:b:_) = words str

Measured memory_bytes: 4000
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ld long double
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rloop(i,a,b) for(ll i=a;i>b;i--)
const int inf=1e9+7;



int main()
{

ll n;
cin>>n;

ld p[n],ans=0.0;
loop(i,0,n)cin>>p[i];

ld dp[n+1][n+1]	;
	
	dp[0][0]=1.0;
	loop(i,1,n+1)dp[0][i]=0.0;
	loop(i,1,n+1)
	{
		
		loop(j,0,n+1)
		{
			
			dp[i][j]=(j)?p[i-1]*dp[i-1][j-1]+(1-p[i-1])*dp[i-1][j]:(1-p[i-1])*dp[i-1][j];
			if(i==n&&j>=(n+1)/2)
			ans+=dp[i][j];
			
		}
		
	}
	
cout<<setprecision(12)<<ans;
	
}

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

int main() {
  int N;
  cin >> N;
  double ans = 0;
  while (N--) {
    double x;
    string u;
    cin >> x >> u;
    if (u == "JPY") ans += x;
    else ans += x * 380000;
  }
  cout << fixed << setprecision(5) << ans << "\n";
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define eb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define output(x) cout<<x<<endl;
#define fre(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define frd(i, a, b) for (int i = (int)(a); i >= b; --i)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<pair<int,int> > vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

const int maxn = 3010;

void lcs( string X, string Y, int m, int n ) 
{ 
   int L[m+1][n+1]; 
  
   /* Following steps build L[m+1][n+1] in bottom up fashion. Note 
      that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
   for (int i=0; i<=m; i++) 
   { 
     for (int j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
       else if (X[i-1] == Y[j-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   } 
  
   // Following code is used to print LCS 
   int index = L[m][n]; 
  
   // Create a character array to store the lcs string 
   char lcs[index+1]; 
   // char temp;
   lcs[index] = '\0'; // Set the terminating character 
  
   // Start from the right-most-bottom-most corner and 
   // one by one store characters in lcs[] 
   int i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      // If current character in X[] and Y are same, then 
      // current character is part of LCS 
      if (X[i-1] == Y[j-1]) 
      { 
          lcs[index-1] = X[i-1]; // Put current character in result 
          i--; j--; index--;     // reduce values of i, j and index 
      } 
  
      // If not same, then find the larger of two and 
      // go in the direction of larger value 
      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   } 
  
   // Print the lcs 
   cout << lcs <<endl; 
} 

int main(){
	cin.tie(0);ios_base::sync_with_stdio(0);	
	string s,t;
	cin>>s>>t;
	lcs(s,t,s.size(),t.size());
	return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

//ライブラリ始まり

//定数

//円周率
const double PI = 3.1415926535897932384;

//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 1000000000000000; // = 10^15

//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";

//関数

//ctoi
int ctoi(char c){
  if (c == '0') {
    return 0;
  }
  if (c == '1') {
    return 1;
  } 
  if (c == '2') {
    return 2;
  } 
  if (c == '3') {
    return 3;
  }
  if (c == '4') {
    return 4;
  } 
  if (c == '5') {
    return 5;
  } 
  if (c == '6') {
    return 6;
  }
  if (c == '7') {
    return 7;
  } 
  if (c == '8') {
    return 8;
  } 
  if (c == '9') {
    return 9;
  }
  return -1;  
}

//素数判定
bool PN(int x) {
  if (x <= 1) {
    return false;
  }
  if (x == 2) {
    return true;
  }
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}

//ライブラリ終わり
 
int main() {
  int N;
  cin >> N;
  bool ok = false;
  for (int i = 0; i <= 25; i++) {
    for (int j = 0; j <= 15; j++) {
      if (i * 4 + j * 7 == N) {
        ok = true;
      }
    }
  }
  if (ok) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
/*ll modexpo(ll a,ll b)
{
     ll ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
*/

 
int par[300005];
int n,m;
vector<int> adj[100005];
int find(int a){
     if(par[a]==a)return a;
     return par[a]=find(par[a]);
}
void unite(int a,int b){
     a=find(a),b=find(b);if(a==b)return ;
     par[b]=a;
}
int main(){
     cin>>n>>m;
     for(int i=1;i<=n;i++){
          int k;cin>>k;
          while(k--){
               int l;cin>>l;
               adj[i].pb(l);
          }
     }
     for(int i=1;i<=n+m;i++){
          par[i]=i;
     }
     for(int i=1;i<=n;i++){
          for(auto it:adj[i]){
               unite(i,it+n);
          }
     }
     int res=find(1);
     int ct=0;
     for(int i=1;i<=n;i++){
          if(i==par[i])ct++;
     }
     if(ct>1)cout<<"NO";
     else cout<<"YES";
}
 
 
 
 
 

























Measured memory_bytes: 12808
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+9
#define MOD 1000000007
using namespace std;


int main(){
    string s;
    cin >> s;
    for(int i=0; i<s.length(); i++){
        if(s[i]=='A'){
            cout<<'T';
        }else if(s[i]=='T'){
            cout<<'A';
        }else if(s[i]=='G'){
            cout<<'C';
        }else{
            cout<<'G';
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
int main() {
  lli A,B=0,C=0,D=0,F=0;
  string S;
  cin >> S;
  A=S.size();
  B=A-2;
  NeOut(S[0]);
  NeOut(B);
  Out(S[A-1]);
}

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

#define int long long
#define endl '\n'

string s;
int dp[100005][14], MOD = 1e9 + 7;

int rec(int id, int val) {
    if (id == (int)s.size()) 
        return (val == 5);
    int &ans = dp[id][val];
    if (ans != -1)  return ans;
    ans = 0;
    if (s[id] != '?')
        return ans = rec(id + 1, (val * 10 + s[id] - '0') % 13);
    for (int i = 0; i < 10; i++)
        ans += rec(id + 1, (val * 10 + i) % 13);
    ans %= MOD;
    return ans;
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> s;
    memset(dp, -1, sizeof dp);
    cout << rec(0, 0);
}

Measured memory_bytes: 17616
/*
memo for solution
*/
#include <cstdlib> 
#include <numeric>
#include <cstring>
#include <cstdio> 
#include <cfloat> 
#include <map> 
#include <cassert>
#include <cmath> 
#include <climits> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <iomanip>
#include<sys/time.h>
using namespace std; 
double e_time(void){static struct timeval now;gettimeofday(&now, NULL);return (double)(now.tv_sec  + now.tv_usec/1000000.0);}
#define REP(i,b,n) for(int i=b;i<n;i++) 
#define rep(i,n)      REP(i,0,n) 
#define pb push_back  
#define mp make_pair 
#define ALL(C)   (C).begin(),(C).end() 
#define fe(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr != (c).end();itr++)
#define BITSHIFT(X)     ( (1<<(X)) )
#define CONTAIN(S,X) ( ((S)&BITSHIFT(X)) != 0)
typedef complex<double>P; 
typedef long long ll; 
typedef unsigned long long ull; 
typedef pair<int,int> pii; 
typedef vector<int> vint;
template<class T> void vp(T &a,int p){rep(i,p)cout << a[i]<<" ";cout << endl;}  
template<class T> T ceilUp(const T& a,const T& b){return (a+b-1)/b;}
const ll mod =   1000000009;
inline ll modadd(ll a,ll b){a %= mod;b %= mod;return (a+b)%mod;}
inline ll modsub(ll a,ll b){a %= mod;b %= mod;a-=b;a%=mod;if (a<0)a+=mod;return a;}
inline ll modmul(ll a,ll b){a %= mod;b %= mod;return (a*b)%mod;}
inline ll modeq(ll a,ll b,ll m){a = (a%m+m)%m; b = (b%m+m)%m;return a == b;}
//ll modpow(ll n,ll p){if (p == 0)return 1;if (p == 1)return n;ll ret=mypow(n,p/2);ret=ret*ret%mod;if (p&1)ret=ret*n%mod;return ret;}
//ll getinv(ll a){return mypow(a,mod-2);}
ll mypow(ll n,ll p){
  if (p == 0)return 1;
  if (p == 1)return n;
  ll ret=mypow(n,p/2);
  ret=ret*ret;
  if (p&1)ret=ret*n;
  return ret;
}
 
int main(){
  int n;
  int a, b;
  cin >> n >> a >> b;
  int p1=0, p2=0, p3=0;
  rep(i,n){
    int tmp;
    cin >> tmp;
    if (tmp <= a)p1++;
    else if (a+1 <= tmp && tmp <= b)p2++;
    else p3++;
  }
  cout << min({p1, p2, p3}) << endl;
  return 0;
}
 
 


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

using namespace std;
typedef long long ll;

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

  // The minimum no. of powerstrips required for B or more empty sockets.
  int A, B, cnt, sockets;
  cin >> A >> B;
  sockets = 1;
  cnt = 0;

  // Every time we attach a socket, we occupy one empty socket.
  while(sockets < B) {
    sockets--; 
    sockets+=A;
    cnt++;
  }

  cout << cnt << '\n';
  return 0;
}



Measured memory_bytes: 3620
n = int(input())
card = []

pattern = ["S","H","C","D"] 
for i in pattern:
    for j in range(1, 14):
        card.append([i, j])

for i in range(1, n+1):
    a, b = input().split()
    card.remove([a, int(b)])
    
for i in range(len(card)):
    print(*card[i])



Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  char x;
  cin>>x;
  if(isupper(x)){
    cout<<'A'<<endl;
  }
  else{
    cout<<'a'<<endl;
  }
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3652
import bisect
while 1:
	r,c,q = map(int,raw_input().split())
	if r == 0: break
	R = [[0,0] for i in range(r)]
	C = [[0,0] for i in range(c)]
	for i in range(1,q+1):
		A,B,order = map(int,raw_input().split())
		if A == 0:
			R[B] = [i,order]
		else:
			C[B] = [i,order]
	c1 = sorted(C[ci][0] for ci in range(c) if C[ci][1] == 1)
	c0 = sorted(C[ci][0] for ci in range(c) if C[ci][1] == 0)
	ans = r*sum(C[ci][1] for ci in range(c))
	for ri in range(r):
		if R[ri][1] == 0:
			ans -= bisect.bisect(c1,R[ri][0])
		else:
			ans += bisect.bisect(c0,R[ri][0])
	print ans

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

typedef vector<int> veci;
typedef pair<int, int> pii;
typedef vector<pii> vecii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vecl;
typedef vector<pll> vecll;
#define EPS (1e-9)
#define MOD (1e9 + 7)
#define fi first
#define se second
#define endl '\n'

void solve() {
    int n;
    cin >> n;

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

    int cnt = 0;
    vector<bool> sieve(1e6+1, false);
    for (auto const& each : hm) {
        if (!sieve[each.first]) {
            for (int j=each.first; j<=1e6; j+=each.first) {
                sieve[j] = true;
            }
            if (each.second==1) cnt += 1;
        }
    }

    cout << cnt << endl;
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    (void)argc;
    int tcs = 1;
    while (tcs-- > 0)
        solve();
}

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

int main()
{
    int n,a,x;
    long long int sum=0;
    cin>>n>>a;
    for(int i=0; i<a; i++)
    {
        cin>>x;
        sum+=x;
    }
    if(sum>n)
        cout<<-1<<endl;
    else cout<<n-sum<<endl;
    return 0;
}


Measured memory_bytes: 3616
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll n;
    ll a[100010];
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    if(n==1){
        std::cout << 1 << std::endl;
        return 0;
    }
    bool hold = true;
    bool up = true;
    ll result= 1;
    for (int i = 0; i < n-1; i++) {
        if(hold){
            if(a[i] == a[i+1]){
                continue;
            }else if(a[i]<a[i+1]){
                up = true;
                hold = false;
            }else{
                up = false;
                hold = false;
            }
        }else{
            if(a[i] == a[i+1]){
                continue;
            }else if(a[i]<a[i+1]){
                if( up ){
                    continue;
                }else{
                    result++;
                    hold = true;
                }
            }else{
                if( !up ){
                    continue;
                }else{
                    result++;
                    hold = true;
                }
            }
        }
    }
    std::cout << result << std::endl;
}


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

int main(){
  int k, s, sum=0;
  cin >> k >> s;
  
  for(int x=0; x <= k; x++){
    if(x > s) break;
    for(int y=0; y <= k; y++){
      if((x+y) > s) break;
      if((s-(x+y)) <= k) sum++;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3608
use std::io::prelude::*;
use std::str::FromStr;
pub struct Scanner<R: Read>(R);
impl<R: Read> Scanner<R> {
    pub fn new(reader: R) -> Self {
        Self(reader)
    }
    pub fn read<T: FromStr>(&mut self) -> T {
        let token = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| (b as char).is_whitespace())
            .take_while(|&b| !(b as char).is_whitespace())
            .collect::<Vec<u8>>();
        unsafe { std::str::from_utf8_unchecked(token.as_slice()) }
            .parse()
            .ok()
            .expect("Can't parse it.")
    }
    pub fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
fn main() {
    let (stdin, stdout) = (std::io::stdin(), std::io::stdout());
    let mut sc = Scanner::new(stdin.lock());
    let mut out = std::io::BufWriter::new(stdout.lock());
    solve(&mut sc, &mut out);
    out.flush().ok().unwrap();
}
fn solve(sc: &mut Scanner<std::io::StdinLock>, out: &mut std::io::BufWriter<std::io::StdoutLock>) {
    let k: u32 = sc.read();

    use std::collections::VecDeque;
    let mut d = VecDeque::<u64>::new();
    for i in 1..10 {
        d.push_back(i);
    }

    for _ in 1..k {
        let num = d.pop_front().unwrap();
        let c = num % 10;

        if c != 0 {
            d.push_back(num * 10 + c - 1);
        }
        d.push_back(num * 10 + c);
        if c != 9 {
            d.push_back(num * 10 + c + 1);
        }
    }

    println!("{}", d.pop_front().unwrap());
}


Measured memory_bytes: 4048