akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
const ll mod=1000000007;
ll fast_mul(ll x,ll y)
{
	ll temp=x*y-(ll)((long double)x*y/mod+1.0e-8)*mod;
	return temp<0?temp+mod:temp;
}
int main()
{
	ll n,k,s,i,j,x,y,p=0,q=0,a[2005];
	cin>>n>>k;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(a[i]>a[j]){
				p++;
			}
		}
	}
	sort(a,a+n);
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(a[j]>a[i]){
				q++;
			}
		}
	}
	if(k%2==0){
		x=k/2;
		y=k-1;
	}
	else{
		x=k;
		y=(k-1)/2;
	}
	s=(p*k)%mod+(fast_mul(x,y)*q)%mod;
	cout<<s%mod<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

#define PI 3.1415926535897932
// #54797
int main(){
    int len,flg;
    char s[84];
    while (fgets(s,84,stdin)!=NULL) {
        len=strlen(s)-1;
        flg=1;

        while (flg) {
            for (int i=0;i<len;i++) {
                if (islower(s[i])) {
                    s[i]=(s[i]-'a'+1)%26+'a';
                }
            }
            for (int i=0;i<len;i++) {
                if (!strncmp(&s[i],"the",3) || !strncmp(&s[i],"this",4) || !strncmp(&s[i],"that",4)) {
                    flg=0;
                    break;
                }
            }
        }
        printf("%s",s);
    }
    return 0;
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main() {
    int a,b,n;
    cin>>a>>b>>n;
    for(int i=0;i<n;i++){
        if(i%2==0){
            if(a%2==1){
                a--;
            }
            a=a/2;
            b+=a;
        }
        else{
            if(b%2==1){
                b--;
            }
            b=b/2;
            a+=b;
        }
    }
    cout<<a<<" "<<b<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

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

// EOF


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define REV(x) (reverse(x.begin(),x.end()))
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))
const ll INF=1e18+7;
const ll MOD=1e9+7;
const ll N=100002;
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}



int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,a,b;
	cin >> n >> a >> b;
	bool y = abs(a-b)&1;
	if(not y){
		cout<<"Alice"<<endl;
	}else{
		cout<<"Borys"<<endl;
	}
}

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

const string YES = "Yes";
const string NO = "No";

void solve(string N){
  if("000" == N.substr(0,3) || "000" == N.substr(1,3)) {
    cout << YES << endl;
    return;
  }

  for(long long i = 111; i <= 999; i+=111) {
    if(to_string(i) == N.substr(0,3) || to_string(i) == N.substr(1,3)) {
      cout << YES << endl;
      return;
    }
  }
  cout << NO << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    string N;
    cin >> N;
    solve(N);
    return 0;
}


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

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

    set<int> st;
    int d;
    
    for(int i = 0; i< N;i++){
        cin >> d;
        st.insert(d);
    }
    cout << st.size()<<endl;
    

    
    
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
double f(int n) {
	if (n == 1) return 1;
	return 1 + 1.0*(2 * n + 2) / (2 * n)*f(n - 1);
}
int main() {
	int N, d, x;
	cin >> N >> d >> x;
	double k = d + (N - 0.5)*x;
	printf("%.15lf\n", k*f(N));
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    LL x, y, z;cin >> x >> y >> z;
    LL k;cin >> k;
    LL a[1000], b[1000], c[1000];
    inc(i, 0, x) cin >> a[i];
    inc(i, 0, y) cin >> b[i];
    inc(i, 0, z) cin >> c[i];
    sort(a, a+x);reverse(a, a+x);
    sort(b, b+y);reverse(b, b+y);
    sort(c, c+z);reverse(c, c+z);
    vector<LL> v;
    inc(i, 0, x){
        inc(j, 0, y){
            v.pb(a[i]+b[j]);
        }
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    vector<LL> w;
    inc(i, 0, min(k, x*y)){
        w.pb(v[i]);
        //cout << v[i] << endl;
    }
    vector<LL> ans;
    inc(i, 0, min(k, x*y)){
        inc(j, 0, z){
            ans.pb(w[i]+c[j]);
        }
    }
    sort(ans.begin(), ans.end());
    reverse(ans.begin(), ans.end());
    inc(i, 0, k){
        cout << ans[i] << endl;
    }
    return 0;
}


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

ll llpow(ll a, ll e){
  if(e==0){
    return 1LL;
  }
  if(e%2==0){
    ll res=llpow(a,e/2);
    return res*res;
  }else{
    return llpow(a,e-1)*a;
  }
}

int main(){
  ll n,ans=0;
  cin>>n;
  if(n%2==1){
    cout<<0<<endl;
    return 0;
  }
  ll temp,i=1;
  while(1){
    temp=llpow(5LL,i)*2;
    i++;
    if(temp>n){
      break;
    }
    ans+=n/temp;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
char a;
int main(){
	cin >> a;
	if(a>='A' and a<='Z')puts("A");
	else puts("a");
	return 0;
}

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

int main(){
  	int n,i = 1;
  	cin >> n;
  
  	while(1){
      if( i*i > n){
        cout << (i-1)*(i-1) <<endl;
        return 0;
      }
      i++;
    }
	return 0; 
}

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

int main() {
  int a,b,c;cin>>a>>b>>c;
  bool ans = b-a==c-b;
  cout << (ans?"YES":"NO") << endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 9e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BBeautifulStrings {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    string w;
	    in >> w;
	    map<char, int> cnt;
	    for(int i=0; i<w.length(); i++){
	        cnt[w[i]]++;
	    }
	    bool res = true;
	    for(auto const& e : cnt){
	        if(e.second % 2 != 0){
	            res = false;
	            break;
	        }
	    }
	    ans(res, out);
	}
};


int main() {
	BBeautifulStrings solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, int> pli;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
        int n;
        scanf("%d", &n);
        set<string> S;
        rep(i, n){
                string s;
                cin>>s;
                S.insert(s);
        }
        int m;
        scanf("%d", &m);
        int state=0;
        while(m--){
                string s;
                cin>>s;
                if(S.find(s)!=S.end()){
                        state^=1;
                        cout << (state ? "Opened " : "Closed ");
                        cout << "by " << s << "\n";
                }
                else{
                        cout << "Unknown " << s << "\n";
                }
        }
}


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

int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for (int i=0; i<N; i++) {
        cin >> A.at(i);
        B.at(i) = A.at(i);
    }

    sort(B.begin(), B.end());

    int max = B.at(N-1);
    int second = B.at(N-2);

    for (int i=0; i<N; i++) {
        if(A.at(i) == max) {
            cout << second << endl;
        } else {
            cout << max << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3200
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

int main(void) {

	int n, sum = 0;

	cin >> n;

	int l[2 * n];

	for (int i = 0; i < 2*n; i++)
	{
		cin >> l[i];
	}

	sort(l, l + 2 * n);

	for (int i = 0; i < n; i++)
	{
		sum += l[i*2];
	}	

	cout << sum << "\n";

	return 0;
}

Measured memory_bytes: 256
//start of jonathanirvings' template v3.0.3 (BETA)

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)

inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}

inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}

inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}

inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}

inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}

inline void OPEN (string s) {
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
}

//end of jonathanirvings' template v3.0.3 (BETA)

int n, k;
int data[100005];
vi adj[100005];
int risan = 0;

int rekur(int x)
{
  int now = 0;
  REP(i,SIZE(adj[x])) MAX(now,rekur(adj[x][i]) + 1);
  if (now >= k - 1)
  {
    if (x > 1 && data[x] > 1) ++risan;
    return -1;
  }
  return now;
}

int main()
{
  scanf("%d %d",&n,&k);
  //n = 100000; k = 2;
  REPN(i,n) scanf("%d",&data[i]);
  //REPN(i,n) data[i] = i - 1; data[1] = 1;
  if (data[1] != 1) ++risan;
  FORN(i,2,n) adj[data[i]].pb(i);
  rekur(1);
  printf("%d\n",risan);
  return 0;
}










Measured memory_bytes: 13952
A,B,K = map(int, input().split())

if A >= K:
  print(A-K, B)
elif A < K:
  ans_A  = 0
  ans_B = B - (K - A)
  
  if A+B < K:
    print(0,0)
  else:
    print(ans_A,ans_B)

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

using int64 = long long;

int64 gcd(int64 a, int64 b) {
  if (b == 0)
    return a;

  int64 c = a % b;
  while (c) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

int main() {
  int n;
  cin >> n;
  int64 x;
  cin >> x;
  int64 ret = -1;
  for (int i = 0; i < n; ++i) {
    int64 y;
    cin >> y;
    int64 d = abs(x - y);
    if (ret < 0)
      ret = d;
    else
      ret = gcd(ret, d);
  }
  cout << ret << "\n";
  return 0;
}


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

signed main(void){
  
  int i,o,t,j,l,s,z;
  
  cin >> i >> o >> t >> j >> l >> s >> z;
  
  int sum = 2*o; // Kではなく2*Kを求めていることに注意
  
  int ans1 = sum,ans2 = sum;
  
  { //I+J+Lを作る場合
    
    bool flag = false;
    
    if( i && j && l ){
      i--; j--; l--; ans1 += 6;
      flag = true;
    }

    ans1 += 4*(j/2); ans1 += 4*(l/2);
    ans1 += 4*(i/2);
    
    if(flag){ i++; j++; l++;}
    
    
  }
  {
    //作らない場合
    ans2 += 4*(j/2); ans2 += 4*(l/2); ans2 += 4*(i/2);
  }
  
  cout << max(ans1,ans2)/2 << endl; return 0;
}

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

N = int(input())
state = [list(input().rstrip()) for _ in range(N)]

ColState = [0]*N
fullcols = 0
for w in range(N):
    isfull = True
    isempty = True
    for h in range(N):
        if state[h][w] == "#":
            isempty = False
        else:
            isfull = False
    if isfull:
        fullcols += 1
    if isempty:
        ColState[w] = -1

ans = 10**14
for h in range(N):
    emp = 0
    for w in range(N):
        if state[h][w] == ".":
            emp += 1
    if ColState[h] == -1:
        emp += 1
    ans = min(ans, emp+(N-fullcols))

if ans == 2*N+1:
    print(-1)
else:
    print(ans)

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

int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n, k, q;
	cin >> n >> k >> q;
	vector<int> score(n, k-q);
	for(int i=0; i<q; i++) {
		int t;
		cin >> t;
		t--;
		score[t]++;
	}
	for(int i=0; i<n; i++) {
		cout << (score[i] > 0 ? "Yes\n":"No\n");
	}
}

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

int main() {
    int N, M;
    cin >> N >> M;
    int likeIt[M+1];
    for (int i=0; i<M+1; i++) likeIt[i] = 0;
    for (int N_i; N_i<N; N_i++) {
        int K, A;
        cin >> K;
        for (int M_i=0; M_i<K; M_i++) {
            cin >> A;
            likeIt[A] += 1;
        }
    }
    int answer = 0;
    for(int i=0; i<M+1; i++) if (likeIt[i] == N) answer += 1;
    cout << answer<< endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <iomanip>
using namespace std;
const int M = 100000;
const double pi = 3.141592653589;

int main()
{
	int n;
	bool a[4][13] = { false };
	char b[M];
	int c[M];

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> b[i] >> c[i];
		if (b[i] == 'S') a[0][c[i] - 1] = true;
		else if (b[i] == 'H') a[1][c[i] - 1] = true;
		else if (b[i] == 'C') a[2][c[i] - 1] = true;
		else if (b[i] == 'D') a[3][c[i] - 1] = true;
	}
	
	for (int i = 0; i < 4; i++) {
		for (int k = 0; k < 13; k++) {
			if (!a[i][k]) {
				if (i == 0) cout << "S " << k+1 << endl;
				else if (i == 1) cout << "H " << k+1 << endl;
				else if (i == 2) cout << "C " << k+1 << endl;
				else if (i == 3) cout << "D " << k+1 << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3092
N, M = map(int, input().split())
A = []
for _ in range(M):
  a, b = map(int, input().split())
  A.append([a, b])
A = sorted(A, key=lambda x: x[1])
ans = 0
f = 0
for i in range(M):
  if A[i][0] >= f:
    ans += 1
    f = A[i][1]
print(ans)

Measured memory_bytes: 63320
#include<stdio.h>

int main(void){
    int N;
    int s[100];
    int i = 0;
    int cnt = 0;
    int side_cnt = 0;

    scanf("%d", &N);
    for(i = 0; i < N; i++){
        scanf("%d", &s[i]);
    }

    for(i = 0; i < N-1; i++){
        if(s[i] != i+1){
            cnt++;
        }
    }

    if(cnt <= 2){
        printf("YES");
    }else{
        printf("NO");
    }

    return 0;
}

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

#define ll long long
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n, m) for (int (i) = (n); (i) < (m); (i)++)
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

int N;
int B[5][200];

void rui2(int h, int w) {
   for (int i = 1; i <= h; i++) {
      for (int j = 1; j <= w; j++) {
         B[i][j] += B[i-1][j] + B[i][j-1] - B[i-1][j-1];
      }
   }
}

void print() {
   for (int i = 1; i <= 2; i++) {
      for (int j = 1; j <= N; j++) {
         printf("%3d", B[i][j]);
      }
      cout << endl;
   }
}

int main() {
   cin >> N;
   rep (i, 0, 2) {
      rep (j, 0, N) {
         cin >> B[i][j];
      }
   }
   // rui2(2, N);
   // print();

   // int ans = 0;
   // rep (i, 1, N+1) { // 上段
   //    int u = B[1][i];
   //    int d = B[2][N] - B[2][i-1] - B[1][i] + B[1][i-1];
   //    debug(d)
   //    ans = max(ans ,u+d);
   // }
   // cout << ans << endl;
   int a = 0;
   rep (i, 0, N) {
      a += B[1][i];
   }

   int ans = 0;
   int sum = 0;
   int b = 0;
   rep (i, 0, N) {
      b += B[0][i];
      if (i >= 1) {
         a -= B[1][i-1];
      }
      sum = b + a;
      ans = max(ans, sum);
   }
   cout << ans << endl;

   return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for(int i = 0; i < n; i++) {
    cin >> p.at(i);
  }
  
  sort(p.begin(), p.end());
  int c = 0;
  for(int i = 0; i < n; i++) {
    c += p.at(i);
    k--;
    if(k==0)break;
  }
  
  cout << c << endl;
}


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

int main() {
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    while(true) {
        C = C - B;
        if(C<=0) {
            cout << "Yes" << endl;
            break;
        }
        A = A - D;
        if(A<=0) {
            cout <<"No" <<endl;
            break;
        }
    }
}

Measured memory_bytes: 3600
#include<iostream>
using namespace std;
int main()
{
    std::string s;
    cin >> s;
    if(s.find("a") != std::string::npos && s.find("b") != std::string::npos && s.find("c") != std::string::npos){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
X=[[int(i) for i in input().split()] for i in range(N)]
X.sort()
t=M
ans=0
for a,b in X:
    if t>b:
        ans+=a*b
        t-=b
    else:
        ans+=a*t
        break
print(ans)


Measured memory_bytes: 21604
//標準関数をすべてインクルードする。
#include <bits/stdc++.h>
using namespace std;

int main(){
    //cin coutを高速化
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);

    int n, m;

    cin >> n >> m;

    if(n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <math.h>

using namespace std;

int main (){
    vector<vector<int>> A(3,vector<int>(3));
    int N;

    for(int i = 0; i < 3; i++) cin >> A[i][0] >> A[i][1] >> A[i][2];
    cin >> N;
    vector<int> b(N);
    for(int j = 0; j < N; j++) cin >> b[j];

    vector<vector<int>> C(3,vector<int>(3, 0));   
    for(int i = 0; i<3; i++){
        for(int j =0; j<3; j++){
            for(int k = 0; k<N; k++){
                if(A[i][j] == b[k]) C[i][j] = 1;
            }
        }
    }
    int ans = 0;
    for(int k=0; k<3; k++){
        if(C[k][0]==1 && C[k][1] && C[k][2]) ans = 1;
    }
    for(int k=0; k<3; k++){
        if(C[0][k]==1 && C[1][k] && C[2][k]) ans = 1;
    }
    if(C[0][0]==1 && C[1][1] && C[2][2]) ans = 1;
    if(C[0][2]==1 && C[1][1] && C[2][0]) ans = 1;

    string S = "No";
    if(ans == 1) S = "Yes";

    cout << S << endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  int a, b;
  cin >> a >> b;
  if(a >= 13){
    cout << b << '\n';
  }else if(a >= 6){
    cout << b / 2 << '\n';
  }else{
    cout << 0 << '\n';
  }

  return 0;
}

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

using namespace std;

signed main()
{
  int N,M;
  cin >> N >> M;
  vector<int> X(M);
  for(int i=0;i<M;i++) cin >> X[i];
  sort(X.begin(),X.end());
  for(int i=0;i<M-1;i++) X[i] = X[i+1] - X[i];
  sort(X.begin(),X.end()-1);
  int sum = 0;
  for(int i=0;i<M-N;i++) sum += X[i];
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int k=sc.nextInt();
		ArrayList<Long> a = new ArrayList<Long>();
		for(long i=1; i<=9; i++) a.add(i);
		while(true) {
			if(k <= a.size()) {
				System.out.println(a.get(k-1));
				break;
			}
			k -= a.size();
			ArrayList<Long>old = new ArrayList<Long>(a);
			a.clear();
			for(long i : old) {
				for(int j=-1; j<=1; j++) {
					long d = i%10+j;
					if(d<0 || d>9) continue;
					a.add(i*10+d);
				}
			}
		}
		sc.close();
	}

}


Measured memory_bytes: 29908
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;

const int MAX_N = 3e5 + 15, MOD = 1e9 + 7;
string s;
int n, ans;
int dp[MAX_N][3][2][2][5];

int _sum (int a, int b) {
	int c = a + b;
	if (MOD <= c)
		c -= MOD;

	return c;
}

int _sub (int a, int b) {
	int c = a - b;
	if (c < 0)
		c += MOD;

	return c;
}

int _mul (int a, int b) {
	int c = 1LL * a * b % MOD;
	return c;
}

int _pow (int a, int b) {
	if (!b)
		return 1;

	int res = _pow(a, b >> 1);
	res = _mul(res, res);

	if (b & 1)
		res = _mul(res, a);
	return res;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> s;
	n = s.size();
	s = '#' + s;

	int num = 0;
	for (int i = 1; i <= n; i++)
		num += s[i] == '?';

	if (s[1] != '0')
		dp[1][2][1][1][0] = 1;
	if (s[1] != '1')
		dp[1][2][0][1][2] = 1;

	for (int i = 1;  i < n; i++)
		for (int j = 0; j < 4; j++) {
			if (s[i + 1] != '1') {
				if (j) dp[i + 1][1][0][0][j - 1] = _sum(dp[i + 1][1][0][0][j - 1], dp[i][0][0][0][j]);
				if (j) dp[i + 1][2][0][1][j - 1] = _sum(dp[i + 1][2][0][1][j - 1], dp[i][0][0][1][j]);

				dp[i + 1][0][0][0][j + 1] = _sum(dp[i + 1][0][0][0][j + 1], dp[i][0][1][0][j]);
				dp[i + 1][2][0][1][j + 1] = _sum(dp[i + 1][2][0][1][j + 1], dp[i][0][1][1][j]);

				dp[i + 1][0][0][0][j + 1] = _sum(dp[i + 1][0][0][0][j + 1], dp[i][1][0][0][j]);
				dp[i + 1][0][0][0][j + 1] = _sum(dp[i + 1][0][0][0][j + 1], dp[i][1][0][1][j]);

				dp[i + 1][1][0][0][j + 1] = _sum(dp[i + 1][1][0][0][j + 1], dp[i][1][1][0][j]);
				dp[i + 1][1][0][0][j + 1] = _sum(dp[i + 1][1][0][0][j + 1], dp[i][1][1][1][j]);

				dp[i + 1][0][0][1][j + 1] = _sum(dp[i + 1][0][0][1][j + 1], dp[i][2][0][1][j]);
				dp[i + 1][1][0][1][j + 1] = _sum(dp[i + 1][1][0][1][j + 1], dp[i][2][1][1][j]);
			}
			if (s[i + 1] != '0' && j) {
				dp[i + 1][0][1][0][j - 1] = _sum(dp[i + 1][0][1][0][j - 1], dp[i][0][0][0][j]);
				dp[i + 1][0][1][0][j - 1] = _sum(dp[i + 1][0][1][0][j - 1], dp[i][0][0][1][j]);

				dp[i + 1][1][1][0][j - 1] = _sum(dp[i + 1][1][1][0][j - 1], dp[i][0][1][0][j]);
				dp[i + 1][1][1][0][j - 1] = _sum(dp[i + 1][1][1][0][j - 1], dp[i][0][1][1][j]);

				dp[i + 1][1][1][0][j - 1] = _sum(dp[i + 1][1][1][0][j - 1], dp[i][1][0][0][j]);
				dp[i + 1][2][1][1][j - 1] = _sum(dp[i + 1][2][1][1][j - 1], dp[i][1][0][1][j]);

				dp[i + 1][1][1][0][j - 1] = _sum(dp[i + 1][1][1][0][j - 1], dp[i][1][1][0][j]);
				dp[i + 1][1][1][0][j - 1] = _sum(dp[i + 1][1][1][0][j - 1], dp[i][1][1][1][j]);

				dp[i + 1][0][1][1][j - 1] = _sum(dp[i + 1][0][1][1][j - 1], dp[i][2][0][1][j]);
				dp[i + 1][1][1][1][j - 1] = _sum(dp[i + 1][1][1][1][j - 1], dp[i][2][1][1][j]);
			}
		}

	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 2; j++)
			for (int t = 0; t < 2; t++)
				for (int k = 1; k < 4; k++)
					ans = _sum(ans, dp[n][i][j][t][k]);

	cout << _sub(_pow(2, num), ans) << "\n";
	return 0;
}
//

Measured memory_bytes: 70996
// Copyright (C) 2017 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>

#define x first
#define y second
#define MP std::make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

using std::pair;
using std::vector;
using std::string;

typedef long long LL;
typedef pair<int, int> Pii;

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
string procStatus()
{
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        if (ch == '-')
            f = -1;
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

const int MAXN = 3e5 + 5;

int N;
int A[MAXN];

void input()
{
    read(N);
    for (int i = 1; i <= N * 3; ++i) {
        read(A[i]);
    }
}

void solve()
{
    std::sort(A + 1, A + N * 3 + 1, std::greater<int>());
    LL ans = 0;
    for (int i = 1; i <= N; ++i) {
        ans += A[i * 2];
    }
    printf("%lld\n", ans);
}

int main()
{
#ifdef __DEBUG
    freopen("A.in", "r", stdin);
    freopen("A.out", "w", stdout);
#endif

    input();
    solve();

    return 0;
}

// 家国兴亡自有时，吴人何苦怨西施。
//     -- 罗隐《西施》


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>

#define MOD 1000000007
using ll = long long;
using namespace std;

int N, Q;
string S;
vector<char> t, d;

int isDel(int now) {
	for (int i = 0; i < Q; i++)
	{
		if (now != -1 && now != N && S[now] == t[i]) {
			if (d[i] == 'L') {
				now--;
			}
			else {
				now++;
			}
		}
	}
	if (now == -1) {
		return -1;
	}
	else if (now == N) {
		return 1;
	}
	else {
		return 0;
	}
}

int main() {
	cin >> N >> Q >> S;
	for (int i = 0; i < Q; i++)
	{
		char a, b;
		cin >> a >> b;
		t.push_back(a);
		d.push_back(b);
	}
	// Find the left edge
	int left = 0, right = N;
	while (right - left > 1) {
		int mid = (left + right) / 2;
		if (isDel(mid) >= 0) {
			right = mid;
		}
		else {
			left = mid;
		}
	}
	int LE = right;
	// Find the right edge
	left = 0, right = N;
	while (right - left > 1) {
		int mid = (left + right) / 2;
		if (isDel(mid) <= 0) {
			left = mid;
		}
		else {
			right = mid;
		}
	}
	int RE = left;
	cout << RE - LE + 1 << endl;
	cin >> left;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

#define MAX_N 1001
#define MAX_W 10001

int dp[MAX_W][MAX_N], W, N, value[MAX_N], w[MAX_N];

int main(){
    int Case = 0;
    
    while(true){
        for(int i = 0; i < MAX_N; ++i)
            memset(dp[i], 0, MAX_W);
        //initialize
        
        ++Case;
        scanf("%d%d", &W, &N);
        if(!W)
            break;
        for(int i = 0; i < N; ++i)
            scanf("%d,%d", &value[i], &w[i]);
        //input
        
        for(int i = 0; i < N; ++i){
            for(int j = 0; j <= W; ++j){
                if(j < w[i])
                    dp[i + 1][j] = dp[i][j];
                else
                    dp[i + 1][j] = std::max(dp[i][j - w[i]] + value[i], dp[i][j]);
            }
        }
        //solve
        
        int ans = dp[N][W];
        
        printf("Case %d:\n%d\n", Case, ans);
        
        int i = 0;
        while(true){
            if(ans != dp[N][W - i]){
                printf("%d\n", W - i + 1);
                break;
            }
            ++i;
        }
    }
    return 0;
}

Measured memory_bytes: 5284
n = int(input())
vs = [[] for i in range(n)]
out = [0]*n

for i in range(n-1):
    a, b = [int(i)-1 for i in input().split()]
    vs[a].append([b,i+1])
    vs[b].append([a,i+1])

nex = [[0,-1]]

def coloring(index,defColor):
    i=0
    for v in vs[index]:
        if i==defColor:
           i+=1
        out[v[1]]=i
        vs[v[0]].remove([index,v[1]])
        nex.append([v[0],i])
        i+=1
    out[0] = max(out[0],i-1)

while nex.__len__()>0:
    c,d = nex.pop()
    coloring(c,d)

for i in range(n):
    print(out[i]+1)





Measured memory_bytes: 48208
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
	int n, a;
	cin >> n;
	vector<int> l;
	for (int i = 0; i < n; i++) {
		cin >> a;
		l.push_back(a);
	}
	l.push_back(0);
	int s = accumulate(l.begin(), l.end(), 0);
	sort(l.begin(), l.end());
	for (int i = 0; i < n; i++)
	{
		s -= l[i];
		if (s % 10 != 0) {
			cout << s << endl; 
			return 0;
		}
		s += l[i];

	}
	cout << 0 << endl;

	return 0;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
mass = []
for h in range(H):
    mass.append(input())
def check(h,w):
    global mass
    x=[1,-1,0,0]
    y=[0,0,1,-1]
    for xx,yy in zip(x,y):
        if 0<=h+xx and h+xx<H and 0<=w+yy and w+yy<W: 
            if mass[h+xx][w+yy] == "#":
                return True
    return False
for h in range(H):
    for w in range(W):
        if mass[h][w] == '#':
            if check(h,w) == False:
                print("No")
                exit()
print("Yes")

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

int main()
{
	char s[4];
    scanf("%s", s);
	if((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])) printf("Yes\n");
    else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

use proconio::input;

fn main() {
    input! {
        A: i32,
        B: i32,
        C: i32,
        X: i32,
    }
    let X = X / 50;
    let mut result = 0;
    for a in 0..=A {
        for b in 0..=B {
            for c in 0..=C {
                if 10 * a + 2 * b + c == X {
                    result += 1;
                }
            }
        }
    }
    println!("{}", result);
}


Measured memory_bytes: 2172
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


int main(){
    int a, b;
    cin >> a >> b;
    if(a >= 13){
        cout << b << endl;
    }
    else if(a >= 6){
        cout << b / 2 << endl;
    }
    else{
        cout << 0 << endl;
    }


    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

class Main {
    final static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int a, l;
        while (true) {
            a = sc.nextInt();
            l = sc.nextInt();
        
            if (a == 0 && l == 0) break;
            int[] ans = new int[21];
            ans[0] = a;
        
            int[] tmp = new int[l];
        
            for (int k = 0; k < 20; k++) {
                a = ans[k];
                for (int i = 0; i < l; i++) {
                    tmp[i] = a % 10;
                    a /= 10;
                }
                Arrays.sort(tmp);
                int min = 0;
                for (int i = 0; i < l; i++) {
                    min = min * 10 + tmp[i];
                }
                int max = 0;
                for (int i = 0; i < l; i++) {
                    max = max * 10 + tmp[l - i - 1];
                }
                ans[k+1] = max - min;
            }
            
            boolean f = false;
            for (int i = 0; i <= 20; i++) {
                for (int j = 0; j < i; j++) {
                    if (ans[i] == ans[j]) {
                        System.out.println(j + " " + ans[i] + " " + (i - j));
                        f = true;
                        break;
                    }
                }
                if (f) break;
            }
        }
    }
}


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

int main(){
    string s;
    cin >> s;
    int k,n;
    cin >> k;
    n = s.size();
    for(int i = 0; i < k; i++){
        if(s[i] != '1'){
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 256
N ,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
cnt = 0
for i in range(N):
	if i == N -1:
		if x == a[i]:
			cnt+=1
			x-=a[i]
		break
	if x >= a[i]:
		cnt+=1
		x-=a[i]
print(cnt)

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

void chmax(ll& a, ll b) { a = max(a, b); }
void chmin(ll& a, ll b) { a = min(a, b); }



int main() {
    int k,a,b; cin >> k >> a >> b;
    int ans = k;
    while(ans <= b) {
        if(ans < a) {
            ans += k;
        } else {
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;
    return 0;

}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pii pair<int, int>
#define piii pair<int,pii>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

int main() {
    int n;
    scanf("%d", &n);
    int ans = 0x7f7f7f7f;
    for (int i = 1; i < n; i++) {
        int t = n - i;
        int tt = i;
        int ttt = 0;
        while(t) {
            ttt += t%10;
            t /= 10;
        }
        while(tt) {
            ttt += tt%10;
            tt /= 10;
        }
        ans = min(ans, ttt);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
	int N, e = 0, c = 0;

	cin >> N;

	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		if (A % 2 == 0) {
			e++;
			if (A % 3 == 0 || A % 5 == 0) {
				c++;
			}
		}
	}
	if (e == c) {
		cout << "APPROVED" << endl;
	} else {
		cout << "DENIED" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import numpy as np

def main(n,k,a):
  # Worst Case
  #n,k=100000,100
  #a=[p for p in range(100000)]
  
  kl=[p for p in range(1,k+1)]
  dp=[10**9]*(n)
  dp[0]=0
  for i in range(n):
    for j in kl:
      ij=i+j
      if ij < n:
        m=dp[i]+abs(a[i]-a[ij])
        if m < dp[ij]:
          dp[ij]=m
  print(dp[n-1])

def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main','(i4,i4,i4[:])')(main)
    cc.compile()

if __name__ == '__main__':
    import sys
    if sys.argv[-1] == 'ONLINE_JUDGE':
      cc_export()
    from my_module import main
    n,k=map(int,input().split())
    a=np.array(input().split(),np.int32)
    main(n,k,a)


Measured memory_bytes: 38140
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		int[] map = new int[N];
		for (int i = 0; i < N; i++) {
			map[i] = sc.nextInt();
		}
		
		int ans = 1;
		int max = map[0];
		for (int i = 1; i < N; i++) {
			if (max <= map[i]) {
				ans++;
			}
			
			max = Math.max(max, map[i]);
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
ll n;
cin>>n;ll a[n+1];
map<ll,ll>m;
ll c;
for(ll i=1;i<=n;i++)
	{cin>>a[i];m[i-a[i]]++;} ll ans=0;
for(ll i=1;i<=n;i++)
{
	c=a[i]+i;
	m[i-a[i]]--;ans+=m[c];
}
cout<<ans;
}

Measured memory_bytes: 27796
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int res = -1;
            int[] ar = new int[n];
            for (int i = 0; i < n; i++) {
                ar[i] = in.nextInt();
            }
            int[] gcd_nat = new int[n];
            int[] gcd_rev = new int[n];
            gcd_nat[0] = ar[0];
            gcd_rev[n - 1] = ar[n - 1];
            for (int i = 1; i < n; i++) {
                gcd_nat[i] = gcd(gcd_nat[i - 1], ar[i]);
                gcd_rev[n - 1 - i] = gcd(gcd_rev[n - i], ar[n - 1 - i]);
            }
            for (int i = 1; i < n - 1; i++) {
                res = Math.max(gcd(gcd_nat[i - 1], gcd_rev[i + 1]), res);
            }
            res = Math.max(res, gcd_nat[n - 2]);
            res = Math.max(res, gcd_rev[1]);

            out.println(res);
        }

        public static int gcd(int a, int b) {
            if (b == 0) {
                return a;
            } else {
                return gcd(b, a % b);
            }
        }

    }
}



Measured memory_bytes: 50084
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <map>
#include <stdio.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pie 3.141592653

using namespace std;


int main()
{
	IO;

	int n,k,tot=0,x;
	cin >> n>>k;
	vector<int>v;
	while (n--)
	{
		cin >> x;
		v.push_back(x);
	}
	sort(v.begin(), v.end());
	

	for(int i=0;i<k;i++)
	{
		tot += v[i];
	}
	cout << tot;

	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	double  N = 0;
	double ans = 0;
	cin >> N;
	if ((int)N % 2 == 0) {
		ans = 1.0/2.0;
		cout << ans;
	}
	else {
		ans = (N + 1.0) / 2.0 / N;
		cout << ans;
	}

	cin >> N;
	return 0;
}

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

int main(){

  int a, b, c;
  cin >> a >> b >> c;
  if(a==b && b==c){
  	cout << 1 << endl;
  }
  else if((a==b && b != c) || (a==c && a != b) || (a != b && b == c))
    cout << 2 << endl;
  else {
  	cout << 3 << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<complex>
using namespace std;
#define EPS 1e-10
double area2( double a, double b, double c){
  double s = ( a + b + c ) / 2;
  return sqrt(s * (s - a) * (s - b) * (s - c));
}

int main(){
  int a, l, x;
  while(cin >> a >> l >> x){
    double h = (l + x) / 2.0; // たぶん真ん中でしょ
    cout << fixed << setprecision(6) << area2(a,l,l) + area2(h,h,l)*2 << endl;
  }
}

Measured memory_bytes: 1236
#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 n, d;
  cin >> n;
  vector<int> a(n);
  REP(i, n) {
    cin >> d;
    a.push_back(d);
  }
  reverse(a.begin(), a.end());

  REP(i, n) {
    cout << a[i];
    if (i == n-1) break;

    cout << " ";
  }

  cout << "\n";
}



Measured memory_bytes: 3136
#!/usr/bin/env python3

from pprint import pprint
from collections import deque, defaultdict
import itertools
import math
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.buffer.readline
INF = float("inf")

n_nodes, m_edges = map(int, input().split())

edges = [[] for _ in range(n_nodes)]
for _ in range(m_edges):
    s, t, d = map(int, input().split())
    edges[s].append([t, d])
# pprint(edges)


def floyd_warshall(n_nodes, edges):
    dist = [[INF for u in range(n_nodes)] for v in range(n_nodes)]
    for u, e in enumerate(edges):
        for v, cost in e:
            dist[u][v] = cost
    for v in range(n_nodes):
        dist[v][v] = 0
    for k in range(n_nodes):
        for s in range(n_nodes):
            for t in range(n_nodes):
                dist[s][t] = min(dist[s][t], dist[s][k] + dist[k][t])
    return dist


dist = floyd_warshall(n_nodes, edges)
# pprint(dist)

has_negative_cycle = False
for v in range(n_nodes):
    if dist[v][v] < 0:
        has_negative_cycle = True
        break

for u in range(n_nodes):
    for v in range(n_nodes):
        if dist[u][v] == INF:
            dist[u][v] = 'INF'


if has_negative_cycle:
    print('NEGATIVE CYCLE')
else:
    for d in dist:
        print(*d)



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

int main() {
  int s;
  int h, m;

  cin >> s;

  m = s / 60;
  s = s % 60;

  h = m / 60;
  m = m % 60;

  cout << h << ":" << m << ":" << s << endl;
}



Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <tuple>
#include <stdbool.h>
#include <bitset>
#include <string>
#include <boost/multiprecision/cpp_int.hpp>

namespace mp = boost::multiprecision;
using namespace std;


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

    int r = 0, b = 0;
    for(const auto& c : s) {
        switch(c) {
            case 'R':
                r++;
                break;
            case 'B':
                b++;
                break;
        }
    }
    if (r > b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int w,h,x,y,r;
    cin >> w >> h >> x >> y >> r;
    if(x+r>w  || x-r<0 || y+r>h || y-r <0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 3096
def main():
 
    import collections
 
    N = int(input())
    A_s = list(map(int, input().split()))
 
    max_A = max(A_s)
 
    CNT_A = collections.Counter(A_s).most_common()
    CNT_A.sort()
 
    NG_list = [True for i in range(max_A)]
    cnt = 0
    
    for i in range(len(CNT_A)):
        counter = CNT_A[i][1]
        num = CNT_A[i][0]
 
        index_num = num - 1
 
        if (counter > 1):
            NG_list[index_num] = False
 
        if (NG_list[index_num] == True):
            cnt += 1
            NG_list[index_num] = False
 
        coef = 1
        while (True):
            coef += 1
            tmp_num = coef * num
            
            if (tmp_num <= max_A):
                NG_list[tmp_num - 1] = False
            else:
                break
 
    print(cnt)
 
 
if __name__ == '__main__':
    main()

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

void solve(void)
{
  int N; std::cin >> N;
  std::vector<int> A(N);
  for(auto& i : A) std::cin >> i;
  std::sort(A.begin(), A.end(), std::greater<int>());

  int r1{}, r2{};
  for (int i = 0; i < N; ++i) {
    if (i % 2 == 0)
      r1 += A[i];
    else
      r2 += A[i];
  }
  std::cout << (r1 - r2) << std::endl;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
		try{
			Scanner sc = new Scanner(System.in);
			String a = sc.next();
			String b = sc.next();
			String c = sc.next();
			a = a.substring(a.length()-1, a.length());
			String b1 = b.substring(0,1);
			if(!a.equals(b1)){
				System.out.println("NO");
			}else{
				String b2 = b.substring(b.length()-1, b.length());
				c = c.substring(0, 1);
				if(b2.equals(c)){
					System.out.println("YES");
				}else{
					System.out.println("NO");
				}
			}
		}catch(Exception e){
			e.printStackTrace();
		}
	}
    
    
    
}

Measured memory_bytes: 23892