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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long

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

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

#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fort(i,v) for(auto i:v)
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) rep(i,sizeof(ar)/sizeof(ll)) ar[i]=val
#define fill2(ar,val) rep(i,sizeof(ar)/sizeof(ar[0])) rep(j,sizeof(ar[0])/sizeof(ll)) ar[i][j]=val
#define fill0(ar) memset(ar,0,sizeof(ar))
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define sd2(x,y) scanf("%d %d",&x,&y)
#define slld2(x,y) scanf("%lld %lld",&x,&y)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pd2(x,y) printf("%d %d\n",x,y)
#define plld2(x,y) printf("%lld %lld\n",x,y)
#define all(ar) ar.begin(), ar.end()
#define endl '\n'
#define sz(x) (int)x.size()
#define len(x) (int)x.length()

typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ii> vii;
typedef vector<ll> vi;

#define INF 1000000000000000000
#define PI 3.14159265358979323846L

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rngb(chrono::steady_clock::now().time_since_epoch().count()); // can give negative values too

void solve()
{
    string s;
    cin >> s;

    ll f[26];
    fill0(f);

    rep(i,4)
    {
        f[s[i]-'A']++;
    }

    rep(i,26)
    {
        if(f[i]!=0 && f[i]!=2)
        {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed;
    cout << setprecision(10);
    #ifdef sarthak
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ll t = 1;
    // cin >> t;
    while(t--)
    {
        solve();
    }

    #ifdef sarthak
    cerr << "Time elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
    #endif
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

static int dp[ 1000001 ];
static bool is_pm[ 1000001 ];
static int n, m;
static VI _array;

int solve( int now, int many ) {
	if ( dp[ many ] >= 0 ) {
		return dp[ many ];
	}
	if ( now == n ) {
		if ( is_pm[ many ] ) {
			return dp[many] = many;
		}
		return dp[many] = 0;
	}
	int res = 0;
	for ( int i = 0; many + _array[ now ] * i <= m; i++ ) {
		res = max( res, solve( now + 1, many + _array[ now ] * i ) );
	}
	return dp[ many ] = res;
}

int main() {
	NCLR( is_pm );
	for ( int i = 2; sq( i ) <= 1000000; i += 2 ) {
		if ( is_pm[ i ] ) {
			for ( int j = i * i; j <= 1000000; j += i ) {
				is_pm[ j ] = false;
				if ( i != 2 ) {
					j += i;
				}
			}
		}
		if ( i == 2 ) {
			--i;
		}
	}
	is_pm[ 0 ] = is_pm[ 1 ] = false;
	while ( ~scanf( "%d %d", &n, &m ) && n && m ) {
		_array.resize( n );
		for ( int i = 0; i < n; i++ ) {
			scanf( "%d", &_array[ i ] );
		}
		sort( _array.rbegin(), _array.rend() );
		_array.erase( unique( _array.begin(), _array.end() ), _array.end() );
		n = _array.size();
		NCLR( dp );
		int ans = solve( 0, 0 );
		if ( ans ) {
			printf( "%d\n", ans );
		}
		else {
			printf( "NA\n" );
		}
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    int n = s.size();
    if (n%2==1){
        cout<<"No\n";
        return 0;
    }
    rep(i,n/2){
        if (!(s[2*i]=='h' && s[2*i+1]=='i')){
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes\n";
    return 0;
}


Measured memory_bytes: 256
S = input()
N = len(S)

tmp = ''
ans = 0
i = 0
while i < N:
    s1 = S[i:i+1]
    if s1 != tmp:
        tmp = s1
        i += 1
    else:
        if i == N-1:
            break
        else:
            tmp = S[i:i+2]
            i += 2
    ans += 1
    
print(ans)    
        

Measured memory_bytes: 3500
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let c = sc.chars()[0];
    let c = (c as u8 + 1) as char;
    println!("{}", c);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
 
#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)
 
ll gcd(ll x, ll y)
{
  if (x % y == 0)
  {
    return y;
  }
  return gcd(y, x % y);
}
 
int main()
{
  ll a, b;
  cin >> a >> b;
  cout << (a-1) * (b-1) << endl;
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>

int main(int argc, char* argv[])
{
  std::string str;
  std::cin >> str;

  std::string judge = "No";
  if (str[0] == str[1] && str[1] == str[2]) {
    judge = "Yes";
  }
  if (str[1] == str[2] && str[2] == str[3]) {
    judge = "Yes";
  }

  std::cout << judge << std::endl;
  return 0;
}


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

int cnt[2][2][555];

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

    int n,u,v,m;
    cin>>n>>u>>v>>m;
    map<int,pair<int,int>> neko,usa;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            int a; cin>>a;
            usa[a]=make_pair(i,j);
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            int a;cin>>a;
            neko[a]=make_pair(i,j);
        }
    }
    int c;
    if(n==1){
        if(u>1 && v>1){
            cout<<"DRAW"<<endl;
            return 0;
        }
        int cat=0,rabi=0;
        for(int i=0;i<m;i++){
            cin>>c;
            if(usa.count(c)){
                rabi++;
            }
            if(neko.count(c)){
                cat++;
            }
            if(cat>=v && rabi>=u){
                cout<<"DRAW"<<endl;
                return 0;
            }
            if(cat>=v){
                cout<<"NEKO"<<endl;
                return 0;
            }
            if(rabi>=u){
                cout<<"USAGI"<<endl;
                return 0;
            }
        }
    }
    
    int naname[2][2]={};
    int line[2]={};
    for(int i=0;i<m;i++){
        cin>>c;
        if(usa.count(c)){
            int x=usa[c].first, y=usa[c].second;
            cnt[0][0][x]++;
            cnt[0][1][y]++;
            if(cnt[0][0][x]==n){
                line[0]++;
            } 
            if(cnt[0][1][y]==n){
                line[0]++;
            }
            if(x==y){
                naname[0][0]++;
                if(naname[0][0]==n) line[0]++;
            }
            if(x+y==n-1){
                naname[0][1]++;
                if(naname[0][1]==n) line[0]++;
            }
        }
        if(neko.count(c)){
            int x=neko[c].first, y=neko[c].second;
            cnt[1][0][x]++;
            cnt[1][1][y]++;
            if(cnt[1][0][x]==n){
                line[1]++;
            } 
            if(cnt[1][1][y]==n){
                line[1]++;
            }
            if(x==y){
                naname[1][0]++;
                if(naname[1][0]==n) line[1]++;
            }
            if(x+y==n-1){
                naname[1][1]++;
                if(naname[1][1]==n) line[1]++;
            }
        }
        //cerr<<i<<" "<<line[0]<<" "<<line[1]<<endl;
        if(line[0]>=u && line[1]>=v){
            cout<<"DRAW"<<endl;
            return 0;
        }
        if(line[0]>=u){
            cout<<"USAGI"<<endl;
            return 0;
        }
        if(line[1]>=v){
            cout<<"NEKO"<<endl;
            return 0;
        }
    }
    cout<<"DRAW"<<endl;


}


Measured memory_bytes: 21080
import heapq

n,m = map(int, input().split())

a = [-i for i in list(map(int, input().split()))]
heapq.heapify(a)

for i in range(m):
    p = heapq.heappop(a)
    p = (-p)//2
    heapq.heappush(a, -p)
    
print(-sum(a))

Measured memory_bytes: 73068
import itertools
N = int(input())
M, A, R, C, H = 0, 0, 0, 0, 0
final_ans = 0
for i in range(N):
    a = input()
    if a[0] =='M':
        M += 1
    elif a[0] =='A':
        A += 1
    elif a[0] =='R':
        R += 1
    elif a[0] =='C':
        C += 1
    elif a[0] =='H':
        H += 1

MARCH = [M, A, R, C, H]
ans = list(itertools.combinations(MARCH,3))

final_ans = 0
for i in ans:
    final_ans += i[0]*i[1]*i[2]
print(final_ans)

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

int main() {
	int k;
    cin >> k;
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[k-1] << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <map>
#include <vector>
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
using namespace std;
typedef long long ll;

int main(void) {
	int n;
	cin >> n;
	int i = n / 111;
	if (n % 111 != 0)i++;
	cout << i * 111 << endl;
	return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

const double INF=1e9;
const double eps=1e-6;

typedef pair<int,int> pi;
typedef pair<pi,int> P;

struct edge{int to,d,c;};
vector<edge> G[30];

int main()
{
    int n,m;
    while(cin >>n >>m,n)
    {
        rep(i,30) G[i].clear();

        int s,g;
        cin >>s >>g;
        --s;
        --g;

        rep(i,m)
        {
            int x,y,dist,cst;
            cin >>x >>y >>dist >>cst;
            --x;
            --y;
            G[x].pb(edge{y,dist,cst});
            G[y].pb(edge{x,dist,cst});
        }

        double t[30][31][30];
        rep(i,30)rep(j,31)rep(k,30) t[i][j][k]=INF;

        t[s][1][s]=0;

        queue<P> que;
        rep(i,G[s].size())
        {
            edge e=G[s][i];
            t[e.to][1][s]=(double)e.d;
            que.push(P(pi(e.to,1),s));
            //printf("push %d\n", e.to+1);
        }
        while(!que.empty())
        {
            P p=que.front();
            que.pop();

            pi now=p.fi;
            int par=p.se;

            //printf("now %d, speed %d, par %d\n", now.fi,now.se,par);

            rep(i,G[now.fi].size())
            {
                edge e=G[now.fi][i];
                int nx=e.to;
                if(nx==par) continue;

                for(int dv=-1; dv<=1; ++dv)
                {
                    int nv=now.se+dv;
                    if(1<=nv && nv<=e.c)
                    {
                        double add=(double)e.d/nv;
                        if(t[nx][nv][now.fi]>t[now.fi][now.se][par]+add)
                        {
                            t[nx][nv][now.fi]=t[now.fi][now.se][par]+add;
                            que.push(P(pi(nx,nv),now.fi));
                        }
                    }
                }
            }
        }

        double ans=INF;
        rep(i,n) ans=min(t[g][1][i],ans);

        if(fabs(ans-INF)<eps) printf("unreachable\n");
        else printf("%.10lf\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3568
#include <cstdio>

int main() {
  //入力
  int W,H,x,y,r;
  std::scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  
  if (0 <= x - r && 0 <= y - r && x + r <= W && y + r <= H) {
      printf("Yes\n");
  }
  else {
      printf("No\n");
  }
  return 0;
}


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

int main()
{
	int a,b,c,d,sum=0;
	cin>>a>>b>>c;
    if(a+b<=b+c)
        if(a+b<=a+c)
            cout<<a+b;
        else
            cout<<a+c;
    else
        if(b+c<=a+c)
            cout<<b+c;
        else
            cout<<a+c;
    
	return 0;
}
	

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		String s = sc.nextLine();
		String[] strArray = s.split("");
		ArrayList<Integer> a= new ArrayList<Integer>();
		ArrayList<Integer> b= new ArrayList<Integer>();

		for(int i =0; i < strArray.length; i++) {
			int n = Integer.parseInt(strArray[i]);
			if((i%2==0 && n ==0) ||  (i%2==1 && n ==1)) {
				a.add(n);
			}else {
				b.add(n);
			};
		}

		if (a.size() < b.size()) {
			System.out.println(a.size());
		}else {
			System.out.println(b.size());
		}
	}
}

Measured memory_bytes: 36616
#include <bits/stdc++.h>
using namespace std;
const int INF=2e5+5;
long long n,a[INF],ans;
signed main()
{
        cin>>n;
        for (int i=1; i<=n; i++) scanf("%lld",&a[i]);
        sort(a+1,a+1+n,greater<int>());
        ans=a[1];
        for (int i=2; i<=n/2; i++) {
                ans+=2*a[i];
        }
        if (n&1) ans+=a[(n+1)/2];
        cout<<ans<<endl;
        return 0;
}


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

#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define pii pair<int, int>
#define pb push_back
#define vec vector
#define beg begin
#define dbg(x) cerr << #x << " = " << x << endl;

template<class T> ostream& operator<<(ostream &str, vector<T> &a) {
    for (auto &i : a) {
        str << i << " ";
    }
    return str;
}

template<class T> istream& operator>>(istream &str, vector<T> &a) {
    for (auto &i : a) {
        str >> i;
    }
    return str;
}

template<class T> ostream& operator<<(ostream &str, pair<T, T> &a) {
    str << a.first << " " << a.second;
    return str;
}

template<class T> istream& operator>>(istream &str, pair<T, T> &a) {
    str >> a.first >> a.second;
    return str;
}

void solve(); signed main() {
#ifdef LOCAL
    freopen("C:\\Users\\artma\\CLionProjects\\problems\\input.txt", "r", stdin);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(6);
    solve();
    return 0;
}

const int MOD = 1e9 + 7, MAXN = 1e6 + 10, INF = 6e18 + 10, BASE = 37;

void solve() {
    int n, m, k;
    cin >> n >> m >> k;
    vec<vec<int>> p(k, vec<int>(3));
    cin >> p;

    vec<vec<int>> val(n + 1, vec<int>(m + 1));
    for (auto it : p) {
        val[it[0]][it[1]] = it[2];
    }
    vec<vec<int>> items(n + 1);
    items[0].pb(0);
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (val[i][j] != 0) {
                items[i].pb(j);
            }
        }
    }

    vec<vec<vec<int>>> dp(n + 1, vec<vec<int>>(m + 1, vec<int>(4)));
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (val[i][j] == 0) {
                dp[i][j][0] = max({dp[i][j - 1][0], dp[i - 1][j][0], dp[i - 1][j][1], dp[i - 1][j][2], dp[i - 1][j][3]});
                dp[i][j][1] = dp[i][j - 1][1];
                dp[i][j][2] = dp[i][j - 1][2];
                dp[i][j][3] = dp[i][j - 1][3];
            }
            else {
                dp[i][j][0] = max({dp[i][j - 1][0], dp[i - 1][j][0], dp[i - 1][j][1], dp[i - 1][j][2], dp[i - 1][j][3]});
                dp[i][j][1] = max({dp[i][j - 1][1], dp[i][j - 1][0] + val[i][j], dp[i - 1][j][0] + val[i][j], dp[i - 1][j][1] + val[i][j], dp[i - 1][j][2] + val[i][j], dp[i - 1][j][3] + val[i][j]});
                dp[i][j][2] = max(dp[i][j - 1][2], dp[i][j - 1][1] + val[i][j]);
                dp[i][j][3] = max(dp[i][j - 1][3], dp[i][j - 1][2] + val[i][j]);
            }
        }
    }

    cout << max({dp[n][m][0], dp[n][m][1], dp[n][m][2], dp[n][m][3]}) << endl;
}

Measured memory_bytes: 720640
gets.to_i
L = Hash.new{|h, k| h[k] = 0}
gets.chomp.split(" ").map(&:to_i).each{|a| L[a] += 1}

ans = L.select{|k, v| v >= 2}.keys.sort.reverse

if ans.size < 1 then
  puts 0
elsif L[ans[0]] >= 4 then
  puts ans[0] ** 2
elsif ans.size < 2 then
  puts 0
else
  puts ans[0] * ans[1]
end


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

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define int long long
#define pb push_back
#define pii pair<int,int>
#define ppii pair<pii,pii>
#define fr(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define ccM 1000000007
#define cfM 998244353;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int32_t main()
{   fastio;
    int s , w;
    cin>>s>>w;
    if(w>=s)cout<<"unsafe\n";
    else cout<<"safe\n";
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <vector>
#include <queue>
#define LL long long
#define N 55555
#define maxn 10005
#define INF 0x3f3f3f3f
#define mase(a,b) memset(a,b,sizeof(a))
#define MIN(a,b) (a<b?a:b)
#define MAX(a,b) (a>b?a:b)
#define DS DisputeSegement
using namespace std;
bool isPrime(int fig)
{
    int limit=(int)sqrt(fig)+1;
    for(int i=2;i<limit;i++)
    {
        if(fig%i==0)
        {
            return false;
        }

    }
    return true;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=2;i<=N;i++)
    {
        if(isPrime(i)&&(i%10)==1)
        {
            printf("%d",i);
            n--;
            printf("%c",n?' ':'\n');
            if(!n)
            {
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3804
class Dice:
    NS = [1, 5, 6, 2]
    EW = [1, 3, 6, 4]

    def question(self, top, front):
        self.setTop(top)
        sides = [self.NS[1], self.EW[1], self.NS[3], self.EW[3]]
        return sides[(sides.index(front) + 3) % 4]

    def setTop(self, n):
        if n in self.NS:
            while self.NS[0] != n:
                self.N()
        else:
            while self.NS[0] != n:
                self.E()

    def N(self):
        tail = self.NS.pop()
        self.NS.insert(0, tail)
        self.EW[0] = self.NS[0]
        self.EW[2] = self.NS[2]

    def E(self):
        tail = self.EW.pop()
        self.EW.insert(0, tail)
        self.NS[0] = self.EW[0]
        self.NS[2] = self.EW[2]


if __name__ == '__main__':
    dnum = input().split()
    for _ in range(int(input())):
        t, f = input().split()
        r = Dice().question(dnum.index(t) + 1, dnum.index(f) + 1)
        print(dnum[r - 1])



Measured memory_bytes: 5612
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
    	cin >> a[i];
    int ret = 0;
    for (int i = 0; i < n; i += 2)
    	ret += a[i] & 1;
    cout << ret << endl;
}

Measured memory_bytes: 3592
N = int(input())
s = []
for i in range(N):
    s.append(str(input()))

M = int(input())
t = []
for i in range(M):
    t.append(str(input()))
ans = 0
for i in s:
    x = s.count(i)
    y = t.count(i)
    if x - y > ans:
        ans = x - y

print(ans)


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node{int p,l,r;};
Node T[MAX];
int n,D[MAX];

void print(int u){
    int i,c;
    cout << "node "<<u<<": ";
    cout << "parent = "<<T[u].p<<", ";
    cout << "depth = "<<D[u]<<", ";
    if(T[u].p==NIL){
        cout<<"root, ";
    }
    else if(T[u].l==NIL){
        cout<<"leaf, ";
    }
    else{
        cout<<"internal node, ";
    }
    cout<<"[";
    
    for(i=0,c=T[u].l; c!=NIL; i++,c=T[c].r){
        if(i){
            cout<<", ";
        }
        cout<<c;
    }
    cout<<"]"<<endl;
}


int rec(int u,int p){
    D[u]=p;
    if(T[u].r!=NIL){
        rec(T[u].r,p);
    }
    if(T[u].l!=NIL){
        rec(T[u].l,p+1);
    }
}

int main(){
    int i,j,d,v,c,l,r;
    cin>>n;
    for(i=0;i<n;i++){
        T[i].p=T[i].l=T[i].r=NIL;
    }
    for(i=0;i<n;i++){
        cin>>v>>d;
        for(j=0;j<d;j++){
            cin>>c;
            if(j==0){
                T[v].l=c;
            }
            else{
                T[l].r=c;
            }
            l=c;
            T[c].p=v;
        }
    }
    for(i=0;i<n;i++){
        if(T[i].p==NIL){
            r=i;
        }
    }
    rec(r,0);
    for(i=0;i<n;i++){
        print(i);
    }
    return 0;
}


Measured memory_bytes: 7784
#include <stdio.h>
#define MAX 100005
#define NIL -1

typedef struct{int p,l,r;}Node;
Node T[MAX];
int n,D[MAX];

void print(int);
void rec(int,int);

int main(){
    int i,j,d,v,c,l,r;        
    scanf("%d",&n);
    for(i=0;i<n;i++) T[i].p=T[i].l=T[i].r=NIL;

    for(i=0;i<n;i++){
        scanf("%d%d",&v,&d);
        for(j=0;j<d;j++){
            scanf("%d",&c);
            if(j==0) T[v].l=c;
            else T[l].r=c;
            l=c;
            T[c].p=v;
        }
    }
    for(i=0;i<n;i++){
    if(T[i].p==NIL) r=i;
    }
    rec(r,0);

    for(i=0;i<n;i++) print(i);

    return 0;

}

void print(int u){
    int i,c;
    printf("node %d: ",u);
    printf("parent = %d, ",T[u].p);
    printf("depth = %d, ",D[u]);

    if(T[u].p==NIL) printf("root, ");
    else if(T[u].l==NIL)printf("leaf, ");
    else printf("internal node, ");

    printf("[");

    for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
        if(i) printf(", ");
        printf("%d",c);
    }
    printf("]\n");
}

void rec(int u,int p){
    D[u]=p;
    if(T[u].r!=NIL) rec(T[u].r,p);
    if(T[u].l!=NIL) rec(T[u].l,p+1);
}


Measured memory_bytes: 6376
from collections import defaultdict
d = defaultdict(list)
X,Y,Z,K = map(int,input().split(' '))
A = sorted(list(map(int,input().split(' '))),reverse=True)
B = sorted(list(map(int,input().split(' '))),reverse=True)
C = sorted(list(map(int,input().split(' '))),reverse=True)

AN = min(K+1,len(A))
BN = min(K+1,len(B))
CN = min(K+1,len(C))
AD =  [A[i]-A[i+1] for i in range(AN-1)]
BD =  [B[i]-B[i+1] for i in range(BN-1)]
CD =  [C[i]-C[i+1] for i in range(CN-1)]

d[0].append([0,0,0])

m = A[0]+B[0]+C[0]
cnt = 0
off = []
while(True):
	if not d:
		exit()
	r = min(d)
	for ind in d[r][:]:
		off.append(ind)
		print(m-r)
		cnt = cnt + 1
		if cnt >= K:
			exit()
		ia,ib,ic = ind
		if ia < AN-1:
			add = [ia+1,ib,ic]
			if not add in off:
				off.append(add)
				d[r+AD[ia]].append(add)
		if ib < BN-1:
			add = [ia,ib+1,ic]
			if not add in off:
				off.append(add)
				d[r+BD[ib]].append(add)
		if ic < CN-1:
			add = [ia,ib,ic+1]
			if not add in off:
				off.append(add)
				d[r+CD[ic]].append(add)
		d[r].remove(ind)
	if not d[r]:
		del d[r]





Measured memory_bytes: 5228
#!/usr/bin/env python
# coding: utf-8

# In[3]:


b = str(input())


# In[4]:


if b == "A":
    print("T")
elif b == "C":
    print("G")
elif b == "G":
    print("C")
elif b == "T":
    print("A")
else:
    print("error")


# In[ ]:






Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

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

    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;

    int c1 = h1*60+m1,c2 = h2 * 60 + m2;
    cout<<c2 - c1 - k<<endl;


    return 0;
}


Measured memory_bytes: 3656
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <math.h>
#include <iomanip>
#include <queue>
#include <map>
#include <list>
#include <set>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define MAX 50
#define LARGENUM 1000000007
#define INF 9223372036854775807
#define ull unsigned long long 
typedef pair <int, int> P;

int main(){
    string S, T;
    int ans = 0;
    cin >> S >> T;
    rep(i, S.length()){
        if (S[i] != T[i]) ans ++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3472
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
while(1){
	int n;
	cin>>n;
	if(n==0)break;
	vector<vector<int> > dp(n+2,vector<int>(n+2,0) );
	vector<vector<bool> > used(n+2,vector<bool>(n+2,false) );
	for(int i=1;i<=n;i++)
	    for(int j=1;j<=n;j++){
		char tmp;
		cin>>tmp;
		if(tmp=='.'){
			used[i][j] = true;
		}
	    }

	int res = 0;
	for(int i=1;i<=n;i++)
	    for(int j=1;j<=n;j++){
		if(used[i][j]){
			dp[i][j] = min(dp[i-1][j-1], min( dp[i][j-1], dp[i-1][j] ) ) + 1;
			res = max(res,dp[i][j]);
		}
	    }
	cout<<res<<endl;


}
	return 0;
}



Measured memory_bytes: 7152
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 

using namespace __gnu_pbds;
using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll i = 0; i < n; i++)
#define FORN(i, a, b) for (ll i = a; i < b; i++)
#define FORE(i, l) for (auto i : l)

#define pb push_back
#define pob pop_back
#define emp emplace
#define fi first
#define se second

#define all(n) n.begin(), n.end()
#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

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

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);	
    //cout << setprecision(15);
    ll n, k;
    cin >> n >> k;
    cout << min(abs(n % k - k), n % k) << '\n';
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double LD;
template <typename tn> void read(tn &a){
	tn x = 0, f = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
	a = x * f;
}

const int mod = 998244353;
int Mod(int x){ return x >= mod ? x - mod : x; }
int dMod(int x){ return x < 0 ? x + mod : x; }
int cMod(int x){ return dMod(Mod(x)); }
int mul(int x, int y){ return (LL) x * y % mod; }
template <typename tn> void Inc(tn &x, int y){ x = Mod(x + y); }
template <typename tn> void Dec(tn &x, int y){ x = dMod(x - y); }
template <typename tn> void Tim(tn &x, int y){ x = mul(x, y); }
int qpow(LL x, LL y){
	LL ret = 1;
	for (LL s = x % mod; y; y >>= 1, s = s * s % mod)
		if (y & 1) ret = ret * s % mod;
	return ret;
}
int inv(LL x){ return qpow(x, mod - 2); }

const int Maxn = 1000500, N = 1000010;

int miu[Maxn], prm[Maxn], minp[Maxn];
int f[Maxn], g[Maxn], F[Maxn];
int n, cprm, Ans;

void init(){
	miu[1] = 1;
	for (int i = 2; i <= N; i++){
		if (!minp[i]) prm[++cprm] = i, miu[i] = -1;
		for (int j = 1, p; j <= cprm && i * prm[j] <= N; j++){
			minp[p = i * prm[j]] = prm[j];
			if (i % prm[j]) miu[p] = -miu[i];
			else { miu[p] = 0; break; }
		}
	}
	for (int i = 1; i <= N; i++)
		miu[i] = cMod(miu[i]);
	for (int i = 1; i <= N; i++)
	for (int j = 1; j <= N / i; j++)
		Inc(g[i * j], mul(i, miu[i]));
	for (int i = 1; i <= N; i++)
	for (int j = 1; j <= N / i; j++)
		Inc(F[i], mul(f[i * j], j));
}

int main(){
	read(n);
	for (int i = 1, x; i <= n; i++)
		read(x), f[x]++, Dec(Ans, x);
	init();
	for (int i = 1; i <= N; i++)
		Inc(Ans, mul(mul(g[i], i), mul(F[i], F[i])));
	Tim(Ans, inv(2));
	cout << Ans << '\n';
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    ll sum=0;
    rep(i,m){
        int a; cin>>a;
        sum+=a;
    }
    if (sum>n){
        cout<<"-1\n";
    }else{
        cout<<n-sum<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='?'){
      cout<<'D';
    }else{
      cout<<s[i];
    }
  }
  cout<<endl;
}

Measured memory_bytes: 3716
#include<stdio.h>

int main(){
	int x,y;
	scanf("%d %d",&x,&y);
	if(x==y){
		printf("Draw");
	}else if((x==1&&y!=1) or (x!=1&&y!=1&&y<x)){
		printf("Alice");
	}else {
		printf("Bob");
	}
	return 0;
}

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

using namespace std;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVC vector<vector<char>>
typedef long long ll;
const int  INF = 2147483647;
const ll INFL = 1LL << 50;
const ll mod = 1000000007;




int main() {
	int n;
	cin >> n;
	VI v(n);
	REP(i, n)cin >> v[i];
	int a = 0;
	REP(i, n)a = max(a, v[i]);
	cout << a << ' ';
	int b = 0;
	REP(i, n) {
		if (abs(a - b * 2) > abs(a - v[i] * 2)) {
			b = v[i];
		}
	}
	cout << b << endl;
	return 0;
}

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

using namespace std;

char a[6];

int bit(int x, int i) { return (x >> i) & 1; }

void print(int bm) {
	cout << int(a[0]);
	for(int j = 0; j < 3; j++) {
		if (bit(bm, j)) cout << '+'; else cout << '-';
		cout << int(a[j + 1]);
	}
	cout << "=7";
}

int main() {
	ios::sync_with_stdio(false); cin.tie(NULL);
	for(int i = 0; i < 4; i++) cin >> a[i], a[i] -= '0';

	for(int i = 0; i < 8; i++) {
		int s = a[0];
		for(int j = 0; j < 3; j++) 
			if (bit(i, j)) s += a[j + 1]; else s -= a[j + 1];
		if (s == 7) {
			print(i);
			return 0;
		}
	}
}


Measured memory_bytes: 256
num = int(input())
bunsyo = input()
count = 0

for i in range(len(bunsyo)):
  if i+2 > num-1:
    continue
  if bunsyo[i] == 'A':
    if bunsyo[i+1] =='B':
      if bunsyo[i+2] == 'C':
        count = count + 1
print(count)

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

void Main()
{
    int x;
    cin >> x;
    auto ans = x>=30 ? "Yes" : "No";
    cout << ans << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


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

int main() {
  int h, w;
  cin >> h >> w;
  string s[h];

  for (int k = 0; k < h; k++) {
    cin >> s[k];
  }

  for (int k = 0; k < h; k++) {
    for (int l = 0; l < w; l++) {
      if (s[k][l] == '.') {
        int count = 0;
        for (int m = -1; m < 2; m++) {
          for (int n = -1; n < 2; n++) {
            if (k + m >= 0 && k + m <= h &&
                l + n >= 0 && l + n <= w &&
                s[k + m][l + n] == '#') count++;
            s[k][l] = '0' + count;
          }
        }
      }
      cout << s[k][l];
    }
    cout << endl;
  }


  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
string s;
int ans;
int main()
{
	int now=0,last=0;
	cin>>s;
	while(now<s.size()){
		if(now-last==0){
			if(s[now]!=s[now+1]){
				ans++;now++,last++;continue;
			}
			if(s[now]==s[now+1]){
				ans++;now+=2;last++;continue;
			}
		}
		else  ans++,now++,last=now;
	}
	printf("%d",ans);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
static const int MAX=(ll) 1e5;

int N;
ll A[MAX +2],B[MAX +2],cunt;

int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i] >> B[i];
    for(int i=N-1;i>=0;i--){
        if(!((A[i]+cunt) % B[i])) continue;
        cunt += ((A[i]+cunt) / B[i] + 1ll) * B[i] - (A[i] + cunt);
    }
    cout << cunt <<"\n";
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int now=0;
  
  while(a>=b){
    b*=2;
    now++;
  }
  while(b>=c){
    c*=2;
    now++;
  }
  
  Ans(now<=k);
}



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

#define int long long
#define form2(i, a, b) for (int i = (a); i < (b); ++i)
#define ford2(i, a, b) for (int i = (a-1); i >= (b); --i)
#define form(i, n) form2(i, 0, n)
#define ford(i, n) ford2(i, n, 0)

#define chmax(x, v) x = max(x, (v))
#define chmin(x, v) x = min(x, (v))
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define vsz(v) (int)(v.size())

const long long BIG = 1000000000000000000LL;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

void solve();
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	return 0;
}

int nbProb, nbJuges, nbIncr, nbPris;
vector<int> prob;

bool peutPrendre(int indProtege)
{
	vector<int> cc = prob;
	int rst = nbPris-1;
	int lsInc = -1;
	form(i, nbProb) if (rst > 0) {
		if (i != indProtege) {
			cc[i] = BIG;
			lsInc = i;
			--rst;
		}
	}
	int resteIncr = nbIncr - nbPris;
	priority_queue<int> dispo;
	int finalProt = prob[indProtege] + nbJuges;
	if (lsInc+1 < nbProb && lsInc+1 != indProtege && prob[lsInc+1] > finalProt) return false;
	if (resteIncr <= 0) return true;

	int score = 0;
	form(i, nbProb) if (i != indProtege && cc[i] < finalProt) {
		score += min(nbJuges, finalProt - cc[i]);
	}

	return score >= nbJuges*resteIncr;
}

void solve()
{
	cin >> nbProb >> nbJuges >> nbIncr >> nbPris;
	prob.resize(nbProb);
	form(i, nbProb) cin >> prob[i];
	sort(all(prob));
	reverse(all(prob));
	int lo = nbPris-1, ri = nbProb-1;
	while (lo < ri) {
		int mid = (lo+ri+1)/2;
		if (peutPrendre(mid)) lo = mid;
		else ri = mid-1;
	}
	cout << lo+1 << "\n";
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;


int main()
{
	int l,r,min=2020;
	
	cin >> l >> r;
	
	int v[2020];
	int a;
	
	if(r-l+1 > 2018) a = 2019;
	else a = (r-l+1)%2019;
	
	for(int i=0;i<a;i++){
		v[i] = (l%2019)+i;
	}
	
	for(int i=0;i<a-1;i++){
		for(int j=i+1;j<a;j++){
			if(min > ((v[i]*v[j])%2019) ) min = (v[i]*v[j])%2019;
		}
	}
	
	cout << min << endl;
	
	
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll A, B, H, M; cin >> A >> B >> H >> M;
    double h = 0.5 * M_PI - 2 * M_PI * (H + M / (double)60) / (double)12;
    double h_x = A * cos(h);
    double h_y = A * sin(h);

    double m = 0.5 * M_PI - 2 * M_PI * M / (double)60;
    double m_x = B * cos(m);
    double m_y = B * sin(m);

    cout << sqrt((m_x - h_x) * (m_x - h_x) + (m_y - h_y) * (m_y - h_y)) << endl;
}

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


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

int main() {

  int N, K, x;
  cin >> N;
  cin >> K;
  
  int d = 0;
  
  for (int i = 0; i < N; i++) {
    cin >> x;
    if (2 * abs(x) < 2 * abs(K - x)) {
   	  d += 2* x;  
    }
    else {
      d += 2 * abs(K - x);
    }
  }
  
  cout << d << endl;
  
}


Measured memory_bytes: 256
import math

def factorize(p):
    while p % 2 == 0:
        p //= 2
        yield 2

    r = 3
    while r < int(math.sqrt(p)+1):
        if p % r == 0:
            p //= r
            yield r
        else:
            r += 2

    if p != 1:
        yield p

n = int(input())
l = factorize(n)

print(str(n)+":",*list(l))

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

int main() {
  int A, B;
  cin >> A >> B;
  
  int sum = 0;
  for (int i = A; i <= B; i++) {
    string rev = to_string(i);
    reverse(rev.begin(), rev.end());
    
    string org = to_string(i);
    if (org == rev) {
      sum++;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main( ) {
    //freopen("B.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin >> s >> t;
    int ans=0;
    rep(i, 0, sz(s)){
        if(s[i]!=t[i]){
            ans++;
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 3884
import sys
import numpy as np

input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


def main():
    # np.set_printoptions(threshold=np.inf)
    N = pow(10, 5)
    is_prime = np.ones(N, dtype=bool)
    is_prime[:2] = False
    max = int(np.sqrt(N))
    for j in range(2, max + 1):
        if (is_prime[j]):
            is_prime[j*j::j] = False
    like_2017 = np.ones(N, dtype=bool)
    like_2017[:2] = False
    for i in range(2, N):
        if (i % 2 == 0):
            like_2017[i] = False
            continue
        if (not is_prime[i]):
            like_2017[i] = False
            continue
        if (not is_prime[(i + 1) // 2]):
            like_2017[i] = False
            continue

    cumsum = np.cumsum(like_2017)
    q = int(input())
    for _ in range(q):
        l, r = map(int, input().rstrip().split())
        print(cumsum[r] - cumsum[l - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 28488
input = STDIN
n = input.gets.to_i
numbers = input.gets.split(' ').map(&:to_i)
if numbers.any?(&:zero?)
  puts 0
else
  result = 1
  numbers.each do |i|
    result *= i
    if result > 1_000_000_000_000_000_000
      result = -1
      break
    end
  end
  puts result
end


Measured memory_bytes: 21712
#B
N, K=map(int,input().split())
d=[]
A=[]
for i in range(K):
    di=int(input())
    Ai=list(map(int,input().split()))
    d.append(di)
    A.append(Ai)
A_all=[]
for i in A:
    for j in i:
        A_all.append(j)
A_set=list(set(A_all))
print(N-len(A_set))

Measured memory_bytes: 9116
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int         long long
#define mod         1000000007
#define FAST        ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n)      for(int i=0;i<n;i++)
#define fp(i,k,n)   for(int i=k;i<=n;i++)
#define fr(i,k,n)   for(int i=k;i>=n;i--)
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define dbg(x)      cout << (#x) << " is " << (x) << '\n' 
#define F           first
#define S           second
#define sz(x)       (int)(x).size()
#define lb          lower_bound
#define ub          upper_bound
#define all(a)      a.begin(),a.end()
#define getc getchar_unlocked
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
/*---------------------------------------------------------------------------------------------------*/

void solve()
{
  int x,n;
  cin >> x >> n;
  map<int,int> m;
  f(i,n)
  {
      int y;
      cin >> y;
      m[y]=1;
  }
  int ans=101;
  fp(i,x,101)
  {
      if(m[i]==0)
      {
          ans=i;break;
      }
  }
  fr(i,x,0)
  {
      if(m[i]==0)
      {
          if((x-i)<=(ans-x))
            ans=i;
          break;
      }
  }
  cout << ans << '\n';
  return;
} 

signed main()
{
  FAST
  int T=1;
  // cin >> T;
  while(T--)
  {
    solve();
  }
  return 0;
}


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

#define llint long long int
#define pb push_back

using namespace std;

int main(){
  int n;
  cin >> n;
  int i = 0;
  for(; ; i++){
    int temp = n/pow(10, i);
    if(temp == 0)
      break;
  }
  i--;
  int temp = n/pow(10, i);
  int num = 0;
  for(int j = 0; j <= i; j++)
    num += temp*pow(10, j);
  if(num >= n)
  	cout << num;
  else{
  	temp++;
    num = 0;
    for(int j = 0; j <= i; j++)
    num += temp*pow(10, j);
    cout << num;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int ret = 0;
  for( int i=1; i<s.size(); i++ ){
    if( s[i] != s[i-1] ) ret++;
  }
  cout << ret << endl;
}

Measured memory_bytes: 512