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

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

/* define const */
const long long INF = (1LL << 60);
/* end defineing */

int main()
{
    int n;
    int h[100];
    int count = 1;
    int highest = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
    }

    highest = h[0];
    for (int i = 1; i < n; i++)
    {
        if (h[i] >= highest)
        {
            count++;
            highest = h[i];
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> pipii;
typedef priority_queue<pii, vector<pii>, greater<pii>> minpq;
typedef priority_queue<pii> maxpq;
//const double PI = acos(-1);
const int mod = 1000000007;

// ----------------------DEBUG TEMPLATE--------------------------
void __print(int x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
	cerr << '{';
	__print(x.first);
	cerr << ',';
	__print(x.second);
	cerr << '}';
}
template <typename T>
void __print(const T &x)
{
	int f = 0;
	cerr << '{';
	for (auto &i : x)
		cerr << (f++ ? "," : ""), __print(i);
	cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
	__print(t);
	if (sizeof...(v))
		cerr << ", ";
	_print(v...);
}
#ifndef ONLINE_JUDGE
#define debug(x...)               \
	cerr << "[" << #x << "] = ["; \
	_print(x)
#else
#define debug(x...)
#endif
// ----------------------DEBUG TEMPLATE--------------------------

#define N 1005

int dp[N][N];
char mat[N][N];
int R,C;

int solve(){
	
	fo(i,R){
		if(mat[i][0]=='#'){
			break;
		}
		dp[i][0]=1;
	}
	fo(i,C){
		if(mat[0][i]=='#'){
			break;
		}
		dp[0][i]=1;
	}
	Fo(i,1,R){
		Fo(j,1,C){
			if(mat[i][j]=='#'){
				dp[i][j]=0;
				continue;
			}
			dp[i][j] = (dp[i-1][j]%mod + dp[i][j-1]%mod)%mod;
		}
	}
	return dp[R-1][C-1];
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>R>>C;
	fo(i,R){
		fo(j,C){
			cin>>mat[i][j];
		}
	}
	memset(dp,0,sizeof(dp));
	cout<<solve()<<endl;


}

Measured memory_bytes: 12472
function f(A)
	now=0
	w=true
	ans=0
	for a=A
		now+=a
		if w
			if now<=0
				ans+=1-now
				now=1
			end
		else
			if now>=0
				ans+=1+now
				now=-1
			end
		end
		w=!w
	end
	ans
end
function main()
	N=parse(Int,readline())
	A=map(x->parse(Int,x),split(readline()))
	println(min(f(A),f(-A)))
end
main()


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll n;cin >>n;
    vector<double>a(n);
    double b=0;
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
        b+=1/a[i];
    }
    cout <<setprecision(20)<<1/b<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

Measured memory_bytes: 256
n=int(input())
box=[list(map(int,input().split())) for i in range(2)]
count=box[0][0]
point=-1
add=0
for j in range(n):
    for i in range(n):
        if add<=i:
            count +=box[1][i]
        else:
            count +=box[0][i+1]
    point=max(point,count)
    count=box[0][0]
    add +=1

print(point)

Measured memory_bytes: 3064
// #include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <map>
#include <math.h>
#include <algorithm> // std::sort, std::min, std::next_permutation, std::lower_bound
#include <iomanip> // std::setprecision
#include <cmath> // std::ceil
#include <numeric> // std::gcd, std::lcm
#include <limits> // std::numeric_limits<long int>::max()
#include <unordered_map>
#include <map>
#include <cmath> // std::atan2
#include <deque>
#include <queue>

using namespace std;
typedef long long ll;
#define INF 1999999999
#define MODA 1000000007 
#define rep(i,n) for (long long i = 0; i < (n); ++i)

template<typename T>
T convert_rooted_tree(const T &tree, long long root = 0) {
  long long N = tree.size();
  T rooted_tree(N);
  vector<bool> foundflag(N);
  foundflag[root] = true;
  queue<long long> que;
  que.emplace(root);
  while(!que.empty()) {
    auto p = que.front();
    que.pop();
    for(auto &to : tree[p]) {
      if(foundflag[to] == false) {
        foundflag[to] = true;
        que.emplace(to);
        rooted_tree[p].emplace_back(to);
      }
    }
  }
  return rooted_tree;
}

int main() {
  ll N;
  cin >> N;
  vector<ll> u(N), v(N), w(N);
  for(ll i=1; i<N; ++i) cin >> u[i] >> v[i] >> w[i];

  vector<vector<pair<ll, ll> > > tree(N+1);
  for(ll i=1; i<N; ++i) {
    tree[u[i]].emplace_back(make_pair(v[i], w[i]));
    tree[v[i]].emplace_back(make_pair(u[i], w[i]));
  }
  ll root = 1;

  vector<vector<pair<ll, ll> > > rooted_tree(N+1);
  vector<bool> foundflag(N+1);
  foundflag[root] = true;
  queue<long long> que1;
  que1.emplace(root);
  while(!que1.empty()) {
    auto p = que1.front();
    que1.pop();
    for(auto &to : tree[p]) {
      if(foundflag[to.first] == false) {
        foundflag[to.first] = true;
        que1.emplace(to.first);
        rooted_tree[p].push_back(to);
      }
    }
  }

  vector<int> color(N+1);
  color[root] = 0;
  queue<ll> que;
  que.emplace(root);
  while (!que.empty()) {
    auto p = que.front();
    que.pop();
    for (auto &edges : rooted_tree[p]) {
      que.emplace(edges.first);
      if(edges.second%2 == 0) {
        color[edges.first] = color[p];
      } else {
        color[edges.first] = color[p] ^ 1;
      }
    }
  }
      
  for (ll i=1; i<N+1; ++i) {
    cout << color[i] << endl;
  } 
  return 0;
}


Measured memory_bytes: 15616
import java.util.Scanner

object Main {

  def solve(sc: => Scanner): Unit = {
    val N = sc.nextInt
    var M = sc.nextInt
    var ans = M
    for (_ <- 0 until N) {
      M += sc.nextInt - sc.nextInt
      if (M < 0) (ans = -1) else (if (ans != -1) (ans = math.max(M, ans)))
    }
    println(math.max(ans, 0))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)

    solve(sc)
  }
}

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

using namespace std;

#define int long long
#define double long double
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

double distance(double x1, double y1, double x2, double y2){
	
	return  sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

bool check(vector<pair<double, double>> &cylinders, double middle, int x){
	
	// cout<<middle<<" "<<cylinders[x].first<<endl;
	if(middle < cylinders[x].first) return false;
	
	for(int i = 0; i < x; i++){
		if(distance(middle, cylinders[x].first,cylinders[i].second,cylinders[i].first)
			< cylinders[x].first + cylinders[i].first){
			return false;
		}
	}
	
	return true;
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	
	const int NUM = 100;
	int n;
	vector<pair<double, double>> cylinders;
	double p = 0, ans = 0;
	
	cin>>n;
	
	cylinders.resize(n);
	
	for(int i = 0; i < n; i++){
		cin>>cylinders[i].first;
	}
	
	for(int i = 0; i < n; i++){
		double right = p, left = 21000*(i+1), middle;
		
		for(int j = 0; j < NUM; j++){
			middle = (right + left)/2;
			// cout<<left<<" <> "<<middle<<" "<<right<<endl;
			if(check(cylinders, middle, i)){
				left = middle;
			} else {
				right = middle;
			}
		}
		p = middle;
		cylinders[i].second = middle;
		// cout<<middle<<endl;
	}
	
	for(int i = 0; i < n; i++){
		ans = max(ans, cylinders[i].first + cylinders[i].second);
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>
int main()
{
    int i,j,k,a,b,n,m,sum=0,cnt=0,p[1001];
    float c,d;
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++) {
        scanf("%d",&p[i]);
    }
    for(i=0;i<n;i++) {
        sum=sum+p[i];
    }
    c=1/(4*(float)m);
    for(j=0;j<n;j++) {
        if(((float)p[j]/sum)>=c) cnt++;
    }
    if(cnt >= m) printf("Yes\n");
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 128
def main():
    def solve(mid,g):
        for t,d in zip(x,y):
            if s[mid]==t:
                mid-=(d<'R')or-1
            if mid==g:
                return 1
        return 0
    n,q,s,*z=open(0).read().split()
    x,y=z[::2],z[1::2]
    n,q=int(n),int(q)
    s=' %s '%s
    ok=0
    ng=n+1
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if solve(mid,0):
            ok=mid
        else:
            ng=mid
    a=ok
    ok=n+1
    ng=0
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if solve(mid,n+1):
            ok=mid
        else:
            ng=mid
    print(max(0,ok-a-1))
if __name__=='__main__':
    main()

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  long long a, b; cin >> a >> b;
  cout << a / __gcd(a, b) * b << endl;
}


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

int main()
{
	long long A, B, C;
	cin >> A >> B >> C;

	int ans = 0;
	long long aa = A;
	long long bb = B;
	long long cc = C;
	for( int i = 0; i < 100000; i++ ) {
		if( A % 2 || B % 2 || C % 2 ) break;
		long long a = A / 2;
		long long b = B / 2;
		long long c = C / 2;
		A = a + b;
		B = b + c;
		C = c + a;
		if( A % 2 || B % 2 || C % 2 ) {
			A = a + c;
			B = b + a;
			C = c + b;
		}
		if( A == aa && B == bb && C == cc ) {
			ans = -1;
			break;
		}
		ans++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int B = 500;
// バケット i は [i*B, (i+1)*B) の記録を持つ
// lazy[i] :=  バケットi の遅延を記録する
// 0 ... 加算の単位元(laze[i] == 0 ⇔ 消化しても伝播しない
//今回は本当に単位元なので例外処理的な扱いをしなくていい
vll lazy(B, 0), a(200010, 0);
 
// a_s, ..., a_t に x を加算する
void add(int s, int t, int x)
{
    // s の属するバケット, t の属するバケット
    int st = s / B, gt = t / B;

    //... || ... s ... t ... || ...
    //更新が同一パケット内で済むなら直接更新しても間に合う
    if (st == gt){
        for (int i = s; i <= t; i++) a[i] += x;
    }

    //... s ... || (被覆されるパケット) || ... t ...
    else{
        //端が属するパケット内は直接更新
        for (int i = s; i < (st + 1) * B; i++) a[i] += x;
 
        for (int i = gt * B; i <= t; i++) a[i] += x;

        //区間に被覆されるパケットについては加算を遅延に残す
        //addは結合法則を満たすのでlazyには消化されるまで何回も遅延を上乗せできる
        //該当パケットが参照されたときにlazy[i]を加算すればよい
        for (int i = st + 1; i < gt; i++){
            lazy[i] += x;
        }
    }
}
 
// a_s を返す
int find(int s){
    int st = s / B;

    // s が属するパケットの遅延を消化
    for (int i = st * B; i < (st + 1) * B; i++) a[i] += lazy[st];
    lazy[st] = 0;
    return a[s];
}

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

    ll N, D, A;
    cin >> N >> D >> A;
    vector<P> p(N);
    REP(i, N) {
        cin >> p[i].first >> p[i].second;
    }
    VSORT(p);
    vll x(N), h(N);
    REP(i, N) {
        x[i] = p[i].first, h[i] = p[i].second;
    }
    ll res = 0;
    REP(i, N) {
        // 体力を削りきっていたら continue
        h[i] -= find(i) * A;
        if (h[i] <= 0) continue;
        ll b = (h[i] - 1) / A + 1; // ここで必要な爆破回数
        res += b;
        ll ub = upper_bound(ALL(x), x[i] + 2 * D) - x.begin() - 1; // 爆破が届く最遠地点の id
        add(i, ub, b);
    }
    cout << res << endl;
    return 0;
}

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

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

using namespace std;

int N;
int F[111][22];
int P[111][13];

int main() {
  cin >> N;
  rep(i, N) rep(j, 10) {
    cin >> F[i][j];
  }
  rep(i, N) rep(j, 11) {
    cin >> P[i][j];
  }

  int64_t ans = -(1LL<<60);
  REP(S, 1, 1<<10) {
    int64_t cand = 0;
    rep(i, N) {
      int C = 0;
      rep(k, 10) {
        if ((S >> k & 1) && F[i][k]) { C++; }
      }
      cand += P[i][C];
    }
    ans = max(ans, cand);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
N=int(input())
S=["" for i in range(N)]

for i in range(N):
  S[i]=input()
S.sort()
A={}
B=set()
for i in range(N):
  if S[i] in B:
    A[S[i]]=A[S[i]]+1
  else:
    A[S[i]]=1
    B.add(S[i])
#print(S)
#print(A)
slist = sorted(A.items(), key=lambda x: x[1], reverse=True)
#print(slist)
flag=slist[0][1]
x=[]
for i in range(len(B)):
  if slist[i][1]<flag:
    break
  x.append(slist[i][0])
x.sort()
for i in x:
  print(i)

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

int main(){
  int ans,num;
  char op;

  cin>>ans;
  while(1){
    cin>>op;
    if(op=='=')break;
    cin>>num;
    if(op=='+')ans+=num;
    else if(op=='-')ans-=num;
    else if(op=='*')ans*=num;
    else if(op=='/')ans/=num;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define F first
#define S second
#define int long long
#define pii pair<int, int>
#define ins insert
#define sz size() 

using namespace std;

template<typename T>
using ordered_set = __gnu_pbds::tree<T,__gnu_pbds::null_type,std::less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;

ordered_set < pii > st;
const int maxn = 2e5+5;
int n, k, ans, a[maxn];

void Speed() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

main(){
    Speed();
    cin >> n >> k;
    for(int i = 1; i <= n; ++ i) {
        cin >> a[i];
        a[i] -= k;
        a[i] += a[i - 1];
    }
    for(int i = 0; i <= n; ++ i) {
        int cnt = st.order_of_key({a[i] + 1, -1});
        ans += cnt;
        st.ins({a[i], i});
    }
    cout << ans;
}




Measured memory_bytes: 14336
#include<iostream>
using namespace std;
int main(){
	int a,b;
	char c;
	cin>>a;
	while(1){
		cin>>c;
		if(c=='=')break;
		if(c=='+'){
			cin>>b;
			a=a+b;
		}
		if(c=='-'){
			cin>>b;
			a=a-b;
		}
		if(c=='*'){
			cin>>b;
			a=a*b;
		}
		if(c=='/'){
			cin>>b;
			a=a/b;
		}
	}
	cout<<a<<endl;
	return 0;
}


Measured memory_bytes: 3096
#create date: 2020-07-05 21:16

import sys
stdin = sys.stdin
from collections import deque

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    a = na()
    a.sort(reverse=True)
    apre = a[0]
    cnt = 1
    q = deque()
    ans = -a[0]
    f = 0
    for ai in a[1:]:
        if ai == apre:
            cnt += 1
        else:
            for i in range(cnt*2):
                q.append(apre)
            apre = ai
            cnt = 1
            f += (cnt+1)
        if f > n:
            break
    for i in range(cnt*2):
        q.append(apre)
    for i in range(n):
        ans += q.popleft()

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 32660
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
#define F first
#define S second
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  int ans = 0;
  bool a = false;
  rep(i,n){
    int d,e;
    cin >> d >> e;
    if(d==e){
      ans++;
    }else{
      ans = 0;
    }
    if(ans>=3){
      a=true;
    }
  }
  if(a){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long int
#define cin(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define ull unsigned long long
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rf1(i,a,n) for(int i=a;i>n;i--)
#define cases() int q;cin>>q;while(q--)
#define ld long double
#define cout(a,n) for(i=0;i<n;i++)cout<<a[i]<<" ";
#define inf 1e9;
#define mod 1000000007;
#define PI 3.14159265358979323846264338327950L
using namespace std;

int main(){
    ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int a,b;
cin>>a>>b;
if(a%b==0){
    cout<<a/b;
}
else
    cout<<(a/b)+1;
 return 0;
 }


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int n,i;
  scanf("%d",&n);
  for(i=1; i<=n; i++)
    {
      if((i%3==0)||(i%10==3)||((i/10)%10==3)||((i/100)%10==3)||((i/1000)%10==3)) printf(" %d",i);
    }
  printf("\n");
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main(void){
    // Your code here!
 int i,n,r;
 r=0;
 cin >> n;
 int a[n];
 for(i=0;i<n;i++)
 {
  cin >> a[i];
  if(a[i]%2==0 && a[i]%3!=0 && a[i]%5!=0)
  r=1;
 }
 if(r==0)
 cout << "APPROVED";
 else
 cout << "DENIED";
 return 0;   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
     string p, s;
  cin >> s;
  cin >> p;
    while(s.size()<=100)s+=s;
   if(s.find(p) != string::npos) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3168
n, a, b = list(map(int, input().split()))
x = list(map(int, input().split()))
ans = 0

for i in range(n-1):
  if a*(x[i+1]-x[i]) >= b:
    ans += b
  else:
    ans += a*(x[i+1]-x[i])

print(ans)

Measured memory_bytes: 15020
#include <iostream>

using namespace std;

int main() {
  int N;
  int a[100];
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  int key;
  for (int i = 1; i < N; i++) {
     for (int k = 0; k < N - 1; k++) {
      cout << a[k] << " ";
    }
    cout << a[N-1] << endl;
    key = a[i];
    int j = i - 1;
    while (j>=0 && a[j] > key) {
      a[j+1] = a[j];
      j--;
    }
    a[j + 1] = key;
  }
  for (int k = 0; k < N - 1; k++) {
      cout << a[k] << " ";
    }
    cout << a[N-1] << endl;
  return 0;
}
    

Measured memory_bytes: 3080
#include <iostream>
#include <string>
#include<fstream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n;
   while(cin >> n){
        vector <int> l(n), sum(n);
        int a=0;
        for(int i = 0; i < n; i++){
            cin >> l[i];
        }
        sort(l.begin(),l.end());
        sum[0]=l[0];
        for(int i = 1; i < n; i++){
            sum[i]=l[i]+sum[i-1];
            }
        for(int i = 0; i < n; i++){
            a+=sum[i];
        }
    cout << a << endl;
   }
}



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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
typedef long long ll;

int getSumDigit(int N) {
  int sum;
  while(N>0) {
    sum += N % 10;
    N /=10;
  }
  return sum;
}
int main() {
  ll N; cin >> N;
  
  int sum = getSumDigit(N);
  if (N % sum == 0) dump("Yes");
  else dump("No");
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, x, l, a = 0, b = 0; cin >> n >> x;
	for (int h = 1; h <= n; h++) {
		cin >> l;
		a += l;
		if (a <= x) {
			b++;
		}
	}
	cout << b + 1 << endl;
	cin >> n;
}

Measured memory_bytes: 256
def main():
    S = list(input())
    lenS = len(S)
    bfr = -1
    cnt = 0
    ans = []
    dwn = 0
    S.append('<')
    while cnt <= lenS:
        nxt = S[cnt]
        if nxt == '<' and dwn == 0:
            ans.append(max(0,bfr+1))
            bfr = max(0, bfr+1)
            cnt += 1
        elif nxt == '<' and dwn > 0:
            ans.append(max(bfr+1, dwn))
            ans += range(dwn-1, -1, -1)
            bfr = 0
            cnt += 1
            dwn = 0
        else:
            dwn += 1
            cnt += 1
    #print(ans)
    print(sum(ans))

if __name__ == "__main__":
    main()


Measured memory_bytes: 27568
X, N = map(int, input().split())
ans = 102

if N == 0:
  ans = X
  
else:
  p = list(map(int, input().split()))
  if X not in p:
    ans = X
  else:
    mi = X
    pl = X
    while ans == 102:
      mi -= 1
      pl += 1
      if mi not in p:
        ans = mi
      elif pl not in p:
        ans = pl
        
print(ans)

Measured memory_bytes: 9200
using System;

namespace atcoder_nomura
{
    class MainClass
    {
        public static void Main(string[] args)
        {

                string[] input = Console.ReadLine().Split(' ');
                int H1 = int.Parse(input[0]);
                var M1 = int.Parse(input[1]);
                var H2 = int.Parse(input[2]);
                var M2 = int.Parse(input[3]);
                var K = int.Parse(input[4]);

                //起きている時間（分）
                var Oki = (H2 * 60 + M2) - (H1 * 60 + M1) - K;

                Console.WriteLine(Oki);
           
        }
    }

}


Measured memory_bytes: 27528
from collections import defaultdict
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
ans = N
tog = defaultdict(list)
arr = set()
cnt = 0

for i in range(M):
    a, b = list(map(int, input().split()))
    tog[a].append(H[b-1])
    tog[b].append(H[a-1])
    '''
    if str(a) not in arr:
        ans -= 1
        arr.add(str(H[a-1]))
    if str(b) not in arr:
        ans -= 1
        arr.add(str(H[b-1]))
    '''
#print(tog)

for ele in tog:
    #print(tog[ele])
    #print(max(tog[ele]))
    if H[ele-1] > max(tog[ele]):
        #print('ok')
        cnt += 1

#print(len(tog))
t = N - len(tog)
#print(t)
#print(len(arr))
#print(len(tog)+N-cnt)
print(cnt+t)


Measured memory_bytes: 99404
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();
        int c = sc.nextInt();
        System.out.println(Math.min(Math.min(a+b, b+c), c+a));
    }

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    char s = a[0] - 32;
    char t = b[0] - 32;
    char u = c[0] - 32;
    cout << s << t << u << endl;
    
}

Measured memory_bytes: 256
N = int(input())
F = [list(map(int,input().split())) for i in range(N)]
P = [list(map(int,input().split())) for i in range(N)]
ans = - 10**9
for i in range(1,2**10):
    s = i
    b = [0]*10
    for j in range(10):
        if s >= (2**(10-j-1)):
            s -= 2**(10-j-1)
            b[j] = 1
    a = 0
    for j in range(N):
        c = 0
        for k in range(10):
            if b[k] == 1 and F[j][k] == 1:
                c += 1
        a += P[j][c]
    ans = max(ans,a)
print(ans)

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

int main() {
	string s;
	cin >> s;
	int m = INT_MAX;
	for (char c = 'a'; c <= 'z'; c++) {
		int k = 0, i = 0;
		for (auto e : s) {
			if (e == c) {
				k = max(k, i);
				i = 0;
			} else {
				i++;
			}
		}
		m = min(m, max(k, i));
	}
	cout << m << endl;
	return 0;
}


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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll Mod = 998244353LL;
const int Maxn = 2e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

map<ll, ll> cnt;

ll a[Maxn];

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n;
	cin >> n;
	for(int i = 0 ; i < n; i++){
		cin >> a[i];
		cnt[ a[i] ] ++;
	}
	if(cnt.size() > 3) return cout << "No", 0;
	if(cnt.size() == 3){
		ll xo = 0;
		for(auto x : cnt){
			if(x.S != (n / 3)) return cout << "No", 0;
			xo ^= x.F;
		}
		if(xo != 0) return cout << "No", 0;
		return cout << "Yes", 0;
	}
	if(cnt.size() == 2){
		if((cnt.count(0) == 0) || (n % 3 > 0)) return cout << "No", 0;
		return cout << (cnt[0] == n / 3 ? "Yes" : "No"), 0;
	}
	if(cnt.count(0)) return cout << "Yes", 0;
	else return cout << "No", 0;
	return 0;
	
}

/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;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--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_a() {
	ll n, m;
	ll x, y;
	ll a, b, c, d;
	ll k;
	//string s, t;
	ll l_ans = 0;
	string s_ans = "NG";

	V g(5);
	rep(i, 5) cin >> g[i];

	rep(i, 5) {
		if (g[i] == 0) {
			cout << i + 1 << "\n";
			return;
		}
	}

	return;
}


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

	solve_abc_a();

	return 0;
}

Measured memory_bytes: 3648
def divisors(n)
  p = []
  2.upto((n**0.5)) do |i|
    break if i > n / i
    while n % i == 0
      p << i
      n /= i
    end
  end
  p << n if n != 1
  p
end
Q = gets.to_i
l, r = Q.times.map{gets.split.map(&:to_i)}.transpose
max = r.max
arr = Array.new(max+1,0)
1.upto(max) do |i|
  arr[i] = arr[i-1]
  if divisors(i).length == 1 && divisors((i+1)/2).length == 1
    arr[i] += 1
  end
end
Q.times do |i|
  puts arr[r[i]] - arr[l[i]-1]
end

Measured memory_bytes: 25060
import bisect,copy,heapq,string
from collections import *
from math import *
from itertools import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = LIST()
b = [0]*100010
ans = 0

for x in a:
        if (x<=1e5):
                b[x] += 1
        else:
                ans += 1
for i in range(100010):
        if (b[i]>=i):
                ans += b[i] - i
        else:
                ans += b[i]

print(ans)

Measured memory_bytes: 21664
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>

typedef struct Point{
	long x,y;
} point;

long m_dist(point a,point b){
	return labs(a.x-b.x)+labs(a.y-b.y);
}

int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	point student[n];
	point cp[m];
	int i,j,nearest_cp;
	long distance;
	for(i=0;i<n;i++){
		scanf("%ld%ld",&(student[i].x),&(student[i].y));
	}
	for(i=0;i<m;i++){
		scanf("%ld%ld",&(cp[i].x),&(cp[i].y));
	}
	
	for(i=0;i<n;i++){
		nearest_cp=100;
		distance=LONG_MAX;
		for(j=0;j<m;j++){
			if(m_dist(student[i],cp[j])<distance){
				distance=m_dist(student[i],cp[j]);
				nearest_cp=j+1;
			}
			//printf("%ld %ld\n",m_dist(student[i],cp[j]),distance);
		}
		printf("%d\n",nearest_cp);
	}
	
    return 0;
}


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

int main()
{
	long long n,a,b,ans;
	cin>>n>>a>>b;
	
	long long x=n/(a+b),y=n%(a+b);
	
	ans=x*a;
	
	if(y>=a)
		ans+=a;
	else
		ans+=y;
	cout<<ans;
	return 0;
}

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

vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>> res;
    for(ll i=2; i*i<=n;++i){
        if(n%i){
            continue;
        }
        res.emplace_back(i,0);
        while (n%i==0)
        {
            n/=i;
            res.back().second++;
        }
    } 
    if(n!= 1){
        res.emplace_back(n,1);
    }
    return res;
}

int main (){
	ll a,b;
	cin >> a>>b;
    ll g = __gcd(a,b);
    auto f = factorize(g);
    int ans = f.size()+1;
    cout<<ans<<endl;

}


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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

signed main() {
    ll N, M;
    cin>>N>>M;
    vector<PLL> v(N); // {値段、個数}
    rep(i,0,N){
        cin>>v[i].first>>v[i].second;
    }
    sort(begin(v), end(v));
    ll ans = 0, i=0;
    while(M){
        ll t = min(M, v[i].second);
        M -= t;
        ans += v[i].first * t;
        i++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;

int main() {

	char res;
	char N; cin >> N;
	if (N == 'A') res = 'T';
	if (N == 'T') res = 'A';
	if (N == 'C') res = 'G';
	if (N == 'G') res = 'C';

	cout << res << endl;

}

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

int p[1010];
int sum[1002010];

int main(void){
	int n,m;

	while(scanf("%d%d",&n,&m) && (n||m)){
		for(int i=0;i<n;i++){
			scanf("%d",&p[i]);
		}
		p[n++] = 0; //0ツ点ツづ個スツコツアツづーツ催ャツづゥ

		int size=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				sum[size++] = p[i] + p[j];
			}
		}
		sort(sum,sum+size);

		int ans = 0;

		for(int i=0;i<size;i++){
			int rem = m - sum[i];
			if(rem < 0) continue;
			int left = 0, right = size;

			while(left < right){
				int center = (left + right) / 2;
				if(rem > sum[center]){
					left = center + 1;
				}
				else if(rem < sum[center]){
					right = center;
				}
				else {
					break;
				}
			}

			ans = max(ans, sum[i] + sum[right-1]);
		}

		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define vb vct<bool>
#define vs vector<string>
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define print(v) for(auto it:v)cout<<it<<' ';cout<<endl;
#define PI 2*acos(0.0)
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
///................function.....................///
#define siz(s) (int)(s.size())
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mod 999999937
int main()
{
    FIO;
    ///freopen("in.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    int n,i,c=0,j,k;
    cin>>n;
    vi cnt(n+1);
    for(i=1; i<=sqrt(n); i++)
    {
        for(j=1; j<=sqrt(n); j++)
        {
            for(k=1; i*i+j*j+k*k+i*j+j*k+k*i<=n; k++)
                cnt[i*i+j*j+k*k+i*j+j*k+k*i]++;
        }
    }
    for(i=1; i<=n; i++)
        cout<<cnt[i]<<endl;
}


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

int main() {
	int k, a, b;
	cin >> k;
	cin >> a >> b;
	bool ans = true;
	for (int i = 1; i <= b/k+1; ++i)
	{
		if (a <= k*i && k*i <= b)
		{
			cout << "OK" << endl;
			ans = false;
			break;
		}
	}
	if(ans)
	{
		cout << "NG" << endl;
	}
}

Measured memory_bytes: 3636
//FROM: https://www.geeksforgeeks.org/queries-number-distinct-elements-subarray/?ref=rp
// C++ code to find number of distinct numbers 
// in a subarray 
#include<bits/stdc++.h> 
using namespace std; 
  
const int MAX = 500005; 
  
// structure to store queries 
struct Query 
{ 
   int l, r, idx; 
}; 
  
// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
   return x.r < y.r; 
} 
  
// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
   for (; idx <= n; idx += idx&-idx) 
      bit[idx] += val; 
} 
  
// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
   int sum = 0; 
   for (; idx>0; idx-=idx&-idx) 
      sum += bit[idx]; 
   return sum; 
} 
   
// driver code 

int main() 
{ 
   ios::sync_with_stdio(false);
   cin.tie(0);
   //cout << "hi" << endl;
   int n;
   int q;
   cin >> n >> q;
    
   int arr[MAX];
   for(int k = 0; k < n; k++){
      cin >> arr[k];
   }
   Query queries[MAX];
   for(int k = 0; k < q; k++){
      int l;
      int r;
      cin >> l >> r;
      queries[k].l=l-1;
      queries[k].r=r-1;
      queries[k].idx=k;
   }
    
        // initialising bit array 
   int bit[MAX+1]; 
   //memset(bit, 0, sizeof(bit)); 
  	
    // holds the rightmost index of any number 
    // as numbers of a[i] are less than or equal to 10^6 
   int last_visit[MAX+1]; 
   //memset(last_visit, -1, sizeof(last_visit)); 
  for(int k = 0; k <= MAX; k++){
      bit[k] = 0;
      last_visit[k] = -1;
    }
      sort(queries, queries+q, cmp); 

    // answer for each query 
   int ans[q]; 
   int query_counter = 0; 
   
   for (int i=0; i<n; i++) 
   { 
      //cout << i << endl;
        // If last visit is not -1 update -1 at the 
        // idx equal to last_visit[arr[i]] 
      if (last_visit[arr[i]] !=-1) 
         update (last_visit[arr[i]] + 1, -1, bit, n); 
   
        // Setting last_visit[arr[i]] as i and updating 
        // the bit array accordingly 
      last_visit[arr[i]] = i; 
      update(i + 1, 1, bit, n); 
   
        // If i is equal to r of any query  store answer 
        // for that query in ans[] 
      while (query_counter < q && queries[query_counter].r == i) 
      { 
       	 //cout << queries[query_counter].idx << endl;
         ans[queries[query_counter].idx] = query(queries[query_counter].r + 1, bit, n)-query(queries[query_counter].l, bit, n); 
         query_counter++; 
      } 
     //cout << query_counter << endl;
   } 
  
    // print answer for each query 
   for (int i=0; i<q; i++) 
      cout << ans[i] << endl; 
    
    
   return 0; 
}

Measured memory_bytes: 17360
#include <bits/stdc++.h>
#include <chrono> 
 
using namespace std;
using namespace std::chrono; 
 
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
// #pragma optimization_level 3
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define f0r(a, b) for (long long a = 0; a < (b); ++a)
#define f1r(a, b, c) for (long long a = (b); a < (c); ++a)
#define f0rd(a, b) for (long long a = (b); a >= 0; --a)
#define f1rd(a, b, c) for (long long a = (b); a >= (c); --a)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define pb push_back
#define send {ios_base::sync_with_stdio(false);}
#define help {cin.tie(NULL); cout.tie(NULL);}
#define fix(prec) {cout << setprecision(prec) << fixed;}
#define mp make_pair
#define f first
#define s second
#define all(v) v.begin(), v.end()
#define getunique(v) {sort(all(v)); v.erase(unique(all(v)), v.end());}
#define readgraph(list, edges) for (int i = 0; i < edges; i++) {int a, b; cin >> a >> b; a--; b--; list[a].pb(b); list[b].pb(a);}
#define ai(a, n) for (int ele = 0; ele < n; ele++) cin >> a[ele];
#define ain(a, lb, rb) for (int ele = lb; ele <= rb; ele++) cin >> a[ele];
#define ao(a, n) {for (int ele = 0; ele < (n); ele++) { if (ele) cout << " "; cout << a[ele]; } cout << '\n';}
#define aout(a, lb, rb) {for (int ele = (lb); ele <= (rb); ele++) { if (ele > (lb)) cout << " "; cout << a[ele]; } cout << '\n';}
#define vsz(x) ((long long) x.size())
typedef long long ll;
typedef double ld;
typedef long double lld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
 
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
  cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
  cin >> p.first;
  return cin >> p.second;
}
 
mt19937 rng(steady_clock::now().time_since_epoch().count());
// mt19937 rng(61378913);
/* usage - just do rng() */
 
void usaco(string filename) {
  // #pragma message("be careful, freopen may be wrong")
	freopen((filename + ".in").c_str(), "r", stdin);
	freopen((filename + ".out").c_str(), "w", stdout);
}
 
const lld pi = 3.14159265358979323846;
// const ll mod = 1000000007;
// const ll mod = 998244353;
// ll mod;
 

 
ll n, m, k, q, l, r, x, y, z;
ll a[1000005];
ll b[1000005];
ll c[1000005];
string s, t;
ll ans = 0;


 
void solve(int tc) {
  cin >> n >> k;
  ai(a, n);

  f0r(i, n - k) cout << (a[i + k] > a[i] ? "Yes\n" : "No\n");
}
 
int main() {
  send help
 
  // usaco("cowland");
 
  int tc = 1;
  // cin >> tc;
  for (int t = 0; t < tc; t++) solve(t);
} 

Measured memory_bytes: 5240
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
const int INF = 2147483647;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

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

	int ans = 0;

	for (int i = 1;i < a;i++) {
		for (int j = 1;j < 31;j++) {
			if (i == j) ans++;
		}
	}

	for (int j = 1;j <= b;j++) {
			if (a == j) ans++;
		}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n, m = [int(x) for x in input().split()]
g = [[] for _ in range(n)]
for _ in range(m):
    x, y = [int(x) for x in input().split()]
    g[x - 1].append(y - 1)
from functools import lru_cache
sys.setrecursionlimit(10**7)
@lru_cache(maxsize=None)
def dp(v):
    res = 0
    for u in g[v]:
        res = max(res, dp(u) + 1)
    return res
ans = -1
for i in range(n):
    ans = max(ans, dp(i))
print(ans)




Measured memory_bytes: 268248
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,t;
	cin >> N >> t;
	vector<pii> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i].first >> a[i].second;
	}
	SORT(a);
	int ans = INF;
	for (int i = 0; i < N; ++i) {
		if (a[i].second <= t) {
			ans = min(ans, a[i].first);
		}
	}
	if (ans == INF)cout << "TLE" << endl;
	else cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
/*
    Author : DemonStar
*/

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

#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<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define ll long long
#define pi pair<int, int>
#define pl pair<long long, long long>
#define pld pair<long double, long double>
#define endl '\n'
#define loop(i, n) for (ll i = 0; i < n; i++)
#define rep(i, begin, end) for (__typeof(begin) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(x) x.begin(), x.end()
#define vl vector<ll>
#define vi vector<int>
#define ml map<ll, ll>
#define vpl vector<pair<ll, ll>>
const ll mod = 1e9 + 7;

template <typename T, typename TT>
ostream &operator<<(ostream &os, const pair<T, TT> &t)
{
    return os << t.first << " " << t.second;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &t)
{
    for (auto &i : t)
        os << i << " ";
    return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (T &t : v)
        is >> t;
    return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, vector<pair<T1, T2>> &v)
{
    for (pair<T1, T2> &t : v)
        is >> t.first >> t.second;
    return is;
}

int main()
{
    int n;
    cin >> n;
    vector<double> v(n);
    cin >> v;
    vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0));
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= i; j++)
        {
            if (!i)
                dp[i][j] = 1;
            else if (!j)
                dp[i][j] = dp[i - 1][j] * (1 - v[i - 1]);
            else
                dp[i][j] = dp[i - 1][j - 1] * v[i - 1] + dp[i - 1][j] * (1 - v[i - 1]);
        }
    }
    // cout << dp << endl;
    double ans = 0;
    for (int i = n / 2 + 1; i <= n; i++)
        ans += dp[n][i];
    printf("%.10lf", ans);
#ifdef LOCAL
    cerr
        << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif

    return 0;
}

Measured memory_bytes: 70656
import java.util.*;

public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[5];
        for (int i = 0; i<5; i++) {
            a[i] = sc.nextInt();
        }
        int th = sc.nextInt();

        int diff = a[4] - a[0];

        if (diff > th) {
        System.out.println(":(");
        sc.close();
        }
        else {
        System.out.println("Yay!");
        sc.close();

        }

       sc.close();
    }
}

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

int main() {
	ll n,k;
	cin >> n >> k;
	ll m = n % k;
	ll ans = min(m, k-m);
	cout << ans << endl;
	return 0;
}


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

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

  	for(int i = 0 ; i < N ;i++){
    	cout << S.at(i);
    }
  
  	cout << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<cctype>
#include<string.h>
#include <stdlib.h>

#define PI 3.1415926
void swap(int* x, int* y) {
	int a = *x;
	int b = *y;
	*x = b;
	*y = a;
}
int factorial(int n);
int sum(int n, int*);
int ave(int n, int*);
int min(int n, int*), min(int n, int m);
int max(int n, int*), max(int n, int m);

int main() {
	int s[10] = { 0 }, h[10]{ 0 };
	scanf("%d %d %d %d %d %d", &s[0], &s[1], &s[2], &s[3], &h[0], &h[1]);
	
	printf("%d\n", sum(4,s)- min(4, s)+max(2,h) );
	return 0;
}

int factorial(int n) {
	if (n > 0) {
		return n * factorial(n - 1);
	}
	else {
		return 1;
	}
}
int sum(int n, int *all) {
	int total = 0;
	for (int i = 0; i < n; ++i) {
		total += all[i];
	}
	return total;
}
int ave(int n, int *all) {
	int total = 0;
	for (int i = 0; i<n; ++i) {
		total += all[i];
	}
	return total / n;
}
int min(int n, int *all) {
	int min = all[0];
	for (int i = 1; i < n; ++i) {
		if (min > all[i]) {
			min = all[i];
		}
	}
	return min;
}
int max(int n, int *all) {
	int max = all[0];
	for (int i = 1; i<n; ++i) {
		if (max<all[i]) {
			max = all[i];
		}
	}
	return max;
}
int max(int n, int m) {
	if (n >= m) {
		return n;
	}
	else {
		return m;
	}
}
int min(int n, int m) {
	if (n >= m) {
		return m;
	}
	else {
		return n;
	}
}

Measured memory_bytes: 2576