akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
static const int INF (1<<30);

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

  int ans = M / N;

  while (ans > 1) {
    //int mul = N;
    int mul = M / ans - 1;
    while (ans * mul < M) {
      mul++;
    }
    if (ans * mul == M) break;
    ans--;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
          int arr[4]={1,1,1,1};
  int a,b;cin>>a>>b;
  arr[a]=0;
  arr[b]=0;
  for(int i=1;i<4;i++)
    if(arr[i])
        cout<<i;
}


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

using ll = long long;
template<class T>
using V = vector<T>;

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for(int i=m; i<n; i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = b - 1; i >= int(a); i--)

int main(){
    int N;
    cin >> N;
    V<int> h(N);
    rep(i, N) cin >> h.at(i);

    V<ll> dp(N);
    dp.at(N-1) = 0;
    dp.at(N-2) = abs(h.at(N-1) - h.at(N-2));
    per(i, N-2){
        ll a = dp.at(i+1) + abs(h.at(i+1) - h.at(i));
        ll b = dp.at(i+2) + abs(h.at(i+2) - h.at(i));
        dp.at(i) = a < b ? a : b;
    }
    cout << dp.at(0) << endl;
}

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

using namespace std;

const long long MaxN = 2e5 + 17;
long long n, x;
long long v[MaxN];

long long f(long long k)
{
    long long ans = n * x;

    for(int i = 0; i < k; ++i)
    {
        vector<int> visit;
        visit.push_back(0);

        for(int j = i; j < n; j += k)
            visit.push_back(v[j]);

        long long m = visit.size();
        ans += visit[m - 1];

        for(int j = m - 1; j > 0; --j)
            ans += (visit[j] - visit[j - 1]) * (m - j + 1) * (m - j + 1);
    }

    return ans + k * x;
}

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

    cin >> n >> x;

    for(long long i = 0; i < n; ++i)
        cin >> v[i];

    long long l = 1, r = n;

    while(r - l > 2)
    {
        long long t = (r - l) / 3;

        long long p1 = l + t;
        long long p2 = r - t;

        long long f1 = f(p1);
        long long f2 = f(p2);

        if(f2 > f1)
            r -= t;
        else
            l += t;
    }

    long long answer = 1e18;

    for(int i = l; i <= r; ++i)
        answer = min(answer, f(i));

    cout << answer << '\n';





}



Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;

int main() {
    int N, x, y, ans;
    string s, t;
    
    cin >> N >> s >> t;
    x = s.size();
    y = t.size();

    if (N >= x + y) {
        ans = N;
    }
    else {
        ans = x + y;
        for (int i = 0; i <= x; i++) {
            for (int j = 1; j <= y; j++) {
                if (s.substr(i, x) == t.substr(0, j) && x + y - j >= N) {
                    ans = min(x + y - j, ans);
                }
            }
        }
    }

    cout << ans;
    
    return 0;
}

Measured memory_bytes: 3616
use std::io::*;
use std::str::FromStr;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    loop {
        let a: u32 = sc.read();
        let b: u32 = sc.read();
        if a == 0 && b == 0 {
            break;
        }
        let (a, b) = if a < b { (a, b) } else { (b, a) };
        println!("{} {}", a, b);
    }
}



Measured memory_bytes: 5028
/*
    Reference :-
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i < int(n); i++)
#define PI pair<int,int>
#define all(vec) vec.begin(),vec.end()
ll mod=1000000007;
ll power(ll n,ll k){
    ll ans=1;
    while(k){
        if(k&1)ans=(ans*n)%mod;
        k/=2;
        n=(n*n)%mod;
    }
    //ans=(ans-1+mod)%mod;
    return ans;
}

int main(){
    //std::ios::sync_with_stdio(false);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s;
    cin>>s;
    if(s=="AAA"||s=="BBB")cout<<"No";
    else cout<<"Yes";


	return 0;
}


Measured memory_bytes: 256
n = int(input())
ls = []
for _ in range(n):
  ls.append(list(map(int,input().split())))
  
ls = sorted(ls,key = lambda x:x[1])

t= 0
ans = "Yes"
for ab in ls:
  t += ab[0]
  if t > ab[1]:
    ans = "No"
    break
    
print(ans)


Measured memory_bytes: 55256
N, M = map(int, input().split())
ans = 0
a = 1
n = 0
while a < M:
    a *= 2
    n += 1
for i in range(N):
    score = i + 1
    if((a/2*score) >= M and n > 0): 
        a = a // 2
        n = n-1
    ans += (1/N) * pow(0.5, n)
print(ans)

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

int main(){
    int a,b,c,d; cin>>a>>b>>c>>d;

    int left = a+b;
    int right = c+d;

    if(left >right) cout<<"Left"<<endl;
    else if(right > left) cout<<"Right"<<endl;
    else cout<<"Balanced"<<endl;

    return 0;
}

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

const int MAXN = 1e6+5;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);          cout.tie(0);
  int n, k; cin >> n >> k;
  vector<int> kamienie;
  for(int i=0; i<n; i++)  {
    int x;  cin >> x;
    kamienie.push_back(x);
  }
  vector<bool> dp(k + 1);
  for(int i=0; i<=k; i++)
      for(int x : kamienie)
          if(i >= x and !dp[i-x]) dp[i] = true;

  if(dp[k]) cout << "First";
    else  cout << "Second";
}


Measured memory_bytes: 256
n = int(input())
ans = ''
for i in range(1,99):
    if(n <= 26**i):
        n-=1
        for j in range(i):
            ans += chr(ord('a') + n%26)
            n//=26
        break
    else:
        n-= 26**i
print(ans[::-1])


Measured memory_bytes: 9160
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int ans=0;
    int i=1;
    for(int i=1;i<=n;i++){
        int lc=0;
        int tn=i;
        while(tn>0){
            tn=tn/10;
            lc++;
        }
        if(lc%2==1){
            ans++;            
        }
    }
    cout << ans;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

string s,ss,x;
 ll a,b,i,j,l=0,k=0;
vector<ll>v;
cin>>a;
for(i=1;i<=a;i++)
{
if(i==1){cin>>b;v.push_back(b);}
else
{
cin>>b;
if(b<=v[i-2])
{k++;
}
else
{
k=0;
}v.push_back(b);
l=max(k,l);}

}
cout<<l<<endl;
}

Measured memory_bytes: 1400
#include <iostream>
#define Max 10001

int main(){
  int data[Max];
  int count;

  for(int i=1; i<Max; i++){
    std::cin >> data[i];
    if(data[i]==0){ break; }
    count++;
  }
  for(int i=1; i<count+1; i++){
    std::cout << "Case " << i << ": " << data[i] << std::endl;
  }
  return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl "\n"
#define all(v) v.begin(),v.end()
#define mp make_pair
#define mm(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define repn(i,a,b) for(ll i = a; i >= b; i--)
#define pb push_back
#define ff first
#define ss second
#define in_edges(m) repp(i, 1, m){ ll a, b; cin >> a >> b; adj[a].pb(b), adj[b].pb(a);}
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define MOD 1000000007
//atoi() = char to int
// stoi() = int to char
//string g(1,"1"); char to string
//f[stoi(g)] = '0';
//cout.precision(14);
ll power(ll x,ll y);
int main()
{
	    // freopen("in.txt","r",stdin);
	    // freopen("out","w",stdout);
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	    ll t;t=1;
	    // cin >> t;
	    while(t--)
	    {
            string s;
            cin >> s;
            ll flag = 0;
            rep(i,0,s.size())
            if(s[i] == '7')
           flag = 1;
           if(flag)cout <<"Yes";
           else cout <<"No";
        }
        
}
// wooooowooooowwwoowwo


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		int w = sc.nextInt();
		sc.close();
		String result = w >= s ? "unsafe" : "safe";

		System.out.println(result);

	}
}


Measured memory_bytes: 35852
#include <stdio.h>

int main(){
  int a,i,n,s[7];

  while(scanf("%d",&n),n!=0){
    for(i=0;i<7;i++) s[i]=0;
    for(i=0;i<n;i++){
      scanf("%d",&a);
      if(a>=60) a=60;
      s[a/10]++;
    }
    for(i=0;i<7;i++) printf("%d\n",s[i]);
  }
  return 0;
}

Measured memory_bytes: 600
s = input()
t = input()

dict_st = {}
dict_ts = {}

for x, y in zip(s, t):
    if x not in dict_st:
        dict_st[x] = y
    else:
        if dict_st[x] != y:
            print("No")
            break

    if y not in dict_ts:
        dict_ts[y] = x
    else:
        if dict_ts[y] != x:
            print("No")
            break
else:
    print("Yes")


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

void bubble_sort(vector<string> &C,int N){
  for(int i=0;i<N;i++){
    for(int j=N-1;j>i;j--){
      if(int(C.at(j).at(1))<int(C.at(j-1).at(1))){
        swap(C.at(j),C.at(j-1));
      }
    }
  }
}

void selection_sort(vector<string> &C,int N){
  for(int i=0;i<N;i++){
    int minj= i; 
    for(int j=i;j<N;j++){
      if(int(C.at(j).at(1))<int(C.at(minj).at(1))){
        minj = j;
      }
    }
    swap(C.at(i),C.at(minj));
  }
}

int main() {

  int N;
  cin >> N;
  vector<vector<char> > V(9);
  queue<char> q;
  vector<string> C(N);
  vector<string> D(N);
  vector<string> F(N);
  
  for(int i=0;i<N;i++){
    cin >> C.at(i);
    V[int(C.at(i).at(1)-'0')-1].push_back(C.at(i).at(0));
    D.at(i) = C.at(i);
    F.at(i) = C.at(i);
  }
  
  for(int i=0;i<9;i++){
    if(V.at(i).size()!=0){
    for(int h=0;h<V.at(i).size();h++){    
      q.push(int(V.at(i).at(h)));
    }
    }
  }
  
  bubble_sort(D,N);
  selection_sort(F,N);
  bool bs=true;
  bool ss=true;
  for(int k=0;k<N;k++){
    if(D.at(k).at(0)!=q.front()){
      bs = false;
    }
    if(F.at(k).at(0)!=q.front()){
      ss = false;
    }
    q.pop();
  }
  
  for(int k=0;k<N-1;k++){
    cout <<  D.at(k) << ' ';
  }
    cout << D.at(N-1) << endl;

  if(bs){
    cout << "Stable" << endl;
  }else{
    cout << "Not stable" << endl;
  }
  for(int k=0;k<N-1;k++){
    cout <<  F.at(k) << ' ';
  }
    cout << F.at(N-1) << endl;

  if(ss){
    cout << "Stable" << endl;
  }else{
    cout << "Not stable" << endl;
  }
   
}


Measured memory_bytes: 3192
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> A(H, vector<char>(W));
  rep(i, H) rep(j, W) cin >> A[i][j];
  vector<vector<char>> res(H, vector<char>(W, '.'));
  int x = 0, y = 0;
  res[x][y] = '#';
  while(x != H-1 || y != W-1) {
    bool d=false, r=false;
    if(x < H-1 && A[x+1][y] == '#')
      d = true;
    if(y < W-1 && A[x][y+1] == '#')
      r = true;
    if(!d && r) {
      y++;
      res[x][y] = '#';
    }
    else if(d && !r) {
      x++;
      res[x][y] = '#';
    } else {
      cout << "Impossible" << endl;
      return 0;
    }
  }
  rep(i, H) rep(j, W) {
    if(res[i][j] != A[i][j]) {
      cout << "Impossible" << endl;
      return 0;
    }
  }
  cout << "Possible" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <queue>
#define rg register
#define mk(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=100010;
template <typename Tp> inline int getmin(Tp &x,Tp y){return y<x?x=y,1:0;}
template <typename Tp> inline int getmax(Tp &x,Tp y){return y>x?x=y,1:0;}
template <typename Tp> inline void read(Tp &x)
{
	x=0;int f=0;char ch=getchar();
	while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
	if(ch=='-') f=1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	if(f) x=-x;
}
int n,dis[maxn];
pii x;
deque<pii> q;
inline int nxt(int x){return x==n-1?0:x+1;}
int main()
{
	read(n);
	memset(dis,0x3f,sizeof(dis));
	q.push_back(mk(1,1));
	while(1)
	{
		x=q.front();q.pop_front();
		if(!getmin(dis[x.first],x.second)) continue;
		if(x.first==0) break;
		if(x.first%10!=9) q.push_back(mk(nxt(x.first),x.second+1));
		q.push_front(mk(x.first*10%n,x.second));
	}
	printf("%d\n",dis[0]);
	return 0;
}


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


# Generated by 1.1.7.1 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():
    C = input()
    if ord(C)>=ord('A') and ord(C)<=ord('Z'):
        print('A')
    else:
        print('a')

    return

    

if __name__ == '__main__':
    main()


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

using namespace std;

using int64 = long long;
// const int mod = 1e9 + 7;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

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

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

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

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int A, B;
  cin >> A >> B;
  string X(A, B + '0');
  string Y(B, A + '0');
  cout << min(X, Y) << endl;
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n,d; cin >> n >> d;
  vector<double> x(n),y(n);
  rep(i,n) cin >> x[i] >> y[i];

  int cnt = 0;
  rep(i,n){
    double r = x[i]*x[i]+y[i]*y[i];
    r = sqrt(r);
    if(r<=(double)d) cnt++;
  }
  cout << cnt << endl;
  
  return 0;
}


Measured memory_bytes: 6488
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <chrono>
#include <ctime>
#include <queue>
#include <math.h>
#include <deque>
#include <stack>
#include <iomanip>
#include <assert.h>
#include <stdio.h>
#include <cstring>
#include <random>

using namespace std;
#define int long long
#define ll long long
#define ld long double
#define ull unsigned long long
#define endl '\n'
#define try tr
#define pii pair<int, int>
#define ti tuple <int, int, int>
#define vi vector <int>
#define vpi vector <pii>
#define umap unordered_map
#define uset unordered_set
#define left left11
#define right right11
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define sqr(a) ((a) * (a))
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define fs first
#define sc second

ld TL = 0.25;
bool is_tl = 0;
int CALLS = 0;

inline bool IS() {
    if (++CALLS == 1000) {
        CALLS = 0;
        is_tl |= clock() > (TL - 0.1) * CLOCKS_PER_SEC;
    }
    return is_tl;
}

template<typename T1, typename T2>
inline void amin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void amax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> &p) {
    os << p.first << ' ' << p.second << endl;
    return os;
}

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

template<typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
    for (auto &u : v) os << u << ' ';
    os << endl;
    return os;
}

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const ll N = 1e6 + 7, NS = 2e3 + 7, lg = 19, sq = 550, inf = 1e18 + 7, SM = 1e2 + 7;
const ld eps = 1e-9;
int hash_mod[4] = {1000000007, 998244353, 1000000009, 999999937}, mod = hash_mod[rnd() % 4];
int hash_pows[4] = {179, 239, 1007, 2003}, P = hash_pows[rnd() % 4];

void solve() {
    int n, c, k;
    cin >> n >> c >> k;
    vi v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(all(v));
    int ans = 0, cnt = 0, r = inf;
    for (auto u : v) {
        if(cnt == c) {
            ans++;
            cnt = 0;
        }
        if(cnt == 0)
            r = u + k;
        if(u <= r)
            cnt++;
        else {
            ans++;
            cnt = 1;
            r = u + k;
        }
    }
    cout << ans + 1;
}

signed main() {
    fast
    solve();
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  intll a, b, c, d ;
  cin >> a >> b >> c >> d ; 
  
  intll ans = a*c ;
  ans = max(ans,a*d) ;
  ans = max(ans,b*c) ;
  ans = max(ans,b*d) ;
  
  intll x = 0 ;
  if((a<=0&&b>=0) || (c<=0&&d>=0)) ans = max(ans,x) ; 
  cout << ans << endl ;
  

}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int k;
  cin>>k;
  vector<int>vec(n);
  for(int i=0;i<n;i++)
        cin>>vec[i];
  sort(vec.begin(),vec.end());
  int sum=0;
  for(int i=0;i<k;i++)
        sum+=vec[i];
  cout<<sum<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

bool ok[51][35];

signed main() {
    int n;
    while (cin >> n) {
	if (n == 0) break;

	memset(ok, false, sizeof(ok));

	rep(i, n) {
	    int f;
	    cin >> f;
	    rep(j, f) {
		int k;
		cin >> k;
		ok[i][k] = true;
	    }
	}

	vector<set<int>> have(n);
	rep(i, n) {
	    have[i].insert(i);
	}
	REP(i, 1, 30) {
	    set<int> al;
	    rep(j, n) {
		if (ok[j][i]) al.insert(all(have[j]));
	    }
	    if (al.size() == n) {
		cout << i << endl;
		break;
	    }
	    rep(j, n) {
		if (ok[j][i]) have[j].insert(all(al));
	    }
	    if (i == 30) {
		cout << -1 << endl;
	    }
	}
    }

    return 0;
}

Measured memory_bytes: 3212
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin >> N;
  int a[N+1]={0};
  int ans=0;
  for(int i=1;i<=N;i++){
    cin >> a[i];
    if(a[i]==a[i-1]){
      ans++;
      a[i]=10000;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import datetime
from decimal import Decimal, ROUND_DOWN
import heapq
from fractions import gcd
from functools import reduce
from collections import deque
# from math import factorial
import itertools
import collections
import math
import sys
sys.setrecursionlimit(2000000)
# import statistics
# import numpy as np
# n = int(input())
# n, m, p = list(map(int, input().split()))
# a = list(map(int, input().split()))
#
#  abc = [int(input()) for i in range(5)]
# n = int(input())
#h, w, k = list(map(int, input().split()))
# A = list(map(int, input().split()))
# a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# q = int(input())
# s = list(map(int, input().split()))
# b = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
# ab = [list(map(int, input().split())) for i in range(n)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))
s = input()
count = collections.Counter(s)
for i in count.values():
    if i != 2:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 10468
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int R, D, X;
  cin >> R >> D >> X;
  int sum = X;
  rep(i, 10) {
    X = sum * (R - 1) - D;
    sum += X;
    cout << sum << endl;
  }
}

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

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

const ll mod =  1000000007;  //ansを出力する時は (ans % mod + mod) % mod とする(負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976


int main()
{
    int n,q; cin >> n >> q;
    string s;
    cin >> s;
    int cnt[n];
    int sum[n+1];
    rep(i,n) cnt[i] = 0;
    rep(i,n+1) sum[i] = 0;
    rep(i,n-1){
        if(s[i+1] == 'C' && s[i] == 'A') cnt[i+1] = 1;
    }
    
    rep(i,n){
        sum[i+1] = sum[i] + cnt[i];
    }
    rep(i,q){
        int l,r; cin >> l >> r;
        cout << sum[r] - sum[l] << endl;
    }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;

double graph[1002][1002];
double dist(pair<double, double> p1, pair<double, double> p2){
    return sqrt(pow(p1.first-p2.first, 2)+pow(p1.second-p2.second, 2));
}

int main ()
{
  prep();
  double sx, sy, fx, fy;
  cin >> sx >> sy >> fx >> fy;
  int n;
  cin >> n;
  tuple<double, double, double> before[n];
  for (int i=1; i<=n; i++){
      double x, y, r;
      cin >> x >> y >> r;
      for (int j=1; j<i; j++){
          tuple<double, double, double> p = before[j-1];
          double distt = dist({get<0>(p), get<1>(p)}, {x, y});
          graph[i][j] = max(distt-get<2>(p)-r, 0.0);
          graph[j][i] = max(distt-get<2>(p)-r, 0.0);
      }
      before[i-1] = tuple<double, double, double> (x, y, r);
  }
  for (int j=1; j<=n; j++){
      tuple<double, double, double> p = before[j-1];
      double distt = dist({get<0>(p), get<1>(p)}, {sx, sy});
      double distt2 = dist({get<0>(p), get<1>(p)}, {fx, fy});
      graph[0][j] = max(distt-get<2>(p), 0.0);
      graph[j][0] = max(distt-get<2>(p), 0.0);
      graph[n+1][j] = max(distt2-get<2>(p), 0.0);
      graph[j][n+1] = max(distt2-get<2>(p), 0.0);
  }
  graph[0][n+1] = dist({sx, sy}, {fx, fy});
  graph[n+1][0] = dist({sx, sy}, {fx, fy});
  // from 0 to n+1
  queue<int> q;
  q.push(0);
  double curdist[n+2];
  for (int i=0; i<=n+1; i++){
      curdist[i] = 1000000000000000001.0;
  }
  curdist[0] = 0;
  while (!q.empty()){
      int node = q.front();
      q.pop();
      
      for (int i=1; i<=n+1; i++){
         
          if (curdist[node]+graph[node][i] < curdist[i]){
              q.push(i);
              curdist[i] = curdist[node]+graph[node][i];
          }
      }
  }
  printf("%.9lf", curdist[n+1]);
  return 0; 
}

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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

ll h, w;
ll ans = INF*INF;

int main() {
    cin >> h >> w;
    if (h%3 == 0 || w%3 == 0) {
        cout << 0 << endl;
        return 0;
    }
    ans = min(h, w);
    ll x[3];
    for (ll i = h/3; i <= h/3+2; i++) {
        if (i > h) break;
        x[0] = i*w;
        x[1] = (h-i)*(w/2);
        x[2] = (h-i)*(w/2+w%2);
        sort(x, x+3);
        ans = min(ans, x[2]-x[0]);
    }
    for (ll i = w/3; i <= w/3+2; i++) {
        if (i > w) break;
        x[0] = i*h;
        x[1] = (w-i)*(h/2);
        x[2] = (w-i)*(h/2+h%2);
        sort(x, x+3);
        ans = min(ans, x[2]-x[0]);
    }
    cout << ans << endl;
}
































Measured memory_bytes: 256
line = gets.split(' ').map(&:to_i)

n = line[0]
a = line[1]
b = line[2]

num_loop = n / (a + b)
num_last = n % (a + b)

if num_last <= a then
  last_blue = num_last
else
  last_blue = a
end
  
print num_loop * a + last_blue

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();

		if(a == b && b == c){
			System.out.println("1");
		}
		else if(a == b && a != c){
			System.out.println("2");
		}
		else if(b == c && b != a){
			System.out.println("2");
		}
		else if(a == c && c != b){
			System.out.println("2");
		}
		else {
			System.out.println("3");
		}
	}
}


Measured memory_bytes: 21840
A = list(input())
intA = list(map(int, A))
if intA[0]+intA[1]+intA[2]+intA[3]==7:
    print(A[0]+"+"+A[1]+"+"+A[2]+"+"+A[3]+"=7")
elif intA[0]+intA[1]+intA[2]-intA[3]==7:
    print(A[0]+"+"+A[1]+"+"+A[2]+"-"+A[3]+"=7")
elif intA[0]+intA[1]-intA[2]+intA[3]==7:
    print(A[0]+"+"+A[1]+"-"+A[2]+"+"+A[3]+"=7")
elif intA[0]+intA[1]-intA[2]-intA[3]==7:
    print(A[0]+"+"+A[1]+"-"+A[2]+"-"+A[3]+"=7")
elif intA[0]-intA[1]+intA[2]+intA[3]==7:
    print(A[0]+"-"+A[1]+"+"+A[2]+"+"+A[3]+"=7")
elif intA[0]-intA[1]+intA[2]-intA[3]==7:
    print(A[0]+"-"+A[1]+"+"+A[2]+"-"+A[3]+"=7")
elif intA[0]-intA[1]-intA[2]+intA[3]==7:
    print(A[0]+"-"+A[1]+"-"+A[2]+"+"+A[3]+"=7")
elif intA[0]-intA[1]-intA[2]-intA[3]==7:
    print(A[0]+"-"+A[1]+"-"+A[2]+"-"+A[3]+"=7")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define pr(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define all(v) (v).begin(), (v).end()
#define int long long
#define sz(v) (int)(v).size()
#define mod 1000000007 // ((a- b)% mod+ mod)% mod

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int dp[444][444];

void solve() {
        int n; cin >> n;
        vector<int> v(n), sum(n+ 2, 0);

        for (auto& i: v) cin >> i;

        for (int i= 1; i<= n; i++) sum[i]= sum[i- 1]+ v[i- 1];

        memset(dp, -1, sizeof(dp));

        function<int(int, int)> calc= [&](int i, int j)->int{
                if (i== j) return 0;
                if (j- i== 1) {
                        return v[i]+ v[j];
                }

                int &ret= dp[i][j];
                if(ret!= -1) return ret;
                ret= 1e18;

                for (int k= i; k< j; k++) {
                        ret= min(ret, calc(i, k)+ calc(k+ 1, j)+ (sum[j+ 1]- sum[i]));

                }
                return ret;
        };
        cout << calc(0, n- 1);
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int T= 1;
        //cin >> T;
        while ( T-- ) {
                solve();
        }
return 0;
}


Measured memory_bytes: 5268
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

s64 n, m;
s64 s[100001];
vs64 a;

s64 check(s64 x)
{
    s64 ret =  0;
    rep (i, n)
    {
        auto it = lower_bound(a.begin(), a.end(), x - a[i]);
        ret += a.end() - it;
    }
    return ret;
}

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

    cin >> n >> m;
    a.resize(n);
    rep (i, n)
    {
        cin >> a[i];
    }

    sort(a.begin(), a.end());
    rep (i, n)
    {
        s[i + 1] = s[i] + a[i];
    }

    s64 l = 2 * a[0], r = 2 * a[n - 1];
    while (l + 1 < r)
    {
        s64  mid = (l + r) / 2;
        if (check(mid) > m)
        {
            l = mid;
        }
        else
        {
            r = mid;
        }
    }

    s64 ans = 0;
    s64 num = 0;
    rep (i, n)
    {
        auto it = lower_bound(a.begin(), a.end(), r - a[i]);
        num += a.end() - it;
        ans += a[i] * (a.end() - it) + (s[n] - s[it - a.begin()]);
    }

    while (num != m)
    {
        rep (i, n)
        {
            if (num == m) break;
            s64 temp = upper_bound(a.begin(), a.end(), l - a[i]) - lower_bound(a.begin(), a.end(), l - a[i]);
            ans += l * MIN(temp, m - num);
            num += MIN(temp, m - num);
        }
        --l;
    }

    cout << ans << "\n";
    return 0;
}



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

int main(){
    unsigned long N;
    cin >> N;
    vector<unsigned long> A(N), r(N), l(N), ans(N);
    for(auto& i : A)cin >> i;
    partial_sum(A.begin(), A.end() - 1, r.begin() + 1, [](auto a, auto b){return __gcd(a, b);});
    partial_sum(A.rbegin(), A.rend() - 1, l.rbegin() + 1, [](auto a, auto b){return __gcd(a, b);});
    transform(r.begin(), r.end(), l.begin(), ans.begin(), [](auto a, auto b){return __gcd(a, b);});
    cout << *max_element(ans.begin(), ans.end()) << endl;
}

Measured memory_bytes: 3328
# coding: utf-8
# Your code here!
import itertools
N=int(input())
A=[[]]*5
L=['M','A','R','C','H']

C=[0]*5

for i in range(N):
    name=input()
    if name[0] in L:
        C[L.index(name[0])]+=1

n=0
ans=0
for i in range(5):
    if C[i]!=0:
        n+=1
        
if n<3:
    print(0)
else:
    C_=[]
    for i in range(5):
        if C[i]!=0:
            C_.append(C[i])
    #print(C_)
    #c = itertools.combinations(C, 3)
    #print(list(c)[0])
    l=len(C_)
    
    for i in range(l-2):
        for j in range(i+1,l-1):
            for k in range(j+1,l):
                
                #print(i,j,k)
                m=C_[i]*C_[j]*C_[k]
                ans+=m
                m=0
    print(ans)

Measured memory_bytes: 3064
package main

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

var (
	sc = bufio.NewScanner(os.Stdin)
	wtr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	h,w := scanInt(),scanInt()
	a := make([][]int, h)
	b := make([][]int, h)

	for i := 0; i < h; i++ {
		a[i] = make([]int, w)
		for j := 0; j < w; j++ {
			a[i][j] = scanInt()
		}
	}

	for i := 0; i < h; i++ {
		b[i] = make([]int, w)
		for j := 0; j < w; j++ {
			b[i][j] = scanInt()
		}
	}

	ab := (h+w)*80
	dp := make([][][]bool, h+1)

	for i := 0; i < h+1; i++ {
		dp[i] = make([][]bool, w+1)
		for j := 0; j < w+1; j++ {
			dp[i][j] = make([]bool, ab)
		}
	}

	dp[0][1][0],dp[1][0][0] = true, true

	p,q := 1,1
	for p< h+1 && q < w+1 {
		for i := p; i < h+1; i++ {
			now := abs(a[i-1][q-1]-b[i-1][q-1])
			for k := 0; k < ab; k++ {
				if now+k < ab {
					if dp[i-1][q][k+now] || dp[i][q-1][k+now] {
						dp[i][q][k] = true
					}
				}

				if k-now >= 0 {
					if dp[i-1][q][k-now] || dp[i][q-1][k-now] {
						dp[i][q][k] = true
					}
				} else {
					if dp[i-1][q][now-k] || dp[i][q-1][now-k] {
						dp[i][q][k] = true
					}
				}
			}
		}

		for i := q; i < w+1; i++ {
			now := abs(a[p-1][i-1]-b[p-1][i-1])
			for k := 0; k < ab; k++ {
				if now+k < ab {
					if dp[p-1][i][k+now] || dp[p][i-1][k+now] {
						dp[p][i][k] = true
					}
				}

				if k-now >= 0 {
					if dp[p-1][i][k-now] || dp[p][i-1][k-now] {
						dp[p][i][k] = true
					}
				} else {
					if dp[p-1][i][now-k] || dp[p][i-1][now-k] {
						dp[p][i][k] = true
					}
				}
			}
		}
		p++;q++
	}
	
	// for k := 0; k < 10; k++ {
	// 	fmt.Println(k)
	// 	for i := 0; i < h+1; i++ {
	// 		for j := 0; j < w+1; j++ {
	// 			fmt.Print(dp[i][j][k])
	// 			fmt.Print(" ")
	// 		}
	// 		fmt.Println()
	// 	}
	// }
	

	for i,e := range dp[h][w] {
		if e {
			fmt.Println(i)
			break
		}
	}

}

func abs(a int) int {
	if a<0 {
		return -a
	}
	return a
}


Measured memory_bytes: 65152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll n;
    cin >> n;
    VL l(n);
    rep(i, 0, n) cin >> l[i];
    ll ans = 0;
    rep(i, 0, n) {
        rep(j, 0, n) {
            if(l[i] == l[j]) continue;
            if(i >= j) continue;
            rep(k, 0, n) {
                if(l[i] == l[k] || l[j] == l[k]) continue;
                if(i >= k || j >= k) continue;
                ll sum = l[i] + l[j] + l[k];
                ll mx = max({l[i], l[j], l[k]});
                if(mx < sum - mx) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;

int main() {
	cin >> N;
	vector<ll>aa(N), b(N);
	for (int i = 0; i < N; i++) cin >> aa[i];
	for (int i = 0; i < N; i++) cin >> b[i];
	A = *max_element(aa.begin(), aa.end());
	B = *max_element(b.begin(), b.end());
	K = log2(max(A, B)) + 1;
	for (int k = 0; k <= K; k++) {
		vector<ll>c(N),a(N);
		for (int j = 0; j < N; j++) {
			c[j] = b[j] % (1 << (k + 1));
			a[j] = aa[j] % (1 << (k + 1));
		}
		sort(c.begin(), c.end());
		ll tmp = 0;
		for (int i = 0; i < N; i++) {
			tmp += lower_bound(c.begin(), c.end(), (1 << (k + 1))-a[i]) - lower_bound(c.begin(), c.end(), (1 << k)-a[i])
				+ lower_bound(c.begin(), c.end(), (1 << (k + 2))-a[i]) - lower_bound(c.begin(), c.end(), ((1 << k) + (1 << (k + 1)))-a[i]);
		}
		if (tmp & 1)ans += (1 << k);
	}
	cout << ans << endl;
}

Measured memory_bytes: 6548
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n,x=0,max=-1,min=1001,score = 0,i;
    
    while (1) {
        
        scanf("%d",&n);
        
        if (n == 0) {
            break;
        }
        
        for (i = 0; i < n; i++) {
            
            scanf("%d",&x);
            score += x;
            if (x > max) {
                max = x;
            }
            if (x < min) {
                min = x;
            }
            
        }
        printf("%d\n",(score-min-max)/(n-2));
        score = 0;
        x = 0;
        max = -1;
        min = 1001;
    }
    return 0;
}

Measured memory_bytes: 600
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )

using namespace std;

int A, B, T;

int main(void) {
	scanf("%d %d %d", &A, &B, &T);

	printf("%d\n", (T / A) * B );

	return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
total=0
A_li=[0]*(1+2*10**5)
for i in range(N):
    A_li[A[i]]+=1
for i in range(1+2*10**5):
    total+=A_li[i]*(A_li[i]-1)//2
for i in range(1,N+1):
    if A_li[A[i-1]]>1:
        print(total-(A_li[A[i-1]]-1))
    else:
        print(total)

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

int main(){
  int H,W;
  while(cin >>H >> W){
    if(H==0 && W== 0)
      break;
    for(int h=0; h<H; h++){
      for(int w=0; w<W; w++){
        cout << '#';
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3088
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
int a[maxn];
int main() {
	int n;
	double m;
	cin>>n>>m;
	int cnt = 0;
	ll sum = 0;
    for(int i=1;i<=n;i++){
    	cin>>a[i];
    	sum+=a[i];
	}
	for(int i=1;i<=n;i++){
		if(4*m*a[i]<sum){
			cnt++;
		}
	} 
	if((n-cnt)<m){
		cout<<"No\n";
	}
	else {
		cout<<"Yes\n";
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string A, B;
    cin >> A >> B;
    int c = 0;
    rep(i, 3) if(A[i] == B[i]) c++;
    cout << c << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<P> p(n);
    rep(i,n) p[i] = P(a[i],i);
    sort(p.begin(),p.end());
    int ans = 0;
    rep(i,n){
        if(abs(p[i].second-i)%2==1) ++ans;
    }
    cout << (ans/2) << endl;
    return 0;
}

Measured memory_bytes: 4580
{-# LANGUAGE
  ScopedTypeVariables, BangPatterns, TupleSections, ExplicitForAll,
  LambdaCase, MultiWayIf, Unsafe, RecordWildCards, FlexibleContexts, CPP,
  NoMonomorphismRestriction, GADTs,
  RankNTypes, EmptyDataDecls, EmptyCase, ViewPatterns #-}


import Data.Bits
import Data.List
import Data.Maybe
import Data.Tuple
import Data.Ord
import Data.Int
import Data.Word
import Data.Function
import Data.STRef
import Data.IORef
import System.IO
import Control.Applicative
import Control.Monad
import Control.Monad.Primitive
import Control.Monad.State.Strict
import Control.Monad.ST
-- import Control.Monad.ST.Safe
import Control.DeepSeq
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.IntMap (IntMap)
import qualified Data.IntMap.Strict as IMS
import qualified Data.IntMap.Lazy as IML
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import qualified Data.Sequence as Seq
import Data.Sequence (Seq)
import qualified Data.Array.IArray as A
import qualified Data.Array.MArray.Safe as A
import qualified Data.Array.MArray as A
import Data.Array (Array)
import Data.Array.Unboxed (UArray)
import Data.Array.IArray (IArray)
import Data.Array.MArray.Safe (MArray)
import Data.Array.IO.Safe (IOArray, IOUArray)
import Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Vector.Primitive as VP
import qualified Data.Vector.Primitive.Mutable as VPM
import qualified Data.Vector.Generic as VG
import qualified Data.Vector.Generic.Mutable as VGM

main :: IO ()
main = do
  [n,m] <- map read . words <$> getLine
  as <- (concat <$>) $ replicateM n
    $ tail . unfoldr (BS.readInt . BS.dropWhile (<'!')) <$> BS.getLine
  let rem = VU.accum  (+) (VU.replicate (m+1) 0) (map (,1) as)
  print $ VU.length $ VU.filter (>= n) $ rem


rInt :: StateT BSL.ByteString Maybe Int
rInt = StateT $ BSL.readInt . BSL.dropWhile (<'!')

#define D(f,r,d) f::Integral a=>a->d;f=fromIntegral;r::String->d;r=read
#define C(f,r,g,h,d) D(f,r,d);g,h::RealFrac a=>a->d;g=floor;h=ceiling
C(_toInteger_,readInteger,floorInteger,ceilInteger,Integer)
C(toInt,readInt,floorInt,ceilInt,Int)
C(toI8,readI8,floorI8,ceilI8,Int8)
C(toI16,readI16,floorI16,ceilI16,Int16)
C(toI32,readI32,floorI32,ceilI32,Int32)
C(toI64,readI64,floorI64,ceilI64,Int64)
C(toWord,readWord,floorWord,ceilWord,Word)
C(toW8,readW8,floorW8,ceilW8,Word8)
C(toW16,readW16,floorW16,ceilW16,Word16)
C(toW32,readW32,floorW32,ceilW32,Word32)
C(toW64,readW64,floorW64,ceilW64,Word64)
D(toDouble,readDouble,Double)
D(toFloat,readFloat,Float)
#undef D
#undef C


#define N(f,g,a,m)\
  f :: forall e i s. (C(a,m)A.Ix i) => (i,i) -> e -> m (a i e); f=A.newArray;\
  g :: forall e i s. (C(a,m)A.Ix i) => (i,i) -> m (a i e); g=A.newArray_
#define C(a,m)
N(newIOA,newIOA_,IOArray,IO)
N(newSTA,newSTA_,STArray s,ST s)
#undef C
#define C(a,m) MArray (a) e (m), 
N(newIOUA,newIOUA_,IOUArray,IO)
N(newSTUA,newSTUA_,STUArray s,ST s)
#undef C
#undef N



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

int N, K, a[100001];
bool dp[100001];

int main()
{
    scanf("%d %d", &N, &K);
    for (int i = 1; i <= N; i++)
    {
        scanf("%d", a + i);
        dp[a[i]] = 1;
    }
    for (int i = 0; i <= K; i++)
    {
        if (dp[i]) continue;
        for (int j = 1; j <= N; j++)
        {
            if (i - a[j] >= 0 && !dp[i - a[j]])
            {
                dp[i] = 1;
                break;
            }
        }
    }
    puts(dp[K] ? "First" : "Second");
    return 0;
}


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

int find(int n) {

	int sum = 0;
	while (n > 0) {
		sum += n % 10;
		n /= 10;
	}
	return sum;
}


int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a.at(i);
	}
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());

	int alice = 0, bob = 0;
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) alice += a.at(i);
		else bob += a.at(i);
	}

	cout << alice - bob << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F first
#define S second
const int N = 1087;
pair<ll,int> solve(ll x[],int n)
{
    ll s = 0, mx = LLONG_MIN;
    int c = 0;
    for (int i = 0; i < n; ++i) 
        if (x[i] >= 0)
            s += x[i], ++c;
        else
            mx = max(mx, x[i]);
    return c ? pair<ll,int>(s,c) : pair<ll,int>(mx, 1);
}
vector<int> op;
ll a[2][N];
void go(int x) {op.push_back(x);}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i&1][i>>1];
    pair<ll,int> p[2] = {solve(a[0],n/2+n%2), solve(a[1],n/2)};
    int k = p[0] < p[1] ? 1 : 0;
    cout << p[k].F << '\n';
    if (p[k].F < 0) {
        for (; a[(n-1)%2][(n-1)/2] < p[k].F; --n)
            go(n);
        for (int i = 0; i < n - 1; ++i)
            go(1);
    } else {
        for (--n; n > k; ) { 
            if (n%2 != k || a[n%2][n/2] < 0) {
                go(n+1);
                --n;
            } else {
                if (a[k][n/2-1] < 0) {
                    if (n-3 >= 0)
                        go(n+1-2);
                    else
                        go(1),go(1),n=0;
                    a[k][n/2-1] = a[k][n/2];
                } else {
                    go(n-1+1);
                }
                n-=2;
            }
        }
        if (k)
            go(1);
    }
    cout << op.size() << '\n';
    for (int x : op)
        cout << x << '\n';
}


Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))
b4=[x for x in a if x%4==0]
a4=[x for x in a if x%4!=0]
b2=[x for x in a4 if x%2==0]
c=[x for x in a4 if x%2!=0]
if len(b4)==0 and (len(c)==0 and len(b2)>1):
    print('Yes')
elif len(b4)==0 and len(c)!=0:
    print('No')
elif len(b4)+1<len(c):
    print('No')
elif len(b4)<len(c) and len(b2)>0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 14480