akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};
int sy,sx,gy,gx;

int main(){
  int n; cin >> n;
  vector<int> a(n),s(n);
  rep(i,n){
    cin >> a[i];
    s[i] = a[i];
  }
  sort(s.begin(), s.end());
  reverse(s.begin(), s.end());
  bool flg = false;
  for(int v: a){
    rep(i,2){
      if(v == s[i]){
        if(!flg){
          flg = true;
          continue;
        }
      }
      cout << s[i] << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  bool ans = false;

  if(s.at(0)==s.at(1) && s.at(2)==s.at(3)){
   if(s.at(0)!=s.at(2))
     ans = true;}
  else if(s.at(0)==s.at(2) && s.at(1)==s.at(3)){
    if(s.at(0)!=s.at(1))
      ans = true;}
  else if(s.at(0)==s.at(3) && s.at(1)==s.at(2)){
    if(s.at(0)!=s.at(2))
    ans = true;}
  
  if(ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int N;
    cin>>N;
    vll A(N);
    for(int i=0;i<N;i++)cin>>A[i];
    ll ans=0;
    for(int i=1;i<N;i++){
        if(A[i-1]>A[i]){
            ans+=A[i-1]-A[i];
            A[i]=A[i-1];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4840
#include <iostream>
#include <string>

using namespace std;

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

    int ans = 0;
    for (char c : S) {
        if (c == '*') break;
        ans += (c == '(' ? 1 : -1);
    }

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public final class Main {

    private static final int MOD = (int) (1e9 + 7);

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final int n = fs.nextInt();
        final long[] arr = fs.readLongArray(n);
        long res = 0;
        long curr = 0;
        for (int i = 1; i < n; i++) {
            curr = (curr + arr[i - 1]) % MOD;
            res = (res + (arr[i] * curr) % MOD) % MOD;
        }
        System.out.println(res);
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] readArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long[] readLongArray(int n) {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++) { a[i] = nextLong(); }
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 56396
def comb(n,k):
    nCk = 1
    MOD = 10**9+7

    for i in range(n-k+1, n+1):
        nCk *= i
        nCk %= MOD

    for i in range(1,k+1):
        nCk *= pow(i,MOD-2,MOD)
        nCk %= MOD
    return nCk
n,m=map(int,input().split())
if m>n:
    n,m=m,n
N,M=1,1
mod=10**9+7
for i in range(1,n+1):
    N*=i
    N%=mod
for i in range(1,m+1):
    M*=i
    M%=mod
if n>=m+2:
    print(0)
    exit()
if n==m+1:
    ans=1
if n==m:
    ans=2
ans*=N*M
print(ans%mod)

Measured memory_bytes: 9228
#include<stdio.h>
int f(int a,int b){
  if(b)return f(b,a%b);
  return a;
}
int main(){
  int n,i,d[3],a;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&d[i]);
  if(d[0]>d[1])a=f(d[0],d[1]);
  else         a=f(d[1],d[0]);
  if(n-2){
    if(a>d[2])a=f(a,d[2]);
    else      a=f(d[2],a);
  }//printf("%d\n",a);
  for(i=1;i<=a;i++){
    if(a%i==0)printf("%d\n",i);
  }
  return 0;
}

Measured memory_bytes: 596
#include <iostream>

using namespace std;
 int a=0 ; int b;int counter =0;int temp;

int main()
{


    cin >>a; cin >>b;


   for(int i=0;;i++){
        counter +=1;
        a= a - b;
        if (a<=0){

            cout<<counter<<endl;
            break;
        }




   }


   }















Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define N 101000
#define ll long long
using namespace std;
int n,last[N],nxt[N*2],to[N*2],tot=1;
ll date[N*2],ans=0,sz[N],mi=0,mx[N];
void putin(int x,int y,ll z)
{
	nxt[++tot]=last[x];last[x]=tot;to[tot]=y;date[tot]=z;
	mi=min(mi,z);
}
void dg(int x,int fa)
{
	sz[x]=1;
	for(int i=last[x];i;i=nxt[i])
	{
		int y=to[i];
		if(y==fa) continue;
		dg(y,x);
		mx[x]=max(mx[x],sz[y]);
		sz[x]+=sz[y];
		ans+=date[i]*min(sz[y],n-sz[y])*2ll;
		if(sz[y]==n-sz[y]) ans-=date[i],mi=-1;
	}
	mx[x]=max(mx[x],n-sz[x]);
}
int main()
{
	scanf("%d",&n);
	fo(i,1,n-1)
	{
		int x,y,z;scanf("%d%d%d",&x,&y,&z);
		putin(x,y,z);putin(y,x,z);
	}
	dg(1,0);
	if(mi==0)
	{
		int x=1;mi=2147483647;
		fo(i,1,n) if(mx[i]<mx[x]) x=i;
		for(int i=last[x];i;i=nxt[i]) mi=min(mi,date[i]);
		ans-=mi;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 9216
#include <stdio.h>

int t1,t2;

int n,m;
bool ix[1000005];
bool iy[1000005];

int px=0,py=0;  // available
long long ans=1;

#define MOD 1000000007;

int main()
{
    #ifdef NOT_DMOJ
    freopen("data.txt","r",stdin);
    #endif // NOT_DMOJ
    scanf("%d%d",&n,&m);
    for (int i=0; i<n; i++) {
        scanf("%d",&t1);
        ix[t1]=1;
    }
    for (int i=0; i<m; i++) {
        scanf("%d",&t1);
        iy[t1]=1;
    }
    // put in the numbers in backwards order
    for (int i=n*m; i>=1; i--) {
        if (!ix[i] && !iy[i]) {
            ans*=px*py-(n*m-i);
        }
        else {
            if (ix[i]) px++;
            if (iy[i]) py++;
            if (ix[i] && iy[i]);
            else if (ix[i]) ans*=py;
            else if (iy[i]) ans*=px;
        }
        ans%=MOD;
        //printf("%d %lld\n",i,ans);
        if (ans==0) break;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
private fun readStrings() = readLine()!!.split(" ")
private fun readInts() = readStrings().map { it.toInt() }

fun main(args: Array<String>) {
    val S = readStrings()[0]
    val T = readStrings()[0]
    (0 until S.length).forEach { rot ->
        if(S.drop(rot) + S.take(rot) == T) {
            println("Yes")
            return
        }
    }
    println("No")
}

Measured memory_bytes: 37868
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<functional>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef queue<P> Q;

#define _CRT_SECURE_NO_WARNINGS

char N[5];
int main() {
	cin >> N;
    int c=0;
	for(auto a:N){
        if(a=='2')c++;
    }
    cout<<c;
	return 0;
}

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

int main(){
 string S;
 cin >> S;
 
bool ans = false; 
 for (int i = 0; i < S.size(); i++){
   if(i%2 == 0) {
     if (S.at(i) == 'L'){
       ans = true;
   }
   }
   if(i%2 == 1) {
     if (S.at(i) == 'R'){
       ans = true;
   }
 }      

 }
  
   
  if(ans){
   cout << "No" << endl; 
  }
  else{
   cout << "Yes" << endl;     
  }
}


Measured memory_bytes: 256
// Problem : C - Remainder Minimization 2019
// Contest : AtCoder - AtCoder Beginner Contest 133
// URL : https://atcoder.jp/contests/abc133/tasks/abc133_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a) for (int i=0; i<(a); i++)
#define rep1(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rep(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define imax INT_MAX
#define imin INT_MIN
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
int main() { 
	ll l,r;
	cin>>l>>r;
	r=min(r,l+2019);
	ll ans=2019;
	for(ll i=l;i<=r;i++)
		for(ll j=i+1;j<=r;j++)
			ans=min(ans,(i*j)%2019);
	cout<<ans<<nl;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3564
# C - One Quadrillion and One Dalmatians
def main():
    N = int(input())
    res = ""
    int_to_abc = lambda i: chr(97 + N % 26)
    while N:
        N -= 1
        res += int_to_abc(N)
        N //= 26
    print(res[::-1])


if __name__ == "__main__":
    main()


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

int main(){
    int n,k;
    cin>>n>>k;
    int arr[10]={0};
    for(int i=0; i<k; i++){
        int x;
        cin>>x;
        arr[x]=1;
    }
    for(int i=n; ;i++){
        int tmp=i;
        bool inval=0;
        while(tmp){
            if(arr[tmp%10])inval=1;
            tmp/=10;
        }
        if(inval)continue;
        cout<<i;
        return 0;
    }
return 0;
}



Measured memory_bytes: 256
import collections
N,M=map(int,input().split())    
H=list(map(int,input().split()))
ans=[1]*N
for _ in range(M):
    AB=list(map(int,input().split()))
    if H[AB[0]-1] < H[AB[1]-1]:
        ans[AB[0]-1]=0
    elif H[AB[0]-1] > H[AB[1]-1]:
        ans[AB[1]-1]=0
    else:
        ans[AB[0]-1]=0
        ans[AB[1]-1]=0
c=collections.Counter(ans)
print(c[1])


Measured memory_bytes: 20584
N, Y = map(int, input().split())
res = (-1, -1, -1)
for x in range(N + 1):
    for y in range(N + 1 - x):
        if N - x - y >= 0 and 10000*x + 5000*y + 1000*(N - x - y) == Y:
            res = (x, y, N - x - y)
print(res[0], res[1], res[2])

Measured memory_bytes: 3064
import copy
import sys
sys.setrecursionlimit(10**7)

N, M = map(int, input().split())
G = [[] for _ in range(N)]
side = []
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    G[a].append(b)
    G[b].append(a)
    side.append((a,b))

def dfs(v,G):
    seen[v] = True
    for next_v in G[v]:
        if seen[next_v] == True:
             continue
        dfs(next_v,G)

bridge = 0
# 各辺を取り除く
for a,b in side:
    Gc = copy.deepcopy(G)
    Gc[a].remove(b)
    Gc[b].remove(a)
    seen = [False]*N
    cnt = 0
    # 連結成分のカウント
    for s in range(N):
        if seen[s] == True:
            continue
        cnt += 1
        dfs(s,Gc)
    # 連結成分が 2 個以上ならその辺は橋    
    if cnt>=2:
        bridge += 1
print(bridge)

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

using namespace std;

using ll = long long;

#define FOR(i,n,m) for(ll i=(n);i<(m);++i)
#define REP(i,n) FOR(i,0,n)

int main() {
	int w;
	cin>>w;
	vector<int> v(w);
	REP(i,w)cin>>v[i];
	vector<int> tmp(w,0);
	int t=0;
	int ans=0;
	REP(i,w){
		t--;
		if(v[i]==0){
			t = 1e9;
		}else if(v[i]<0){
			t=min(t,-v[i]);
		}else{
			tmp[i]=max(tmp[i],min(t,v[i]));
		}
	}
	t=0;
	for(int i=w-1;i>=0;--i){
		t--;
		if(v[i]==0){
			t = 1e9;
		}else if(v[i]<0){
			t=min(t,-v[i]);
		}else{
			tmp[i]=max(tmp[i],min(t,v[i]));
		}
	}
	REP(i,w)ans+=tmp[i];
	cout<<ans<<endl;
}


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

int main() {
	int n,d,c=0;
	cin>>n>>d;
	int a[n][d];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<d;j++)
		{
			cin>>a[i][j];
		}
	}
	for(int i=0;i<n-1;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			double x=0;
			for(int k=0;k<d;k++)
			{
				x+=pow(a[i][k]-a[j][k],2);
			}
			if((double)sqrt(x)-(double)floor(sqrt(x))==0)
			c++;
		}
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        k: usize,
    }
    if gcd(k, 2) != 1 || gcd(k, 5) != 1 {
        println!("-1");
        return;
    }
    let mut sevens = 7 % k;
    let mut count = 1;
    while sevens != 0 {
        sevens *= 10;
        sevens += 7;
        sevens %= k;
        count += 1;
    }
    println!("{}", count);
}

fn gcd(x: usize, y: usize) -> usize {
    if x < y {
        return gcd(y, x);
    } else if y == 0 {
        return x;
    } else {
        return gcd(y, x - (x / y) * y);
    }
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
const int mod=1e9+7;

int main(){
  string s;
  cin>>s;
  int n=s.size();
  if(s[n-1]=='s'){string t="es";s+=t;}
  else{s+='s';}
  cout<<s<<endl;
  return 0;                       
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <iostream>
using namespace std;

int n;
int a[100005];
int f[100005];

int main()
{
    scanf ("%d",&n);
    for (int i=1;i<=n;i++)
        scanf ("%d",&a[i]);
    for (int i=1;i<=n;i++)
        {
        if (a[i]!=0) f[a[i]-1]++;
        f[a[i]]++;
        f[a[i]+1]++;
        }
    int ans=0;
    for (int i=0;i<=100000;i++)
        if (f[i]>ans)
            ans=f[i];
    printf ("%d",ans);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll c[51][51];
ll comb_table(int n) {
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= i; j++) {
            if (j == 0 || j == i) {
                c[i][j] = 1LL;
            } else {
                c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
            }
        }
    }
}

int main() {
    int n, p;
    cin >> n >> p;
    comb_table(n);
    int a[n];
    vi odd, even;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] % 2 == 0) {
            even.push_back(a[i]);
        } else {
            odd.push_back(a[i]);
        }
    }
    ll ans = 0;
    if (p == 0) {
        ll totalEven = 0;
        ll totalOdd = 0;
        for (int i = 0; i <= even.size(); i++) {
            totalEven += c[even.size()][i];
        }
        for (int i = 0; i <= odd.size(); i += 2) {
            totalOdd += c[odd.size()][i];
        }
        ans = totalEven * totalOdd;
    } else {
        ll totalEven = 0;
        ll totalOdd = 0;
        for (int i = 0; i <= even.size(); i++) {
            totalEven += c[even.size()][i];
        }
        for (int i = 1; i <= odd.size(); i += 2) {
            totalOdd += c[odd.size()][i];
        }
        ans = totalEven * totalOdd;
        if (odd.size() == 0) {
            ans = 0;
        }
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    ll d;   cin >> d;
    vector<ll> c(26), days(26, 1);
    REP(i, 26) cin >> c[i];
    vector<vector<ll>> s(d, vector<ll>(26, 0));
    REP(i, d) REP(j, 26) cin >> s[i][j];
    REP(q, d){
        ll obj=-1, tmp=-LINF;
        REP(i, 26){
            if(tmp<days[i]*c[i]+s[q][i]){
                if(0<=obj) days[obj] += 1;
                obj = i;
                tmp = days[i]*c[i]+s[q][i];
            }else days[i] += 1;
        }
        days[obj] = 1;
        cout << obj+1 << endl;
    }
}


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

int main() {
  ll n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n)cin >> a[i];
  sort(a.begin(),a.end());
  cout << a[n/2]-a[n/2-1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
  int W,a,b;
  cin >> W >> a >> b;
  if(b > a+W)
    cout << b-(a+W) << endl;
  else if(b+W < a)
    cout << a-(b+W) << endl;
  else
    cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
n,a,b,c,d, = map(int, input().split())
s = input()
s = "_" + s

if a > b:
    a,b,c,d = b,a,d,c

#print("{0},{1},{2},{3}".format(str(a), str(b), str(c), str(d)))

# print(s)
"""
  012345678
 "#####...#####".find("...")
5
>>> "#####...#####"[:5]
'#####'
>>> "#####...#####"[5+3:]
'#####'
>>> "0123456789"[1:7]
'123456'
"""

if c < d:
    # 追い越しが不要の場合
    #print("c<d")
    # print(s)
    #print(s[a:d+1])
    if s[a:d+1].find("##") == -1: # 障害がないなら
        print("Yes")
    else:
        print("No")

else:
    # 追い越しが必要の場合
    #print(s)
    #print("takeover")
    #print(s[b-1:d+2])
    if s[b-1:d+2].find("...") != -1:
        #print(s[a:c+1])
        if s[a:c + 1].find("##") == -1: # 障害がないなら
            print("Yes")
        else:
            print("No")
    else:
        # 追い越し区間がないなら抜けない
        print("No")

Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
const int N=1e6+8;
ll n,x,y,k,val[N],ans,dp[N],mx=0,a[N],b[N];
vector<ll>g[N];
inline void dfs(ll v,ll fa)
{
	for(int i=0;i<g[v].size();i++)
	{
		//cout<<v<<endl;
		ll u=g[v][i];
		if(u==fa)continue;
		dfs(u,v);
		dp[v]++;
		dp[v]+=dp[u];
		mx=max(dp[v],mx);
	}
}
int main()
{
	ios::sync_with_stdio(0);
   	cin>>n;
   	for(int i=1;i<=n;i++)cin>>a[i]>>b[i];
   	for(int i=3;i<=n;i++)
   	{
   		if(a[i]==b[i]&&a[i-1]==b[i-1]&&a[i-2]==b[i-2])
   		{
   			cout<<"Yes"<<endl;
   			return 0;
		}
	}
    cout<<"No"<<endl;
}

Measured memory_bytes: 27092
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
a = list(map(int, input().replace("\n","").split()))

count = 0
allhyou = sum(a)

# print(allhyou)

for i in range(len(a)):
    if a[i] >= (allhyou/(4*m)):
        count += 1

if count >= m:
    print("Yes")
else:
    print("No")

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n,k; 
	cin >> n >> k;
	int cnt=1;
	int now=k;
	while(now<=n){
		now*=k;
		cnt++;
	}
	cout << cnt << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 3644
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  unsigned i,j;
  unsigned a[100][100],b[100][11],c[100][11],m,n,o,u,v;
  pair<pair<unsigned,unsigned>,unsigned> mn;
  while(cin>>m>>n>>o>>u>>v&&m+n+o+u+v){
    u--;
    v--;
    memset(a,-1,sizeof(a));
    for(i=0;i<o;i++){
      int p,q,r;
      cin>>p>>q>>r;
      p--;
      q--;
      a[p][q]=a[q][p]=r;
    }
    memset(b,0,sizeof(b));
    memset(c,-1,sizeof(c));
    c[u][0]=0;
    mn.first.first=u;
    mn.first.second=0;
    mn.second=0;
    while(mn.first.first!=v){
      b[mn.first.first][mn.first.second]=1;
      for(i=0;i<n;i++){
	if((int)a[mn.first.first][i]!=-1){
	  c[i][mn.first.second]=min(c[i][mn.first.second],mn.second+a[mn.first.first][i]);
	  if(mn.first.second<m)
	    c[i][mn.first.second+1]=min(c[i][mn.first.second+1],mn.second+a[mn.first.first][i]/2);
	}
      }
      mn.second=-1;
      for(i=0;i<m+1;i++){
	for(j=0;j<n;j++){
	  if(b[j][i]==0&&mn.second>c[j][i]){
	    mn.first.first=j;
	    mn.first.second=i;
	    mn.second=c[j][i];
	  }
	}
      }
    }
    cout<<mn.second<<endl;
  }
  return 0;
}    

Measured memory_bytes: 0
n, k = map(int, input().split())
S = list(map(int, input()))
T = []    
if S[0] == 1:
    T.append(1)
else:
    T.append(0)
    T.append(-1)
for i in range(1, n):
    if S[i] == S[i-1] and S[i] == 1:
        T[-1] += 1
    elif S[i] == S[i-1]:
        T[-1] -= 1
    elif S[i] == 1:
        T.append(1)
    else:
        T.append(-1)
if T[-1] < 0:
    T.append(0)
m = len(T)

ans = []
ans.append(T[0])
for i in range(0, k):
    if 2*i+2 < m:
        ans[0] = ans[0] - T[2*i+1] + T[2*i+2]
    else:
        break

i = 0
j = k+1
while True:
    if 2*j >= m:
        break
    re = ans[-1] - T[2*i] + T[2*i+1] - T[2*j-1] + T[2*j]
    i += 1
    j += 1
    ans.append(re)
    
    
print(max(ans))



Measured memory_bytes: 6232
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
int n , k , tmp , ans;
vector<int> g[N];
void dfs(int node , int par) {
    if(par == -1)
        tmp = k - 1;
    else
        tmp = k - 2;
    for(auto &i : g[node])
        if(i != par)
            ans = (1ll * ans * tmp--) % mod;
    for(auto &i : g[node])
        if(i != par)
            dfs(i , node);
}
int main() {
    abdelrahman010
    cin >> n >> k;
    for(int i = 1;i < n;i++) {
        int u , v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    ans = k;
    dfs(1 , -1);
    cout << ans;
    return 0;
}

Measured memory_bytes: 7552
#include <bits/stdc++.h>
#define nl ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define pi acos(-1)

using namespace std;

int main() {
    nl // 

    ll n, d;
    cin >> n >> d;

    ll cnt = 0;

    for(ll i=0; i<n; ++i) {
        ll x, y; 
        cin >> x >> y;
        if(x*x + y*y <= d*d) cnt++;
    }

    cout << cnt;

    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
using namespace std;
const int N=1e5+1;
long long ar[N];
int main(){
	long long n,k,i,j,sum1,sum0,sum=0,m,now=0;
	cin>>n>>k;
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	for(i=40;i>=0;i--){
		sum1=0;
		sum0=0;
		m=(1ll<<i);
		//cout<<m<<endl;
		for(j=1;j<=n;j++){
			if((m&ar[j])){
				sum1++;
			}
			else{
				sum0++;
			}
		}
		//cout<<sum1<<" "<<sum0<<endl;
		if(sum1>=sum0){
			sum+=sum1*m;
		}
		else{
			if(now+m<=k){
				now+=m;
				sum+=sum0*m;
			}
			else{
				sum+=sum1*m;
			}
		}
	}
	cout<<sum;
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int,input().split()))
m = 100000000000
count = 0
ans = 0
for i in range(n):
    if a[i] < 0:
        count += 1
    x = abs(a[i]) 
    ans += x
    m = min(m,x)
if count % 2 != 0:
    ans -= 2*m
print(ans)


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

int dp[100005];

int helper(int arr[], int i, int n, int k){
    if(i == n - 1){
        return 0;
    }
    
    if(dp[i] != -1){
        return dp[i];
    }
    
    int ans = 1e9;
    for(int j = 1; j <= k; j++){
        if(i + j < n){
            ans = min(ans, helper(arr, i + j, n, k) + abs(arr[i + j] - arr[i]));
        }
    }
    
    return dp[i] = ans;
}

int main(){
    int n;
    cin >> n;
    int arr[n];
    int k;
    cin >> k;
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    
    memset(dp, -1, sizeof(dp));
    cout << helper(arr, 0, n, k) << endl;
    
}


Measured memory_bytes: 13752
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    int N;
    cin >> N;
    vector<int> B(N-1);
    REP(i,0,N-1){
        cin >> B[i];
    }
    int ans=0;

    if(N==2){
        ans=B[0]*2;
        goto ANS;
    }

    RREP(i,0,N-1){
        if(i==N-2){
            ans+=B[i];
        }else{
            ans+=min(B[i],B[i+1]);
        }
        if(i==0) ans+=B[0];
    }

    ANS:
    P(ans);
}

Measured memory_bytes: 256
X,Y = list(map(int,input().split()))
if X == Y:
  print(1)
  exit()
A = Y//X
B = A//2
num = 0
ans = 0
for i in range(1,10000000):
    num += 2**i
    if num > B:
        ans = i+1
        break
if X*(2**ans) <= Y:
    ans += 1
print(ans)

Measured memory_bytes: 38256
import sys
from itertools import accumulate

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))
    B = list(accumulate(A))

    total = sum(A)
    ans = float('inf')
    for b in B[:N-1]:
        ans = min(ans, abs((total - b) - b))

    return ans



if __name__ == '__main__':
    print(main())


Measured memory_bytes: 24168
n = int(input())
h = [int(xi) for xi in input().split()]

step = 0
mstep = 0
for xi in range(n-1):
    if h[xi] >= h[xi+1]:
        step += 1
    else:
        if mstep<step:
            mstep = step
        step = 0

if mstep<step:
    mstep = step

print(mstep)


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

typedef long long ll;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n, a, b;
    cin >> a >> b >> n;

    if(n>=b) n=b-1;
    
    cout << floor((n*a)/b) <<'\n';

    return 0;
}


Measured memory_bytes: 3792
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

  static int l, r, d;
  static long ans;

  public static void main(String[] args) throws Exception {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);

    String[] in = br.readLine().split(" ");
    l = Integer.parseInt(in[0]);
    r = Integer.parseInt(in[1]);
    d = Integer.parseInt(in[2]);


    br.close();

    for (int i = l; i <= r; i++) {
      if (i % d == 0) ans++;
    }

    out.println(ans);

    out.flush();
  }
}

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

int main()
{
    unsigned long long n,k;
    
    cin>>n>>k;
    
    if(n%k==0)
        cout<<"0\n";
    else if(k>=(2*n))
        cout<<n<<"\n";
    else if(k>n)
        cout<<(k-n)<<"\n";
    else 
    {
        if((n%k)*2>=k)
            cout<<k-(n%k)<<"\n";
        else
            cout<<n%k<<"\n";
    }
        
    return 0;
}



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

using namespace std;

typedef long long llint;

const int MAXN = 2005;
const int MOD = 1000000007;

llint n, k;
llint dp[MAXN][MAXN], f[MAXN*MAXN], inv[MAXN*MAXN], r[MAXN*MAXN];

inline llint add (llint x, llint y) {
    x += y;
    if (x >= MOD) return x - MOD; return x;
}

void precompute () {
    f[0] = inv[0] = 1;
    for (int i=1; i<n*k; i++) {
        if (i == 1) r[i] = 1; else r[i] = (MOD - (MOD / i * r[MOD % i]) % MOD) % MOD;
        f[i] = f[i-1] * i % MOD;
        inv[i] = inv[i-1] * r[i] % MOD;
    }
}

llint nck (llint n, llint k) {
    return f[n] * inv[k] % MOD * inv[n-k] % MOD;
}

void calc () {
    dp[1][1] = 1;
    for (int i = 2; i <= n; i++) {
        llint curr = 0;
        for (int j = i; j >= 1; j--) {
            if (j > 1) curr = add(curr, dp[i-1][j-1]);
            dp[i][j] = curr * nck(k*i - j - 1, k-2) % MOD;
            dp[i][0] = add(dp[i][0], dp[i][j]);
        }
    }
}

int main () {
    cin >> n >> k;
    if (n == 1 || k == 1) {
        cout << 1;
        return 0;
    }
    precompute();
    calc();
    cout << dp[n][0] * f[n] % MOD;
    return 0;
}


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

int main(void) {
  int N;
  cin >> N;
  map<string, int> ma;
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    ma[S]++;
  }

  int max_cnt = -1;
  for (auto m : ma) {
    max_cnt = max(max_cnt, m.second);
  }
  for (auto m : ma) {
    if (m.second == max_cnt) {
      cout << m.first << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 25216
#include<iostream>
    #include<cstdio>
    #include<math.h>
    #include<string>
    #include<algorithm>
    #include<functional>
    #include<vector>
    #include<set>
    #include<map>
    #define INF 1000000000000000
    #define EPS 1.0e-6
     
    using namespace std;
     
    typedef long long ll;
    typedef pair<int, int> P;
     
    int n, m, r;
    int city[9];
    ll d[210][210];
     
    void warshall_floyd()
    {
    	for (int k = 0; k < n; k++) {
    		for (int i = 0; i < n; i++) {
    			for (int j = 0; j < n; j++) {
    				if (i != j) {
    					if (d[i][j] > d[i][k] + d[k][j]) {
    						d[i][j] = d[i][k] + d[k][j];
    					}
    				}
    		
    			}
    		}
    	}
     
    }
     
    int main()
    {
     
    	cin >> n >> m >> r;
    	int cityi;
    	for (int i = 0; i < r; i++) {
    		cin >> cityi;
    		cityi--;
    		city[i] = cityi;
    	}
     
    	for (int i = 0; i < n; i++) {
    		for (int j = 0; j < n; j++) {
    			if (i != j)d[i][j] = INF;
    			else d[i][j] = 0;
    		}
    	}
    	for (int i = 0; i < m; i++) {
    		int a, b, c;
    		cin >> a >> b >> c;
    		a--; b--;
    		d[a][b] = c;
    		d[b][a] = c;
    	}
    	warshall_floyd();
    /*
    	for (int i = 0; i < n; i++) {
    		for (int j = 0; j < n; j++) {
    			printf("d[%d][%d]:%d\n", i+1, j+1, d[i][j]);
    		}
    	}
    */
     
     
    	sort(city, city + r);
    	
    	ll cur_0 = 0;
    	for (int i = 1; i < r; i++) {
    		cur_0 += d[city[i - 1]][city[i]];
    	}
    	ll ans = cur_0;
     
    	while (next_permutation(city, city + r)) {
    		ll cur = 0;
    		
    		for (int i = 1; i < r; i++) {
    			
    		//	printf("city[%d]:%d,city[%d]:%d\n", i - 1, city[i - 1], i, city[i]);
    			
    			cur += d[city[i - 1]][city[i]];
    		}
    		if (cur<ans)ans = cur;
     
    	}
    	cout << ans << endl;
     
    	return 0;
    }

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

int main()
{
    char s[101];

    scanf("%s",s);

    int len = strlen(s);
    int i;

    for (i = 0; i < len; i++)
    {
        if(i % 2 == 0)
        {
            if (s[i] == 'L')
            {
                break;
            }
        }
        else
        {
            if (s[i] == 'R')
            {
                break;
            }
        }
    }
    
    if (i == len)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    
    
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int N;
int C[555], S[555], F[555];

int main() {
   cin >> N;
   rep (i, N-1) {
      cin >> C[i] >> S[i] >> F[i];
   }

   rep (i, N) { // スタート
      int t = 0;
      repp (j, i, N-1) {
         if (j == i) t += S[j];
         int k = 0;
         for ( ; ; k++) {
            if ((S[j] + F[j]*k) >= t) break;
         }
         t = S[j] + F[j]*k;
         t += C[j];
      }
      cout << t << endl;
   }

   return 0;
}

Measured memory_bytes: 256
n = input()

list1 = [str(x) for x in n]
list2 = []
list3 = []
matu = 0

for x in range(int((len(n)-1)//2)):
    list2.append(n[x])

for x in range(int(len(n)-(len(n)+3)//2 + 1)):
    matu = len(n) - x -1
    list3.append(n[matu])

list2_ke = ''.join(list2)
list3_ke = ''.join(list3)

if list1 == list(reversed(n)) and list2 == list(reversed(list2_ke)) and list3 == list(reversed(list3_ke)) :
    print("Yes")

else :
    print("No")

Measured memory_bytes: 38256
<?php

fscanf(STDIN, "%d %d %d", $a11, $a12, $a13);
fscanf(STDIN, "%d %d %d", $a21, $a22, $a23);
fscanf(STDIN, "%d %d %d", $a31, $a32, $a33);

fscanf(STDIN, "%d", $n);

$inputs = [];
for ($i = 0; $n > $i; $i++) {
    fscanf(STDIN, "%d", $x);
    $inputs[] = (int)$x;
}

$map = [
    $a11 => 0, $a12 => 0, $a13 => 0,
    $a21 => 0, $a22 => 0, $a23 => 0,
    $a31 => 0, $a32 => 0, $a33 => 0,
];
#var_dump([$n, $inputs]);
foreach ($inputs as $input) {
    if (isset($map[$input])) {
        $map[$input]++;
    }
}
#var_dump($map);
$pattern = [
    [$a11, $a12, $a13],
    [$a21, $a22, $a23],
    [$a31, $a32, $a33],
    [$a11, $a21, $a31],
    [$a12, $a22, $a32],
    [$a13, $a23, $a33],
    [$a11, $a22, $a33],
    [$a31, $a22, $a13]
];
foreach ($pattern as $p) {
    $counter = 0;
    foreach ($p as $num) {
        if ($map[$num] > 0) {
            $counter++;
        }
    }
    if ($counter > 2) {
        echo "Yes";
        exit;
    }
}
echo "No";



Measured memory_bytes: 4604
import bisect
import os

import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


D = int(sys.stdin.buffer.readline())
C = list(map(int, sys.stdin.buffer.readline().split()))
S = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(D)]
T = [int(sys.stdin.buffer.readline()) for _ in range(D)]
M = int(sys.stdin.buffer.readline())
DQ = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(M)]

S = [0] + S + [[0] * 26]
T = [-1] + [t - 1 for t in T]


def score():
    lasts = [0] * 26
    score = 0
    ret = []
    for d in range(1, D + 1):
        t = T[d]
        score += S[d][t]

        lasts[t] = d
        for j, c in enumerate(C):
            score -= (d - lasts[j]) * c
        ret.append(score)
    return ret


days = [[] for _ in range(26)]
for d, t in enumerate(T[1:], start=1):
    days[t].append(d)
for t in range(26):
    days[t].append(D + 1)

scores = [0 for _ in range(26)]


def calc(t):
    last = 0
    ret = 0
    for d in days[t]:
        diff = d - last
        ret += S[d][t]
        ret -= C[t] * (diff - 1) * diff // 2
        last = d
    return ret


for t in range(26):
    scores[t] = calc(t)

score = sum(scores)

for d, q in DQ:
    q -= 1
    before_t = T[d]
    T[d] = q
    days[before_t].remove(d)
    days[q].insert(bisect.bisect_left(days[q], d), d)

    score -= scores[before_t]
    score -= scores[q]
    scores[before_t] = calc(before_t)
    scores[q] = calc(q)
    score += scores[before_t]
    score += scores[q]

    print(score)


Measured memory_bytes: 84444
#include<stdio.h>


 
int main() {

	
	int n,h[20],i,cnt=0,j,cnt1=1;

	scanf("%d",&n);
	for (i = 0; i < n; i++)scanf("%d", &h[i]);
	for (i = 0; i < n; i++) {
		cnt = 0;
		for (j = 0; j < i; j++) {
			
			if (h[j] <= h[i])cnt++;
			if (cnt == i)cnt1++;
		}
		
		//printf("%d", cnt1);
	}
	
		
	
	 printf("%d", cnt1);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>

 

 

 

using namespace std;

 

 

 

int main() 
{
    int i, x;
    for(i=1; i<=10000; i++)
    {
        cin >> x;
        if(x == 0)
            break;
        cout << "Case" << " " << i << ":" << " " << x << endl;
    }
}


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

int main()
{
	int array[200];
	int n;
	while (scanf("%d", &n) != EOF){
		for (int i = 0; i < n; i++){
			scanf("%d", &array[i]);
		}
		
		sort(array, array + n);
		
		for (int i = 0; i < n - 1; i++){
			array[i + 1] += array[i];
		}
		
		int sum = 0;
		for (int i = 0; i < n; i++){
			sum += array[i];
		}
		
		printf("%d\n", sum);
	}
	
	return 0;
}

Measured memory_bytes: 1044
def acinput():
    return list(map(int, input().split(" ")))



import numpy as np
#from functools import reduce
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
import copy
import functools

H,A=acinput()

print(int(np.ceil(H/A)))

Measured memory_bytes: 23808
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N = getN()
A = getList()

r, tmp = 0, A[0]
# l:左端
cnt = 0
for l in range(N):
    while r + 1 < N and tmp ^ A[r + 1] == tmp + A[r + 1]:
        # 右端を伸ばす
        tmp += A[r + 1]
        r += 1
    cnt += r - l + 1

    if r + 1 < N and l == r:
        r += 1
        tmp = A[r]
    else:
        # 左端が1進むと同時にtmpの左端の分を削る
        tmp -= A[l]
print(cnt)

Measured memory_bytes: 95416
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var NT = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var (N, T) = (NT[0], NT[1]);
            var t = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToList();
            t.Add(t[N - 1] + T);
            var answer = 0;
            for (var i = 1; i < t.Count; i++)
            {
                answer += Math.Min(T, t[i] - t[i - 1]);
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 45980
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n) - 1; i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

template<typename T>
inline void setmax(T& a, T b) {
    if (a < b) a = b;
}

template<typename T>
inline void setmin(T& a, T b) {
    if (a > b) a = b;
}

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); 
    srand((unsigned)chrono::high_resolution_clock::now().time_since_epoch().count());
    int n, a, b;
    cin >> n >> a >> b;
    if (a % 2 == b % 2) cout << "Alice\n";
    else cout << "Borys\n";
}


Measured memory_bytes: 256
/*input
2 1
1 10

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
 
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

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

  int a, b;
  cin >> a >> b;
  cout << (a <= 9 && b <= 9 ? a * b : -1) << endl;

  return 0;
}

Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    ll p = 1;
    int cnt = 0;
    while (1) {
        p *= 26;
        cnt++;
        if (n <= p) break;
        else n -= p;
    }
    n--;
    // cout << n << endl;
    string s = "";
    FOR(i,1,cnt) {
        int e = n % 26;
        n /= 26;
        s += char(e + 'a');
    }
    reverse(ALL(s));
    cout << s;
    return 0;
}


Measured memory_bytes: 3652