akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define        optimize    ios_base::sync_with_stdio(false);cin.tie(NULL);


#define  mod 1000000007

ll power(ll a, ll n){ll res = 1;while (n > 0) {if (n & 1) {res = (res*a)%mod;}a = (a*a)%mod;n = n/2;}return res;}

inline void normal(ll &a) { a %= mod; (a < 0) && (a += mod); }
inline ll modMul(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a * b) % mod; }
inline ll modAdd(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a + b) % mod; }
inline ll modSub(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return power(a, mod - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }
ll pre[20099];

void cal()
{
    pre[0] = 1;

    for(ll i=1; i<=20009; i++)
    {
        pre[i] = (i*pre[i-1])%mod;
    }
}

ll ncr(ll n,ll r)
{
    return  modMul(pre[n],modMul(modInverse(pre[r]),modInverse(pre[n-r])));
}

int main()
{
    int tst;
    cal();

    ll n,i,j,k,l,m,ans = 0,kel,N;

    cin >> n;

    for(i=1;i<=2000;i++)
    {
        k = i;
        N = n - (3*i);
        if(N<0)break;
        kel = ncr(N+k-1,min(N,k-1));
        ans = (ans + kel)%mod;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3784
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {

	static List<Integer> preList = new ArrayList<>();
	static List<Integer> distList = new ArrayList<>();
	static List<List<Integer>> to = new ArrayList<>();

	public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)) {
			int N = scanner.nextInt();
			int M = scanner.nextInt();

			for (int i = 0; i < N; i++) {
				to.add(new ArrayList<>());
				preList.add(-1);
				distList.add(-1);
			}
			for(int i = 0; i < M; i++) {
				int A = scanner.nextInt() - 1;
				int B = scanner.nextInt() - 1;
				to.get(A).add(B);
				to.get(B).add(A);
			}

	        Deque<Integer> queue = new ArrayDeque<>();
	        distList.set(0, 0);
	        queue.add(0);
	        while (!queue.isEmpty()) {
	            int v = queue.poll();
	            // 行くことができる行き先を一通り調べる
	            for (int u : to.get(v)) {
	            	// すでに距離がわかっている要素に関しては処理を行わない
	            	if (distList.get(u) != -1) {continue;}
	            	distList.set(u, distList.get(v) + 1);
	            	preList.set(u, v);
	            	queue.add(u);
	            }
	        }
	        System.out.println("Yes");
	        for (int i = 0, len = preList.size(); i < len; i++) {
	        	if (i == 0) {continue;}
	        	System.out.println(preList.get(i) + 1);
	        }
		}
	}
}

Measured memory_bytes: 81628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][][] array = new int[4][3][10];
		for(int i = 0 ;i < n; i++) {
			int b = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			int v = sc.nextInt();
			array[b -1][f -1][r - 1] = array[b -1][f -1][r - 1] + v;			
		}
		for(int i = 0 ;i < 4; i++) {
			for(int j = 0 ;j < 3; j++) {
				for(int k = 0 ;k < 10; k++) {
					System.out.print(" ");
					System.out.print(array[i][j][k]);
				}
				System.out.println();
			}
			if(i <3)System.out.println("####################");
		}
	}
}



Measured memory_bytes: 30248
using System;
using System.IO;
using static System.Console;
using static System.Math;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace atcoder
{
    class Program
    {
        //メイン関数
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            string s = ReadLine();


            if (s.Length % 2 == 0)
                if (s.Substring(0, s.Length / 2) == s.Substring(s.Length / 2, s.Length / 2)) WriteLine("Yes");
                else WriteLine("No");
            else WriteLine("No");
        }




        #region 細々としたツール(関数)

        #region 標準入力
        //変数の入力
        static string scan() => ReadLine();
        static int scanInt() => int.Parse(ReadLine());
        static long scanLong() => long.Parse(ReadLine());

        //配列の入力
        static string[] MultiScan(char Split)
        {
            string[] N = ReadLine().Split(Split);
            return N;
        }
        static string[] MultiScan()
        {
            string[] N = ReadLine().Split(' ');
            return N;
        }

        static List<int> MultiScanInt(char Split)
        {
            string[] N = ReadLine().Split(Split);
            List<int> output = new List<int>();

            for (int i = 0; i < N.Length; i++)
            {
                output.Add(int.Parse(N[i]));
            }

            return output;
        }
        static List<int> MultiScanInt(char Split, int roop)
        { 
            string[] N = ReadLine().Split(Split);
            List<int> output = new List<int>();

            for (int i = 0; i < roop; i++)
            {
                output.Add(int.Parse(N[i]));
            }

            return output;
        }
        #endregion

        #region 数学関連
        public static int Gcd(int a, int b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }//最大公約数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }//最小公倍数
        public static int PlusOneSigma(int x, int loop)
        {
            int output = 0;
            for (int i = 0; i < loop; i++)
            {
                output = output + x + i;
            }
            return output;
        }//１づつ加算のシグマ
        #endregion

        #endregion
    }
}


Measured memory_bytes: 13140
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define U(v) cerr << #v << ": " << (v) << endl

int main() {
    int N;
    cin >> N;
    int D[13]{};
    for (int i = 0; i < N; ++i) {
        int d;
        cin >> d;
        ++D[d];
    }
    if (D[0] || D[12] >= 2) {
        cout << 0 << endl;
        return 0;
    }
    for (int d = 1; d < 12; ++d) {
        if (D[d] >= 3) {
            cout << 0 << endl;
            return 0;
        }
    }
    bool a[24]{};
    a[0] = true;
    vector<int> b;
    for (int d = 1; d < 12; ++d) {
        if (D[d] == 2)
            a[d] = a[24 - d] = true;
        else if (D[d] == 1)
            b.emplace_back(d);
    }
    if (D[12])
        a[12] = true;
    bool c[24];
    int mx = -1 << 30;
    for (int i = 0; i < (1 << b.size()); ++i) {
        copy_n(a, 24, c);
        for (int j = 0; j < (int)b.size(); ++j) {
            if ((i >> j) & 1) {
                c[24 - b[j]] = true;
            } else {
                c[b[j]] = true;
            }
        }
        int mn = 1 << 30;
        for (int j = 0; j < 24; ++j) {
            for (int k = j + 1; k < 24; ++k) {
                if (c[j] && c[k])
                    mn = min(mn, min(k - j, j - k + 24));
            }
        }
        mx = max(mx, mn);
    }
    cout << mx << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int black[1010101];

int main(){
    
    // 1. 入力情報.
    int N, M, K;
    scanf("%d %d %d", &N, &M, &K);
    
    // 2. 黒く塗られたマスの個数をちょうど K個に出来るか.
    // 例) 4行5列 の 場合.
    // □■□□□
    // ■□■■■
    // ■□■■■
    // ■□■■■
    // => 黒の候補は, 0 4 5 7 8 9 10 11 12 13 15 16 20個
    // 黒く塗られたマスの個数を保存.
    // 1列で, 黒が b個 のものが, j列あったとした場合,
    // 1列で, 黒が (N - b)個 の ものが, (M - j)列あるはず.
    for(int b = 0; b <= N; b++) for(int j = 0; j <= M; j++) black[b * j + (N - b) * (M - j)]++;
    
    // 3. 出力.
    if(black[K] > 0) printf("%s\n", "Yes");
    else             printf("%s\n", "No");
    return 0;
    
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

vector<int> sieve_of_eratosthenes(int n = 200010) {
  vector<bool> is_prime(n+1, true);
  is_prime[0] = is_prime[1] = false;
  for (int i = 0; i <= n; ++i) if (is_prime[i]) {
    for (int j = i+i; j <= n; j+=i) is_prime[j] = false;
  }
  vector<int> primes;
  for (int i = 2; i <= n; ++i) if (is_prime[i]) primes.push_back(i);
  return primes;
}

map<long long, int> prime_factorize(long long n, const vector<int> &primes) {
  map<long long, int> prime_factor;
  for (int p : primes) {
    if (n < (long long) p * p) break;
    while (n % p == 0) {
      prime_factor[p] += 1;
      n /= p;
    }
  }
  if (n != 1) prime_factor[n] += 1;
  return prime_factor;
}

int main() {
  int n; cin>>n;
  auto primes = sieve_of_eratosthenes();

  vector<int> fac(110, 0);
  REP(i, 1, n+1) {
    auto pf = prime_factorize(i, primes);
    for (auto x: pf) fac[x.first] += x.second;
  }

  int ans = 0;
  if (fac[2] >= 74) ++ans;
  rep(i, 110) rep(j, 110) {
    if (i == j) continue;
    if (fac[i] >= 24 and fac[j] >= 2) ++ans;
    if (fac[i] >= 14 and fac[j] >= 4) ++ans;
  }
  rep(i, 110) rep(j, 110) rep(k, 110) {
    if (i <= j or j == k or k == i) continue;
    if (fac[i] >= 4 and fac[j] >= 4 and fac[k] >= 2) ++ans;
  }
  print(ans);

  return 0;
}

Measured memory_bytes: 640
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define MAXN 100010
using namespace std;
int X,Y,A,B,C;
long long p[MAXN],q[MAXN],r[MAXN];
bool cmp(int a,int b){
    return a>b;
}
long long all[2*MAXN],head;
int main(){
    //freopen("data.in","r",stdin);
    scanf("%d %d %d %d %d",&X,&Y,&A,&B,&C);
    for(int i=1;i<=A;i++)
        scanf("%lld",&p[i]);
    for(int i=1;i<=B;i++)
        scanf("%lld",&q[i]);
    for(int i=1;i<=C;i++)
        scanf("%lld",&r[i]);
    sort(p+1,p+A+1,cmp);
    sort(q+1,q+B+1,cmp);
    sort(r+1,r+C+1,cmp);
    int R=0,G=0;
    for(int i=1;i<=A;i++){
        all[++head]=p[i];
        R++;
        if(R==X) break;       
    }
    for(int i=1;i<=B;i++){
        all[++head]=q[i];
        G++;
        if(G==Y) break;
    }
    //cout<<R<<" "<<G<<endl;
    int c=0;
    while(R<X){
        all[++head]=r[++c];
        R++;
    }
    while(G<Y){
        all[++head]=r[++c];
        G++;
    }
    //for(int i=1;i<=head;i++) cout<<all[i]<<" "; cout<<endl;
    sort(all+1,all+head+1,cmp);
    c++;
    for(int i=head;i>=1&&c<=C;i--,c++){
        if(all[i]>r[c]) break;
        all[i]=r[c];
    }
    long long ans=0;
    for(int i=1;i<=head;i++){
        ans=ans+all[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7520
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define srep(i) for (int i = 0; i < s.size(); i++)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
    using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

int n, w;
int weight[105] = {}, value[105] = {};

int dp[105][10005] = {};

int main()
{
    int a,b;
    string s;
    cin >> a >> b >> s;
    if(s[a]=='-'&&s[a-1]!='-'&&s[a+1]!='-'){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
 int N;
 int sum=0;
 cin >> N;
 vector <int> L(N);
 for(int i=0;i<N;i++){
   cin >> L.at(i);
 }
 sort(L.begin(), L.end());
 for(int i=0;i<N-1;i++){
   sum+=L.at(i);
 }
 if(sum>L.at(N-1)){
   cout <<"Yes" <<endl;
 }
 else{
   cout <<"No" <<endl;
 }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
   ll a,b,c,res=0;
   cin>>a>>b>>c;
   while(a>0)
   {
     a=a-b;
     res+=c;
   }
   cout<<res<<endl;
return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >>n;
  vector<int>a(n),b(n),sa(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    cin>>b[i];
  }
  for(int i=0;i<n;i++){
    sa[i]=a[i]-b[i];
  }
  sort(sa.rbegin(),sa.rend());
  int sum=0;
  for(int i=0;i<n;i++){
    if(sa[i]<0)break;
    sum+=sa[i];
  }
  cout<<sum<<endl;
  return 0;
}
  


Measured memory_bytes: 256
import sys
from heapq import heappop, heappush
sys.setrecursionlimit(10000000)

h, w = map(int, input().split())
c = [input() for _ in range(h)]
d = [[10000]*w for _ in range(h)]

que = []
if c[0][0] == '.':
    heappush(que, (0, 0, 0))
    d[0][0] = 0
else:
    heappush(que, (1, 0, 0))
    d[0][0] = 1

while len(que):
    dist, px, py = heappop(que)
    if d[h-1][w-1] < dist:
        break
    for dx, dy in [(0, 1), (1, 0)]:
        qx, qy = px + dx, py + dy
        if not (0 <= qx < h and 0 <= qy < w):
            continue
        if d[qx][qy] > dist:
            if c[px][py]=='.' and c[qx][qy]=='#':
                d[qx][qy] = dist + 1
                heappush(que, (d[qx][qy], qx, qy))
            else:
                d[qx][qy] = dist
                heappush(que, (d[qx][qy], qx, qy))
print(d[h-1][w-1])

Measured memory_bytes: 3188
object Main {
    def step(s: Array[Int], i: String): Array[Int] = i match {
        case "North" => s.updated(3, s(0)).updated(0, s(1)).updated(1, 7 - s(0))
        case "East"  => s.updated(2, s(0)).updated(0, s(4)).updated(4, 7 - s(0))
        case "West"  => s.updated(4, s(0)).updated(0, s(2)).updated(2, 7 - s(0))
        case "South" => s.updated(1, s(0)).updated(0, s(3)).updated(3, 7 - s(0))
        case "Right" => s.updated(1, s(2)).updated(2, s(3)).updated(3, s(4)).updated(4, s(1))
        case "Left"  => s.updated(1, s(4)).updated(2, s(1)).updated(3, s(2)).updated(4, s(3))
    }

    def main(args: Array[String]) = {
        val in = io.Source.stdin.getLines
        for (n <- in if n != "0") println(in.take(n.toInt).scanLeft(Array(1, 2, 3, 5, 4))(step).map(_(0)).sum)
    }
}

Measured memory_bytes: 60836
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	n = INT()
	a = [x for x in LIST() if x%2 == 0]

	for x in a:
		if x % 3 != 0 and x % 5 != 0:
			break
	else:
		print("APPROVED")
		sys.exit()

	
	print("DENIED")


if __name__=='__main__':
	main()


Measured memory_bytes: 5224
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    string s, t;
    cin >> s >> t;

    int ans = 0;
    rep(i, 3){
        if(s[i] == t[i]){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* library */

/* main */

signed main() {
    ll K, X;
    cin >> K >> X;
    FOR(i, -1000000, 1000001) {
        if (abs(i - X) < K) {
            cout << i << ' ';
        }
    }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    ll n;
    cin >> n;
    ll ans = 1;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
        if(a[i] == 0){
            dunk(0);
            return 0;
        }
    }
    rep(i,n){
        if(a[i] > 1000000000000000000/ans){
            dunk(-1);
            return 0;
        }
        ans *= a[i];
        if(ans > 1000000000000000000){
            dunk(-1);
            return 0;
        }
    }
    dunk(ans);
    return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1001001001;
static const ll MOD = 1000000007;


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

    vector<int> a(n);
    rep(i, n)cin >> a[i];

    vector<int> b = a;
    sort(b.rbegin(), b.rend());

    int first = b[0];
    int second = b[1];

    for (auto i : a) {
        if (i == first) {
            cout << second << endl;
        } else {
            cout << first << endl;
        }
    }


}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

ll mod = 1000000007;

signed main()
{
    int n;
    cin >> n;
    vi a;
    rep(i, n)
    {
        int b;
        cin >> b;
        a.push_back(b);
    }
    //all 0
    bool f = true;
    rep(i, n)
    {
        if (a[i] != 0)
        {
            f = false;
            break;
        }
    }
    if (f)
    {
        cout << "Yes" << endl;
        return 0;
    }
    //2/3 x, 1/3 0
    if (n % 3 != 0)
    {
        cout << "No" << endl;
        return 0;
    }
    map<int, int> m;
    rep(i, n)
    {
        m[a[i]]++;
    }
    if (m.size() == 2)
    {
        if (m[0] == n / 3)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    else if (m.size() == 3)
    {
        int res = 0;
        for (auto &i : m)
        {
            res = (res ^ i.first);
        }
        if (res != 0)
        {
            cout << "No" << endl;
            return 0;
        }

        for (auto &i : m)
        {
            if (i.second != n / 3)
            {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
  int n; cin >> n;
  vector<LL> a(n), b(n);
  LL suma = 0, sumb = 0;
  for (int i = 0; i < n; i ++) cin >> a[i];
  for (int i = 0; i < n; i ++) cin >> b[i];

  LL cnta = 0, cntb = 0;
  for (int i = 0; i < n; i ++) {
    if (a[i] >= b[i]) cntb += a[i] - b[i];
    else cnta += (b[i] - a[i]) / 2;
  }

  string ans;
  if (cnta >= cntb) ans = "Yes";
  else ans = "No";

  cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#include <algorithm>
#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mm(arr) memset(arr, 1, sizeof(arr))
#define scanArray(a,n) for(int i = 0; i < n; i++){cin >> a[i];}
using namespace std;

int main(){
    FAST
    int a[5];
    scanArray(a,5);
    for(int i=0; i<5; i++){
        if(a[i] == 0){
            cout << i+1 << endl;
        }
        else{
            continue;
        }
    }




    return 0;
}


Measured memory_bytes: 3552
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);

		String str;
		if((str=br.readLine())!=null){

			if(str.equals("1 0 0") || str.equals("0 1 0") || str.equals("0 0 0")){
				System.out.println("Close");
			} else{
				System.out.println("Open");
			}
		}
	}
}

Measured memory_bytes: 24372
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int n = S.length();
    int tmp=0;
    String part[] = new String[n*(n+1)/2];
    for(int i=0;i<n;i++){
      for(int j=i;j<n;j++){
        part[tmp]=S.substring(i,j+1);
        tmp=tmp+1;
      }
    }
    int answer = 0;
    for(int i=0;i<part.length;i++){
      if(isATGC(part[i])){
        if(answer<part[i].length()){
          answer=part[i].length();
        }
      }
    }
    System.out.println(answer);
    
  }
  
  public static boolean isATGC(String s){
    for(int i=0;i<s.length();i++){
      if(s.substring(i,i+1).equals("A")||s.substring(i,i+1).equals("T")||s.substring(i,i+1).equals("G")||s.substring(i,i+1).equals("C")){
        continue;
      }else{
        return false;
      }
    }
    return true;
  }
  

  
}

Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef long long ll;

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

// [1,n]に格納
vector<int> fenwick;

// [1,c]の和
int fw_sum(int i)
{
    int ret = 0;
    while (i >= 1)
    {
        ret += fenwick[i];
        i -= i & -i;
    }
    return ret;
}

// c番目にxを足す
void fw_add(int i, int x)
{
    while (i <= fenwick.size())
    {
        fenwick[i] += x;
        i += i & -i;
    }
}

struct interval
{
    int right;
    int left;
    int index;
};

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    int n, q;
    cin >> n >> q;
    fenwick.resize(n + 1);
    vector<int> col_s(n + 1);
    FOR(pos, 1, n + 1)
    {
        cin >> col_s[pos];
        col_s[pos]--;
    }
    vector<interval> intervals(q);
    rep(i_q, q)
    {
        int l, r;
        cin >> l >> r;
        intervals[i_q] = {r, l, i_q};
    }
    sort(intervals.begin(), intervals.end(), [](interval x, interval y) {
        return x.right < y.right;
    });

    // good_ball[color] : 一番右のcolor(0-indexed)の場所pos(1-indexed)
    vector<int> good_ball(n);
    vector<int> ans(q);
    int i_q_sorted = 0;
    FOR(pos, 1, n + 1)
    {
        // good_ball の更新
        if (good_ball[col_s[pos]] >= 1)
        {
            fw_add(good_ball[col_s[pos]], -1);
        }
        good_ball[col_s[pos]] = pos;
        fw_add(pos, 1);

        // ansに格納
        while (i_q_sorted < q and intervals[i_q_sorted].right == pos)
        {
            auto cur_int = intervals[i_q_sorted];
            ans[cur_int.index] = fw_sum(cur_int.right) - fw_sum(cur_int.left - 1);
#ifdef DEBUG
            clog << i_q_sorted << ' ' << cur_int.left << ' ' << cur_int.right << ' ' << cur_int.index << ' ' << ans[cur_int.index] << '\n';
#endif
            i_q_sorted++;
        }
    }

    rep(i_q, q)
    {
        cout << ans[i_q] << '\n';
    }

    return 0;
}


Measured memory_bytes: 17444
S = input()

if 1 <= int(S[0:2]) <= 12:
    if 1<= int(S[2:4]) <= 12: 
        print("AMBIGUOUS")
    else: print("MMYY")

elif 1<= int(S[2:4]) <= 12:
    print("YYMM")
else: print("NA") 

Measured memory_bytes: 3060
using System;

namespace AOJ {
    class ALDS1_2_A {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split();
            int[] data = new int[n];
            for(int i = 0; i < input.Length; i++) {
                data[i] = int.Parse(input[i]);
            }
            BubbleSort(data, n);
        }

        static void BubbleSort(int[] A, int n) {
            bool flag = true;
            int count = 0;
            while (flag) {
                flag = false;
                for (int i = n - 1; i > 0; i--) {
                    if (A[i] < A[i - 1]) {
                        int tmp = A[i];
                        A[i] = A[i - 1];
                        A[i - 1] = tmp;
                        flag = true;
                        count++;
                    }
                }
            }
            for(int i = 0; i < A.Length; i++) {
                if (i != A.Length - 1) Console.Write(A[i] + " ");
                else Console.WriteLine(A[i]);
            }
            Console.WriteLine(count);
        }
    }
}



Measured memory_bytes: 17912
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
using namespace std;
int main(){
    int n,z,w,a[2005];
    cin>>n>>z>>w;
    for(int i=1;i<=n;i++)cin>>a[i];
    if(n==1){
        cout<<llabs(a[n]-w);
    }
    else{
        cout<<max(llabs(a[n]-a[n-1]),llabs(a[n]-w));
    }
    return 0; 
}

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

string s;

int main(void){
	cin >> s;
	lli ans = 0;
	rep(i, s.size()-1){
		if(s[i] != s[i+1]) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3740
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <map>

#define AS(a) (sizeof(a)/sizeof(a[0]))
using namespace std;
long long int MOD = 1000000007;
long long int INF = 1000000007;

int main() {
  int a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  double max = 0.0;
  int A = 100 * a;
  int B = 0;
  for(int i = 0; i <= f / a / 100; i++) {
    for(int j = 0; j <= f / b / 100; j++) {
      for(int k = 0; k <= f / c; k++) {
        for(int l = 0; l <= f / d; l++) {
          int w = 100 * a * i + 100 * b * j;
          if(w > f) continue;
          int s = k * c + l * d;
          if(s > e * w / 100) continue;
          if(w + s > f) continue;
          if(w + s == 0) continue;
          if(max < 100.0 * s / (w + s)) {
            max = 100.0 * s / (w + s);
            A = w;
            B = s;
          }
        }
      }
    }
  }
  cout << (A+B) << " " << B << endl;


}


Measured memory_bytes: 256
import numpy
s = list(map(int, input().split()))
n=s[0]
ans=11
for a in range(1,int(numpy.sqrt(n))+1):
    b=n/a
    if b.is_integer():
        b=int(b)
        if max(len(str(a)),len(str(b)))<ans:
            ans = max(len(str(a)), len(str(b)))
print(ans)

Measured memory_bytes: 12488
#include<iostream>
using namespace std;
int main(){
  int N,p[1000][3],count=0;
  cin >> N;

  for(int i=0;i<N;i++)
    for(int j=0;j<3;j++)
      cin >> p[i][j];

  for(int i=0;i<N;i++){
    for(int j=0;j<3;j++){
      for(int k=j;k<3;k++){
	if(p[i][j]<p[i][k]) swap(p[i][j],p[i][k]);
      }
    }
  }//sort OK
  
  for(int i=0;i<N;i++){
    if(p[i][0]==0 || p[i][1]==0 || p[i][2]==0) continue;
    for(int j=i+1;j<N;j++){
      if(p[i][0]==0 || p[i][1]==0 || p[i][2]==0) continue;
      else if(p[i][0]==p[j][0] && p[i][1]==p[j][1] && p[i][2]==p[j][2]){
	count++;
	p[j][0]=0; p[j][1]=0; p[j][2]=0;
      }
    }
  }

  cout << count <<endl;
  
  return 0;
}

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

int main()
{
    int a[4], i, sum[3];


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

    for(i=0; i<3; i++)
    {
        sum[i] = a[i] + a[i+1];
    }
    sort(sum, sum+3);

    cout<<sum[0];

}


Measured memory_bytes: 256
/*
 * c.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 1000;

/* typedef */

struct UFT {
  int links[MAX_N], ranks[MAX_N], sizes[MAX_N];

  void clear(int n) {
    for (int i = 0; i < n; i++) links[i] = i, ranks[i] = sizes[i] = 1;
  }
  UFT() {}
  UFT(int n) { clear(n); }

  int root(int i) {
    int i0 = i;
    while (links[i0] != i0) i0 = links[i0];
    return (links[i] = i0);
  }

  int rank(int i) { return ranks[root(i)]; }
  int size(int i) { return sizes[root(i)]; }
  bool same(int i, int j) { return root(i) == root(j); }

  int merge(int i0, int i1) {
    int r0 = root(i0), r1 = root(i1), mr;
    if (r0 == r1) return r0;
    if (ranks[r0] == ranks[r1]) {
      links[r1] = r0;
      sizes[r0] += sizes[r1];
      ranks[r0]++;
      mr = r0;
    }
    else if (ranks[r0] > ranks[r1]) {
      links[r1] = r0;
      sizes[r0] += sizes[r1];
      mr = r0;
    }
    else {
      links[r0] = r1;
      sizes[r1] += sizes[r0];
      mr = r1;
    }
    return mr;
  }
};

/* global variables */

UFT uft;

/* subroutines */

/* main */

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

  uft.clear(n);

  for (int i = 0; i < m; i++) {
    int ai, bi;
    cin >> ai >> bi;
    ai--, bi--;
    uft.merge(ai, bi);
  }

  int cn = 0, vn = 0;
  for (int i = 0; i < n; i++) {
    int ri = uft.root(i);
    if (ri == i) {
      if (uft.size(i) > 1) cn++;
      else vn++;
    }
  }

  printf("%d\n", abs(cn - vn));
  return 0;
}

Measured memory_bytes: 1160
n = int(input())
ba = []
cd = []
for i in range(n):
  a, b = map(int, input().split())
  ba.append([b, a])
for j in range(n):
  c, d = map(int, input().split())
  cd.append([c, d])
ba.sort(reverse = True)
cd.sort()
ans = 0
for c, d in cd:
  for i in range(n):
    b, a = ba[i]
    if a < c and b < d:
      ans += 1
      ba[i] = [201, 201]
      break
print(ans)


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

using namespace std;

#define int unsigned long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;
const long long INF = 1LL << 60;

signed main()
{
    double a;
    double b;
    cin >> a >> b;

    //int b100 = (b[0] - '0') * 100 + (b[2] - '0') * 10 + (b[3] - '0');
    int b100 = 100 * b + 0.1;

    print((int)a * (b100) / 100);
}


Measured memory_bytes: 3764
class Partion
  def solve
    n    = gets.chomp.to_i
    a = gets.scan(/\d+/).map(&:to_i)
    return partion(a, 0, n-1).join(" ")
  end

  def partion(a, p, r)
    x = a[r]
    i = p - 1
    (p...r).each do |j|
      if a[j] <= x
        i += 1
        a[i], a[j] = a[j], a[i]
      end
    end
    a[i+1], a[r] = "[#{a[r]}]" , a[i+1]
    return a
  end
end

if $0 == __FILE__
  puts Partion.new.solve
end

Measured memory_bytes: 22124
import java.io.*;
import java.util.*;

class Main
{
  public static void main (String[] arg)
  {
    Scanner scan = new Scanner(System.in);
    int n = Integer.parseInt(scan.next()); //整数
    int k = Integer.parseInt(scan.next()); //進数
    int d; //割られる数
    int count; //割った数
    
    d = n;
    
    if(d >= k){
      for(count = 0; (d / k) >= k; count ++){
        d = d / k;
      }
      count ++;
    }
    else{
      count = 0;
    }    
    System.out.println(count + 1);
    
  }
}

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

int main()
{
    long long N;
    long long ans=0;
    cin >> N;
    unordered_map<string, long long> umap;
    string s;
    while(N--) {
        cin >> s;
        sort(s.begin(),s.end());
        if(umap.find(s) == umap.end()) {
            umap.insert(make_pair(s, 1));
        }
        else {
            umap.at(s) += 1;
        }
    }
    unordered_map<string, long long>::iterator itr;
    for(itr = umap.begin();itr != umap.end(); itr++) {
        long long x = itr->second;
        ans += (x*(x-1))/2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10660
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

const int N=5e5+5;
const int mod=998244353;
int n,m,l,r,ans,tmp=1,f[N],fac[N],inv[N];

inline int mul(int x,int y) {return 1ll*x*y%mod;}
inline int C(int n,int m) {return mul(fac[n],mul(inv[m],inv[n-m]));}
inline int modpow(int x,int y,int res=1) {
	for(;y;y>>=1,x=mul(x,x)) if(y&1) res=mul(res,x);
	return res;
}

int main() {
	scanf("%d%d",&n,&m),
	l=min(n,m),r=max(n,m),fac[0]=inv[0]=1;
	for(int i=1;i<=r;++i) fac[i]=mul(fac[i-1],i);
	for(int i=1;i<=r;++i) inv[i]=modpow(fac[i],mod-2);
	for(int i=0;i<=l;++i)
		f[i]=mul(mul(mul(C(m,i),C(n,i)),mul(modpow(m+1,n-i),modpow(n+1,m-i))),fac[i]),
		(ans+=mul(tmp,f[i]))%=mod,tmp=mod-tmp;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 6144
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>


typedef long long ll;

using namespace std;

int main() 
{ 
	int av, bv;
	bool done = false;
	
	cin >> av >> bv;

	for (int i = 1; i < 10000; i++){
			int a = (int) i * 0.08;
			int b = (int) i * 0.10;
			if (a == av && b == bv){
				cout << i << endl;
				done = true;
				break;
			}
	}

	if (!done){
		cout << -1 << endl;
	}
	return 0; 
} 


Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while(in.hasNext()){
			long a = in.nextLong();
			long b = in.nextLong();
			System.out.println(GCD(a, b) + " " + LCM(a, b));
		}
		in.close();
	}

	static long GCD(long a, long b) {//a>b
		if (a < b) {
			long temp = a;
			a = b;
			b = temp;
		}
		if (b == 0) {
			return a;
		} else {
			return GCD(b, a % b);
		}
	}

	static long LCM(long a, long b) {
		return a * b / GCD(a, b);
	}
}

Measured memory_bytes: 26256
x = input()
ans = 'A' if x in ('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z') else 'a'
print(ans)

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

using namespace std;
int main()
{
    int n;
    long kill=0;
    cin >> n;
    long a[n+1],b[n];
    int i=0;
    
    for(i=0;i<=n;i++)
    {
        cin >> a[i];
    }

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

    for(i=0;i<n;i++)
    {
        if(b[i] >= a[i])//勇者が強いとき
        {
            kill += a[i];
            b[i] -= a[i];
            a[i] = 0;

            if(b[i] > 0)//まだ余力があるとき
            {
                if(b[i] >= a[i+1])
                {
                    kill += a[i+1];
                    b[i] -= a[i+1];
                    a[i+1] = 0;
                }
                else//勇者負け
                {
                    a[i+1] -= b[i];
                    kill += b[i];
                    b[i] = 0;
                }
            
            }
        }
        else//勇者が弱いとき
        {
            a[i] -= b[i];
            kill += b[i];
            b[i] = 0;
        }
    }

    cout << kill << endl;

    return 0;
}

Measured memory_bytes: 1792
# cook your dish here
# n=int(input())
# l =  list(map(int,input().split()))
#import numpy as np
a,b,c,k = map(int,input().split())

if abs(b-a)> 10**18:
    print('Unfair')
    quit()
if k%2 == 0:
    print(a-b)
else:
    print(b-a)

Measured memory_bytes: 2940
import Data.Char
import Control.Monad

import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM

import qualified Data.ByteString.Char8 as BS
import Data.Maybe

import Data.Bits

getInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine


main :: IO ()
main = do
  BS.getLine
  a <- getInts
  
  let x = foldl xor 0 a

  forM_ a $ \i -> do
    print $ x `xor` i


Measured memory_bytes: 19048
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

D=int(input())
c=tuple(map(int,input().split()))
s=[tuple(map(int,input().split())) for _ in range(D)]
last=[-1]*26

t=tuple([int1(input()) for _ in range(D)])
ans=0

for d,x in enumerate(t):
    ans+=s[d][x]
    last[x]=d
    for i in range(26):
        ans-=(d-last[i])*c[i]
    print(ans)

Measured memory_bytes: 68312
from itertools import permutations

n, m = map(int, input().split())
edges = set()
for _ in range(m):
    a, b = map(int, input().split())
    edges.add((a, b))
    edges.add((b, a))

print(sum(all(move in edges for move in zip((1,)+p, p)) for p in permutations(range(2, n+1))))

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

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

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

template<class T>
bool umax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(vector<int> arr) {
    int result = arr[0];
    for (auto a: arr) {
        result = gcd(a, result);
    }
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


int dx[5] = {1, 0, -1, 0};
int dy[5] = {0, 1, 0, -1};

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
ll euler_phi(ll n) {
    ll ret = n;
    for(ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            ret -= ret / i;
            while(n % i == 0) n /= i;
        }
    }
    if(n > 1) ret -= ret / n;
    return ret;
}

int main() {
    int K, X; cin >> K >> X;

    if(K*500 >= X){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <assert.h>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
typedef long long ll;
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<ld>> vvd;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

ll m, d;

bool check(ll mm, ll dd) {
    if (dd > 99 || dd < 10) return false;
    ll d1 = dd % 10;
    ll d2 = (dd / 10) % 10;
    if (d1 < 2 || d2 < 2) return false;
    return d1 * d2 == mm;
}

int main() {
    cout << setprecision(30);
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    cin >> m >> d;
    ll ans = 0;
    for (int mm = 1; mm <= m; ++mm) {
        for (int dd = 1; dd <= d; ++dd) {
            if (check(mm, dd)) {
                // cerr << mm << " " << dd << endl;
                ++ans;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a, b = map(int, input().split())
p_list = list(map(int, input().split()))

len_p_over_a = len([p_i for p_i in p_list if p_i <= a])
len_p_ap1_to_b = len([p_i for p_i in p_list if a+1 <= p_i <= b])
len_p_over_bp1 = len([p_i for p_i in p_list if b+1 <= p_i])

min_combi = min(len_p_over_a, len_p_ap1_to_b, len_p_over_bp1)
print(min_combi)


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

using namespace std;

#define ll long long
#define ld long double

const int KEY_BIT = 0x00000FFF;
const int inf = 1000000000;

signed main() {
	vector<int> mincost(KEY_BIT + 1, inf);
	mincost[0] = 0;
	int n; cin >> n;
	int m; cin >> m;
	for (int i = 0; i < m; ++i) {
		int a, b; cin >> a >> b;
		int key = 0;
		for (int j = 0; j < b; ++j) {
			int c; cin >> c; --c;
			key |= (1 << c);
		}
		for (int j = 0; j <= KEY_BIT; ++j) {
			mincost[j | key] = min(mincost[j | key], a + mincost[j]);
		}
	}

	int ansbit = 0;
	for (int i = 0; i < n; ++i)
		ansbit |= 1 << i;

	if (mincost[ansbit] == inf) {
		cout << -1 << endl;
	}
	else {
		cout << mincost[ansbit] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#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 i64 = long long;
using vi64 = vector<i64>;

i64 n;
vi64 a;
vi64 c;

void add(int x) {
  while (x <= 2 * n) {
    c[x]++;
    x += x & -x;
  }
}

i64 sum(int x) {
  i64 s = 0;
  while (x) {
    s += c[x];
    x -= x & -x;
  }
  return s;
}

bool check(i64 md) {
  vi64 v(n), s(n + 1);
  c = vi64(n * 3);
  rep(i, n) {
    if (a[i] >= md) v[i] = 1;
    else v[i] = -1;
  }
  rep(i, n) {
    s[i + 1] += s[i] + v[i];
  }
  i64 cnt = 0;
  rep(i, n + 1) {
    cnt += sum(s[i] + n);
    add(s[i] + n);
  }
  return cnt >= n * (n + 1) / 4;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  cerr << fixed << setprecision(16);
  cin >> n;
  a = vi64(n);
  rep(i, n) cin >> a[i];
  i64 ok = *min_element(all(a)), ng = *max_element(all(a)) + 1;
  while (ng - ok > 1) {
    i64 md = (ok + ng) / 2;
    if (check(md)) {
      ok = md;
    } else {
      ng = md;
    }
  }
  cout << ok << endl;
  return 0;
}


Measured memory_bytes: 7352