akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct event{
  ll time, type, x;
  bool operator>(const event& a){
    return time>a.time;
  }
  bool operator<(const event& a){
    return time<a.time;
  }
  bool operator>=(const event& a){
    return time>=a.time;
  }
  bool operator<=(const event& a){
    return time<=a.time;
  }
  bool operator>(const event& a)const {
    return time>a.time;
  }
  bool operator<(const event& a)const {
    return time<a.time;
  }
};

/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, Q;
  cin >> N >> Q;
  
  llvec S(N);
  llvec T(N);
  llvec X(N);
  llvec D(Q);
  priority_queue<event, vector<event>, greater<event>> evs;
  rep(i, N){
    cin >> S[i] >> T[i] >> X[i];
    evs.push({S[i]-X[i], 1, X[i]});
    evs.push({T[i]-X[i], -1, X[i]});
  }
  rep(i, Q)cin >> D[i];
  //sort(ALL(evs));

  multiset<ll> s;
  rep(i, Q){
    while(evs.top().time <= D[i] and evs.size()>0){
      event e = evs.top();evs.pop();
      //cout << e.time << " " << e.type << " " << e.x << endl;
      if(e.type==1){
        s.insert(e.x);
      }else{
        s.erase(s.find(e.x));
      }
    }

    if(s.empty()){
      cout << -1 << endl;
    }else{
      /*for(auto is: s){
        cout << is << " ";
        }*/
      cout << *s.begin() << endl;
    }
    
  }
  
  /*
  llvec ans(Q, 1e12);
  rep(i, N){
    ll ib =(ll)( lower_bound(ALL(D), S[i]-X[i]) - D.begin());
    ll ie =(ll)( upper_bound(ALL(D), T[i]-1-X[i]) - D.begin());
    for(ll j=ib;j<ie;j++){
      ans[j]=min(X[i], ans[j]);
    }
  }
  rep(i, Q){
    if(ans[i]==1e12)ans[i]=-1;
    cout << ans[i] << endl;
  }
  */
  return 0;
}


Measured memory_bytes: 28008
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  string s,t;
  cin>>s>>t;
  Int n=s.size();
  for(Int i=0;i<n;i++){
    if(s==t){
      cout<<"Yes"<<endl;
      return 0;
    }
    s.insert(s.begin(),char(s[n-1]));
    s.pop_back();
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
	    int S = sc.nextInt();
	    int W = sc.nextInt();
	    if(S>W) {
	    	System.out.println("safe");
	    }else {
	    	System.out.println("unsafe");
	    }
	}
}


Measured memory_bytes: 35756
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);

const LL mod = 998244353;

char s[10];

int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif

  scanf("%s", s);
  if (s[0] >= 'a' && s[0] <= 'z') {
    printf("a\n");
  } else {
    printf("A\n");
  }


#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

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

using namespace std;
const int N = 1e5+7;

int a[N],b[N],c[N];
int dp[N][3];


int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i]>>b[i]>>c[i];
	for(int i=1;i<=n;i++){
		dp[i][0] = max(dp[i-1][1]+b[i],dp[i-1][2]+c[i]);
		dp[i][1] = max(dp[i-1][0]+a[i],dp[i-1][2]+c[i]);
		dp[i][2] = max(dp[i-1][0]+a[i],dp[i-1][1]+b[i]);
	}
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
	return 0;
} 

Measured memory_bytes: 5964
fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let s: Vec<char> = iter.next().unwrap().chars().collect();
    let t: Vec<char> = iter.next().unwrap().chars().collect();

    println!("{}", if calc(&s, &t) && calc(&t, &s) {"Yes"} else {"No"});
}

fn calc(s: &[char], t: &[char]) -> bool {
    let mut map = std::collections::HashMap::new();
    let mut yes = true;
    for i in 0..s.len() {
        let copt = map.get(&s[i]).cloned();
        match copt {
            Some(&c) if c == t[i] => (),
            Some(_) => {
                yes = false;
                break;
            },
            None => {map.insert(s[i], &t[i]);}
        }
    }
    yes
}

Measured memory_bytes: 6396
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N, K = iim()
    A = list(iim())

    d1 = 0
    for i in range(K-1):
        d2 = A[i+1] - A[i]
        d1 = max(d1, d2)
    d1 = max(d1, N-A[-1]+A[0])
    print(N-d1)


if __name__ == "__main__":
    resolve()


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

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

int main(){
  int n;
  int par[100],left[100],right[100],p[100],q[100],r[100],b[100];
  bool use[100];

  while(cin >> n && n){
    for(int i=0;i<n;i++)par[i] = -1;
    for(int i=0;i<n;i++){
      cin >> p[i] >> q[i] >> r[i] >> b[i];
      int tmp = gcd(p[i],q[i]);
      p[i]/=tmp;
      q[i]/=tmp;
      if(r[i]){
	left[i] = 0;
	par[r[i]-1] = i;
      }else left[i] = 1;
      if(b[i]){
	right[i] = 0;
	par[b[i]-1] = i;
      }else right[i] = 1;
      use[i] = false;
    }

    int ans;
    for(int j=0;j<n;j++){
      for(int i=0;i<n;i++){
	if(!use[i] && left[i] && right[i]){
	  int x = 1;
	  while( (p[i]*x)%right[i] || (q[i]*x)%left[i])x++;
	  right[i] = p[i]*x;
	  left[i] = q[i]*x;
	  ans = right[i] + left[i];
	  //cout << left[i] << " " << right[i] << endl;
	  if(0<=par[i]){
	    if(r[par[i]]==i+1)left[par[i]] = ans;
	    else right[par[i]] = ans;
	  }
	  use[i] = true;
	  break;
	}
      }
    }
    for(int i=0;i<n;i++)
      if(par[i]<0)cout << right[i]+left[i] << endl;
  }
}

Measured memory_bytes: 868
mod = 1000000007
n,m = map(int,input().split())

a = []
for _ in range(m):
    tmp = int(input())
    a.append(tmp)
a = set(a)

dp = [0] * (10**5 + 7)
dp[0] = 1

for i in range(1,n+1):
    if i in a:
        continue
    dp[i] = dp[i-1]
    if i > 1:
        dp[i] = (dp[i-1] + dp[i-2])%mod

print(dp[n]%mod)

Measured memory_bytes: 13216
import math
k = int(input())
a = list(map(int,input().split()))
ar = list(reversed(a))
syou = 0
for i in ar:
  if syou > i:
    l = math.ceil(syou/i)
    syou = l * i
  else:
    syou = i
dai = 0
for i in ar:
  if dai > i:
    l = math.ceil(dai/i)
    if dai == l * i:
      dai = l* i + i -1
    else:
      dai = max(l * i -1,dai)
  else:
    dai = i + i -1
kaku = syou + 0
for i in a:
  kaku = (kaku//i) *i
if kaku ==2:
  print(syou,dai)
else:
  print(-1)

Measured memory_bytes: 15020
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
int n, a, b, c;
int main(){
	scanf("%d", &n);
	for(Rint i = 1;i <= n;i ++){
		int x; scanf("%d", &x);
		if((x & 3) == 0) ++ c;
		else if((x & 3) == 2) ++ b;
		else ++ a;
	}
	puts((a <= c || a == c + 1 && !b) ? "Yes" : "No");
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	static boolean A[];
	
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt(),D[]=new int[n],max=0,cnt=0;
		
		for(int i=0;i<n;i++) {
			D[i]=Integer.parseInt(in.next());
			if(D[i]>max)max=D[i];
		}
		sieve(max);
		for(int i=0;i<D.length;i++) {
			if(!A[D[i]])cnt++;
		}
		System.out.println(cnt);
	}
		
	static void sieve(int n) {
		A=new boolean[n+1];
		for(int i=2;i<Math.sqrt(A.length);i++) {
			if(!A[i]) {
				int p=i,s=p*2;
				for(int j=s;j<A.length;j+=p)A[j]=true;
			}
		}
	}

}


Measured memory_bytes: 139240
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    for (;;) {
        int b; cin >> b;
        if (b == 0) break;
        b *= 2;
        int len, start;
        for (int i = 1; i * i < b; ++i) {
            if (b % i != 0) continue;
            int l = b / i - (i + 1);
            if (l % 2 == 0) {
                len = i;
                start = l / 2 + 1;
            }
        }
        cout << start << " " << len << endl;
    }

    return 0;

}



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

int main(){
  int S, W;
  cin >> S >> W;
  if (W >= S) cout << "unsafe" << endl;
  else cout << "safe" << endl;
}


Measured memory_bytes: 3584
/*  -*- coding: utf-8 -*-
 *
 * b.cc: D: 連結 / Connectivity
 */

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

/* constant */

const int MAX_N = 200000;

/* typedef */

typedef pair<int,int> pii;
typedef map<pii,int> mpii;

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

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

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

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

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

/* global variables */

UFT uft0, uft1;
mpii cs;

/* subroutines */

/* main */

int main() {
  int n, k, l;
  cin >> n >> k >> l;

  uft0.clear(n);
  uft1.clear(n);

  for (int i = 0; i < k; i++) {
    int ai, bi;
    cin >> ai >> bi;
    ai--, bi--;
    if (! uft0.same(ai, bi)) uft0.merge(ai, bi);
  }
  for (int i = 0; i < l; i++) {
    int ai, bi;
    cin >> ai >> bi;
    ai--, bi--;
    if (! uft1.same(ai, bi)) uft1.merge(ai, bi);
  }

  for (int i = 0; i < n; i++) {
    int r0 = uft0.root(i);
    int r1 = uft1.root(i);
    cs[pii(r0, r1)]++;
  }

  for (int i = 0; i < n; i++) {
    if (i) putchar(' ');
    int r0 = uft0.root(i);
    int r1 = uft1.root(i);
    printf("%d", cs[pii(r0, r1)]);
  }
  putchar('\n');

  return 0;
}


Measured memory_bytes: 16640
#include <stdio.h>

int main ()
{	
	int r,s,t;
	
	scanf("%d %d %d", &r, &s, &t);
	
	if(r + s + t >= 22)
{
	printf("bust\n");
}	
	else if(r + s + t < 22)
{
	printf("win\n");
}
	return 0;
}	

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
typedef __int128 ll;
long long inf=1e18;
void print(ll ans)
{
    if(ans>9) print(ans/10);
    putchar(ans%10+'0');
}
int main()
{
    int n;scanf("%d",&n);
    ll ans=1;
    bool flag=false;
    while(n--)
    {
        long long x;scanf("%lld",&x);
        if(x==0)
        {
            printf("0\n");return 0;
        }
        ans=ans*x;
        if(ans>inf) flag=true;
    }
    if(flag) printf("-1\n");
    else print(ans);
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { cout << p.first << ' ' << p.second; return os; }

void solve() {
  int N; cin >> N;
  unordered_map<int, int> ma;
  rep(i, N) {
    int a; cin >> a;
    ma[a]++;
  }
  
  pqdesc<int> q;
  each(m, ma) q.push(m.second);
  while (true) {
    auto v = q.top();
    if (v == 1) break;
    q.pop();
    if (v == 2) {
      auto u = q.top(); q.pop();
      v--, u--;
      if (v > 0) q.push(v);
      if (u > 0) q.push(u);
    } else if (v >= 3) {
      v -= 2, q.push(v);
    }
  }
  cout << q.size() << '\n';
}


Measured memory_bytes: 5284
#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<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define all(x) x.begin(),x.end()
#define nl      '\n'
typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
	faster
	ll n;
	cin>>n;
	ll ans=(n-1)*2-1;
	int i;
	for(i=2;i<=sqrt(n);i++)
	{
		ll div;
		div=n/i;
		if(div>=i)
		{
			//cout<<i<<" "<<div<<" "<<ans<<nl;
			if(n%i==0)
			{
				ans+=(div-i)*2-1;
				if(div==i)ans++;
			}
			else ans+=(div+1-i)*2-1;
		}
	}
	cout<<ans<<nl;
	return 0;
}

Measured memory_bytes: 3692
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math

#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
n = I()
X = readInts()
nya = sorted(X)
m1 = nya[n//2-1]
m2 = nya[n//2]
for x in X:
    if x <= m1:
        print(m2)
    else:
        print(m1)


Measured memory_bytes: 33348
#include<bits/stdc++.h>
using namespace std;
int a[100000+5];
int main()
{
    int n,k,m,ans=0;
    scanf("%d%d",&n,&k);
    int t;
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&a[i]);
    }
    if(n==k)
        printf("1\n");
    else
    {
        t=1;
        for(int i=t; i<n;)
        {
            i+=k-1;
            ans++;
        }
        for(int i=t; i>1;)
        {
            i-=k-1;
            ans++;
        }
        printf("%d\n",ans);
    }
}


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

using namespace std;

using ll = long long;

int main (void) {
  int n;
  cin >> n;
  cin.ignore();
  int a[n];
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a, a + n);
  ll asum = 0;
  ll bsum = 0;
  bool sw = false;
  for (int i = 0; i < n; i++){
    if(sw==false){
      asum += a[n-1-i];
      sw = true;
    }else {
      bsum += a[n-1-i];
      sw = false;
    }
  }
  ll result;
  result = asum - bsum;
  cout << result << endl;
  return 0;
}


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

string toUpper(string x){
    string y = x;
    for(int i=0;i<x.size();i++){
        y[i] = toupper(x[i]);
    }
    return y;
}

int main(){
    int cnt=0;
    string word,word2;
    cin >> word;
    word = toUpper(word);
    cin >> word2;
    while(1){
        if(word2=="END_OF_TEXT") break;
        word2 = toUpper(word2);
        if(word==word2) cnt++;
        cin >> word2;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3216
from collections import Counter
from itertools import product


def solve(N):
    sum = 0
    for k in range(1, 10):
        for i in product('357', repeat=k):
            d = int("".join(list(i)))
            c = Counter(i)
            if '3' in c and '5' in c and '7' in c and len(c) == 3 and d <= N:
                sum += 1
    return sum


if __name__ == "__main__":
    print(solve(int(input())))


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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; }

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

  rep(i,k) {
    if (s[i] != '1') {
      cout << s[i] << endl;
      return 0;
    }
  }

  cout << '1' << endl;
  return 0;
}

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

using namespace std;

const int N = 3005;

int n, m, dp[N][N], trace[N][N];
string s, t;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s >> t; n = s.length(); m = t.length();
    memset(dp, -0x3f, sizeof dp);
    for (int i = 0; i <= n; i++) dp[i][0] = 0;
    for (int i = 0; i <= m; i++) dp[0][i] = 0;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            if (dp[i][j] > -1e9) {
                if (dp[i + 1][j] < dp[i][j]) {
                    dp[i + 1][j] = dp[i][j];
                    trace[i + 1][j] = 0;
                }
                if (dp[i][j + 1] < dp[i][j]) {
                    dp[i][j + 1] = dp[i][j];
                    trace[i][j + 1] = 1;
                }
                if (i < n && j < m && s[i] == t[j]) {
                    if (dp[i + 1][j + 1] < dp[i][j] + 1) {
                        dp[i + 1][j + 1] = dp[i][j] + 1;
                        trace[i + 1][j + 1] = 2;
                    }
                }
            }
        }
    }
    
    stack <char> st;
    int pt1 = n, pt2 = m;
    while (pt1 && pt2) {
        if (trace[pt1][pt2] == 2) st.push(s[pt1 - 1]), pt1--, pt2--;
        else if (trace[pt1][pt2] == 1) pt2--;
        else pt1--;
        
    }
    
    while (!st.empty()) cout << st.top(), st.pop();
    return 0;
}

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

int main(){
  int k;
  cin >> k;
  string s;
  cin >> s;
  if(s.size() <= k){
    cout << s << endl; 
  }
  else if(s.size() > k){
    for(int i = 0;i < k;i++){
      cout << s.at(i);
    }
    cout << "..." << endl;
  }
}

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

using namespace std;

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

	int a, b, c, k;
	cin >> a >> b >> c;
	cin >> k;
	while(k>0 && b<=a){
        b*=2;
        k--;
	}
	while(c<=b && k>0){
        c*=2;
        k--;
	}
	if(c>b && b>a)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3648
#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
   int n;
   while(scanf("%d",&n)!=EOF){
    int tmp = sqrt(n);
    int ans =1;
    for(int i = 2; i <= tmp; i++){
        int t = i * i;
        while(t <= n){
            t *= i;
        }
        t /= i;
        if(ans < t){
            ans = t;
        }
    }
    printf("%d\n",ans);
   }
    return 0;
}


Measured memory_bytes: 128
ints = input().split(' ')
N = int(ints[0])
M = int(ints[1])

L_list = []
R_list = []
for i in range(M):
	L, R = input().split(' ')
	L_list.append(int(L))
	R_list.append(int(R))

L_max = max(L_list)
R_min = min(R_list)
if L_max <= R_min:
	print(len(range(L_max, R_min+1)))
else:
	print(0)

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, H, J;
  cin >> n;
  vector<ll> x(n), y(n), h(n);
  rep(i, n) cin >> x[i] >> y[i] >> h[i];
  bool flg;

  for (int i = 0; i <= 100; ++i) {
    for (int j = 0; j <= 100; ++j) {
      vector<int> c;
      for (int k = 0; k < n; ++k) {
        int d = abs(x[k] - i) + abs(y[k] - j);
        c.emplace_back(h[k] + d);
      }

      for (auto &a : c) {
        bool flg = true;
        for (int k = 0; k < n; ++k) {
          int d = abs(x[k] - i) + abs(y[k] - j);
          if (max(a - d, 0) != h[k]) flg = false;
        }
        if (flg) {
          cout << i << " " << j << " " << a << endl;
          return 0;
        }
      }
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int N=2e5+1;
int n,m,x,y,c[N];
int main()
{
	cin>>n>>m;
	while(m--&&cin>>x>>y)
		c[x]++,c[y]++;
	for(int i=1;i<=n;i++)
		if(c[i]&1)
		{
			cout<<"NO";
			return 0;
		}
	cout<<"YES";
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long a, b, c, x;
	cin >> a >> b >> c;
	x = min(a, c);
	a -= x;
	c -= x;
	x = min(b, c);
	b -= x;
	c -= x;

	cout << a << " " << b << "\n";

	return 0;
}



Measured memory_bytes: 256
public class Main {
	public static void main(String[] args) {
		java.util.Scanner s = new java.util.Scanner(System.in);
		int a[] = new int[s.nextInt()];
		for(int i=0;i<a.length;i++) {
			a[i]=s.nextInt();
		}
		System.out.println(calc(a));
	}
	public static int calc(int a[]) {
		int count=0;
		for(int i=0;i<a.length-2;i++) {
			if((a[i]<a[i+1] && a[i+1]<a[i+2])||
					(a[i]>a[i+1] && a[i+1]>a[i+2])){
				count++;
			}
		}
		return count;
	}
}


Measured memory_bytes: 23508
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long ans = 0;
		for(int i = 1; i <= n; i++) {
			int atop, alast;
			alast = i % 10;
			int tmp = i;
			while(tmp >= 10) {
				tmp /= 10;
			}
			atop = tmp;
			if(alast != 0) {
				for(int j = 0; j < n; j++) {
					if(j == 0 && atop == alast && atop <= n) {
						ans++;
					} else if(j > 0) {
						int bmin = alast;
						bmin *= Math.pow(10, j - 1);
						bmin *= 10;
						bmin += atop;
						int bmax = alast;
						for(int k = 0; k < j - 1; k++) {
							bmax *= 10;
							bmax += 9;
						}
						bmax *= 10;
						bmax += atop;
						if(bmax <= n) {
							ans += Math.pow(10, j - 1);
						} else if(bmin <= n && bmax > n) {
							int b = n;
							while(b % 10 != atop) {
								b--;
							}
							b -= alast * Math.pow(10, j);
							b /= 10;
							ans += b + 1;
							break;
						} else {
							break;
						}
					}
				}
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 23252
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  string S;
  cin>>S;
  
  ll ans=0,cnt=0;
  REP(i,3){
    if(S[i]=='S') cnt=0;
    else cnt++;
    chmax(ans,cnt);
  }
  
  co(ans);
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
typedef long long ll;
#define SZ(x) ((int)(x).size())

using namespace std;


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

	vector<ll> vx(N), vy(N), vh(N);
	int si = -1;
	for (int i = 0; i < N; i++)
	{
		cin >> vx[i] >> vy[i] >> vh[i];

		//vh[i]が0より大きいときHも決まるので、iを覚えておく(1つだけあれば十分)
		if (vh[i] > 0) {
			si = i;
		}
	}

	/*
	ll resx = -1;
	ll resy = -1;
	ll resh = -1;
	for (int x = 0; x <=100; x++)
	{
		for (int y = 0; y <= 100; y++)
		{
			//h > 0 → h = H - |X - Cx| + |Y - Cy|なので式変形
			ll H = vh[si] + abs(x - vx[si]) + abs(y - vy[si]);
			bool ok = true;

			for (int i = 0; i < N; i++)
			{
				//h > 0 → h = H - |X - Cx| + |Y - Cy|なので
				if (vh[i] > 0 && H - vh[i] != abs(x - vx[i]) + abs(y - vy[i])) {
					ok = false;
				}
				//h == 0 → H < |X - Cx| + |Y - Cy|なので
				if (vh[i] == 0 && H > abs(x - vx[i]) + abs(y - vy[i])) {
					ok = false;
				}

				if (ok) {
					resx = x;
					resy = y;
					resh = H;
				}
			}
		}

	}
	*/
	long long resx = -1, resy = -1, resh = -1;
	for (long long x = 0; x <= 100; ++x) {
		for (long long y = 0; y <= 100; ++y) {
			long long h = vh[si] + abs(x - vx[si]) + abs(y - vy[si]);
			bool ok = true;
			for (int i = 0; i < N; ++i) {
				if (vh[i] > 0 && h - vh[i] != abs(x - vx[i]) + abs(y - vy[i]))
					ok = false;
				if (vh[i] == 0 && h > abs(x - vx[i]) + abs(y - vy[i]))
					ok = false;
			}
			if (ok) resx = x, resy = y, resh = h;
		}
	}


	cout << resx << " " << resy << " " << resh << endl;

	return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;

ll MOD = 1000000007LL;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

ll get_lis_length(const vector<ll>& seq, bool strictly = true, bool ascending = true)
{

	vector<ll> min_last_seq_elem;
	using iter_type = decltype(min_last_seq_elem.begin());
	auto get_iter = [&strictly, &ascending](iter_type begin, iter_type end, ll elem)
	{
		if (strictly)
		{
			if (ascending)
				return lower_bound(begin, end, elem, less<ll>());
			else
				return lower_bound(begin, end, elem, greater<ll>());
		}
		else
		{
			if (ascending)
				return upper_bound(begin, end, elem, less<ll>());
			else
				return upper_bound(begin, end, elem, greater<ll>());
		}
	};

	for (auto& elem : seq)
	{
		auto iter = get_iter(min_last_seq_elem.begin(), min_last_seq_elem.end(), elem);
		if (iter == min_last_seq_elem.end())
			min_last_seq_elem.emplace_back(elem);
		else
			*iter = elem;
	}

	return min_last_seq_elem.size();
}

ll get_lis(const vector<ll>& seq, bool strictly = true, bool ascending = true)
{
	vector<ll> min_last_seq_elem;
	using iter_type = decltype(min_last_seq_elem.begin());
	auto get_iter = [&strictly, &ascending](iter_type begin, iter_type end, ll elem)
	{
		if (strictly)
		{
			if (ascending)
				return lower_bound(begin, end, elem, less<ll>());
			else
				return lower_bound(begin, end, elem, greater<ll>());
		}
		else
		{
			if (ascending)
				return upper_bound(begin, end, elem, less<ll>());
			else
				return upper_bound(begin, end, elem, greater<ll>());
		}
	};

	vector<ll> update_pos;
	update_pos.reserve(seq.size());


	for (auto& elem : seq)
	{
		auto iter = get_iter(min_last_seq_elem.begin(), min_last_seq_elem.end(), elem);		

		if (iter == min_last_seq_elem.end())
		{
			min_last_seq_elem.emplace_back(elem);
			update_pos.emplace_back(-1LL);
		}
		else
		{
			*iter = elem;
			update_pos.emplace_back(distance(min_last_seq_elem.begin(), iter));
		}
	}

	return min_last_seq_elem.size();
}


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

	ll N;
	cin >> N;

	vector<ll> vs(N);
	for (ll i = 0; i < N; ++i)
	{
		cin >> vs[i];
	}

	cout << get_lis_length(vs, false, false) << endl;

	return 0;
}


Measured memory_bytes: 2168
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		long x1 = sc.nextLong();
		double x2 = (double) x1 / (double) a; // 2D

		double y = a * b / 2; // 45度

		double result;
		if (x2 <= y) {
			double c = (double) (2 * x1) / (a * b);
			result = Math.atan(b / c);
		} else {
			double d = (2 * (a * b - x2)) / a;
			result = Math.atan(d / a);
		}

		result = Math.toDegrees(result);
		System.out.println(result);
		sc.close();
	}

}


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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;

lli k;
lli n = 50;
vll a;

int main(){
  cin >> k;
  a = vll(n,n-1 + k/n);
  for(lli i = 0;i < k%n;i++){
    a[i]++;
  }
  for(lli i = k%n;i < n;i++){
    a[i] -= k%n;
  }
  cout << n << endl;
  cout << a[0];
  for(lli i = 1;i < n;i++){
    cout << " " << a[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>
#include<map>
using namespace std;


int main(){
	priority_queue<int,vector<int>,greater<int>> q;
	long long int N,miria,flag=1,ans;
	cin>>N;
	for(int i=0;i<N;i++){
		int b;
		cin>>b;
		q.push(b);
	}
	if(N%2==0){
		miria=1;
		ans=1;
		while(!q.empty()){
			if(miria==q.top()){
				q.pop();
				if(miria==q.top()){
					q.pop();
					ans*=2;
					ans%=1000000007;
					miria+=2;
				}else{
					flag=0;
					break;
				}
			}else{
				flag=0;
				break;
			}
		}
	}else{
		miria=0;
		ans=1;
		if(miria==q.top()){
			q.pop();
			miria+=2;
		}else{
			flag=0;
		}
		while(!q.empty()){
			if(miria==q.top()){
				q.pop();
				if(miria==q.top()){
					q.pop();
					ans*=2;
					ans%=1000000007;
					miria+=2;
				}else{
					flag=0;
					break;
				}
			}else{
				flag=0;
				break;
			}
		}
	}
	if(flag==1){
		cout<<ans<<endl;
	}else{
		cout<<"0"<<endl;
	}
}

Measured memory_bytes: 892
#pragma GCC optimize("O3")
 
#include <iostream>
#include <math.h>
#include <vector>
#include <fstream>
#include <iomanip>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <queue>
#include <stack>
#include <string.h>
#include <unordered_map>
#include <random>
#include <cassert>
#include <unistd.h>
 
#define ll int
#define ld long double
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pi acos(-1.0)
#define uniq(v) (v).erase(unique((v).begin(),(v).end()),(v).end())
#define fcin(a) ifstream cin(a);
#define fcout(a) ofstream cout(a);
#define inf (1e16)
#define MOD 1000000007

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    int n, k;
    cin >> k >> n;
    vector <int> v(n), q;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        if (!i) {
            q.push_back(k - v[n - 1] + v[0]);
        }
        else {
            q.push_back(v[i] - v[i - 1]);
        }
        ans += q.back();
    }
    
    long long ans1 = ans;
    for (int i = 0; i < q.size(); i++) {
        ans = min(ans, ans1 - q[i]);
    }
    cout << ans;
    
}


Measured memory_bytes: 2168
s=input()
t=input()
sl=len(s)
tl=len(t)
dp=[[0 for i in range(tl+1)] for _ in range(sl+1)]

if s[0]==t[0]:
    dp[0][0]=1

for i in range(sl):
    for j in range(tl):
        if s[i]==t[j]:
            dp[i+1][j+1]=max(dp[i][j]+1,dp[i+1][j+1])
        dp[i+1][j+1]=max(dp[i+1][j+1],dp[i+1][j],dp[i][j+1])

ans=str()
while sl>0 and tl>0:
    if dp[sl][tl]==dp[sl-1][tl]:
        sl-=1
    elif dp[sl][tl]==dp[sl][tl-1]:
        tl-=1
    else:
        ans+=s[sl-1]
        sl-=1
        tl-=1

print(ans[::-1])



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

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  long long cnt = 0;
  for (int r = 0; r <= N/R; r++) {
    for (int g = 0; g <= N/G; g++) {
      int tmp = N - R*r - G*g;
      if (tmp % B == 0 && tmp / B >= 0) cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int ball[10];

bool dfs(int left, int right, int n) {
  if (n == 10) return true;
  return ((left < ball[n]) && dfs(ball[n], right, n + 1)) ||
    ((right < ball[n]) && dfs(left, ball[n], n + 1));
}

int main() {
  int n;
  scanf("%d", &n);

  while (n--) {
    for (int i = 0; i < 10; ++i) {
      scanf("%d", &ball[i]);
    }

    if (dfs(0, 0, 0)) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }
  
  return 0;
}

Measured memory_bytes: 2576
while True:
        n = input()
        if n == 0:
            break
        m = input()
        s = raw_input()
        cur,score = 0,0
        for c in s:
            if cur <= 2*n:
                if cur % 2 == 0:
                    cur = cur+1 if c=="I" else 0
                else:
                    cur = 1 if c=="I" else cur+1
            elif cur == 2*n+1:
                score += 1
                cur = 1 if c=="I" else 2*n
        print score

Measured memory_bytes: 5316
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int A[100000];
ll N, c;

vector<int> merge(vector<int> v1, vector<int> v2) {
    vector<int> ret;
    int i1 = 0, i2 = 0, s1 = v1.size(), s2 = v2.size();
    while (i1 != s1 && i2 != s2) {
        if (v1[i1] <= v2[i2]) {
            ret.push_back(v1[i1++]);
        }
        else {
            ret.push_back(v2[i2++]);
            c += s1 - i1;
        }
    }
    FOR(i, i1, s1) ret.push_back(v1[i]);
    FOR(i, i2, s2) ret.push_back(v2[i]);
    return ret;
}

vector<int> m_sort(vector<int> vi) {
    if (vi.size() <= 1) return vi;
    vector<int> l, r;
    int mid = vi.size() / 2;
    REP(i, mid) l.push_back(vi[i]);
    FOR(i, mid, vi.size()) r.push_back(vi[i]);
    return merge(m_sort(l), m_sort(r));
}

bool check(int n) {
    c = 0;
    vector<int> vi = {0};
    REP(i, N) {
        if (A[i] >= n) vi.push_back(vi[i] + 1);
        else vi.push_back(vi[i] - 1);
    }
    m_sort(vi);
    ll c_max = (N + 1) * N / 2;
    return c <= c_max / 2;
}

int main() {
    int sorted[100000];
    cin >> N;
    REP(i, N) cin >> A[i];
    REP(i, N) sorted[i] = A[i];
    sort(sorted, sorted + N);

    int ok = 0, ng = N;
    while (ng - ok > 1) {
        int mid = (ng + ok) / 2;
        if (check(sorted[mid])) ok = mid;
        else                    ng = mid;
    }
    cout << sorted[ok] << endl;
    return 0;
}

Measured memory_bytes: 5436
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
	
	long maxDiff = 1_000_000_000;

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int x = fs.nextInt();
		
		HashMap<Long, Integer> powMap = new HashMap<>();
		powMap.put(0L, 0);
		powMap.put(1L, 1);
		
		long beforePow = 1;
		long base = 2;
		while(true) {
			long powVal = pow(base, 5);
			powMap.put(powVal, (int)base);
			if(powVal - beforePow > x) {
				break;
			}
			base++;
			beforePow = powVal;
		}
		
		for(Map.Entry<Long, Integer> mapEntry : powMap.entrySet()) {
			long powVal = mapEntry.getKey();
			
			long diff = Math.abs(x - powVal);
			if(powMap.containsKey(diff)) {
				System.out.print(powMap.get(powVal));
				if(powVal - x < 0) {
					System.out.print(" -"+powMap.get(diff));
				}else {
					System.out.print(" "+powMap.get(diff));
				}
				System.out.print("\n");
				return;
			}
		}
		
	}

	public long pow(long base, int n) {
		long retVal = 1;
		while (n > 0) {
			if ((n & 1) == 1) {
				retVal *= base;
			}
			n >>= 1;
			base *= base;
		}
		return retVal;
	}
	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 36720
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int A,B;
  cin >> A >> B;
  cout << (A+B)%24 << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
k = int((2*N)**0.5)+1
if k*(k-1)==2*N:
    print('Yes')
    print(k)
    S = [[0 for j in range(k-1)] for i in range(k)]
    sx,sy = 0,0
    n = 1
    while sx<k:
        for i in range(k-1-sx):
            S[sx][sy+i] = n+i
            S[sx+1+i][sy] = n+i
        n += k-1-sx
        sx += 1
        sy += 1
    for s in S:
        print(len(s),*s)
else:
    print('No')

Measured memory_bytes: 46940
#include<cstdio>
#include<cmath>
#include<algorithm> 
int N;
long long s[100010],maxs;
int pr[5000],pc,lim;
bool com[5000];
struct item{
	long long a,b;int c;
	bool operator<(const item&it)const{return b<it.b;}
}st[100010];
bool del[100010];
int max(int a,int b){return a>b?a:b;}
int main(){
	scanf("%d",&N);
	for(int i=0;i<N;i++)scanf("%lld",s+i),s[i]>maxs?maxs=s[i]:1; 
	while(1ll*lim*lim*lim<=maxs)lim++;
	for(int i=2;i<lim;i++){
		if(!com[i])pr[pc++]=i;
		for(int j=0;j<pc&&1ll*i*pr[j]<lim;j++){
			com[i*pr[j]]=1;
			if(i%pr[j]==0)break;
		}
	}
	lim=sqrt(maxs+0.5);
	int ans=0,cnt=0;
	for(int i=0;i<N;i++){
		long long a=1,b=1;
		for(int j=0;j<pc;j++)if(s[i]%pr[j]==0){
			int c=0;
			while(s[i]%pr[j]==0)s[i]/=pr[j],c++;
			c%=3;
			if(c==1)a*=pr[j],b=b*pr[j]*pr[j];
			if(c==2)a=a*pr[j]*pr[j],b*=pr[j];
		}
		long long t=sqrt(s[i]+0.5);
		if(t*t==s[i])st[cnt++]=(item){a*s[i],b*t,0};
		else if(s[i]<=100000)st[cnt++]=(item){a*s[i],b*s[i]*s[i],0};
		else ans++;
	}
	//for(int i=0;i<cnt;i++)printf("%lld %lld\n",st[i].a,st[i].b);
	std::sort(st,st+cnt);
	int tot=0;
	for(int l=0,r=0;l<cnt;l=r){
		while(r<cnt&&st[l].b==st[r].b)r++;
		st[tot++]=(item){st[l].a,st[l].b,r-l};
	}
	for(int i=0;i<tot;i++){
		if(st[i].a==st[i].b)ans++;
		else if(!del[i]){
			item*j=std::lower_bound(st,st+tot,(item){0,st[i].a,0});
			int c=0;
			if(j<st+tot&&j->b==st[i].a)del[j-st]=1,c=j->c;
			ans+=max(st[i].c,c);
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 3328
#include<cstdio>
#include<cstring>

int main(){
  char s[201], t[1010], p[1010];
    
  scanf("%s %s", s, p);
  strcpy(t, s);
  strcat(s, t);
    
  if ( strstr(s, p) == NULL ) printf("No\n");
  else printf("Yes\n");
    
    
    
    return 0;
}   

Measured memory_bytes: 972
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(false) , cin.tie(0) ;
#define all(v) v.begin(),v.end()
#define w(x) cout << (#x) << " is " << x << "\n" ;

int main()
{
    fast ;
    int n,c=0,i,t;
    cin >> t ;
    vector<int>v(t);
    for(auto &x:v)
        cin >> x ;
    for(i=0 ; i<t ; i++)
    {
        cin >> n;
        if(v[i]-n>0)
            c=c+v[i]-n;
    }
    cout << c << "\n";
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  int c=0;
  int d=0;
  if(n > 81){
    cout << "No" << endl;
  }
  else if(n == 1){
    cout << "Yes" << endl;
  }
  else{
    for(int i=2;i<10;i++){
      if(n%i != 0){
        c+=1;
      }
      else if(n/i >9){
        d+=1;
      }
    }
    if(c+d==8){
      cout << "No" << endl;
    }
    else{
      cout << "Yes" << endl;
    }
  }
}

Measured memory_bytes: 256
n = int(input())

for _ in range(n):
    x1, y1, w, h = map(int, input().split())
    x2 = x1 + w
    y2 = y1 + h

    m = int(input())
    cnt = 0
    for _ in range(m):
        x, y = map(int, input().split())
        if x1 <= x <= x2 and y1 <= y <= y2:
            cnt += 1

    print(cnt)


Measured memory_bytes: 5608