akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = 0;
        String W = sc.next();
        while(true){
            String T = sc.next();

            if(T.equalsIgnoreCase(W)){
                count++;
            }
            if(T.equals("END_OF_TEXT")){
                break;
            }
        }
        System.out.println(count);
    }

}


Measured memory_bytes: 26180
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 998244353
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    int n;
    string s;
    cin>>n>>s;

    ll r=0,b=0,g=0,rb=0,rg=0,bg=0,no=n;
    ll ans=1;
    ll prev = n;
    for(int i=0;i<3*n;i++)
    {
        if( s[i] == 'R' )
        {
            if( bg > 0 )
            {
                ans *= bg;
                bg--;
            }
            else if( b > 0 )
            {
                ans *= b;
                b--;
                rb++;
            }
            else if( g > 0 )
            {
                ans *= g;
                g--;
                rg++;
            }
            else
            {
                ans *= no;
                no--;
                r++;
            }
        }
        else if( s[i] == 'G' )
        {
            if( rb > 0 )
            {
                ans *= rb;
                rb--;
            }
            else if( b > 0 )
            {
                ans *= b;
                b--;
                bg++;
            }
            else if( r > 0 )
            {
                ans *= r;
                r--;
                rg++;
            }
            else
            {
                ans *= no;
                no--;
                g++;
            }
        }
        else
        {
            if( rg > 0 )
            {
                ans *= rg;
                rg--;
            }
            else if( r > 0 )
            {
                ans *= r;
                r--;
                rb++;
            }
            else if( g > 0 )
            {
                ans *= g;
                g--;
                bg++;
            }
            else
            {
                ans *= no;
                no--;
                b++;
            }
        }
        ans = mod(ans);
    }
    cout<<ans,nl;

    return 0;
}

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

ll ans,a[51],b[51];

void eat(ll l,ll x){
    if(l==0){
        ans++;
        return;
    }
    if(--x<=0)return;
    if(a[l-1]<x){
        ans+=b[l-1];
        x-=a[l-1];
    }else{
        eat(l-1,x);
        return;
    }
    ans++;
    if(--x<=0)return;
    if(a[l]<x){
        ans+=b[l-1];
        x-=a[l-1];
    }else{
        eat(l-1,x);
        return;
    }
}

int main(){
    ll n,x;
    cin>>n>>x;
    a[0]=1;
    b[0]=1;
    for(int i=1;i<=n;i++){
        a[i]=2*a[i-1]+3;
        b[i]=2*b[i-1]+1;
    }
    ans=0;
    eat(n,x);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
L, R = [int(n) for n in input().split()]

if R - L >= 2019:
    print(0)
else:
    min_mod = 2019
    for a in range(L, R):
        for b in range(a+1, R+1):
            min_mod = min(min_mod, (a * b) % 2019)

    print(min_mod)

Measured memory_bytes: 9020
#include<iostream>
#define ll long long int
#define vi vector<ll>
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define iiii pair<ii,ii>
#define pb push_back
#define fi first
#define se second
using namespace std;
int t;
int main(){
	ios::sync_with_stdio(0), cin.tie(0);
	ll n,a,b;
	cin>>n>>a>>b;
	ll ans = n/(a+b) * a;
	if(n > a+b) ans+=min(a,n - (n/(a+b) * (a+b)));
	else if(a<=n && !ans) ans+=a;
	else if(a > n) ans = n;
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
//C++14 (Clang 3.8.0)
     
    #include <vector>
    #include <list>
    #include <map>
    #include <set>
    #include <queue>
    #include <deque>
    #include <stack>
    #include <bitset>
    #include <algorithm>
    #include <functional>
    #include <numeric>
    #include <utility>
    #include <sstream>
    #include <iostream>
    #include <iomanip>
    #include <cstdio>
    #include <cmath>
    #include <cstdlib>
    #include <ctime>
    #include <string>
    #include <cstdlib>
    #define rp(i,a,b) for(int (i)=(int)(a);i<(int)(b);++i)
     
    typedef long long ll;
     
    using namespace std;
     
    int main(){
        int N;
        int a[100001];
     
        cin>>N;
        int ans=0;
        rp(i,0,N) cin>>a[i];
        rp(i,0,N) {
            if (a[a[i]-1]-1==i) ans++;
                }
        cout<<ans/2<<endl;;
     
        return 0;
    }


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

using namespace std;

int main(){
  int a, b , c, d;
  cin >> a >> b >> c >> d;
  while(1){
    c-=b;
    if(c<=0){
      cout << "Yes" << endl;
      return 0;
    }
    a-=d;
    if(a<=0){
      cout << "No" << endl;
      return 0;
    }
  }
}



Measured memory_bytes: 3600
a, b, c, x, y = map(int, input().split())

s = 0
s2 = 0
s3 = 0

s += c * min([x, y]) * 2
s += a * (x - min([x, y]))
s += b * (y - min([x, y]))

s2 += a * x
s2 += b * y

s3 += c * max([x, y]) * 2

print(min([s, s2, s3]))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    LCIN(X);LCIN(Y);
    COUT((abs(X-Y)<=1?"Brown":"Alice"));
    return 0;
}


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

using namespace std;

const int MOD = 1000 * 1000 * 1000 + 7;

class modulo_calc
{
public:
	modulo_calc(int modulo) : m_modulo(modulo)
	{
	}

	int mod() const
	{
		return m_modulo;
	}

	int mul(int x, int y) const
	{
		return 1LL * x * y % mod();
	}

	// O(log n) time
	int pow(int x, int n) const
	{
		int ans = 1;
		for (; n > 0; n >>= 1) {
			if (n & 1) {
				ans = mul(ans, x);
			}
			x = mul(x, x);
		}
		return ans;
	}

	int inv(int x) const
	{
		return pow(x, mod() - 2);
	}

	int fact(int n) const
	{
		return m_fact[n];
	}

	int ifact(int n) const
	{
		return m_ifact[n];
	}

	int comb(int n, int r) const
	{
		return mul(mul(fact(n), ifact(n - r)), ifact(r));
	}

	// O(n) time, O(n) space
	void make_fact(int n)
	{
		m_fact.resize(n + 1);
		m_fact[0] = 1;
		for (int i = 1; i <= n; ++i) {
			m_fact[i] = mul(m_fact[i - 1], i);
		}
	}

	// O(n * log m) time, O(n) space
	void make_ifact(int n)
	{
		m_ifact.resize(n + 1);
		for (int i = 0; i <= n; ++i) {
			m_ifact[i] = inv(m_fact[i]);
		}
	}

private:
	int m_modulo;
	vector<int> m_fact;
	vector<int> m_ifact;
};

map<int, int> prime_factorize(int n)
{
	map<int, int> f;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			++f[i];
			n /= i;
		}
	}
	if (n != 1) {
		++f[n];
	}
	return f;
}

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

	int ans = 1;
	modulo_calc m(MOD);
	m.make_fact(N + 100);
	m.make_ifact(N + 100);

	auto f = prime_factorize(M);
	for (auto &e : f) {
		int b = e.second;
		ans = m.mul(ans, m.comb(b + N - 1, b));
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
typedef unsigned long long ULL;

int main() {
	int n, m;
	std::vector<int> vec;
	int ans = 0;

	std::cin >> n >> m;

	for (int i = 0; i < n; ++i) {
		int a;
		std::cin >> a;
		for (int j = 0; j < a; ++j) {
			int b;
			std::cin >> b;
			vec.push_back(b);
		}
	}
	for (int i = 1; i <= m; ++i) {
		if (std::count(vec.begin(), vec.end(), i) == n) {
			ans += 1;
		}
	}
	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	s := 0
	t := n
	for t > 0 {
		s += t % 10
		t /= 10
	}
	if n%s == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 998244353

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
	int N;
	cin >> N;
	vector<int> D(N);
	map<int, int> mp;
	rep(i,N) {
		cin >> D[i];
		mp[D[i]]++;
	}
	int maxi = -1;
	rep(i,N) chmax(maxi, D[i]);
	if(D[0] != 0 || mp[0] != 1) {
		cout << 0 << endl;
		return 0;
	}
	ll ans = 1;
	for(int i=1; i<=maxi; i++) {
		rep(j, mp[i]) {
			ans *= mp[i-1];
			ans %= MOD;
		}
	}
	cout << ans << endl;
	

  return 0;
}


Measured memory_bytes: 5376
/*
	Auther:_Destiny
	time:2020.5.3
*/
#include <bits/stdc++.h>
#define ll long long
#define N 100010
#define M 1010

using namespace std;
int n, m;
int head[N << 1], add_edge, high[N];
struct node {
	int next, to;
}edge[N << 1];

int read() {
	int s = 0, f = 0; char ch = getchar();
	while (!isdigit(ch)) f |= (ch == '-'), ch = getchar();
	while (isdigit(ch)) s = s * 10 + (ch ^ 48), ch = getchar();
	return f ? -s : s;
}

void add(int from, int to) {
	edge[++add_edge].next = head[from];
	edge[add_edge].to = to;
	head[from] = add_edge;
}

int main() {
	n = read(), m = read();
	for (int i = 1; i <= n; i++)
		high[i] = read();
	int ans = 0;
	for (int i = 1, x, y; i <= m; i++) {
		x = read(), y = read();
		add(x, y), add(y, x);
	}
	for (int i = 1; i <= n; i++) {
		int flag = 0;
		for (int j = head[i]; j; j = edge[j].next) {
			int to = edge[j].to;
			if (high[to] >= high[i]) {
				flag = 1;
				break;
			}
		}
		if (!flag) ans++;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 5940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#define so(v) sort(v.begin(),v.end())
using ll = long long;
using vi=vector<int>;
using vii=vector<vi>;
const int MAX = 510000;
const int MOD = 1000000007;
ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
  ll n,k;cin>>n>>k;
  
  ll ans=0;
  ans=(k-n-2)*((2*k*k-k*(n+2)-n*n-n-6))/6%MOD;
  cout<<ans<<endl;
}

Measured memory_bytes: 3644
/*
author: shah_entrance
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,i,j,res;
    cin>>n;
    ll arr[n],dp[n+5][2]={};
    for(i=0;i<n;i++)
        cin>>arr[i];
    if(n==2)
        cout<<abs(arr[1]-arr[0])<<endl;
    else
    {
        dp[1][0]=abs(arr[1]-arr[0]);
        dp[1][1]=abs(arr[1]-arr[0]);
        for(i=2;i<n;i++)
        {
            dp[i][0]=min(dp[i-1][0],dp[i-1][1])+abs(arr[i]-arr[i-1]);
            dp[i][1]=min(dp[i-2][0],dp[i-2][1])+abs(arr[i]-arr[i-2]);
        }
        cout<<min(dp[n-1][0],dp[n-1][1])<<endl;
    }
    return 0;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

const int MOD = 1000000007;
const int MAXN = 100000;
int dp[MAXN][2]; // node, node can be black

void dfs(graph& g, int i, int p = -1) {
  ll ifwhite = 1LL;
  ll ifblack = 1LL;
  trav(e, g[i]) if (e.to != p) {
    dfs(g, e.to, i);
  }
  trav(e, g[i]) if (e.to != p) {
    ifwhite = (1LL * ifwhite * dp[e.to][1]) % MOD;
    ifblack = (1LL * ifblack * dp[e.to][0]) % MOD;
  }
  dp[i][0] = ifwhite;
  dp[i][1] = (ifwhite + ifblack) % MOD;
}

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

  int n;
  cin >> n;
  graph g(n);
  rep(i, 0, n - 1) {
    int u, v;
    cin >> u >> v;
    --u; --v;
    g[u].PB({v});
    g[v].PB({u});
  }
  dfs(g, 0);
  cout << dp[0][1] << '\n';
}


Measured memory_bytes: 13440
#include <cstdio>

#define R register
#define maxn 100010
#define cmin(_a, _b) (_a > (_b) ? _a = (_b) : 0)
#define cmax(_a, _b) (_a < (_b) ? _a = (_b) : 0)
int a[maxn];
int main()
{
	R int n; scanf("%d", &n);
	R int maxx = 0, minn = 0x7fffffff;
	for (R int i = 1; i <= n; ++i) scanf("%d", a + i), cmax(maxx, a[i]), cmin(minn, a[i]);
	if (maxx - minn > 1) puts("No");
	else if (maxx - minn == 1)
	{
		R int cnt = 0;
		for (R int i = 1; i <= n; ++i) if (a[i] == minn) ++cnt;
		if (cnt + (n - cnt) / 2 >= maxx && n - cnt > 1 && cnt <= minn && minn <= cnt - 1 + (n - cnt) / 2) puts("Yes");
		else puts("No");
	}
	else
	{
//		printf("%d\n", maxx);
		if (maxx <= n / 2 || maxx == n - 1) puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 512
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]

# n: コマ
# x: 目的地 len(x)=M
def main(N, M, Xm):
    # コマ数N >= 目的地数M: クリア
    if N >= M:
        print(0)
        return
    # 目的地は個体区別しないので、簡単のためソート
    Xm.sort()
    # コマ数N == 1: 1コマで端から端まで移動
    if N == 1:
        d = Xm[M-1] - Xm[0]
        print(d)
        return
    # 2 <= コマ数N < 目的地数M: どうする？
    # 発想を変えて、目的地間の距離に注目
    Dm = [Xm[i] - Xm[i-1] for i in range(1, M)]
    # 区間は、間隔が短い順に並ぶとする
    Dm.sort()
    # 全てのコマの移動方向は右とする
    # コマ1は一番左の目的地からスタート
    # コマ2～Nは右端の目的地から埋めていく
    # 1             5     4      3       2      コマ
    # x-x--x---x----x-----x------x-------x      目的地（区間が短い順）
    # あとは、コマ1が、コマNの隣まで進めばよい、その距離が答えとなる
    d = 0
    for i in range(M-N):
        d += Dm[i]
    print(d)

N, M = i2nn()
Xm = i2nn()
main(N, M, Xm)

"""
C - Streamline
https://atcoder.jp/contests/abc117/tasks/abc117_c

2 5
10 12 1 2 14
    5

3 7
-10 -3 0 9 -100 2 17
    19

100 1
-100000
    0
"""


Measured memory_bytes: 14972
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int $1 = 0;
		int $2 = 0;
		int $4 = 0;
		for(int i = 0; i < n; i++) {
			long l = sc.nextLong();
			if(l % 4 == 0) {
				$4++;
			} else if(l % 2 == 0) {
				$2++;
			} else {
				$1++;
			}
		}
		if($2 != 0) $1++;
		System.out.println($1-1 <= $4 ? "Yes" : "No");
	}
}

Measured memory_bytes: 48728
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
	int r, g, b;
	cin >> r >> g >> b;
	if((10 * g + b) % 4 == 0)cout << "YES";
	else cout << "NO";
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
# ABC 124 c
s = input()
n = len(s)

# 1010...
t = ''.join(['0' if i % 2 == 0 else '1' for i in range(n)])
t_count = 0
for i, j in zip(s, t):
    if i == j:
        pass
    else:
        t_count += 1

# 0101...
u = ''.join(['1' if i % 2 == 0 else '0' for i in range(n)])

u_count = 0
for i, j in zip(s, u):
    if i == j:
        pass
    else:
        u_count += 1
print(min(t_count, u_count))


Measured memory_bytes: 4068
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int a,b;cin>>a>>b;
  int ans=a+b;
  if(ans>=24)ans-=24;
  
  cout(ans);
  
  return 0;
}

Measured memory_bytes: 125568
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define pb(a) push_back(a)
using namespace std;

typedef long long ll;

const int N=1e4+5,Mo=1e9+7;

int pwr(int x,int y) {
	int z=1;
	for(;y;y>>=1,x=(ll)x*x%Mo)
		if (y&1) z=(ll)z*x%Mo;
	return z;
}

int n,h[N],row[N],column[N],tot;
vector<int> son[N];

int build(int l,int r,int d) {
	int mn=1e9,cnt=0,v=++tot;
	fo(i,l,r) mn=min(mn,h[i]);
	column[v]=r-l+1;row[v]=mn-d;
	fo(i,l,r) cnt+=h[i]==mn;
	if (cnt==r-l+1) return v;
	int la=l-1;
	fo(i,l,r) 
		if (h[i]==mn) {
			if (la!=i-1) son[v].pb(build(la+1,i-1,mn));
			la=i;
		}
	if (la!=r) son[v].pb(build(la+1,r,mn));
	return v;
}

ll f[N],g[N];

void dfs(int x) {
	f[x]=1;g[x]=0;int c=column[x]-1;
	for(int y:son[x]) {
		dfs(y);
		g[x]=(g[x]*(f[y]+g[y])+f[x]*g[y])%Mo;
		f[x]=f[x]*f[y]%Mo;
		c-=column[y]-1;
	}
	g[x]=(g[x]*pwr(2,c)+f[x]*(pwr(2,c)-1))%Mo;
	f[x]=f[x]*pwr(2,row[x]-(x==1))%Mo;
}

int main() {
	scanf("%d",&n);
	fo(i,1,n) scanf("%d",&h[i]);
	int ans=1;
	fo(i,2,n-1) 
		if (h[i]>h[i-1]&&h[i]>h[i+1]) {
			ans=(ll)ans*pwr(2,h[i]-max(h[i-1],h[i+1]))%Mo;
			h[i]=max(h[i-1],h[i+1]);
		}
	build(1,n,0);dfs(1);
	ans=(ll)ans*(f[1]+g[1])%Mo;
	printf("%d\n",ans*2%Mo);
	return 0;
}

Measured memory_bytes: 512
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val hs = readLine()!!.split(" ").map { it.toInt() }.toMutableList()

    val inf = 1L shl 60
    val dp = Array(n) {inf}
    dp[0] = 0

    for (i in 0 until n) {
        var j = 1
        while (j <= k && i + j < n) {
            dp[i + j] = Math.min(dp[i + j], dp[i] + Math.abs(hs[i + j] - hs[i]))
            j++
        }
    }
    println(dp[n - 1])
}

Measured memory_bytes: 117164
#include <iostream>

using namespace std;

int main(){
	int n;
	while(cin >> n){
		int count = 0;
		for(int a = 0; a <= 9; ++a){
			for(int b = 0; b <= 9; ++b){
				for(int c = 0; c <= 9; ++c){
					for(int d = 0; d <= 9; ++d){
						if(a + b + c + d == n){
							++count;
						}
					}
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>

typedef long long ll;

int main(void){
  ll n;
  scanf("%lld",&n);

  ll a[n];
  for(int i = 0;i < n;i ++){
    scanf("%lld",&a[i]);
  }

  ll max = a[0] , ans = 0;

  for(int i = 0;i < n;i ++){
    if(max >= a[i]){
      ans += max - a[i];
    }

    else{
      max = a[i];
    }
  }

  printf("%lld\n",ans);

  return 0;
}

Measured memory_bytes: 3284
def main():
    data = list(map(int, input().split()))
    Xn = data[0]
    Yn = data[1]
    X = data[2]
    Y = data[3]

    Xs = list(map(int, input().split()))
    Ys = list(map(int, input().split()))

    mergin = list(range(X, Y))
    if not mergin:
        mergin.append(0)
    x_line = min(mergin)
    y_line = max(mergin)

    max_x = max(Xs)
    min_y = min(Ys)

    if (max_x < min_y):
        if ((max_x + min_y) // 2 in mergin):
            print('No War')
        else:
            print('War')
    else:
        print('War')

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
H, N = map(int, input().split())
A = []
B = []
for _ in range(N):
    a, b = list(map(int, input().split()))
    A.append(a)
    B.append(b)

dpl = H+max(A)
x = 10**10
dp = [x]*dpl
dp[0] = 0

for a, b in zip(A, B):
    for i in range(a, dpl):
        dp[i] = min(dp[i-a]+b, dp[i])
    for i in range(dpl-2, -1, -1):
        dp[i] = min(dp[i+1], dp[i])

print(dp[H])

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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define pli pair<long long,int>
#define pil pair<int,long long>
#define ll long long
#define el '\n'

using namespace std;

int n;
string s;
bool ada[10];

void sol(int cur, int byk){
    if (cur == n){
        cout << s << el;
        // cnt++;
        // s.pop_back();
        return;
    }
    int ncur = cur+1;
    for (int i=0;i<=byk;i++){
        s.pb(char(i + 'a'));
        if (i == byk) sol(ncur, byk + 1);
        else sol(ncur, byk);
        s.pop_back();
    }
}

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

    cin >> n;
    sol(0, 0);
    // cout << cnt << el;

    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std ;
int main()
{
    ios_base::sync_with_stdio(false) ;
    cin.tie(0);
    cout.tie(0);
    ll n ;
    cin >> n ;
    bool found = false ;
    ll res = 0 ;
    for(ll i = 1 ; i <= 10000000 ; i++)
    {
        res = res*10 + 7 ;
        res = res % n ;
        if(!res)
        {
            cout << i;
            found = true ;
            break ;
        }
    }
    if(!found) cout << -1  << endl ;
}


Measured memory_bytes: 3612
//============================================================================
// 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

//============================================================================
#define PI 3.14159265359
#define succ(x) ((x)+1)
#define pred(x) ((x)-1)
//============================================================================
void enter()
{
    int x,y,i,j;

    while(1){
        scanf("%d", &y);
        scanf("%d", &x);
        if (!x && !y)
            return;
        for (i=0; i<y; i++){
            for (j=0; j<x; j++)
                printf("#");
            printf("\n");
        }
        printf("\n");
    }
}
//============================================================================
int main(void)
{
    enter();
    return 0;
}
//============================================================================

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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 vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

vector<ll> A;
void dfs(string s) {
  // 終了条件
  if(s.size() == 11) {
    return;
  }

  // 判定
  A.push_back(stoll(s));

  // 再帰
  int a = char_to_int(s[s.size() - 1]);
  for(int i = a - 1; i <= a + 1; ++i) {
    if(i < 0 || i >= 10) continue;
    s.push_back('0' + i);
    dfs(s);
    s.pop_back();
  }
}

int main() {
  int K; cin >> K;
  for(int i = 1; i <= 9; ++i) {
    dfs(to_string(i));
  }
  sort(all(A));
  cout << A[K - 1] << endl;
}

Measured memory_bytes: 5412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n;
    cin >> n;
    ll ret = 0;
    ll sum = 0;
    while(n--){
        int a;
        cin >> a;
        if(a==0){
            ret += sum/2;
            sum = 0;
        }else{
            sum += a;
        }
        if(n==0){
            ret += sum/2;
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stddef.h>
#include <stack>
#include <queue>
 
using namespace std;
 
 
int main() {
    int n, x;
    int count;
    while (1) {
        count = 0;
        cin >> n >> x;
        if (n == 0 && x == 0) break;
        for (int i = 1; i <= n; i++) {
            for (int j = i+1; j <=n; j++) {
                for (int k = j+1; k <=n; k++) {
                    if (i != j&&j != k&&k != i&&i + j + k == x) count++;
                }
            }
        }
        cout << count << endl;
    }
}

Measured memory_bytes: 3088
def main():
    b = [list(map(int, input().split())) for _ in [0]*3]
    n = int(input())
    x = [int(input()) for _ in [0]*n]
    memo = [[False]*3 for _ in [0]*3]

    for i in x:
        for j in range(3):
            for k in range(3):
                if b[j][k] == i:
                    memo[j][k] = True
    for i in range(3):
        if memo[i][0] == memo[i][1] == memo[i][2] == True:
            print("Yes")
            return
        if memo[0][i] == memo[1][i] == memo[2][i] == True:
            print("Yes")
            return
    if memo[0][0] == memo[1][1] == memo[2][2] == True:
        print("Yes")
        return
    if memo[0][2] == memo[1][1] == memo[2][0] == True:
        print("Yes")
        return
    print("No")


main()


Measured memory_bytes: 3064
#include<stdio.h>
   
int main(){
   
int a,b,youbi,i;
int hi[13];


hi[0]=0;
hi[1] =31;
hi[2] =29;
hi[3] =31;
hi[4] =30;
hi[5] =31;
hi[6] =30;
hi[7] =31;
hi[8] =31;
hi[9] =30;
hi[10] =31;
hi[11] =30;
hi[12] =31;
 
while(1){
  scanf("%d %d\n", &a,&b);
  if(a==0){break;}
  youbi=0;
  for(i=0;i<a;i++){
    youbi=youbi+hi[i]; 
  }
  youbi =youbi +b+2;  
  youbi = youbi%7;

  switch(youbi){
    case 0:
       printf("Monday\n");
       break;
    case 1:
       printf("Tuesday\n");
       break;
    case 2:
       printf("Wednesday\n");
       break;
    case 3:
       printf("Thursday\n");
       break;
    case 4:
       printf("Friday\n");
       break;
    case 5:
       printf("Saturday\n");
       break;
    case 6:
       printf("Sunday\n");
       break;
    default:
       break;
  }
 
}
   
    return 0;
}

Measured memory_bytes: 588
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP_ll(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VREP_int(v) for(std::vector<int>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;


int main(int argc, const char * argv[]) {
	int n;
	cin >> n;
	vector<string> ss;
	string s;
	char cs[10];
	REP(i,n){
		cin >> s;
		REP(j,10){
			cs[j] = s[j];
		}
		sort(cs,cs+10);
		s = string(cs);
		ss.push_back(s);
	}
	sort(ss.begin(),ss.end());
	string curr = "";
	ll curr_len = 0;
	ll ret = 0;
	REP(i,n){
//		println(ss[i]);
//		cout << i << " : " << curr << " == " << ss[i] << " => "<< endl;
		if(curr == ss[i]){
			curr_len++;
		}else{
			if(curr_len>=2){
				ret += curr_len*(curr_len-1)/2;
			}
			curr = ss[i];
			curr_len = 1;
		}
	}
	if(curr_len>=2){
		ret += curr_len*(curr_len-1)/2;
	}


	println(ret);
	return 0;
}


Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  if(C<A){
    if(D<=A) cout << 0 << endl;
    else if(A<D && D<=B) cout << D-A << endl;
    else if(B<D) cout << B-A << endl;
  }
  else if(A<=C && C<B){
    if(A<D && D<=B) cout << D-C << endl;
    else if(D>B) cout << B-C << endl;
  }
  else if(B<=C) cout << 0 << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			string s = cin.Next();
			if (s[0] == s[1] && s[1] == s[2]) {
				Console.WriteLine("No");
			} else {
				Console.WriteLine("Yes");
			}
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private readonly Func<string> reader_;
		private string[] buf_;
		private int index_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

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

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

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

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#define mem(a,b) memset(a,b,sizeof(a))
#define IOSF ios::sync_with_stdio(false)
typedef long long LL;
using namespace std;
const int INF=0x3f3f3f3f;
const int MAX=10e6+5;
const int MOD=10e9+7;



int main()
{
    IOSF;
    LL a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a>=b&&a>=c){
        while(k--)
            a*=2;
        cout<<a+b+c<<endl;
    }
    else if(b>=a&&b>=c){
        while(k--){
            b*=2;
        }
        cout<<a+b+c<<endl;
    }
    else{
        while(k--){
            c*=2;
        }
        cout<<a+b+c<<endl;
    }

    return 0;
}
/*
7 5 3
*****
*...*
*****
*..**
*****
*.***
*****
4 4 0
****
*...
*.**
*.**
*/



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count =0;
		char c[] = sc.next().toCharArray();
		for (int i=0;i<3;i++) {
			if (c[i]=='1') {
				count ++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define frw(i, a, b) for(int i = a; i < b; i++)
#define fi first
#define se second
#define pb push_back
#define in insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) int(a.size())
#define pii pair<int, int>
#define piii pair<int, pii>
#define pll pair<ll, ll>
#define plll pair<ll, pll>
#define vpii vector<pii>
#define vpiii vector<piii>
#define vpll vector<pll>
#define vplll vector<plll>
#define mod 1000000007

int modInverse(ll a, ll m) 
{ 
    ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) 
      return 0; 
    while (a > 1) 
    { 
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    } 
    if (x < 0) 
       x += m0; 
    return x; 
} 


int main() {
	int n;
	cin>>n;
	ll a[n];
	frw(i,0,n)
	cin>>a[i];
	vector<bool> ans(n,false);

	for(int i=n-1;i>=0;i--)
	{
		int cnt=0;
		for(int j=1;j*(i+1)-1<n;j++)
		{
			if(ans[j*(i+1)-1])
				cnt++;
		}
		if(cnt%2!=a[i])
			ans[i]=true;
	}
	int cnt=0;
   frw(i,0,n)
   if(ans[i])
   	cnt++;

   cout<<cnt<<endl;
   frw(i,0,n)
   if(ans[i])
   	cout<<i+1<<endl;
}


Measured memory_bytes: 2560
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int K = in.Int();
            String S = in.next();
            if (S.length() > K) {
                S = S.substring(0, K) + "...";
            }
            out.println(S);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 36664
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cout << #v "=" << (v) << endl;
#define ppa(v) cout << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;

int main() {
  ll n;cin>>n;
  int ans = 0;
  for(ll i=1;i<=n;i++) if (i * i <= n) ans = i * i;
  cout << ans << endl;
}


Measured memory_bytes: 256
// Contest.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include"iostream"
#include"string"
#include"vector"
#include"algorithm"

using namespace std;

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

	int memo = a[0];
	int ans = 1;
	for (int i = 1; i < N; i++) {
		if (memo<= a[i]) {
			ans++;
			memo = a[i];
		}
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 256
#Code by Sounak, IIESTS
#------------------------------warmup----------------------------

import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading



threading.stack_size(10**8)
sys.setrecursionlimit(300000)

BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
    
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
     
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
  
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

#-------------------game starts now-----------------------------------------------------
mod=10**9+7
n=int(input())
c=n//3
r=0
for i in range (c,0,-1):
    avl=n-i*3
    r+=math.factorial(avl+i-1)//(math.factorial(i-1)*math.factorial(avl))
    r%=mod
print(r)

Measured memory_bytes: 78188
n = int(input())
T = [0] + list(map(int, input().split()))
V = [0] + list(map(int, input().split())) + [0]

unit = 2

acumT = [0] * (n + 1)
for i in range(n):
  acumT[i+1] = acumT[i] + T[i+1]
  
PV = [0] * (sum(T) * unit + 1)
for p in range(1, n + 1):
  t1 = acumT[p-1]
  t2 = acumT[p]
# for (t1, t2), (v1, v2, v3) in zip(zip(acumT, acumT[1:]), zip(V, V[1:], V[2:])):
  for i in range(t1 * unit, t2 * unit + 1):
    ii = i / unit 
    PV[i] = min([ii - acumT[k] + V[k] for k in range(0, p)] + [V[p]] + [-ii + acumT[m] + V[m+1] for m in range(p, n+1)])

area = sum((i + j) / unit / 2 for i, j in zip(PV, PV[1:]))  
print(area)

Measured memory_bytes: 3700
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdlib>
using namespace std;

int main() {
	int a, b, k, i,count=0;
	vector<int> ans;
	cin >> a >> b >> k;
	for (i = 1; i <= 100; i++) {
		if ((a%i == 0) && (b%i == 0)) {
			ans.push_back(i);
			count++;
		}
	}
	cout << ans[count - k];
	return(0);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;

const int inf = 2147483647;
/*
 n : 葉の数
 N : 全ノードの数
 D[] : 木構造をリストで表現したもの
*/

class Segment_Tree{
private:
  int N;
  vector<int> D;
public:
  Segment_Tree(int n){
    N = 1;
    while(N < n) N *= 2;
    D.resize(2*N-1);
    for(int i=0;i<2*N-1;++i){
      D[i] = inf;
    }
  }
  
  void update(int k,int x){
    k += N - 1;
    D[k] = x;
    while(k > 0){
      k = (k-1)/2;
      D[k] = min(D[k*2+1],D[k*2+2]);
    }
  }
  
  int findMin(int a,int b){
    return query(a,b+1,0,0,N);
  }
  
  int query(int a,int b,int k,int l,int r){
    if(r <= a || b <= l) return inf;
    if(a <= l && r <= b) return D[k];
    int m = (l+r)/2;
    return min(query(a,b,2*k+1,l,m),query(a,b,2*k+2,m,r));    
  }
};

int main(){
  int n;
  int WINDOW;
  int start,end;
  
  // 一列目読み込み
  scanf("%d %d",&n,&WINDOW);
  // セグメントツリー初期化
  Segment_Tree st(n);
  int* array = new int[n+1];
  // 二列目読み込み
  for(int i = 0; i < n; i++)scanf("%d",&array[i]);
  
  // ここから事前処理
  // WINDOWサイズ分あらかじめ入れておく
  for(int i=0; i < WINDOW; i++) st.update(i, array[i]);
    
  int result;
  result = st.findMin(0,WINDOW);
  printf("%d",result);
  if (n != WINDOW){
      printf(" ");
  }else{
      printf("\n");
  }
  // 事前処理終わり

  for (int i = WINDOW; i < n; i++){
      st.update(i,array[i]);
      
      // 最小値求める範囲
      start = i - WINDOW;
      end = WINDOW + (i - WINDOW);

      result = st.findMin(start+1, end);
      printf("%d",result);
      if(i != n-1){
        printf(" ");
      }else{
          printf("\n");
      }
  }
  
  
  
 
  return 0;
}


Measured memory_bytes: 14532
H, W, K = map(int, input().split())
mod = 10**9 + 7
draw_array = [1, 1, 2, 3, 5, 8, 13, 21, 34]

if W == 1:
    print(1)
    exit()

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

ans_array[0][0] = draw_array[W - 1]
ans_array[0][1] = draw_array[W - 2]

for i in range(1, H):
    for w in range(W):
        if w == 0:
            ans_array[i][w] = (ans_array[i - 1][w] * draw_array[W - 1]) + (
                ans_array[i - 1][w + 1] * draw_array[W - 2])
            ans_array[i][w] = ans_array[i][w] % mod
        elif w == W - 1:
            ans_array[i][w] = (ans_array[i - 1][w] * draw_array[W - 1]) + (
                ans_array[i - 1][w - 1] * draw_array[W - 2])
            ans_array[i][w] = ans_array[i][w] % mod
        else:
            from_left = ans_array[i - 1][w - 1] * (
                draw_array[w - 1] * draw_array[W - w - 1])
            from_left = from_left % mod
            from_center = ans_array[i - 1][w] * (
                draw_array[w] * draw_array[W - w - 1])
            from_center = from_center % mod
            from_right = ans_array[i - 1][w + 1] * (
                draw_array[w] * draw_array[W - w - 2])
            from_right = from_right % mod
            ans_array[i][w] = (from_left+from_center+from_right) % mod

# print(ans_array)
print(ans_array[H-1][K-1])


Measured memory_bytes: 38256