akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
  int n, q;
  long long k;
  cin >> n >> k >> q;
  vector<long long> v(n, 0);
  for(int i=0; i<q; i++){
    int a;
    cin >> a;
    v[a-1]++;
  }
  for(int i=0; i<n; i++){
    if(k-(q-v[i])>0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1408
using System;

class latte
{
    public static void Main()
    {
        int[] h = new int[10];

        for (int i = 0; i < 10; i++)
        {
            h[i] = int.Parse(Console.ReadLine());
        }

        Array.Sort(h);
        Array.Reverse(h);

        for (int i = 0; i < 3; i++)
        {
            Console.WriteLine(h[i]);
        }

    }

}

Measured memory_bytes: 5748
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define INF (1LL<<60)
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl
#define SP << " " << 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
#define parity(i,j) (i&(1LL<<j))
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n,a,b;
  cin >> n >> a >> b;

  int ans = n/(a+b)*a;
  n %= a+b;

  ans += min(a,n);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e,n;
  string s,ss,sss;
  cin>>a>>b>>c>>d;
  if(a==c)cout<<0<<endl;
  else cout<<1<<endl;
 
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;

//////////一般化した二分探索

const bool LEFT = false;
const bool RIGHT = true;
bool judgeLR(ll X);// 左に属するか右に属するかを判断する関数。下で定義する。

ll nibutanL(ll size) {// LEFTグループに属するうち最も右側のindexを得る
	ll L = -1;
	ll R = size;
	while (abs(R - L) > 1) {
		ll mid = (L + R) / 2;
		if (judgeLR(mid) == RIGHT) R = mid;
		else L = mid;
	}
	return L;
}
ll nibutanR(ll size) {//RIGHTグループに属するうち最も左側のindexを得る
	return nibutanL(size) + 1;
}


//////   使用例
//int* x;// 昇順ソート済み配列
ll N, K;
vector<ll> a, f;

//	LEFTグループ	...	  要素がkeyより小さい
//	RIGHTグループ	...	  要素がkey以上
bool judgeLR(ll X) {// 最大値をX以下にするために必要なコストがK以下かどうか
	ll sum = 0;
	for (int i = 0; i < N; i++) {
		ll x = f[i] * a[i] - X;
		if (x > 0) { sum += (x + f[i] - 1) / f[i]; }
	}
	if (sum <= K) {
		return RIGHT;
	}
	return LEFT;
}

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		ll x; cin >> x;
		a.push_back(x);
	}
	for (int i = 0; i < N; i++) {
		ll x; cin >> x;
		f.push_back(x);
	}

	ll ans = 0;

	sort(f.begin(), f.end(), greater<ll>());
	sort(a.begin(), a.end());

	for (int i = 0; i < N; i++) {
		ans = max(ans, f[i] * a[i]);
	}

	cout << nibutanR(ans) << endl;

	return 0;
}

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

using namespace std;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);	
	double n ;
	cin >> n;
	double ans = 0;
	ans = (n / 3.0 )* (n / 3.0 )* (n / 3.0 );
	printf("%.10lf", ans);
}




Measured memory_bytes: 256
n,q= map(int, input().split())
S=input()

aflag=0
count=0
arr=[]
for num,i in enumerate(S):
    if i == "A":
        aflag=1
    elif aflag==1 and i == "C":
        #arr.append(num-1)
        count+=1
        aflag=0
    else:
        aflag=0
    arr.append(count)

#print(arr)
for i in range(q):
    l,r=map(int, input().split())
    print(arr[r-1]-arr[l-1])


Measured memory_bytes: 6104
import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.IO as T
import qualified Data.Text.Lazy.Read as T

main :: IO ()
main = do
  let
    modulus = 1000000007 :: Int
    modExp :: Integral a => Int -> a -> Int
    modExp = exp' 1
      where
        exp' z _ 0 = z
        exp' z w y = exp' z' w' y'
          where
            y' = y `div` 2
            w' = w * w `mod` modulus
            z' | even y    = z
               | otherwise = (z * w) `mod` modulus
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  print $ (modExp 10 n - 2 * modExp 9 n + modExp 8 n) `mod` modulus

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    int x_1, y_1, x_2, y_2;
    cin >> x_1 >> y_1 >> x_2 >> y_2;

    int x_3 = x_2 + (y_1 - y_2);
    int y_3 = y_2 + (x_2 - x_1);
    int x_4 = x_1 + (y_1 - y_2);
    int y_4 = y_1 + (x_2 - x_1);

    cout << x_3 << ' ' << y_3 << ' ' << x_4 << ' ' << y_4 << endl;

    /*
    x' = x*cos(T) - y*sin(T)
    y' = x*sin(T) + y*cos(T)
    */

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int x;
	int n;
	int i=1;

	scanf("%d", &n);

	while(i <= n){
		x = i;
		if (x % 3 == 0){
			printf(" %d", i);
		}
		else{
			while (x){
				if (x % 10 == 3){
					printf(" %d", i);
					break;
				}
				x /= 10;
			}
		}
		++i;
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 596
import java.util.*;
public class Main{

     public static void main(String []args){
        Scanner in=new Scanner(System.in);
        
        int n=in.nextInt();
        int A[]=new int[n];
        for(int i=0;i<n;i++)
        {
            A[i]=in.nextInt();
        }
        int dp[]=new int[n+1];
        dp[1]=0;
        dp[2]=Math.abs(A[1]-A[0]);
        for(int i=3;i<=n;i++)
        {
            dp[i]=Math.min(dp[i-2]+Math.abs(A[i-1]-A[i-3]),dp[i-1]+Math.abs(A[i-1]-A[i-2]));
        }
        System.out.println(dp[n]);
     }
}

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

using namespace std;

int ans[100][100];

int main() {
	int h,w; cin >> h >> w;
	int n; cin >> n;
	vector<int> a(n);
	for(auto&e:a) cin >> e;
	int ud=1,x=0,y=0;
	int c=0;
	while(y!=w) {
		ans[x][y]=c+1; --a[c];
		if(!a[c]) ++c;
		if(x==h-1&&ud==1) ++y,ud=-1;
		else if(!x&&ud==-1) ++y,ud=1;
		else x+=ud;
	}
	for(int i=0;i<h;++i) {
		for(int j=0;j<w;++j) {
			if(j) cout << " ";
			cout << ans[i][j];
		}
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 384
s = gets.chomp
if s[0] == s[1] && s[1] != s[2] && s[2] == s[3]
  print "Yes\n"
elsif s[0] == s[2] && s[2] != s[1] && s[1] == s[3]
  print "Yes\n"
elsif s[0] == s[3] && s[3] != s[1] && s[1] == s[2]
  print "Yes\n"
else
  print "No\n"
end

Measured memory_bytes: 1788
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,K=MI()
    P=LI()
    S=[0]*(N+1)
    
    for i in range(N):
        S[i+1]=S[i]+P[i]
        
    M=0
    for i in range(N-K+1):
        temp=S[K+i]-S[i]
        M=max(M,temp)
        
    ans=(M+K)/2
    print(ans)

main()


Measured memory_bytes: 98864
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	
	static class FastReader{
		BufferedReader br;
		StringTokenizer tok;
		
		FastReader(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		
		String next() {
			if(tok==null || (!tok.hasMoreTokens())) {
				try {
					tok = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return tok.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(this.next());
		}
		String nextLine() {
			String s="";
			try {
				s = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return s;
		}
	}
	
	public static void main(String[] args) {
		FastReader fr=new FastReader();
		int n=fr.nextInt();
		int[][] arr=new int[n][3];
		for(int i=0; i<n; i++) {
			arr[i][0]=fr.nextInt();
			arr[i][1]=fr.nextInt();
			arr[i][2]=fr.nextInt();
		}
		
		int[][] dp=new int[n][3];
		dp[0]=arr[0];
		for(int i=1; i<n; i++) {
			for(int j=0; j<3; j++) {
				dp[i][j]=Integer.MIN_VALUE;
				for(int k=0; k<3; k++) {
					if(k!=j)
						dp[i][j]=Math.max(dp[i][j], dp[i-1][k]+arr[i][j]);
				}
			}
		}
		System.out.println(Math.max(Math.max(dp[n-1][0], dp[n-1][1]), dp[n-1][2]));	
	}
}


Measured memory_bytes: 47836
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int W, H;
  while (cin >> W >> H, W) {
    vs v(H);
    rep(i, H) cin >> v[i];
    vvi dp(H, vi(W));
    int b = 0, w = 0;
    rep(i, H) rep(j, W) {
      dp[i][j] = 2 * (v[i][j] == 'B') + (v[i][j] == 'W');
      b -= v[i][j] == 'B';
      w -= v[i][j] == 'W';
    }
    rep(_, W * H) rep(i, H) rep(j, W) {
      if (v[i][j] != '.') continue;
      if (i > 0) dp[i][j] |= dp[i - 1][j];
      if (j > 0) dp[i][j] |= dp[i][j - 1];
      if (i < H - 1) dp[i][j] |= dp[i + 1][j];
      if (j < W - 1) dp[i][j] |= dp[i][j + 1];
    }
    rep(i, H) rep(j, W) {
      b += dp[i][j] == 2;
      w += dp[i][j] == 1;
    }
    cout << b << ' ' << w << endl;
  }
}

Measured memory_bytes: 3008
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int N;
long long a[100000], b[100000], c[100000];

long long upper_search1(long long key) {
  long long r = N;
  long long l = -1;
  while(r - l > 1) {
    long long half = (r + l) / 2;
    if(key < a[half]) r = half;
    else l = half;
  }
  return r;
}

long long upper_search2(long long key) {
  long long r = N;
  long long l = -1;
  while(r - l > 1) {
    long long half = (r + l) / 2;
    if(key < c[half]) r = half;
    else l = half;
  }
  return r;
}
long long lower_search1(long long key) {
  long long r = N;
  long long l = -1;
  while(r - l > 1) {
    long long half = (r + l) / 2;
    if(key <= a[half]) r = half;
    else l = half;
  }
  return r;
}

long long lower_search2(long long key) {
  long long r = N;
  long long l = -1;
  while(r - l > 1) {
    long long half = (r + l) / 2;
    if(key <= c[half]) r = half;
    else l = half;
  }
  return r;
}


int main() {
  cin >> N;
  rep(i, N) {
    cin >> a[i];
  }
  rep(i, N) {
    cin >> b[i];
  }
  rep(i, N) {
    cin >> c[i];
  }

  sort(a, a+N);
  sort(b, b+N);
  sort(c, c+N);

  long long count = 0;

  for(int i = 0; i < N; i++) {
    long long aend = lower_search1(b[i]);
    long long cstart = upper_search2(b[i]);
    count += aend * (N - cstart);
  }

  cout << count << endl;


  return 0;
}

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

int main()
{
    string s,s1,s2;
    cin>>s;
    s1 = s.substr(0,2);
    s2 = s.substr(2,3);
    if(s=="0000")
    {

        cout<<"NA";
        return 0;
    }

    if(s1>="13"&&s2>="13")
    {

        cout<<"NA";
        return 0;
    }

    if(s1<="12"&&s1 >= "01")
    {

        if(s2<="12"&&s2>="01")
        {

            cout<<"AMBIGUOUS";
            return 0;
        }
        else
        {

            cout<<"MMYY";
            return 0;
        }
    }
    if(s2<="12"&&s2 >= "01")
    {

        if(s1<="12"&&s1>="01")
        {

            cout<<"AMBIGUOUS";
            return 0;
        }
        else
        {

            cout<<"YYMM";
            return 0;
        }
    }
    cout<<"NA";
    return 0;


}


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


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():
    ans=[]

    while 1:
        n = INT()
        if n==0:
            break
        else:
            a=LIST()
            a.sort()
            mi=max(a)
            for i in range(n-1):
                for j in range(i+1,n):
                    mi=min(mi,a[j]-a[i])

            ans.append(mi)

    for x in ans:
        print(x)

if __name__ == '__main__':
    main()



Measured memory_bytes: 6864
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REPR(i, n) for (int i = (n)-1; i >= 0; i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase(unique(ALL(v)), v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 2e18;
const double PI = acos(-1);

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, A, B;
	cin >> N >> A >> B;
	vi P(N);
	REP(i, N)
	cin >> P[i];
	so(P);
	int i1 = distance(P.begin(), upper_bound(ALL(P), A));
	int i2 = distance(P.begin(), upper_bound(ALL(P), B));
	int p1 = i1;
	int p2 = i2 - i1;
	int p3 = N - i2;
	cout << min({p1, p2, p3}) << endl;
	return 0;
}


Measured memory_bytes: 256
ary = $stdin.readlines
n = ary.first.to_i
ary.shift
ary.map!(&:chomp!)
answer='Yes'
if ary.uniq.size != ary.size then
  answer='No'
end
i =0
(ary.size-1).times{|i|
  if ary[i][-1] != ary[i+1][0] then
    answer='No'
    break
  end
  i+=1
}

puts answer


Measured memory_bytes: 1788
import java.util.*;

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

		int n = sc.nextInt();

		boolean[] nums = new boolean [82];

		for (int i=1; i<=9; i++)
		{
			for (int a=1; a<=9; a++)
			{
				nums[a*i] = true;
			}
		}

		if (n > 81)
			System.out.println ("No");
		else if (nums[n])
			System.out.println ("Yes");
		else
			System.out.println ("No");



	}
}

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

long long n, rez;

long long boss_fight(long long health)
{
    if (health == 1) return 1;
    else return 1 + 2 * boss_fight(health / 2);
}

int main()
{
    cin >> n;
    rez = boss_fight(n);
    cout << rez;
    return 0;
}



Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<int,int> P;
int main(){
	int a,b;
	cin>>a>>b;
	cout<<(a+b+1)/2<<endl;
}



Measured memory_bytes: 256
// Created by ...Lusifer
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void solveTest(){
	int n,a,b;
	cin>>n>>a>>b;
	ll sum=0;
	for(int i=1;i<=n;i++){
		int m=i;
		ll s=0;
		while(m!=0){
			int r=m%10;
			s+=r;
			m/=10;
		}
		if(s>=a&&s<=b){
			sum+=i;
		}
	}
	cout<<sum<<endl;
	
	return ;
}
 
int main(){
	fastio();

	int t=1;
	//cin>>t;
	while(t--){
		solveTest();
 
	}
	return 0;
}

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

inline void Boost() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.in", "r", stdin);
	#endif
}

int n, DP[5][110];

int main() {
	//Boost();

	cin >> n;

	for(int i = 1; i <= n; ++i)
		cin >> DP[1][i];
	for(int i = 1; i <= n; ++i)
		cin >> DP[2][i];
	
	for(int i = 1; i <= n; ++i)
		DP[1][i] += DP[1][i - 1];

	for(int i = 1; i <= n; ++i)
		DP[2][i] = max(DP[2][i - 1], DP[1][i]) + DP[2][i];

	cout << DP[2][n];
	return 0;
}


Measured memory_bytes: 256
def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass




a = int(input())
print(str(a)+': ',end='')
print(*prime_factor(a))


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


int total(int a, int b){
	int c = a + b;
	return c;
}

int times(int a, int b){
	int c = a * 200 + b * 300;
	return c;
}


int main(){
	int a[9];
	int b[9];
	int c[9];
	int d[9];
	string name[9];
	for (int i = 0; i < 9; i++){
		cin >> name[i];
		cin >> a[i];
		cin >> b[i];
	}
	for (int i = 0; i < 9; i++){
		c[i] = total(a[i], b[i]);
		d[i] = times(a[i], b[i]);
	}
	for (int i = 0; i < 9; i++){
		cout << name[i] << " " << c[i] << " " << d[i] << endl;
	}
	return 0;
}


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

typedef long long int64;

const int N = 2e5, M = 1e6, S = 26;

int n, idx, ch[M + 5][S], cnt[M + 5];
std::string str[N + 5];

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cin >> n;
	for (int i = 1; i <= n; i++) {
		std::cin >> str[i];
		std::reverse(str[i].begin(), str[i].end());
		int u = 0;
		for (auto c : str[i]) {
			c -= 'a';
			if (ch[u][c] == 0) {
				ch[u][c] = ++idx;
			}
			u = ch[u][c];
		}
		cnt[u]++;
	}
	int64 ans = 0;
	for (int i = 1; i <= n; i++) {
		int u = 0, rst[26];
		std::fill(rst, rst + 26, 0);
		for (auto c : str[i]) {
			rst[c - 'a']++;
		}
		for (auto c : str[i]) {
			for (int j = 0; j < 26; j++) {
				if (rst[j] > 0 && ch[u][j] > 0) {
					ans += cnt[ch[u][j]];
				}
			}
			c -= 'a';
			rst[c]--;
			u = ch[u][c];
		}
	}
	std::cout << ans - n << '\n';
	return 0;
}

Measured memory_bytes: 115380
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=sorted(LI())

    MAX=10**6
    divible=[False]*(MAX+1)

    ans = 0
    for i,a in enumerate(A):
        if(i+1<N and A[i+1]==a or divible[a]):
            pass
        else:
            ans += 1
            
        b = a
        if(not divible[a]):#エラトステネスの篩と同じ計算量解析.
            while(b<=MAX): 
                divible[b] = True
                b += a
    print(ans)
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 34212
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
    cin>>n;
    if(n%2==0) printf("-1\n");
    else
    {
        int i;
        int ans=0;
        for(i=1;i<1e6;++i)
        {
            ans=(ans*10+7)%n;
            if(ans==0)
            {
                printf("%d\n",i);
                return 0;
            }
        }
        if(i==1e6) printf("-1\n");
    }
    return 0;
}

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

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;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;  cin >> n >> k;
    vector<int> x(n);
    rep(i, n) {
      cin >> x[i];
    }
    int ans = 0;
    rep(i, n) {
      ans += min(x[i] * 2, (k - x[i]) * 2);
    }
    cout << ans << '\n';

    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    string acgt = "ACGT";

    int ans = 0;
    int c = 0;
    for (int i = 0; i < n; i++) {
        if (acgt.find(s[i]) != string::npos) c++;
        else c = 0;
        ans = max(ans, c);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = pow(10, 9) + 7;

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

    if (n == m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;cin>>s;
    string ans;
    if(s[0]=='S')ans="Cloudy";
    if(s[0]=='C')ans="Rainy";
    if(s[0]=='R')ans="Sunny";
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define 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 eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,M; cin >> N >> M;
    vi G[M];
    rep(i,M){
        int k; cin >> k;
        rep(j,k){
            int a; cin >> a;
            a--;
            G[i].eb(a);
        }
    }

    int A[M];
    rep(i,M) cin >> A[i];

    int cnt=0;
    rep(i,1<<N){
        bool frag = true;
        rep(j,M){
            int pos=0;
            for(auto a:G[j]){
                if((i>>a)&1)pos++;
            }
            if(pos%2!=A[j]) frag = false;
        }
        if(frag) cnt++;
    }

    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll H[100100];

ll dp[100100];

int main() {
    fastio
    ll N,K;
    cin>>N>>K;
    for(ll i=0;i<N;i++){
        cin>>H[i];
        dp[i]=0;
    }
    for(ll i=0;i<=K;i++){
        dp[i]=abs(H[i]-H[0]);
    }
    for(ll i=K+1;i<N;i++){
        ll mn = LLONG_MAX;
        for(ll j=1;j<=K;j++){
            mn = min(mn,dp[i-j]+abs(H[i]-H[i-j]));
        }
        dp[i]=mn;
    }
    cout<<dp[N-1]<<"\n";

    return 0;
}

Measured memory_bytes: 5168
#include <stdio.h>
#define MAX_L 101
#define INFI 1000001
#define NIL -1
#define BLACK 2
#define GRAY 1
#define WHITE 0
int Graph[MAX_L][MAX_L];
int dCost[MAX_L];
int color[MAX_L];
int minVal;
void initialize(int n)
{
    for(int i=0;i<n;i++){dCost[i]=INFI;color[i]=WHITE;}
    dCost[0]=0;
    color[0]=GRAY;
}
int main() {
    int n;
    int id;
    int temp;
    int v = 0;
    int num_v;
    scanf("%d", &n);
    for(int j=0;j<n;j++)
    {
        for(int i=0;i<n;i++)
        {Graph[j][i]=INFI;}
    }
    for(int i=0;i<n;i++)
    {
        scanf("%d %d", &id, &num_v);
        for(int j=0;j<num_v;j++)
        {
            scanf("%d %d", &v, &temp);
            Graph[id][v]=temp;
        }
    }
    initialize(n);
    while(1)
    {
        minVal = INFI;
        id = NIL;
        for(int i=0;i<n;i++)
        {
            if(color[i]!=BLACK && dCost[i]<minVal)
            {
                minVal = dCost[i];
                id = i;
            }
        }
        if(id == NIL)break;
        color[id]=BLACK;
        for(v=0;v<n;v++)
        {
            if(color[v]!=BLACK && Graph[id][v]!=INFI)
            {
                if(dCost[id]+Graph[id][v]<dCost[v])
                {
                    dCost[v] = Graph[id][v] + dCost[id];
                    color[v] = GRAY;
                }
            }
        }
    }
    for(int j=0;j<n;j++)
    {
        if(dCost[j]==INFI){printf("%d -1\n", j);}
        else{printf("%d %d\n", j, dCost[j]);}
    }
    return 0;
}



Measured memory_bytes: 2112
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

def main():
    n = int(input())

    A = [0]*n
    for i in range(n):
        a = list(map(int, input().split()))
        a = [a_-1 for a_ in a]
        A[i] = a

    g = [[] for i in range(n*(n-1)//2)]
    id = [[[-1] for i in range(n)] for j in range(n)]

    temp = 0
    for i in range(n-1):
        for j in range(i+1, n):
            id[i][j] = temp
            id[j][i] = temp
            temp += 1

    for i in range(n):
        for j in range(n-2):
            g[id[i][A[i][j]]].append(id[i][A[i][j+1]])

    visit = [-1]*(n*(n-1)*2)
    clc = [-1]*(n*(n-1)*2)
    dp = [1]*(n*(n-1)*2)
    def dfs(v):
        if visit[v] != -1:
            if clc[v] == -1:
                return -1
            return dp[v]
        visit[v] = 0
        for u in g[v]:
            res = dfs(u)
            if res == -1:
                return -1
            dp[v] = max(dp[v], res+1)
        clc[v] = 0
        return dp[v]

    ans = 0
    for i in range(n*(n-1)//2):
        res = dfs(i)
        if res == -1:
            print(-1)
            exit()
        ans = max(ans, res)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 244828
import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
a.sort()
b.sort()
c.sort()

for j in range(n):
    ans += bisect.bisect_left(a,b[j])*(n-bisect.bisect_right(c,b[j]))
print(ans)

Measured memory_bytes: 23232
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, M, sum int
	fmt.Scan(&N, &M)
	a := make([]int, N)

	for i := 0; i < N; i++ {
		fmt.Scan(&a[i])
		sum += a[i]
	}
	// 降順に並ぶ
	sort.Sort(sort.Reverse(sort.IntSlice(a)))

	ok := true

	for i := 0; i < M; i++ {
		if a[i]*4*M < sum {
			ok = false
		}
	}

	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 512
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ll N;
  cin >> N;
  ll F = 0, jump = 0, answer = 0;
  REP(i, N) {
    ll H;
    cin >> H;
    if (H <= F) {
      jump++;
      answer = max(answer, jump);
    } else {
      jump = 0;
    }
    F = H;
  }
  cout << answer << endl;
  return 0;
}


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

const int N = 3000 + 5;
const int M = 3000 + 5;

int dp[N][M];

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    int n = (int) s.size();
    int m = (int) t.size();
    s = ' ' + s;
    t = ' ' + t;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (t[j] == s[i]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            } else {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }       
        }
    }
    string lcs;
    int i = n, j = m;
    while (i != 0 and j != 0) {
        if (dp[i][j] > max(dp[i - 1][j], dp[i][j - 1])) {
            lcs.push_back(s[i]);
            --i;
            --j;
        } else if (dp[i][j] == dp[i][j - 1]) {
            --j;
        } else if (dp[i][j] == dp[i - 1][j]) {
            --i;
        }
    }
    reverse(lcs.begin(), lcs.end());
    cout << lcs << '\n';
}

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

int main(){
	int N; cin >> N;
	
	vector<string> W(N);
	for (int i = 0; i < N; i++){
		cin >> W[i];
	}

	vector<string> usedStr;
	usedStr.push_back(W[0]);

	int ans = true;
	char endChar = W[0][W[0].length() - 1];

	for (int i = 1; i < N; i++){
		auto itr = find(usedStr.begin(), usedStr.end(), W[i]);
		if (itr != usedStr.end()){
			ans = false;
			break;
		}
		else{
			usedStr.push_back(W[i]);
		}

		char startChar = W[i][0];
		if (startChar != endChar){
			ans = false;
			break;
		}
		else{
			endChar = W[i][W[i].length() - 1];
		}
	}

	if (ans == true) cout << "Yes";
	else cout << "No";

	return 0;
}

Measured memory_bytes: 256
A, B, C, D = map(int, input().split())
cnum = B//C-(A-1)//C
dnum = B//D-(A-1)//D
mx = max(C, D)
mn = min(C, D) 
while mn != 0:
    mx, mn = mn, mx%mn
    #print(mx)
    E = int(C*D/mx)
enum = B//E-(A-1)//E
ansback = cnum+dnum-enum
ans = B-A+1-ansback
print(ans)


Measured memory_bytes: 3060
#![allow(non_snake_case)]

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let N: usize = read_line().parse().unwrap();
    let mut hash = std::collections::HashMap::new();
    let mut ans: i64 = 0;
    for i in 0..N {
        let mut s: Vec<char> = read_line().chars().collect();
        s.sort();
        let num = hash.entry(s).or_insert(0);
        ans += *num;
        *num += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 16636
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main(){
  	
  	int n,x;
  	cin >> n >> x;
  	int a[n];
  
  	rep(i,0,n){
      cin >> a[i];     
    }
  
  	sort(a,a+n);
  
  	rep(i,0,n){
      if(i == n-1){
        if(a[i] != x){
          cout << i << endl;
          return 0;
        }
        else{
          cout << n << endl;
          return 0;
        }
      }
      
      
      if(a[i] <= x){
        x -= a[i];
      }
      else{
        cout << i << endl;
        return 0;
      }
    }
  
  	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static IntStream REPS(int v){
		return IntStream.range(0,v);
	}
	static IntStream INS(int n){
		return REPS(n).map(i->getInt());
	}
	static int getInt(){
		return Integer.parseInt(s.next());
	}
	
	public static void main(String[]__){
		int n=getInt(),b[]=INS(n).toArray();
		boolean[]sh=new boolean[n];
		
		int i=0,c=0;
		while(true){
			if(sh[i])break;
			sh[i]=true;
			if(i==1)break;
			i=b[i]-1;
			c++;
		}
		
		System.out.println(sh[1]?c:-1);
	}
}


Measured memory_bytes: 53676
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  char x,y;
  cin >> x >> y;
  int xi = x - 'A';
  int yi = y - 'A';  

  if(xi<yi){
    cout << "<" << "\n";
  }
  else if(xi>yi){
    cout << ">" << "\n";
  }
  else{
    cout << "=" << "\n";
  }
  
  return 0;
}


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


int main()
{
	ios::sync_with_stdio(false);
	ll a, b, c;
	cin >> a >> b >> c;
	int cnt = 0;
	if(a % 2 == 0) cnt++;
	if(b % 2 == 0) cnt++;
	if(c % 2 == 0) cnt++;
	if(cnt != 0) { cout << '0' << endl; return 0;}
	int t;
	if(a > b) { t = a; a = b; b = t;}
	if(a > c) { t = a; a = c; c = t;}
	if(b > c) { t = b; b = c; c = t;}
	cout << a * b << endl;
	return 0;
}

Measured memory_bytes: 256
//package com.company;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), k = sc.nextInt();
        ArrayList<Integer> a = new ArrayList<>(n);
        for (int i = 0; i < n; i++)
        {
            int val = sc.nextInt();
            a.add(val);
        }
        Collections.sort(a, Collections.reverseOrder());
        long ans = 0;
        for (int i = k; i < n; i++)
            ans += a.get(i);
        System.out.println(ans);
    }
}


Measured memory_bytes: 95360
#include <cstdio>
#include <iostream>
#include <complex>

using namespace std;

#define X real()
#define Y imag()
typedef double D;
typedef complex<D> P;
#define EPS (1e-9)

inline D inprd(const P &a, const P &b){ return (conj(a) * b).X; }
inline D outprd(const P &a, const P &b){ return (conj(a) * b).Y; }
inline D sign(D d){ return (d<0)?-1:d>0?1:0; }

int main(){
    string s;
    while(getline(cin, s)){
        double xa,ya,xb,yb,xc,yc,xd,yd;
        sscanf(s.c_str(), "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd); 
        P a(xa,ya), b(xb,yb), c(xc,yc), d(xd,yd);

        double sa = sign(outprd(b-a, d-a));
        double sb = sign(outprd(c-b, a-b));
        double sc = sign(outprd(d-c, b-c));
        double sd = sign(outprd(a-d, c-d));
        if(sa == sb && sb == sc && sc == sd){
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1264
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    if (n % 2 == 0) {
        cout << n * (n-2) / 2 << endl;
        for (int i = 1; i <= n; ++i) {
            for (int j = i+1; j <= n; ++j) {
                if (i + j == n+1) continue;
                cout << i << " " << j << endl;
            }
        }
    } else {
        cout << (n-1) * (n-1) / 2 << endl;
        for (int i = 1; i <= n; ++i) {
            for (int j = i+1; j <= n; ++j) {
                if (i + j == n) continue;
                cout << i << " " << j << endl;
            }
        }
    }
}

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

def ascending(ndig, first_digit_max):
    for x in range(1, first_digit_max+1):
        if ndig == 1:
            yield [x]
        else:
            for y in ascending(ndig-1, x):
                yield y+[x]

def solve(N: int, M: int, Q: int, a: "List[int]", b: "List[int]", c: "List[int]", d: "List[int]"):
    As = list(ascending(N, M))

    d_sum_max = 0

    for A in As:
        d_sum = 0
        for i in range(Q):
            if A[b[i]-1]-A[a[i]-1]==c[i]:
                d_sum += d[i]
        d_sum_max = max(d_sum, d_sum_max)

    print(d_sum_max)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    a = [int()] * (Q)  # type: "List[int]"
    b = [int()] * (Q)  # type: "List[int]"
    c = [int()] * (Q)  # type: "List[int]"
    d = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
        c[i] = int(next(tokens))
        d[i] = int(next(tokens))
    solve(N, M, Q, a, b, c, d)

if __name__ == '__main__':
    main()


Measured memory_bytes: 94612
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <cmath>
#include <set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

void debug_out() {};
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif

ll gcd(ll x, ll y) {
    if (x < y) {
        swap(x, y);
    }
    if (y == 0) {
        return x;
    }
    ll p = x / y;
    return gcd(y, x-p*y);
}
struct C1 {
    ll A_;
    ll B_;
    explicit C1(ll A, ll B) : A_(A), B_(B) {}
    ll resolve() {
        ll g = gcd(A_, B_);
        set<ll> primes{};
        while(g > 1) {
            bool divided = false;
            for(ll i = 2; i < sqrt((double)g)+10; ++i)  {
                if (g % i == 0) {
                    primes.emplace(i);
                    g = g / i;
                    divided = true;
                    break;
                }
            }
            if (!divided) {
                primes.emplace(g);
                break;
            }
        }
        return primes.size() + 1;
    }
};

int main() {
    ll A, B;
    cin >> A >>  B ;
    C1 c{A, B};
    cout << c.resolve() << endl;
    debug(c.resolve());
    return 0;
}


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

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

    int ans=0;
    for (int i = 2; i < N; i++)
    {
        if(S[i-2]=='A'&&S[i-1]=='B' && S[i]=='C')
        {
            ++ans;
        }
    }
    
    cout<<ans<<endl;
    return 0;
}

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

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

	vector<vector<int>> tbl( 10, vector<int>( 10 ) );
	for( int i = 1; i < N + 1; i++ ) {
		char buff[20000+5];
		sprintf( buff, "%d", i );
		int len = strlen( buff );
		int st = buff[0] - '0';
		int end = buff[len - 1] - '0';
		tbl[st][end]++;
	}
	long long ans = 0;
	for( int i = 1; i < 10; i++ ) {
		for( int j = 1; j < 10; j++ ) {
			ans += tbl[i][j] * tbl[j][i];
		}
	}

	cout << ans << endl;
}


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

int main() {
  string s, ans = "Good";
  cin >> s;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == s.at(i + 1)) {
      ans = "Bad";
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>

#define MOD 1000000007
#define DEBUG 0


using namespace std;

long long int modpow(long long int a, int n) {

	if (n == 0)return 1;
	if (n == 1) return a;

	long long int wk = modpow(a, n / 2);

	long long int ret = 0;
	if (n % 2 == 0) {
		ret = 1;
	}
	else {
		ret = a;
	}

	return (((ret * wk) % MOD) * wk) % MOD;

}

long long int gcd(long long int a, long long int b) {
	long long int tmp;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	long long int r = a % b;

	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

long long int lcm(long long int a, long long int b) {

	long long int wk_int;

	wk_int = (a * b) % MOD;
	
	long long int ret;

	ret = (wk_int * modpow(gcd(a, b), MOD - 2)) % MOD;

	return ret;

}

bool isPrime(int n) {
	if (n == 1)return false;
	if (n == 2)return true;

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

	return true;
}




int hana(vector<int> h) {

	if (h.size() == 0)return 0;
	
	int min = 100;
	int minindex = 0;

	for (int i = 0; i < h.size(); i++) {
		if (h[i] < min) {
			min = h[i];
			minindex = i;
		}
	}

	vector<int> mae;
	vector<int> usiro;

	for (int i = 0; i < h.size(); i++) {
		if (i < minindex) {
			mae.push_back(h[i] - min);
		}
		else if (i > minindex) {
			usiro.push_back(h[i] - min);
		}
	}

	return hana(mae) + min + hana(usiro);

}



int main()
{

	int n;
	cin >> n;

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

	int ans = hana(h);

	cout << ans << endl;



	return 0;

}



Measured memory_bytes: 256