akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

int main() {
  int a, b;
  cin >> a >> b;
  int c = a + b;
  if (c >= 10) {
    cout << "error" << endl;
  } else {
    cout << c << endl;
  }
  return 0;
}


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

using namespace std;
const int IINF = INT_MAX;
using ll = long long;
using P = pair<int,int>;
#define INF 100000000

const double pai = 3.141592653589793238;
int main(){
    int m;
    cin >> m;
    
    if(m%2 == 0)
     cout << m/2 << endl;
else cout << m/2 + 1 << endl;
    
    return 0;	
}

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(n);
  int sum=0;
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    sum+=a[i];
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());

  if(a[m-1] >= (sum+4*m-1)/(4*m)) puts("Yes");
  else puts("No");

  
  
}

Measured memory_bytes: 256
while True:
    m, f, r = map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break
    elif m ==-1 or f==-1:
        print('F')
    elif m+f >= 80:
        print('A')
    elif m+f >= 65 and m+f < 80:
        print('B')
    elif m+f >= 50 and m+f < 65:
        print('C')
    elif m+f >= 30 and m+f < 50:
        if r >= 50:
            print('C')
        else:
            print('D')
    elif m+f < 30:
        print('F')


Measured memory_bytes: 5596
def solve():
  N = int(input())
  ans = [0]*(N+1)
  for x in range(1,100):
    for y in range(1,100):
      for z in range(1,100):
        left = x*x+y*y+z*z+x*y+y*z+z*x
        if left<=N:
          ans[left] += 1
  return ans[1:]
print(*solve(),sep='\n')

Measured memory_bytes: 74812
//abc061_d.cpp
//Sat Apr 20 18:21:42 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;
struct edge {
	ll to,from,cost;
};

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

	ll d[n];
	fill(d,d+n,LLINF);
	d[0] = 0;

	edge es[m];
	for (int i=0;i<m;i++){
		ll a,b,c;
		cin >> a >> b >> c;
		a--;
		b--;
		c = c*(-1);
		es[i].from = a;
		es[i].to = b;
		es[i].cost = c;
	}

	for (int i=0;i<n-1;i++){
		for (int j=0;j<m;j++){
			edge e = es[j];
			if (d[e.from]!=LLINF && d[e.from]+e.cost < d[e.to]){
				d[e.to] = d[e.from]+e.cost;
			}
		}
	}

	int neg[n];
	fill(neg,neg+n,0);
	for (int i=0;i<n;i++){
		for (int j=0;j<m;j++){
			edge e = es[j];
			if (d[e.from]!=LLINF && d[e.from]+e.cost < d[e.to]){
				d[e.to] = d[e.from]+e.cost;
				neg[e.to] = 1;
			}
			if (neg[e.from] == 1){
				neg[e.to] = 1;
			}
		}
	}

	if (neg[n-1] == 1){
		cout << "inf" << endl;
	}else {
		cout << d[n-1]*(-1) << endl;
	}
//	printf("%.4f\n",ans);
}

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

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

    int tim=0;
    while(true){
        for(int i=0;i<=a;i++){
            if(tim%60==c){
                cout<<tim<<endl;
                return 0;
            }
            if(i==a)break;
            tim++;
        }
        tim+=b;
        if(tim%60==0){
            cout<<-1<<endl;
            break;
        }
    }

    return 0;
}

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

int main(){
    string s;
    cin >> s;

    int ans = 0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='+'){
            ans++;
        }
        else{
            ans--;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE TypeApplications #-}

import           Control.Monad
import           Control.Applicative
import           Data.List
import           Data.Char
import           Control.Arrow
import           Data.Bits


main = do
  n <- readLn @Int
  h <- map (read @Int) . words <$> getLine
  print $ solve h 0 0
 where
  solve [_] k m = m
  solve (a : b : rs) k m | a >= b    = solve (b : rs) (k + 1) (max (k + 1) m)
                         | otherwise = solve (b : rs) 0 m


Measured memory_bytes: 34460
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:isize,
    b:isize,
    c:isize,
    }
    if (c-b)%2==0{
        println!("Alice")
    }
    else {
        println!("Borys")
    }
}

Measured memory_bytes: 2172
#include <stdio.h>

int main(void){
  int i,j,n,m,cn;
  char c,s[5]={'S','H','C','D','\0'};
  static int card[4][13];
  scanf("%d\n",&n);

  for(i=0;i<n;i++){
    scanf("%c %d\n",&c,&m);
    for(j=0;j<4;j++)
      if(s[j]==c)
        card[j][m-1]=1;
  }
  
  for(i=0;i<4;i++)
    for(j=0;j<13;j++)
      if(card[i][j]==0)
        printf("%c %d\n",s[i],j+1);

  return 0;
}
 


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define mod 1000000007

int main()
{

    ll m, n;
    cin >> m >> n;
    ll a = max(m,n);
    ll b = min(m,n);
    if(a-b > 1)
    {

        cout << 0;
    }
    else
    {

        vector<ll> v(a+1);
        for(ll i = 1; i <= a; i++) v[i]=i;
        for(ll i = 2; i <= a; i++)
        {

            v[i] = (v[i-1]*v[i])%mod;
        }
        if(a==b) cout << (v[a]*v[b]* 2)%mod;
        else cout << (v[a]*v[b])%mod;
    }
}


Measured memory_bytes: 1024
require 'prime'

n = gets.chomp.to_i

MOD = 10**9 + 7

# √1000（31）までの素数を求める
prime = [2]

(3..31).each do |i|
  judge = true
  prime.each do |number|
    if i % number == 0
      judge = false
      break
    end
  end

  prime.push(i) if judge
end

h = Hash.new(0)

1.upto(n) do |i|
  arr = i.prime_division
  arr.each do |k,v|
    h[k] += v
  end
end

ans = 1

h.each do |k, v|
  ans = ans * (v + 1) % MOD
end

p ans

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


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

    int N,M;
    cin >> N >> M;
    int L[M][2];
    rep(i,M){
        cin >> L[i][0] >> L[i][1];
    }
    int L1=0;
    int R=1000000;
    rep(i,M){
        L1=max(L1,L[i][0]);
    }
    rep(i,M){
        R=min(R,L[i][1]);
    }
    int ans=R-L1+1;
    ans = max(ans, 0);
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;
int S[2001][2001];

int main(){
  int N,K;
  cin>>N>>K;
  int x[N],y[N];
  char c[N];
  REP(i,N){
    cin>>x[i]>>y[i]>>c[i];
    x[i]%=2*K;
    y[i]%=2*K;
  }
  REP(i,2*K)REP(j,2*K)S[i][j]=0;
  REP(i,N){
    FOR(ii,-2,2)FOR(jj,-2,2){
      if((ii+2)%2!=(jj+2)%2)continue;
      int u,d,l,r;
      l=x[i]+1+K*ii;
      r=l+K-1;
      d=y[i]+1+K*jj;
      u=d+K-1;
      // cerr<<l<<" "<<r<<" "<<d<<" "<<u<<endl;
      if(r<0 or u<0)continue;
      if(l>=2*K or d>=2*K)continue;
      l=max(l,0);
      r=min(r,2*K-1);
      d=max(d,0);
      u=min(u,2*K-1);
      // cerr<<" "<<l<<" "<<r<<" "<<d<<" "<<u<<endl;
      if(c[i]=='B'){
        S[d][l]+=1;
        S[d][r+1]-=1;
        S[u+1][l]-=1;
        S[u+1][r+1]+=1;
      } else{
        S[d][l]-=1;
        S[d][r+1]+=1;
        S[u+1][l]+=1;
        S[u+1][r+1]-=1;
      }
    }
    if(c[i]=='W')S[0][0]+=1;
  }
  FOR(i,1,2*K)REP(j,2*K)S[i][j]+=S[i-1][j];
  REP(i,2*K)FOR(j,1,2*K)S[i][j]+=S[i][j-1];
  // REP(i,2*K){
  //   REP(j,2*K)cerr<<S[i][j];
  //   cerr<<endl;
  // }
  int ans=0;
  REP(i,2*K)REP(j,2*K)ans=max(ans,S[i][j]);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 16768
from sys import stdin

lines = stdin.readlines

l = [[int(i) - 1 for i in line.split()] for line in lines()]

N, M = l[0][0] + 1, l[0][1] + 1


def main():
    f = [False] * N
    t = [False] * N

    for a, b in l[1:]:
        if a == 0:
            f[b] = True
        elif b == N - 1:
            t[a] = True

    for a, b in zip(f, t):
        if a and b:
            print("POSSIBLE")
            return
    else:
        print("IMPOSSIBLE")

    return


main()


Measured memory_bytes: 53524
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
const double pi=3.1415926535897932384626;

int main(){
    int a,b;
    std::cin >> a>>b;
    if(a<0){
        if(b<0){
            if((b-a+1)%2==0)std::cout << "Positive" << std::endl;
            else std::cout << "Negative" << std::endl;
        }
        else std::cout << "Zero" << std::endl;
    }
    else{
        if(a==0)std::cout << "Zero" << std::endl;
        else{
            std::cout << "Positive" << std::endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <climits>

#define F first
#define S second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

//#define ZERO(p) memset(p, 0, sizeof(p))
//#define MINUS(p) memset(p, -1, sizeof(p))
//INT_MAX
//INT_MIN
//LLONG_MAX
//LLONG_MIN
//DBL_MIN
//DBL_MAX
//LDBL_MIN
//LDBL_MAX

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int n, m;
    cin >> n >> m;
    string s;
    vector<string> a(n), b(m);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    bool flag = false;
    for (int i = 0; i <= n - m && !flag; i++) {
        for (int j = 0; j <= n - m  && !flag; j++) {
            if (a[i][j] == b[0][0]) {
                flag = true;
                for (int k = 0; k < m && flag; k++) {
                    for (int l = 0; l < m && flag; l++) {
                        if (a[i+k][j+l] != b[k][l]) {
                            flag = false;
                        }
                    }
                }
            }
        }
    }
    if (flag) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import Data.Maybe
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V
main=putStrLn.solve.map(fst.fromJust.B.readInt).B.words=<<B.getContents
solve(n:k:as)=f k.V.fromList$as
f 0 as=unwords.map show.V.toList$as
f k as=f(if as==bs then 0 else k-1)bs where
  n=V.length as
  bs=V.scanl1(+).V.accum(+)(V.replicate n 0)$concatMap g.zip[0..].V.toList$as
  g(i,a)=(max 0$i-a,1):if i+a+1<n then [(i+a+1,-1)] else []

Measured memory_bytes: 17308
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);
const long double PI=3.14159265358979;

// Required random number generators

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    READAR(A,N);
    sort(A,A+N);
    ll tot=A[N-1];
    ll t=N-2;
    FORD(i,N-2,-1)
    {
        if(t==0)
        {
            break;
        }
        tot+=min(t,2LL)*A[i];
        t-=min(t,2LL);
    }
    cout<<tot<<endl;


//-----------------------------------------------------------------------------------------------------------//


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

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

int main() {
  long long x, k, d;
  cin >> x >> k >>d;
  x = abs(x);
  
  if (x/d >= k) cout << x - k * d << endl;
  else {
    long long m = x % d, n = k - x / d;
    if (n % 2 == 0) cout << m << endl;
    else cout << d - m << endl;
  }
}

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

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());

  int sub = 0;
  sub = A.at(N - 1) - A.at(0);
  
  cout << sub << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define ff first
#define ss second
#define inf 9e18
#define pii pair<int,int>
#define fastio ios_base::sync_with_stdio(0);  cin.tie(0); cout.tie(0);
using namespace std;
vector<vector<int> > v;
int dp[100005];
int dfs(int src){
    if(dp[src]!=-1)
        return dp[src];
    int ans = 0;
    for(int i:v[src]){
        ans = max(ans,1+dfs(i));
    } 
    return dp[src]=ans;
}
int32_t main()
{
    
    fastio
  
    int n,m;
    cin>>n>>m;
    v.reserve(n+1);
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        v[x].pb(y);
    }
    memset(dp,-1,sizeof(dp));
    int ans = 0;
    for(int i=1;i<=n;i++){
        
            ans = max(ans,dfs(i));
        
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 8192
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    for(int i = 0; i < 5; ++i) {
        int x;
        cin >> x;
        if(!x) {
            cout << (i + 1);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3600
#ifdef __GNUC__
#pragma GCC target("avx2")
#pragma GCC optimize ("O20")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC optimize("unroll-loops")
#define iss std::cin
#endif
#include "bits/stdc++.h"
#define rep(i, times) for(ll i = 0; i < (times); ++i)
#define p(x) (cout << x << "\n")
using ll = uint16_t; using ld = long double; using namespace std;

#ifndef __GNUC__
string text =
R"X(
8
7 3 5 4 2 1 6 8
3 8 2 5 4 6 7 1
)X";
stringstream iss{text};
#endif

class CountOrder
{
	ll N{0};
	vector<ll> p, q;
	void inp( ) {
		iss >> N; p.resize(N); q.resize(N);
		rep(n, N) { iss >> p[n]; }
		rep(n, N) { iss >> q[n]; }
		//for_each(begin(p), end(p), [](auto x) { cout << x << "\n"; });
	}
	void change( ) {
		long long sa{0};
		if (p > q) swap(p, q);
		do {
			if (p == q) break;
			++sa;
		} while (next_permutation(begin(p), end(p)));
		p(sa);
	}
public:
	void procedures( ) {
		inp( );
		change( );
	}
};
//https://atcoder.jp/contests/abc145/tasks/abc145_c
int main( ) {
	cin.tie(0);	ios::sync_with_stdio(0);
	cout << fixed << setprecision(15);
	class CountOrder a; a.procedures( );
}

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

int main() {
  double D,S,T;
  cin >> D >> T >> S;
  double m = D/S;
  if(m <= T) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3692
n = int(input())
an = [int(i) for i in input().split()]
lowe, min_an_sub = 0, an[0]
an_sub = []
for i in range(0, n):
    an_sub.append(an[i])
    min_an_sub = min(min_an_sub, an[i])
    if an_sub[i] <= min_an_sub:
        lowe += 1
print(lowe)

Measured memory_bytes: 25768
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n,x;
	int ans=1;
	cin >>n>>x;
	int d=0;
	Vi l(n);
	rep(i,n){
		cin>>l[i];
		d+=l[i];
		if(d <=x){
			ans++;
		}
	}

	cout<<ans<<endl;
} 

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long a[] = new long[N];
		for (int i=0;i<N;i++) {
			a[i] = sc.nextLong();
		}
		int count =0;
		for (int i=0;i<N;i++) {
			for (int j=i+1;j<N;j++) {
				for (int k=j+1;k<N;k++) {
					if (a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[k]+a[j]>a[i]&&a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k]) {
						count ++;
					}
				}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 36912
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;
u64 over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  cout << a + b + c - max(a, max(b, c)) << endl;
  return 0;
}


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

int main() {
  //int n;
  string s;
  cin >> s;
  char a;
  char b = 'a';
  int count_a = 1;
  int count_b = 0;

  a = s.at(0);
  for(int i = 1; i < 4; i++) {
    if(s.at(i) == a) {
      count_a++;
    } else if(b == 'a'){
      b = s.at(i);
      count_b++;
    } else if(s.at(i) == b) {
      count_b ++;
    } else {
      cout << "No" << endl;
      return 0;
    }
    //cout << a << endl;
    //cout << b << endl;
  }

  if(count_a == 2 && count_b == 2) 
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
# /usr/bin/python
# -*- coding: utf-8 -*-
#
import math


n = int(input())
capacity = []
for _ in range(5):
  capacity.append(math.ceil(n / int(input())))

ans = 5 + capacity[0]-1
mn = capacity[0]
for i in capacity[1:]:
  if mn < i:
    ans += i - mn
    mn = i
print(ans)


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

int main(){

  ll n;
  cin>>n;
  ll ans[n];
  vector<vector<ll> >V;
  V.resize(n);
  rep(i,0,n){
    ll a;cin>>a;
    --a;
    ll k;cin>>k;
    rep(j,0,k){
      ll b;cin>>b;
      --b;
      V[a].push_back(b);
    }
    ans[i]=INF;
  }

  queue<ll>q;
  q.push(0);

  ans[0]=0;
  while(!q.empty()){
    ll u=q.front();q.pop();

    for(auto v:V[u]){
      // out(u<<":"<<v);
      if(ans[v]!=INF)continue;
      chmin(ans[v],ans[u]+1);
      q.push(v);
    }

  }


  rep(i,0,n){
    // out(ans[i]<<"=="<<inf);
    if(ans[i]==INF)out(i+1<<" "<<-1);
    else out(i+1<<" "<<ans[i]);
  }


  return 0;
}



Measured memory_bytes: 3124
#include <iostream>
#include <complex>

using namespace std;
typedef complex<double> xy_t;
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }
const double eps = 1e-11;
double x[4],y[4];
int N;
int main() {
    cin >> N;
    for(int t=0; t<N; ++t){
        for(int i=0; i<4; ++i){
            cin >> x[i] >> y[i];
        }
        xy_t a[2] ={
            xy_t(x[0],y[0]) - xy_t(x[1],y[1]),
            xy_t(x[2],y[2]) - xy_t(x[3],y[3])
        };
        bool p = abs(cross_product(a[0], a[1])) < eps;
        cout << (p ? "YES" : "NO") << endl;
        }
    return 0;
}

Measured memory_bytes: 1236
Module Module1

    Sub Main()

        Dim tmp As String() = Split(Console.ReadLine(), " ")
        Dim a As Integer = CInt(tmp(0))
        Dim b As Integer = CInt(tmp(1))
        Dim strA As String = ""
        Dim strB As String = ""

        For i As Integer = 1 To b
            strA += tmp(0)
        Next
        For i As Integer = 1 To a
            strB += tmp(1)
        Next

        If strA < strB Then
            Console.WriteLine(strA)
        Else
            Console.WriteLine(strB)
        End If

    End Sub

End Module


Measured memory_bytes: 22352
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            
            var H = cin.nextInt();
            var W = cin.nextInt();
            var N = cin.nextInt();

            var m = Math.Max(H, W);
            var ans = 0;
            var mass = 0;
            while (true)
            {
                mass += m;
                ans++;
                if (mass>= N)
                {
                    break;
                }
                
            }

            Console.WriteLine(ans);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
using namespace std;
const int N = 1e6 + 5;
const ll inf = -1e18;
const int MOD = 1e9 + 7;


ll a[N];
int main(){
   fast;
   ll n, t;
   cin >> n;
   a[1] = 1;
   for(int i = 2; i <= n + 2; i++){
    t = a[i - 1] + 1;
    for(int j = 6; ; j *= 6){
      if(i - j < 0)
        break;
      t = min(t, a[i - j] + 1);
    }
    for(int j = 9; ; j *= 9){
      if(i - j < 0)
        break;
      t = min(t, a[i - j] + 1);
    }
    a[i] = t;
   }
   cout << a[n];




   return 0;
} 

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

vector<ll> prime; //素因数分解で出てきた素数を全て挿入するvector

//O(√n)
//整列済み
void prime_factorize(ll n)
{
    if (n <= 1)
    {
        return;
    }
    ll l = sqrt(n);
    for (int i = 2; i <= l; i++)
    {
        if (n % i == 0)
        {
            prime_factorize(i);
            prime_factorize(ll(n / i));
            return;
        }
    }
    prime.push_back(n);
    return;
}

int main()
{
    ll n;
    cin >> n;
    prime = vector<ll>();
    prime_factorize(n);
    if (prime.size() == 0)
    {
        cout << 0 << endl;
        return 0;
    }
    ll count = 0;
    ll prev = prime[0];
    ll ans = 0;
    for (int i = 0; i < prime.size(); i++)
    {
        if (prev == prime[i])
        {
            count++;
        }
        else
        {
            prev = prime[i];
            for (int j = 1; j <= count; j++)
            {
                if (count < j)
                {
                    break;
                }
                else
                {
                    ans++;
                    count -= j;
                }
            }
            count = 1;
        }
        if (i == prime.size() - 1)
        {
            for (int j = 1; j <= count; j++)
            {
                if (count < j)
                {
                    break;
                }
                else
                {
                    ans++;
                    count -= j;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3688
n,m = map(int,input().split())
k = [0]*n
a = [0]*(m+1)
b = [0]*(m+1)

for i in range(n) :
    a = list(map(int,input().split()))
    for j in range(1,len(a)) :
        b[a[j]] += 1

print(b.count(n))

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

int main()
{
	int n;
	int ans = 0;

	cin >> n;
	for( int i = 0; i < n; i++ ) {
		int l, r;

		cin >> l >> r;
		ans += r - l + 1;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.next()
    println(problem176b(n))
}

fun problem176b(n: String): String {
    var sum = 0L
    for (i in 0 until n.length) {
        val ni = n[i]
        sum += ni.toString().toInt()
    }
    return if (sum == 0L || sum % 9 == 0L) "Yes" else "No"
}

Measured memory_bytes: 51348
x, n = map(int, input().split())

p = list(map(int, input().split()))
if len(p) == 0:
    print(x)
    exit(0)
for abs in range(n+1):
    if (x - abs) not in p:
        print(x-abs)
        exit(0)
    elif (x + abs) not in p:
        print(x+abs)
        exit(0)

Measured memory_bytes: 9192
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

const ll DENOMI = 1000000007;


int main()
{
	int n, k;
	cin >> n >> k;
	auto pas = vector<vector<ll>>(n + 2, vector<ll>(n + 2));
	pas[0][0] = 1;
	for(auto i = 1; i <= n; ++i){
		pas[i][0] = 1;
		for(auto j = 1; j <= i; ++j){
			pas[i][j] = (pas[i - 1][j - 1] + pas[i - 1][j]) % DENOMI;
		}
	}
	for(auto i = 1; i <= k; ++i){
		ll b = pas[k - 1][i - 1];
		ll r = pas[n - k + 1][i];
		cout << b *r % DENOMI << endl;
	}
	return 0;
}

Measured memory_bytes: 31616
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<iostream>
#include<algorithm>//next_permutation

using namespace std;

int main() {
	string s, test = "";
	cin >> s;
	bool F = false;
	for (int i = 0;i < 20;i++) {
		test += "hi";
		if (test == s) {
			F = true;
			break;
		}
	}
	if (F) {
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

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

typedef long long ll;

int main(){
    ll N;
    cin >> N;
    ll a[N];
    for(ll i=0; i<N; i++){
        cin >> a[i];
    }
    if(N%2==1){
        for(ll i=N-1; i>=0; i-=2){
            cout << a[i] << " ";
        }
        for(ll i=1; i<=N-2; i+=2){
            cout << a[i] << " ";
        }
    }else{
        for(ll i=N-1; i>=1; i-=2){
            cout << a[i] << " ";
        }
        for(ll i=0; i<=N-2; i+=2){
            cout << a[i] << " ";
        }
    }
    cout << endl;
}


Measured memory_bytes: 3712
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
	Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		for(int n=0,i=0;b>=(a+i);++i) {
			if(c%(a+i)==0) {
			++n;
			}
			if(b==(a+i))
			System.out.println(n);
		}
    }
}


Measured memory_bytes: 26352
a,b,c,x,y=map(int,input().split())
if a+b<=c*2:
  print(a*x+b*y)
else:
  z=min(x,y)
  ans=(c*2)*z
  x-=z;y-=z
  ans+=min((x+y)*2*c,x*a+y*b)
  print(ans)

Measured memory_bytes: 3060
#H=4
#W=6
#
#S[0]=["#",".",".","#",".","."]
#S[1]=[".",".",".",".",".","#"]
#S[2]=[".",".",".",".","#","."]
#S[3]=["#",".","#",".",".","."]

H,W = map(int,input().split())

S = [[0]*W for i in range(H)]

for i in range(H):
    T=list(input())
    for j in range(W):
        if T[j] == "#":
            S[i][j] = 0
        else:
            S[i][j] = 1
MAP=[[0]*(W+2) for i in range(H+2)]
MAPH=[[0]*(W+2) for i in range(H+2)]
MAPU=[[0]*(W+2) for i in range(H+2)]
MAPL=[[0]*(W+2) for i in range(H+2)]
MAPR=[[0]*(W+2) for i in range(H+2)]

MAX=0

for i in range(1,W+1):
    for j in range(1,H+1):
            MAPH[j][i]=(MAPH[j-1][i]+1)*S[j-1][i-1]
            MAP[j][i]+=MAPH[j][i]
            MAPU[H-j+1][W-i+1]=(MAPU[H-j+2][W-i+1]+1)*S[H-j][W-i]
            MAP[H-j+1][W-i+1]+=MAPU[H-j+1][W-i+1]
for j in range(1,H+1):
    for i in range(1,W+1):
            MAPL[j][i]=(MAPL[j][i-1]+1)*S[j-1][i-1]
            MAP[j][i]+=MAPL[j][i]
            MAPR[H-j+1][W-i+1]=(MAPR[H-j+1][W-i+2]+1)*S[H-j][W-i]
            MAP[H-j+1][W-i+1]+=MAPR[H-j+1][W-i+1]
            MAX=max(MAX,MAP[j][i]-3,MAP[H-j+1][W-i+1]-3)
print(MAX)

Measured memory_bytes: 231432
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 5005
#define P 998244353
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
using namespace std;

int n, ans=INF, t1, t2, p[MAXN], q[MAXN];
char s[MAXN], t[MAXN];

int solve(int x)
{
    int sum=0;
    for(rint i=1; i<x; ++i) sum+=p[i];
    for(rint i=1; i<=t2; ++i, ++x)
    {
        if(x<=0) sum+=q[i];
        else if(x<=t1) sum+=abs(p[x]-q[i]);
        else sum+=n-q[i];
    }
    for(rint i=max(x, 1); i<=t1; ++i) sum+=n-p[i];
    return sum;
}

int main()
{
    scanf("%d%s%s", &n, s+1, t+1);
    for(rint i=1; i<n; ++i)
        if(s[i]!=s[i+1]) p[++t1]=i;
    for(rint i=1; i<n; ++i)
        if(t[i]!=t[i+1]) q[++t2]=i;
    if(!t1 && !t2 && s[1]!=t[1]) {printf("%d\n", n); return 0;}
    int tag=(s[1]==t[1]);
    for(rint i=-t2-1; i<=t1+1; ++i)
        if((i+INF-tag)&1) ans=min(ans, solve(i));
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>
#include <bitset>
#include <functional>
#include <iomanip>

using namespace std;
using lint = long long;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<int>;
using pii = pair<int, int>;
using pll = pair<lint, lint>;
using pqi = priority_queue<int>;
using pql = priority_queue<lint>;
#define mii = map<int, int>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define repf(i, f, n) for (int i = (f); i < (n); i++)
#define mp(x, y) make_pair((x), (y))
#define pb(x) push_back((x))
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define foreach(it, x) for (auto it = (x).begin(); it != (x).end(); it++)
#define space (char)0x20
#define yes "Yes"
#define no "No"

constexpr lint MOD = 1e9 + 7;
const double PI = acos(-1);
int A, B, C, D, E, F, G, H, I, J, K, L, M, N;
int O, P, Q, R, S, T, U, V, W, X, Y, Z;
// string s;
// int ans;
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	cin >> N;
	vi ans(N + 1, 0);
	rep(i, N - 1) {
		cin >> A;
		ans[A]++;
	}
    
	rep1(i, N) {
		cout << ans[i] << endl;
	}

    return 0;
}

Measured memory_bytes: 3992
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>

using namespace std;

int main(){

    string S;
    cin >> S;
    int ans = 0;
    for(int i = 1; i < (int)S.size(); i++){
        if(S[i - 1] != S[i]){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

        int n=gi();
        
        double sum=0;
        for (int i=0; i<n;i++) {
        	double x=gd();
        	String u = gs();
        	if (u.equals("JPY")) {
        		sum+=x;
        	} else {
        		sum+=x*380000;
        	}
        }
      
        
	    System.out.println(sum);

//        if (s>L[n-2]) {
//        	System.out.println("Yes");
//        }else {
//        	System.out.println("No");
//        }
	}


	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35832
n = int(input())
x = input()
popcnt = x.count("1")

def powmod(lst,mod):
    if not mod: return
    d = 1
    for i in range(n)[::-1]:
        d %= mod
        lst[i] = d
        d *= 2

def xmod(mod):
    if not mod: return 
    res = 0
    d = 1
    for i in range(n)[::-1]:
        d %= mod
        if int(x[i]):
            res += d
            res %= mod
        d *= 2
    return res

def solve(x):
    res = 1
    while x != 0:
        popcnt = 0
        for i in range(20):
            if x>>i & 1: popcnt += 1
        x %= popcnt
        res += 1
    return res
    
powlst0 = [0]*n
powlst1 = [0]*n
powmod(powlst0,popcnt+1)
x0 = xmod(popcnt+1)
powmod(powlst1,popcnt-1)
x1 = xmod(popcnt-1)

for i in range(n):
    if int(x[i]):
        if popcnt == 1: print(0)
        else: print(solve((x1-powlst1[i])%(popcnt-1)))
    else: print(solve((x0+powlst0[i])%(popcnt+1)))

Measured memory_bytes: 25092
def binarySearch(left, right, l1, key):
    while left < right:
        mid = int((left + right) / 2)        
        if (l1[mid] == key): 
            return True            
            break
        elif (key < l1[mid]):
            right = mid
        else:
            left = mid + 1
    return False

n = int(input())
l1 = [int(x) for x in input().split()] 
m = int(input())
l2 = [int(x) for x in input().split()] 

cnt = 0
left = 0
right = n

for key in l2: 
    if(binarySearch(left, right, l1, key) == True):
        cnt = cnt + 1

print(cnt)



Measured memory_bytes: 16892
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

ll n;

bool is753(ll a){
  vector<bool> check(9,0);
  while(a){
    int dig = a%10;
    if(dig == 3 || dig == 5 || dig == 7){
      check[dig] = 1;
    }else return 0;
    a /= 10;
  }
  return check[3]+check[5]+check[7] == 3;
}

int rec(ll a){
  if (a>n) return 0;
  return is753(a)+rec(10*a+7)+rec(10*a+5)+rec(10*a+3);
}

int main(){
  cin >>n;
  cout << rec(0) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n;
	while(cin>>n,n){
		vp a;
		vip b;
		a.pb(pii(0,1000000007));
		while(n--){
			char c;
			cin>>c;
			if(c=='R'){
				int r;cin>>r;
				bool h=false;
				rep(i,b.size())if(b[i].second.first<=r&&r<b[i].second.second){
					h=true;
					cout<<b[i].first<<endl;
				}
				if(!h)cout<<-1<<endl;
			}else if(c=='D'){
				int r;cin>>r;
				rep(i,b.size())if(b[i].first==r){
					a.pb(b[i].second);
					b.erase(b.begin()+i);
					i--;
				}
			}else{
				int s,t;
				cin>>s>>t;
				rep(i,a.size()){
					if(t==0)break;
					int r=min(t,a[i].second-a[i].first);
					b.pb(pip(s,pii(a[i].first,a[i].first+r)));
					t-=r;
					a[i].first+=r;
					if(a[i].first==a[i].second){
						a.erase(a.begin()+i);
						i--;
					}
				}
			}
			sort(all(a));
			sort(all(b));			
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1372
import copy
n = int(input())
a = list(map(int, input().split()))
a2 = copy.copy(a)
a2.sort()
x = a2[n//2 - 1]
y = a2[n//2]
for i in a:
    if i <= x:
        print(y)
    else:
        print(x)

Measured memory_bytes: 93128
#include <bits/stdc++.h>
using namespace std;
int n;
vector <string> str;
string mem[15][15];
typedef pair <string,int> P;

string con(string a,string b){
  int K=0;
  for(int i=0;i<a.size();i++){
    int j=i,k=0;
    while(a[j]&&b[k]&&a[j]==b[k]) j++,k++;
    if(!a[j]||!b[k])K=max(K,k);
  }
  return b.substr(K,b.size());
}

string solve(){
  string dp[1<<14][14];
  for(int i=0;i<n;i++) dp[1<<i][i]=str[i];
  
  for(int i=0;i<(1<<n);i++)
    for(int k=0;k<n;k++){
      if(dp[i][k]=="")continue;
      for(int j=0;j<n;j++){
	if((i&(1<<j)))continue;
	string nx=dp[i][k]+mem[k][j];
	int ni=i|1<<j;
	if(!dp[ni][j].size()||
	   nx.size()<dp[ni][j].size()||
	   (nx.size()==dp[ni][j].size()&&dp[ni][j]>nx))dp[ni][j]=nx;
      }
    }

  string res=dp[(1<<n)-1][0];
  for(int i=1;i<n;i++) {
    string a=dp[(1<<n)-1][i];
    if(res.size()>a.size()||(a.size()==res.size()&&res>a)) res=a;
  }
  return res;
}

int main(){
  
  while(cin>>n,n){
    str.resize(n);
    for(int i=0;i<n;i++)cin>>str[i];

    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
	if(i!=j&&con(str[i],str[j])==""){
	  str.erase(str.begin()+j);
	  n--;
	  i=-1;
	  break;
	}
    
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)mem[i][j]=con(str[i],str[j]);

    cout<<solve().size()<<endl;
  }

  return 0;
}

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

#define debug 0

using namespace std;
typedef long long lint;

const int maxd = 1e5+5, inf = 0x3f3f3f3f;

int i, j;
int n, w, we, val;
lint ans;
lint d[2][maxd];

int main()
{
    #if debug
    freopen("f.in", "r", stdin);
    freopen("f.out", "w", stdout);
    #endif

    cin >> n >> w;

    for(i = 1; i <= 1e5; i ++) {
        d[1][i] = inf;
    }

    for(i = 1; i <= n; i ++) {
        cin >> we >> val;
        for(j = 0; j <= 1e5; j ++) {
            d[0][j] = d[1][j];
        }
        for(j = val; j <= 1e5; j ++) {
            if(!(j - val != 0 && d[0][j - val] == inf)) {
                d[1][j] = min(d[0][j], we + d[0][j - val]);
                if(d[1][j] <= w && j > ans) {
                    ans = j;
                }
            }
        }
    }

    cout << ans << '\n';

    return 0;
}


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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

int n;
string s;

int main()
{
    scanf("%d",&n);
    cin>>s;
    if (n%2==1)
    {
        cout<<"No";
    }
    else
    {
        s="1"+s;
        for (int i=1;i<=n/2;++i)
            if (s[i]!=s[i+n/2])
            {
                cout<<"No";
                return 0;
            }
        cout<<"Yes";
    }
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = n-1; i >= 0; i--) {
    if (i != n-1) cout << " ";
    cout << a[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
int main()
{
    int n, m; cin >> n >> m;
    vector<int> a(n+1, 0);
    int k;
    rep(i, m){
        cin >> k;
        a[k] = -1;
    }
    a[0] = 1;
    if(a[1]!=-1) a[1]=1;
    FOR(i, 2, n+2){
        if(a[i]==-1) continue;
        FOR(j, 1, 3){
            a[i] += (a[i-j]==-1? 0 : a[i-j]);
        }
        a[i] %= MOD;
    }
    pr(a[n]);
    return 0;}

Measured memory_bytes: 3776
#include<stdio.h>
#include<iostream>

int N;

int main(void) {
    std::cin >> N;

    for(int i = 1;i < 10;i++) {
        if (N % i == 0 && N / i < 10) {
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }

    std::cout << "No" << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
    int ten (int i){
        int a;
        while (0<i){
           a +=i%10;
           i/=10; 
        }
        return a;
    }

 int main() {
     int n;
     cin >> n;
     int ans =  ten(n);
     if (n % ans ==0){
         cout << "Yes" << endl;
     }
     else cout << "No" << endl;     
     }



Measured memory_bytes: 256
n,k = gets.split.map(&:to_i)
arr = gets.split.map(&:to_i)
bucket = Array.new(200000){|i| i = 0}

arr.each do |a|
  bucket[a] += 1
end

sort_b = bucket.sort.reverse
p n - sort_b[0..k-1].inject(:+)

Measured memory_bytes: 19972