akhauriyash/Code-Regression huggingface dataset:
#include <array>
#include <iostream>

using namespace std;

int w, h;

using P = pair<int, int>;
P s, g;
const int INF = 10e6;

template <typename M>
bool update(P& p, M& m, pair<int, int> d) {
  bool flag = false;
  while (true) {
    if (p.first + d.first < h &&
        p.first + d.first >= 0 &&
        p.second + d.second < w &&
        p.second + d.second >= 0) {
      if (m[p.first + d.first][p.second + d.second] == 1) {
        if (!flag) return false;
        m[p.first + d.first][p.second + d.second] = 0;
        return true;
      } else {
        p.first += d.first;
        p.second += d.second;
        flag = true;
        if (p.first == g.first && p.second == g.second) return true;
      }
    } else {
      return false;
    }
  }
}

template <typename M>
void dfs(const P& p, const M& m, int& ans, int dps) {
  if (dps > 10) return;
  if (p.first == g.first && p.second == g.second) {
    if (ans > dps) {
      ans = dps;
      return;
    }
  }
  // up
  {
    P new_p = p;
    M new_m = m;
    if (update(new_p, new_m, {1, 0})) {
      dfs(new_p, new_m, ans, dps + 1);
    }
  }
  // down
  {
    P new_p = p;
    M new_m = m;
    if (update(new_p, new_m, {-1, 0})) {
      dfs(new_p, new_m, ans, dps + 1);
    }
  }
  // left
  {
    P new_p = p;
    M new_m = m;
    if (update(new_p, new_m, {0, -1})) {
      dfs(new_p, new_m, ans, dps + 1);
    }
  }
  // right
  {
    P new_p = p;
    M new_m = m;
    if (update(new_p, new_m, {0, 1})) {
      dfs(new_p, new_m, ans, dps + 1);
    }
  }
}

int main() {
  while (true) {
    array<array<int, 20>, 20> m;
    cin >> w >> h;
    if (w == 0 && h == 0) break;
    
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        cin >> m[i][j];
        if (m[i][j] == 2) {
          s.first = i;
          s.second = j;
        } else if (m[i][j] == 3) {
          g.first = i;
          g.second = j;
        }
      }
    }

    int ans = INF;
    dfs(s, m, ans, 0);
    if (ans != INF) {
      cout << ans << endl;
    } else {
      cout << -1 << endl;
    }
  }
}

Measured memory_bytes: 3044
/*@sh*/
#include<bits/stdc++.h>
using namespace std;
#include<cstdio>
#define pi 3.141592653589
#define pb push_back
#define ld long double
#define rem 1000000007
#define F first
#define S second
#define pii pair<long long,long long>
#define el "\n"
#define sp " "
typedef long long ll;
ll  p = 1000000007;
ll Pow(ll,ll,ll);
ll Pow(ll a,ll b,ll p){
	if(b==0) return 1;
	return !(b%2) ? (Pow(a,b/2,p)%p)*(Pow(a,b/2,p)%p)%p : (a%p)*(Pow(a,b-1,p))%p;
}   
main()
{ 
	// fast io
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);ll i; 
	ll n;
	cin>>n;
	ll dp[n][3];
	vector <ll> a(n),b(n),c(n);
	for(i=0;i<n;i++)
	{
	cin>>a[i]>>b[i]>>c[i];
	dp[i][0]=dp[i][1]=dp[i][2]=1e15;}
	dp[0][0]=a[0];dp[0][1]=b[0];dp[0][2]=c[0];
	for(i=1;i<n;i++)
	{
		dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
		dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
		dp[i][2]=max(dp[i-1][1]+c[i],dp[i-1][0]+c[i]);
	}
	ll m=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	cout<<m<<el;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
typedef long long ll;

using namespace std;

int main() {

  int a,b;
  cin >> a >> b;

  cout << a * b  << " " << 2 * (a + b) << "\n";
  

  return(0);
}


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

#define N 1000010 

using namespace std;

char s[N];

queue <int> q;

int main() {
    scanf("%s", s + 1);
    int n = strlen(s + 1);
    if (s[1] == '0' || s[n] == '1') {
        puts("-1");
        return 0;
    }
    for (int i = 1; i < n; i ++ ) {
        if (s[i] != s[n - i]) {
            puts("-1");
            return 0;
        }
    }
    for (int i = 1; i <= n; i ++ ) {
        if (s[i] == '1') {
            q.push(i);
        }
    }
    q.push(n);
    for (int i = 1; i < n; i ++ ) {
        if (i == q.front()) {
            q.pop();
        }
        printf("%d %d\n", i, q.front());
    }
    return 0;
}

Measured memory_bytes: 1920
my ($K) =split(/ /,<>);

my $max = 10**6;
my $count = 0;
my $keta  =7;
my $num =0;
for(my $i=0;$i<$max;$i++){
    $count++;
    $num = $num + $keta;
    $num = $num%$K;
    if($num == 0){last;}
    $keta = ($keta * 10)%$K; 
}
if($count == $max ){ $count = -1;}
print "$count";

Measured memory_bytes: 4808
/*
  テヲツ鳴?・ツュツ療」ツ?ョテ・ツ閉湘ゥツ。ツ古」ツ??
  テ・ツ渉ウテヲツ可凝」ツつソテ」ツつ、テ」ツδ療」ツ?凝・ツキツヲテヲツ可凝」ツつソテ」ツつ、テ」ツδ療」ツ?ョテ」ツ?ゥテ」ツ?。テ」ツつ嘉」ツ?凝」ツ?ョテヲツ鳴?・ツュツ療」ツつ津ゥツ?催・ツ按療」ツ?ィテ」ツ?療」ツ?ヲテァツ板ィテヲツ?湘」ツ?療」ツ??ァツ崢エテ・ツ可催」ツ?ョテヲツ可凝」ツ?ィテヲツャツ。テ」ツ?ョテヲツ可凝」ツつ津ヲツッツ氾ィツシツε」ツ??
 */

import java.util.*;
public class Main {
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args) {
	char[] right = {'y', 'u', 'i','o', 'p', 'h', 'j', 'k', 'l', 'n', 'm'};

	while(kbd.hasNext()){
	    String word = kbd.next();
	    if(!word.equals("#")){
		String hand = "";
		int p = 0;
		int count = 0;
		char c = word.charAt(p);

		for(p=0; p<word.length(); p++){
		    int a=0;
		    c = word.charAt(p);
		    while(a<right.length && c!=right[a]) a++;

		    //テヲツャツ。テ」ツ?ョテ・ツ?・テ・ツ環崚」ツ?古・ツ渉ウテヲツ可凝」ツ??」ツ?」テ」ツ??
		    if(a<right.length && c == right[a]){
			//テァツ崢エテ・ツ可催」ツ?ョテヲツ可凝」ツ?ッ...
			if(hand.equals("l")) { hand="r"; count++; }
			else hand = "r";
		    }
		    //テヲツャツ。テ」ツ?ョテ・ツ?・テ・ツ環崚」ツ?古・ツキツヲテヲツ可凝」ツ??」ツ?」テ」ツ??
		    else {
			//テァツ崢エテ・ツ可催」ツ?ョテヲツ可凝」ツ?ッ...
			if(hand.equals("r")) { hand="l"; count++; }
			else hand = "l";
		    }

		}

		System.out.println(count);
	    }
	}
    }
}

Measured memory_bytes: 21368
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
using namespace std;
using ll = unsigned long long;
using p = pair<int, int>;

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, 0, N)
    {
        cin >> a[i];
    }

    sort(a.begin(), a.end(), greater<int>());

    int alice = 0;
    int bob = 0;

    rep(i, 0, N)
    {
        if (i % 2 == 0)
        {
            alice += a[i];
            continue;
        }
        bob += a[i];
    }

    cout << alice - bob << endl;

    return 0;
}


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

using namespace std;

const int maxn = 1e5+10;
int dp[maxn];
int h[maxn];
int n, k;

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

	cin >> n >> k;
	for(int i=0; i<n; i++)
		cin >> h[i];

	for(int i=n-2; i>=0; i--){
		dp[i] = 1e9;
		for(int j=i+1; j<i+k+1; j++){
			if(j > n-1)
				break;
			dp[i] = min(dp[i], abs(h[i]-h[j]) + dp[j]);
		}
	}

	cout << dp[0] << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int a[300000],n;
int main(){
	cin>>n;
	for(int i=0;i<n*3;i++)cin>>a[i];
	sort(a,a+n*3);
	long long ans=0;
	for(int i=n*3-2;i>=n;i-=2)ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

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

int	main()
{
    string S;
    cin >> S;
    int N = S.size();
    int max_len = 0;
    set<char> ATGC_set({'A', 'T', 'G', 'C'});
    for (int i = 0; i < N; ++i) {
        int len = 0;
        for (int j = i; j < N; ++j) {
            if (ATGC_set.count(S.at(j)))
                ++len;
            else
                break;
        }
        if (max_len < len)
            max_len = len;
    }
    cout << max_len << endl;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    int N; cin >> N;
    map<string,int> m;
    int mx=0;
    rep(i, N){
        string s; cin >> s;
        m[s];
        m[s]++;
        mx = max(mx, m[s]);
    }

    for(auto a: m){
        if(mx == a.second) cout << a.first << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 27904
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
const int mm=1e6;
ll d[mm];
int main()
{
	ll n,m,i,j; string s,ss,sss;ll k=0;
	cin>>s;
	for(i=0;i<s.size()/2;i++)
	{
		if(s[i]==s[s.size()-1-i])
		continue;
		else 
		k=1;
	}
	ss="";  sss="";
	for(i=0;i<s.size()/2;i++)
	{
		ss=ss+s[i];
	}
	for(i=s.size()/2+1;i<s.size();i++)
	{
		sss+=s[i];
	}
	for(i=0;i<ss.size()/2;i++)
	{
		if(ss[i]==ss[ss.size()-1-i])
		continue;
		else 
		k=1;
	}
	for(i=0;i<sss.size()/2;i++)
	{
		if(sss[i]==sss[sss.size()-1-i])
		continue;
		else 
		k=1;
	}
//	cout<<s<<endl<<ss<<endl<<sss<<endl;
	if(k)printf("No\n");
	else printf("Yes\n");
	


}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

   
    (a, b, c, k) = [int(e) for e in lines[0].split(' ')]

    return (a, b, c, k)


def solve(a, b, c, k):
    
    result = None
    if a >= k:
        result = 1 * k
    elif a + b >= k:
        result = 1 * a
    elif a + b + c >= k:
        result = 1 * a + 0 * b - 1 * (k - (a + b))
    else:
        result = 1 * a + 0 * b - 1 * c

    return result

    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Measured memory_bytes: 62220
#define rep(i,n) for (int i=0;i<n;i++)
#include <vector>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const long long INF = 1LL<<60;

int main(){
  
  int N,M;
  bool torf=true;
  cin >> N >> M;
  
  vector<int> c(N,0);
  vector<bool> torf2(N,false);
  if(M==0){
    if(N!=1)
    	c.at(0)=1;
    
    rep(i,N){  
    	cout << c.at(i);
  }
     
  
  cout << endl;
  }
    
 else{ 
  rep(i,M){
    int a,b;
    cin >> a >> b;
   
    if(N!=1 && a==1 && b==0)
      torf=false;
    else if(torf2.at(a-1)==false){
      c.at(a-1)=b;
      torf2.at(a-1)=true;
    }
    else if(torf2.at(a-1)==true && c.at(a-1)!=b)
      torf=false;
    
    
  }
    
 
  
  
  
  
  if(N!=1 && c.at(0)==0)
  	c.at(0)=1;
  if(torf==false)
    cout << "-1" << endl;
  else{
    rep(i,N){  
    	cout << c.at(i);
  }
     
  
  cout << endl;
}
 }
  
}

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

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

char sep[2] = {' ', '\n'};

int main() {
  int i, j, k;
  int n;
  int a[110];

  cin >> n;
  rep(i, n) cin >> a[n - i - 1];
  rep(i, n) cout << a[i] << sep[(i == n - 1)];
  cout << flush;
  
  return 0;
}
  

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
	int h, w, k;
	cin >> h >> w >> k;
    vector<string> c(h);
    rep(i,h) cin >> c[i];
    int ans = 0;
    rep(is,1<<h) rep(js,1<<w) {
        int cnt = 0;
        rep(i,h) rep(j,w) {
            if (is>>i&1) continue;
            if (js>>j&1) continue;
            if (c[i][j] == '#') cnt++;
        }
        if (cnt == k) ans++;
    }
    cout << ans << "\n";
	return 0;
}


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

#define M 1046527
#define NIL  (-1)
#define L 14

char H[M][L];

int getChar(char ch) {
    if(ch ==   'A') return 1;
    else if (ch == 'C') return 2;
    else if (ch == 'G') return 3;
    else if (ch == 'T') return 4;
    else return 0;
}

long long getKey(char str[]) {
    long long sum = 0,p = 1, i;
    for (i = 0; i < strlen(str); i++) {
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key) {return key % M; }
int h2(int key) {return 1 + (key % (M - 1));}

int find(char str[]) {
    long long key,i,h;
    key = getKey(str);
    for (i = 0;; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h],str) == 0) return 1;
        else if (strlen(H[h]) == 0) return 0;
    }
    return 0;
}

int insert(char str[]) {
    long long key,i,h;
    key = getKey(str);
    for (i = 0; ; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h],str) == 0) return 1;
        else if (strlen(H[h]) == 0) {
            strcpy(H[h],str);
            return 0;
        }
    }
    return 0;
}

int main() {
    int i,n = 0;
    char str[L],com[9];
    for (i = 0; i < n; i++) H[i][0] = '\0';
    scanf("%d",&n);
    for (i = 0; i < n; i++) {
        scanf("%s %s",com,str);
        //printf("com: %s str: %s\n",com,str);
        if (com[0] == 'i') {
            insert(str);
        } else {
            if( find(str) ) {
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 16004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main(void){
	string s; cin >> s;
	string a = s.substr(0, 5);
	string b = s.substr(6, 7);
	string c = s.substr(14);
	cout << a << " " << b << " " << c << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
  
    int n,k,a={0},i; 
      
    scanf("%d%d",&n,&k);
   
    int h[n+1];
  
    for(i=0;i<n;i++) scanf("%d",&h[i]);
        
    for(i=0;i<n;i++){
        if(h[i]>=k) a=a+1;
    }
  
    printf("%d",a);
  
    return 0;
}  

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
string s,t;
void blue(){
	cout<<"No"<<endl;
	exit(0);
}
void red(){
	cout<<"Yes"<<endl;
	exit(0);
}
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>s>>t;
	if(t.size()!=s.size()+1) blue();
	for(int i=0;i<s.size();i++)
		if(s[i]!=t[i])
			blue();
	red();
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define LLI long long int
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}

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

  string s; cin >> s;

  cout << count(ALL(s), '2') << endl;
  
  return 0;
}


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

#define SIZE 100005
#define PI acosl(-1) //3.14159265358979323846264338327950L 
#define rep(i, N) for (i = 0; i < N; i++) //制御変数iを用いてN回転
#define array(N, t) (t*)calloc(N, sizeof(t)) //t型N要素の1次元配列を動的確保後0クリア(freeを忘れずに)
#define zero(a); {int iter; rep(iter, sizeof(a)/sizeof((a)[0])) (a)[iter]=0;} //1次元配列aのゼロ初期化?

typedef long long ll; typedef long double ld;
typedef struct node { int data; struct node *next; } Node;

Node *list[SIZE];
int queue[SIZE]; int q_head = 0, q_tail = 0;

void print_log(); //とりあえず文字を出力してどこまで実行できているか確認(for debug)
void printa_int(int *a, int size); //int型の1次元配列aを出力(for debug)
void printl_int(int size); //リンクリストを出力(for debug)
Node* add_node(int i, int data); void free_list(Node* head);
int queue_empty(); int queue_full();
void enqueue(int data); int dequeue();
ll* factorize(ll N); //Nを素因数分解、得られる配列は素因数,指数,素因数,…となっている(添字はintで指定する必要あり?)
void check_factorization(ll *fact); //素因数分解を表示(for debug)

int main() {
    int i, x, sum = 0;
    rep(i, 5) {
        scanf("%d", &x);
        sum += x;
    }
    printf("%d\n", 15 - sum);
    return 0;
}

void print_log() {
    printf("=== print log ===\n");
}
void printa_int(int *a, int size) {
    int i;
    printf("[");
    for (i = 0; i < size; i++)
        printf("%d, ", a[i]);
    printf("]\n");
}
void printl_int(int size) {
    int i;
    Node *t;
    rep(i, size) {
        printf("[%d] ", i);
        for (t = list[i]; t; t = t->next) printf("%d, ", t->data);
        printf("\n");
    }
}
Node* add_node(int i, int data) {
    if (!list[i]) {
        list[i] = (Node*)malloc(sizeof(Node*));
        list[i]->data = data;
    } else {
        Node *t;
        t = list[i];
        list[i] = (Node*)malloc(sizeof(Node*));
        list[i]->data = data;
        list[i]->next = t;
    }
    return list[i];
}
void free_list(Node* head) {
    Node *prev = NULL, *t = head;
    while (t) {
        prev = t;
        t = t->next;
        free(prev);
    }
}
int queue_empty() {
    return q_head == q_tail;
}
int queue_full() {
    return (q_head - 1) % SIZE == q_tail % SIZE;
}
void enqueue(int data) {
    if (queue_full()) {
        printf("full!\n");
        return;
    }
    queue[q_tail++] = data;
    q_tail %= SIZE;
}
int dequeue() {
    if (queue_empty()) {
        printf("empty!\n");
        return -444444;
    }
    int data = queue[q_head++];
    q_head %= SIZE;
    return data;
}
ll* factorize(ll N) {
    ll *res = array(((sqrt(N) + 1) * 2), ll);
    ll i, x = N;
    int count = 0;
    for (i = 2; i * i <= N; i++) {
        ll e = 0;
        while (x % i == 0) {
            x /= i;
            e++;
        }
        if (e > 0) {
            res[count * 2] = i;
            res[count * 2 + 1] = e;
            count++;
        }
    }
    if (x > 1) {
        res[count * 2] = x;
        res[count * 2 + 1] = 1;
    }
    return res;
}
void check_factorization(ll *fact) {
    int i = 1;
    printf("%lld^%lld", fact[0], fact[1]);
    while (fact[i * 2] > 0) {
        printf(" * %lld^%lld", fact[i * 2], fact[i * 2 + 1]);
        i++;
    }
    printf("\n");
}

Measured memory_bytes: 2156
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        Integer n = scanner.nextInt();
        List<Integer> inputs = new ArrayList<>();
        IntStream.range(0, n).forEach(i -> {
            inputs.add(scanner.nextInt());
        });

        Integer size = inputs.size();
        Integer max = null;
        Integer min = inputs.get(0);
        for (int i = 1; i < size; i++) {
            Integer input = inputs.get(i);
            max = max == null || max < input - min ? input - min : max;
            min = min < input ? min : input;
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 108056
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1e9+7
using namespace std;
typedef long long ll;

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

    int a=1;
    int b=0;
    char tmp = s[0];
    char c;
    for(int i=1;i<4;i++){
        if(s[i]==tmp){
            a++;
        }else if(b==0){
            c = s[i];
            b++;
        }else if(s[i]==c)
            b++;
    }

    if(a==2&&b==2)
        cout<<"Yes";
    else
    {
        cout<<"No";
    }
    

}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,i;
	int w[100];
	int sum=0,sum2=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&w[i]);
		sum+=w[i];
	}
	i=0;
	while(sum2<sum/2){
		sum2+=w[i];
		i++;
	}
	if(sum-sum2>=sum2-w[i-1])
		printf("%d",sum2-sum+sum2);
	else
		printf("%d",sum-sum2+w[i-1]-sum2+w[i-1]);
	return 0;
}

Measured memory_bytes: 128
def f(n)
    return n if n < 3
    if n.odd?
        ( (f(n-2) - 1) / 4 * 3 + 1 ) * 4 + 1
    else
        ( (f(n-1) - 1) / 4 * 3 + 1 ) * 2
    end
end
        
puts f($_.to_i) while gets

Measured memory_bytes: 6088
class Dice
	def initialize(array)
		@a = Array.new(array)
	end
	
	def rotate(direction)
		if direction == "N" then
			tmp = @a[0]
			@a[0] = @a[1]
			@a[1] = @a[5]
			@a[5] = @a[4]
			@a[4] = tmp
		elsif direction == "S" then
			tmp = @a[0]
			@a[0] = @a[4]
			@a[4] = @a[5]
			@a[5] = @a[1]
			@a[1] = tmp
		elsif direction == "E" then
			tmp = @a[0]
			@a[0] = @a[3]
			@a[3] = @a[5]
			@a[5] = @a[2]
			@a[2] = tmp
		elsif direction == "W" then
			tmp = @a[0]
			@a[0] = @a[2]
			@a[2] = @a[5]
			@a[5] = @a[3]
			@a[3] = tmp
		end
	end
	
	def get_top
		@a[0]
	end
	
	def get_right
		@a[2]
	end
	
	def get_front
		@a[1]
	end
	
	def get_left
		@a[3]
	end
	
	def get_bottom
		@a[5]
	end
	
	def get_rear
		@a[4]
	end
end

def array_to_i(a)
	0.upto(a.length) {|i|
		a[i] = a[i].to_i
	}
	return a
end

a = STDIN.gets.chop.split(" ")
a = array_to_i(a)
dice = Dice.new(a)

q_num = STDIN.gets.to_i

0.upto(q_num - 1) {
	q = STDIN.gets.chomp.split(" ")
	q = array_to_i(q)
	
	if dice.get_left == q[1] then
		dice.rotate("E")
		dice.rotate("S")		
	elsif dice.get_right == q[1] then
		dice.rotate("W")
		dice.rotate("S")
	else
		until dice.get_front == q[1] do
			dice.rotate("S")
		end
	end
	
	until dice.get_top == q[0] do
		dice.rotate("E")
	end
	
	print dice.get_right, "\n"
}


Measured memory_bytes: 6872
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <typename T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const vector<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
void ce(void){cerr << '\n';}
template <typename T>
void ce(const T n){cerr << n << '\n';}
template <typename T>
void cesp(const T n){cerr << n << ' ';}
template <typename T>
void ce(initializer_list<T> v){for(T i : v) cesp(i); ce();}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

int main(void){
	ll n, k;
	cin >> n >> k;
	Vec p(n), c(n);
	rep(i, n) cin >> p[i];
	rep(i, n) p[i]--;
	rep(i, n) cin >> c[i];

	Vec2<P> dp(n, VecP(1050));

	rep(j, 1050) {
		rep(i, n) {
			if (!j) {
				dp[i][j] = {p[i], c[p[i]]};
				continue;
			}
			P t = dp[i][j - 1];
			dp[i][j] = {dp[t.fs][j - 1].fs, t.sc + dp[t.fs][j - 1].sc};
		}
	}

	ll ans = -LINF;
	rep(i, n) {
		ll sum = 0, pos = i;
		rep(j, min(k, n)) {
			pos = p[pos];
			sum += c[pos];
			chmax(ans, sum);
		}

		if (k <= n) continue;

		sum = 0;
		pos = i;
		ll tmp = k - n;
		ll t = tmp;
		ll cnt = 0;
		while (t) {
			if (t & 1) {
				sum += dp[pos][cnt].sc;
				pos = dp[pos][cnt].fs;
			}
			cnt++;
			t >>= 1;
		}
		chmax(ans, sum);
		rep(j, n) {
			pos = p[pos];
			sum += c[pos];
			chmax(ans, sum);
		}
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 85624
#include<cstdio>

int main(){
    int count[100];
    for(int i = 0; i < 100; i++){
        count[i] = 0;
 	}
    char ch;
    while(scanf("%c",&ch) != EOF){
        if(ch >= 'a' && ch <= 'z'){
            count[ch-'a']++;
        }
        else if(ch >= 'A' && ch <= 'Z'){
            count[ch-'A']++;
        }
    }
    for(int j = 0;j < 26; j++){
        printf("%c : %d\n",j + 'a',count[j]);
    }
    return 0;
}


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

int a[3];

int main(){
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  if(a[0] == 5 && a[1] == 5 && a[2] ==7){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<complex>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
#define EPS (long double) 1e-8
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};

vector<int> card;
vector<vector<int> > g;
vector<int> match;
vector<bool> used;

bool euclid(int a, int b) {
	if(a < b) swap(a, b);
	if(a % b == 0) return !(b == 1);
	else {
		return euclid(b, a % b);
	}
}

bool dfs(int v) {
	used[v] = true;
	REP(i, g[v].size()) {
		int u = g[v][i], w = match[u];
		if(w < 0 || !used[w] && dfs(w)) {
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}

int main(void) {
	while(true) {
		int m, n;
		cin>>m>>n;
		if(m == 0 && n == 0) break;
		card.resize(0);
		card.resize(m + n);
		g.resize(0);
		g.resize(m + n);
		match.resize(0);
		match.resize(m + n);
		used.resize(0);
		used.resize(m + n);
		REP(i, m) cin>>card[i];
		REP(i, n) cin>>card[m + i];
		REP(i, m) {
			FOR(j, m, m + n) {
				if(euclid(card[i], card[j])) g[i].pb((int)j);
			}
		}
		FOR(i, m, m + n) {
			REP(j, m) {
				if(euclid(card[i], card[j])) g[i].pb((int)j);
			}
		}
		int res = 0;
		REP(i, m + n) match[i] = -1;
		REP(v, m + n) {
			if(match[v] < 0) {
				REP(i, m + n) used[i] = false;
				if(dfs((int)v)) {
					++res;
				}
			}
		}
		cout<<res<<endl;
	}
}

Measured memory_bytes: 4428
S=input()
d=[0]*13
d[0]=1
for i in range(len(S)):
  n=[0]*13
  for j in range(13):
    for k in range(10):
      if S[i]=='?' or int(S[i])==k: n[(10*j+k)%13]+=d[j]
  for j in range(13): d[j]=n[j]%(10**9+7)
print(d[5])

Measured memory_bytes: 44224
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N; cin >> N;
  vector<int64_t> dp(N);
  int H[N]; for (int &h: H) cin >> h;
  for (int i{1}; i < N; ++i)
    dp[i] = min(dp[i - 1] + abs(H[i] - H[i - 1]), i >= 2 ? dp[i - 2] + abs(H[i] - H[i - 2]) : int64_t(1e15));
  cout << dp[N - 1];}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

inline int n_base(int n, int base){
    int ret = 0;
    int d = floor(log(n)/log(base));
    for(int i = d; i >= 0; i--){
        ret += (int)(n/pow(base,i))*pow(10,i);
        n %= (int)pow(base,i);
    }
    return ret;
}

int N;
signed main(){
    cin >> N;
    int ans = 0;
    bitset<3> b = 0;
    
    rep(i,pow(4,10)){
        string s = to_string(n_base(i,4));
        b = 0;
        rep(j, s.length()){
            if(s[j]=='1'){
                s[j] = '3'; b.set(0);
            }else if(s[j]=='2'){
                s[j] = '5'; b.set(1);
            }else if(s[j]=='3'){
                s[j] = '7'; b.set(2);
            }else{
                b = 0; break;
            }
        }
        if(!b.all()) continue;
        if(N < stoll(s)) break;
        ans++;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
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 long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    string s;
    cin >> s;
    ll ans = 0;
    
    for (int i = 0; i < 4; i++){
        if(s[i] == '+')ans += 1;
        else ans += -1;
    }
    
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt(), W = sc.nextInt();
		int A[][] = new int[H][W], B[][]= new int[H][W], C[][]=new int[H][W];
		for(int i=0;i<H;i++) for(int j=0;j<W;j++) A[i][j]=sc.nextInt();
		for(int i=0;i<H;i++) for(int j=0;j<W;j++) B[i][j]=sc.nextInt();
		sc.close();
		for(int i=0;i<H;i++) for(int j=0;j<W;j++) C[i][j]=Math.abs(A[i][j]-B[i][j]);
		
		//c配列だけ見て、値の符号をうまく決めて、合計で０に近づけられる道を決める。
		//そんなうまい方法が見つからない→DP
		
		boolean dp[][][] = new boolean[H][W][80*(H+W+5)]; //dp[h][w][k] := (h,w)にいるときに和kが作れるかいなか
		//initialize
		dp[0][0][C[0][0]]=true;
		for(int h=0;h<H;h++) {
			for(int w=0;w<W;w++) {
				for(int k=0;k<=80*(h+w+1);k++) {
					if(dp[h][w][k]==true) {
						//h+1
						if(h!=H-1) {
							int hi = k + C[h+1][w];
							int lo = Math.abs(k - C[h+1][w]);
							dp[h+1][w][hi]=dp[h+1][w][lo]=true;
						}
						//w+1
						if(w!=W-1) {
							int hi = k + C[h][w+1];
							int lo = Math.abs(k - C[h][w+1]);
							dp[h][w+1][hi]=dp[h][w+1][lo]=true;
						}
					}
				}
			}
		}		
		for(int i=0;i<dp[0][0].length;i++) {
			if(dp[H-1][W-1][i]==true) {
				System.out.println(i);
				return;
			}
		}
		sc.close();
	}
}


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

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> l(N);
    for (int i = 0; i < N; i++)
    {
        cin >> l.at(i);
    }
    
    sort(l.begin(), l.end());
    reverse(l.begin(), l.end());
    
    int sum = 0;
    for (int i = 0; i < K; i++)
    {
        sum += l.at(i);
    }
    cout << sum << endl;    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#define SIZE 1000000007
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;

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

    int num[2]={};
    rep(i,S.size()){
        if(S[i]=='0')num[0]++;
        else num[1]++;
    }
    cout<<2*min(num[0],num[1])<<endl;

    return 0;
}

Measured memory_bytes: 512
n = int(input())
t = list(map(int, input().split()))
m = int(input())

sum_t = sum(t)

res = []
for _ in range(m):
    p, x = map(int, input().split())
    res.append(sum_t + (x - t[p-1]))

for v in res:
    print(v)

Measured memory_bytes: 62708
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		const long MOD = 1000000007;
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			string s = cin.Next();
			int n = s.Length;

			int ans = n;
			for (int i = 0; i < n - 1; i++) {
				if (s[i] != s[i + 1]) {
					int temp = Math.Max(i + 1, n - (i + 1));
					ans = Math.Min(ans, temp);
				}
			}

			Console.WriteLine(ans);
		}
	}

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

		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: 13792
/*|In The Name of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 7e3+5;

int n;

int main(){
    cin >> n;
    int mx = 0 , cnt = 0;
    for(int i = 1; i <= n; i++){
        int x;
        cin >> x;
        if(x >= mx){
            cnt++;
        }
        mx = max(mx , x);
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF 1e9
#define MOD 1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
}


signed main(){
	
	ll n,cnt = 0;
	cin >> n;
	ll h[n] = {};
	
	rep(i,0,n)cin >> h[i];
	
	
	rep(i,0,n){
		rep(j,0,i){
			if(h[i] < h[j]) break;
			else if(j == i-1) cnt++;
		}
	}
	
	cout << cnt+1 << endl;
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  string s;
  cin>>s;
  int n = s.size();
  REP(i,n-8){
    cout<<s[i];
  }
  cout<<endl;
  return 0;
}


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

int main(){
  int a;
  string s;
  cin >> a >> s;
  
  if(a >= 3200) cout << s << endl;
  else cout << "red" << endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,k; cin>>n>>k;
	if(k>(n+1)/2) cout<<"NO\n";
	else cout<<"YES\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;using int32=int_fast32_t;using uint32=uint_fast32_t;using int64=int_fast64_t;using uint64=uint_fast64_t;using pi=pair<int32,int32>;using pll=pair<int64,int64>;using vi=vector<int32>;using vvi=vector<vector<int32>>;using vll=vector<int64>;using ll=int64;using ull=uint64;
#define all(x) x.begin(),x.end()
inline ll read(){ll x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
void Main(){
    int A = read(), B = read(), C = read();
    printf("%d\n", B+min(A+B+1, C));
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 256
#include <cassert>
#include <algorithm>
#include <cctype>
#include <complex>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <tuple>
#include <typeinfo>
#include <unordered_set>
#include <unordered_map>
#include <vector>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REPD(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define PB(e) push_back(e)
#define FOREACH(i, c) for(auto i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define BIT(n, m) (((n) >> (m)) & 1)

typedef long long ll;

template <typename S, typename T> ostream &operator<<(ostream &out, const pair<S, T> &p) {
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}

template <typename T> ostream &operator<<(ostream &out, const vector<T> &v) {
  out << "[";
  REP(i, v.size()){
    if (i > 0) out << ", ";
    out << v[i];
  }
  out << "]";
  return out;
}

int calc(const vector<int> &A, int min_value, int N, int K, int Q) {
  vector<int> candidates;
  int l = 0;
  while (l < N) {
    if (A[l] < min_value) {
      l++;
      continue;
    } else {
      int r = l;
      while (r < N && A[r] >= min_value) {
        r++;
      }

      vector<int> local_candidates;
      while (l < r) {
        local_candidates.push_back(A[l++]);
      }
      sort(ALL(local_candidates));
      REP(i, int(local_candidates.size()) - K + 1) {
        candidates.push_back(local_candidates[i]);
      }
    }
  }

  sort(ALL(candidates));
  if (int(candidates.size()) >= Q) {
    return candidates[Q - 1] - candidates[0];
  } else {
    return 1e9;
  }
}

int main(int argc, char *argv[])
{
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> A(N);
  REP(i, N) cin >> A[i];

  vector<int> B(A);
  sort(ALL(B));
  int res = 1e9;
  REP(i, B.size()) {
    res = min(res, calc(A, B[i], N, K, Q));
  }
  cout << res << endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;
typedef long long ll;

int D,N;
int T[211];
vector<int> Ds[211];

inline int ab(int a){ return a>0?a:-a; }
int dp[211][101];
int solve(int day,int c){
  if(dp[day][c]!=-1) return dp[day][c];
  if(day==D) return 0;
  int ret=0;
  for(int i=0;i<(int)Ds[day].size();i++){
    ret = max( ret, solve(day+1,Ds[day][i]) + ab(c-Ds[day][i]) );
  }
  //  printf("%d\n",ret);
  return dp[day][c]=ret;
}
int solve(){
  int ret = 0;
  memset(dp,-1,sizeof(dp));
  for(int i=0;i<(int)Ds[0].size();i++){
    ret = max( ret, solve(1,Ds[0][i]) );
  }
  return ret;
}
int main(){
  scanf("%d %d",&D,&N);
  for(int i=0;i<D;i++){
    scanf("%d",&T[i]);
  }
  for(int i=0;i<N;i++){
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    for(int j=0;j<D;j++){
      if(A<=T[j] && T[j]<=B) Ds[j].push_back(C);
    }
  }
  printf("%d\n",solve());
}

Measured memory_bytes: 1392
#include<iostream>
#include<string>
using namespace std;
int main()
{
    long long int a,b,c,k; cin >> a >> b >> c >> k;
    long long int result = 0;

    int x = min(a,k);
    k-=x;
    result+=(x*1);

    x= min(b,k);
    k-=x;
    result+=(x*0);

    x=min(c,k);
    k-=x;
    result+=(x*-1);

    cout << result << endl;
    return 0;
}


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

#define fst first
#define snd second
#define INF 0x3FFFFFFF
#define PI (2*acos(0))

using namespace std;

typedef long long ll;
typedef complex<double> pt;

int main() {
  int r, g;
  cin >> r >> g;
  int diff = g - r;
  cout << r + 2 * diff << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
vector <pair<pair<int,int>,int> > v;
int main(int argc, char** argv) {
	int x;
	cin >> x;
	--x;
	if(!x)
	{
		cout << "2 1\n1 2 0";
		return 0;
	}
	int now=1,n=1;
	while((now<<1)<=x+1) now<<=1,++n;
	cout << n << " ";
	int W=1;
	for(int i=n-1;i>=1;i--)
	{
		v.push_back({{i,i+1},W});
		v.push_back({{i,i+1},0});
		W<<=1;
	}
	x^=W,now=1;
	int qwq=W;
	++x;
	while(W)
	{
		W>>=1,++now;
		if(x&W)
			v.push_back({{1,now},qwq}),x^=W,qwq+=W;
	}
	cout << v.size() << "\n";
	for(auto x:v) cout << x.first.first << " " << x.first.second << " " << x.second << "\n";
	return 0;
}

Measured memory_bytes: 504
N,K=map(int,input().split())
P=list(map(int,input().split()))
ans=sum(P[:K])/2+0.5*K
A,S=[0]*N,[0]*N
A[0]=S[0]=P[0]
for i in range(N-1):
    A[i+1]=P[i+1]
    S[i+1]=S[i]+A[i+1]

for i in range(N-K):
    tmp=(S[K+i]-S[i])/2+0.5*K
    if ans<tmp:
        ans=tmp
print(ans)

Measured memory_bytes: 25316
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
 
#define REP(i,n) for (int i=0;i<(n);i++)
#define PII pair<int,int>
#define LL long long
#define vi vector<int>
 
int main() {
    long double x, y;
    LL n=0;
 
    cin >> x >> y;
 	
  	while(x<=y){
      n++;
      x *= 2;
    }
  
  	cout << n;
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
using namespace std;
const int N=1e5+100;
const int mod=998244353;
typedef long long ll;

int main()
{
    char s[200];
    int x;
    scanf("%d%s",&x,s+1);
    if(x>=strlen(s+1)) printf("%s",s+1);
    else {
      for(int i=1;i<=x;i++) cout<<s[i];
      printf("...");
    }
    return 0;
}


Measured memory_bytes: 3824