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

using namespace std;

string str[6];

void make(){
  str[1] = "afkpuz";
  str[2] = "bglqv.";
  str[3] = "chmrw?";
  str[4] = "dinsx!";
  str[5] = "ejoty ";
}
int main(){
  make();
  string in;
  while(cin >> in){
    string out;
    if(in.length()%2){
      cout << "NA" << endl;
      continue;
    }
    int status = 0;
    for(int i = 0; i < in.length(); i++){
      if(in[i] < '1' || in[i] > '7') status = 1;
    }
    if(status){
      cout << "NA" << endl;
      continue;
    }
    for(int i = 0; i < in.length()-1; i+=2){
      if(in[i+1]-'0' >= 6){
	status = 1;
	break;
      }
      out += str[in[i+1]-'0'][in[i]-'0'-1];
    }
    if(status) cout <<"NA" <<endl;
    else cout << out << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VL = vector<LL>;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define FILL(a, b) memset(a, b, sizeof(a))

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    map<string, int> cnt;
    FOR(i, 0, n)
    {
        string s;
        cin >> s;
        cnt[s]++;
    }
    vector<pair<int, string>> a;
    for (auto& p: cnt)
    {
        a.EB(p.S, p.F);
    }
    sort(ALL(a));
    int mx = a.back().F;
    FOR(i, 0, SZ(a))
    {
        if (a[i].F == mx)
            cout << a[i].S << "\n";
    }
    return 0;
}

Measured memory_bytes: 28016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

// const ll mod = 1e9+7;

// void chmod(ll &M){
//     if(M >= mod) M %= mod;
//     else if(M < 0){
//         M += (abs(M)/mod + 1)*mod;
//         M %= mod;
//     }
// }


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

    int ans = 0;

    for(int k=28; k>=0; --k){
        int T = 1<<k;
        for(int i=0; i<N; ++i) { a[i] %= 2*T; b[i] %= 2*T; }
        sort(b.begin(), b.end());
        int cnt = 0;
        for(int i=0; i<N; ++i){
            cnt += lower_bound(b.begin(), b.end(), 2*T-a[i]) - lower_bound(b.begin(), b.end(), T-a[i]);
            cnt += lower_bound(b.begin(), b.end(), 4*T-a[i]) - lower_bound(b.begin(), b.end(), 3*T-a[i]);
        }
        if(cnt%2) ans += T;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = std::vector<int>;
using VI2D = std::vector<vector<int>>;
using VLL = std::vector<long long>;
using VLL2D = std::vector<vector<long long>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int n, k;
	cin >> n >> k;
	VI v(n);
	REP(i, n) { cin >> v[i]; }

	int res_max = 0;
	REP(i, n) { res_max += max(v[i], 0); }
	VI left(k + 1, 0);
	REP(ope, k + 1) {
		REP(bound, ope + 1) {
			int tmp = 0;
			priority_queue<int, VI, greater<int>> pq;
			REP(index, ope) {
				if(index < min(n, bound)) {
					tmp += v[index];
					pq.push(v[index]);
				} else if(!pq.empty() && pq.top() < 0) {
					tmp -= pq.top();
					pq.pop();
				}
			}
			chmax(left[ope], tmp);
		}
	}
	reverse(ALL(v));
	VI right(k + 1, 0);
	REP(ope, k + 1) {
		REP(bound, ope + 1) {
			int tmp = 0;
			priority_queue<int, VI, greater<int>> pq;
			REP(index, ope) {
				if(index < min(n, bound)) {
					tmp += v[index];
					pq.push(v[index]);
				} else if(!pq.empty() && pq.top() < 0) {
					tmp -= pq.top();
					pq.pop();
				}
			}
			chmax(right[ope], tmp);
		}
	}

	int result = 0;
	REP(i, k + 1) { chmax(result, left[i] + right[k - i]); }

	cout << min(result, res_max) << endl;
	return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
#include <sstream>
#include <numeric>
#include <bitset>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>
#include <cassert>
using namespace std;

typedef long long ll;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
bool ISINT(double x){return fabs(x-(int)x)<EPS;}
bool ISEQ(double x,double y){return fabs(x-y)<EPS;}
string itos(ll x){stringstream ss;ss<<x;return ss.str();}
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define EREP(i,a,b) for(int i=a;i<=b;i++)
#define erep(i,n) EREP(i,0,n)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin();itr!=c.end();itr++)

ll sum(ll n){
  return n * (n + 1) / 2;
}

ll lcm(ll a,ll b){
  return a / __gcd(a,b) * b;
}

int main(void){
  ll m,n;
  ll t[22];

  while(cin>>m>>n,m||n){
    rep(i,n){
      cin>>t[i];
    }

    ll to = (1<<n);
    ll p = sum(m), q = m;

    for(ll i=1;i<to;i++){
      ll bitCnt = 0;
      ll l = 1;

      for(ll bit=1,j=0;bit<=i;bit<<=1,j++){
        if(i & bit){
          bitCnt++;
          l = lcm(l,t[j]);
        }
      }

      if(bitCnt % 2 == 1){
        p -= l * sum(m / l);
        q -= m / l;
      }
      else{
        p += l * sum(m / l);
        q += m / l;
      }
    }

    printf("%.10f\n",q==0 ? 0 : (double)p/q);
  }
}

Measured memory_bytes: 912
import itertools
n = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
cnt = 0
a = -1
b = -1
for per in itertools.permutations(range(1,n+1)):
  cnt += 1
  if list(per) == P and a == -1:
    a = cnt
  elif list(per) == Q and a == -1:
    a = cnt
  if list(per) == P and a != -1:
    b = cnt
  elif list(per) == Q and a != -1:
    b = cnt
print(abs(a-b))


Measured memory_bytes: 9204
h,w,n=map(int,input().split())
spots=set([eval(input().replace(' ','*w+'))-w-1 for i in range(n)])
anss=[0]*10
from itertools import product as pr
moves=(tuple(x+w*y for x,y in pr(range(0,3),repeat=2)))
for i in spots:
    a,b=divmod(i,w)
    pre=[0]*9
    for x in range(max(0,a-2),min(h-2,a+1)):
        for y in range(max(0,b-2),min(w-2,b+1)):
            ind=w*x+y
            pre[x-a+(y-b)*3+8]+=sum(ind+m in spots for m in moves)
    for v in pre:anss[v]+=1
tans=[0]*10

ans0=(h-2)*(w-2)
for i in range(1,10):
    tans[i]=anss[i]//i
    ans0-=anss[i]//i
tans[0]=ans0
print(*tans,sep='\n')


Measured memory_bytes: 19056
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a * b > c * d) {
    cout << a * b << endl;
  } else {
    cout << c * d << endl;
  }

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;
using System.Numerics;
using System.Text.RegularExpressions;
using System.Runtime.Serialization.Formatters.Binary;

namespace atcorder2
{
    [Serializable]
    static class  Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long Gcd(long x,long y)
        {
            if (x < y) Gcd(y, x);
            while (y > 0)
            {
                var z = x;
                x = y;
                y = z % y;
            }
            return x;
        }

        public static long Lcm(long x,long y)
        {
            return x * y / Lcm(x, y);
        }

        public static bool IsLowercaseAlphabet(char target)
        {
            return new Regex("^[a-z]+$").IsMatch(target.ToString());
        }

        public static T DeepCopy<T>(this T src)
        {
            using (var memoryStream = new MemoryStream())
            {
                var binaryFormatter = new BinaryFormatter();
                binaryFormatter.Serialize(memoryStream, src);
                memoryStream.Seek(0, System.IO.SeekOrigin.Begin);
                return (T)binaryFormatter.Deserialize(memoryStream);
            }
        }


        public static bool Prime(long n)
        {
            if (n < 2) return false;
            else if (n == 2) return true;
            else if (n % 2 == 0) return false;

            for (int i = 3; i <=Math.Sqrt(n); i++)
            {
                if (n % i == 0) return false;
            }
            return true;
        }
        


        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            
            var n = Read();
            
            var ans = 0;
            for (long i = 2; i * i <= n; i++)
            {
                if (Prime(i))
                {
                    var s = 1;
                    var c = 1;

                    for (int j = 1; n % i == 0; j++)
                    {
                        if (c == j)
                        {
                            ans++;
                            s++;
                            c += s;
                        }
                        n /= i;
                    }
                }
            }
            if (Prime(n)) ans++;
            WriteLine(ans);
            
            
           

           


            Console.Out.Flush();
        }
    }
}



Measured memory_bytes: 17552
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  int n; cin>>n;
  vector<vector<bool>> f(n,vector<bool>(10,0));
  vector<vector<int>> p(n,vector<int>(11));
  rep(i,n){
    rep(j,10){
      int F; cin>>F;
      if(F==1) f[i][j]=1;
    }
  }
  rep(i,n){
    rep(j,11) cin>>p[i][j];
  }

  int ans=-INF;
  for(int bit=1;bit<(1<<10);bit++){
    int sum=0;
    rep(j,n){
      int c=0;
      rep(i,10){
        int id=(1<<i);
        if((id&bit)!=0&&f[j][i]) c++;
      }
      sum+=p[j][c];
    }
    // if(sum==0){
    //   cout<<bitset<10>(bit)<<endl;
    // }
    ans=max(sum,ans);
  }
  cout<<ans<<endl;

  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll N, M, K;
ll A[20005];
ll cost[20005][1005];

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

	cin >> N >> M >> K;

	for (int i = 1;i <= N;i++){
		cin >> A[i];
	}

	for (int i = 1;i <= N;i++){
		ll MIN = LLONG_MAX;
		ll MAX = -1;
		for (int j = 0;j < M;j++){
			if(i+j > N) break;
			MIN = min(MIN, A[i+j]);
			MAX = max(MAX, A[i+j]);
			cost[i][j] = K + (j+1)*(MAX-MIN);
		}
	}


	ll dp[20005]; fill(dp, dp+N+1, LLONG_MAX);
	dp[0] = 0;

	for (int i = 0;i < N;i++){
		for (int j = 0;j < M;j++){
			if(i+1+j > N) break;
			dp[i+1+j] = min(dp[i+1+j], dp[i]+cost[i+1][j]);
		}
	}

	cout << dp[N] << endl;

	return 0;

}



Measured memory_bytes: 159624
n = int(input())
ll = list(map(int, input().split()))
from bisect import bisect_left

def binary_search(arr, low, high, x):
    while low < high:
        mid = (low + high) // 2
        if arr[mid] < x: low = mid+1
        else: high = mid

    return low


def rec_binary_search(arr, l, r, x):
    if r-l <= 0:
        return l
    
    else:
        mid = (l + r) // 2
        if arr[mid] == x:
            return mid
    
        elif arr[mid] > x:
            return binary_search(arr, l, mid-1, x)

        else:
            return binary_search(arr, mid+1, r, x)

ll.sort()
ans = 0

for i in range(n-2):
    for j in range(i+1, n-1):
        c = ll[i] + ll[j]
        limit = bisect_left(ll, c)
        ans += limit - j - 1

print(ans)

Measured memory_bytes: 3188
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int n, m, x;
int c[13];
int a[13][13];
int INF = 9999999;

struct Takahashi {
    int cost;
    int rikai[12];
};

int dfs(Takahashi t, int book) {
    bool rikaiAll = true;
    for (int i = 0; i < m; i++) {
        if (t.rikai[i] < x) {
            rikaiAll = false;
            break;
        }
    }
    if (rikaiAll) {
        return t.cost;
    } else if (book >= n) {
        return INF;
    }
    // 買わない場合
    Takahashi tNo = t;
    int no = dfs(tNo, book + 1);
    // 買う場合
    Takahashi tYes = t;
    tYes.cost += c[book];
    for (int i = 0; i < m; i++) {
        tYes.rikai[i] += a[book][i];
    }
    int yes = dfs(tYes, book + 1);
    return min(no, yes);
}

int main(int argc, char const *argv[]) {
    cin >> n >> m >> x;
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    int rikai[m];
    memset(rikai, 0, m);
    Takahashi t = {0, {*rikai}};
    int ans = dfs(t, 0);
    if (ans == INF) {
        ans = -1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll n; cin >> n;
    vvl v(n+1);
    for(ll i=1; i<=n; i++){
        for(ll j=1; j <= (ll)sqrtl(i); j++){
            if(i % j == 0) {
                v[i].push_back(j);
                if(j*j != i){
                    v[i].push_back(i/j);
                }
            }
        }
    }
    rep(i,n+1) sort(all(v[i]));
    vl a(n);
    rep(i,n) cin >> a[i];
    for(int i=n-1; i>=0; i--){
        if(a[i] % 2 == 1){
            for(ll j=0; j<v[i+1].size()-1; j++){
                //if(v[i+1][j] != i+1) a[v[i+1][j]]++;
                a[--v[i+1][j]]++;
            }
        }
    }
    //rep(i,v[3].size()) cout << v[3][i] << endl;
    /*rep(i,n) cout << a[i] << " ";
    cout << endl;*/
    ll cnt = 0;
    vl b;
    rep(i,n){
        if((a[i] % 2) == 1){
            cnt++;
            b.push_back(i+1);
        }
    }
    cout << cnt << endl;
    rep(i,cnt) cout << b[i] << " ";
}

Measured memory_bytes: 34804
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin >> s;
  int n = s.length();
  int i;
  int chk = 0;
  long ans = 0;
  int a[n+1];
  for(i=0;i<n+1;i++){
    a[i] = 0;
  }
  
  
  while(chk == 0){
    chk = 1;
    for(i=0;i<n;i++){
      if(s[i] == '<'){
        if(a[i] >= a[i+1]){
          a[i+1] = a[i]+1;
          chk = 0;
        }
      }else{
        if(a[i] <= a[i+1]){
          a[i] = a[i+1]+1;
          chk = 0;
        }
      }
    }
    for(i=n-1;i>=0;i--){
      if(s[i] == '<'){
        if(a[i] >= a[i+1]){
          a[i+1] = a[i]+1;
          chk = 0;
        }
      }else{
        if(a[i] <= a[i+1]){
          a[i] = a[i+1]+1;
          chk = 0;
        }
      }
    }
  }
  for(i=0;i<=n;i++){
    ans += a[i];
  }
  cout << ans;
}

Measured memory_bytes: 2820
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using tiii = tuple<int,int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const ll DIV =1e9+7;
//const double PI = M_PI;
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
#define chmax(a,b) a=max(a,b)

/*Coding Space*/
int main(){
  ll a,b; cin >> a >> b;
  ll g = __gcd(a,b);
  set<ll> li;
  for(int i = 1; i < 1000001; ++i){
    if(g % i == 0){
      li.insert(i);
      li.insert(g/i);
    }
  }

  vt<ll> ans;
  for(auto l : li){
    rep(j, ans.size()){
      if(__gcd(l, ans[j]) != 1)  break;
      if(j == int(ans.size() - 1)) ans.pb(l);
    }
    if(ans.size() == 0)  ans.pb(l);
  }
  cout << ans.size() << endl;
}


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

using namespace std;
typedef long long ll;

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

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

  if (a + b >= 10) cout << "error" << "\n";
  else cout << a + b << "\n";
}


Measured memory_bytes: 3636
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <set>
using namespace std;

typedef pair<int,int> Pii;

int main(int argc, char const *argv[]) {
  long long n;cin>>n;
  vector<long long> a(n),b(n);
  for(int i=0;i<n;++i){
    cin>>a[i];
    cin>>b[i];
  }
  long long res = 0;
  for(int i=n-1;i>-1;--i){
    if((a[i]+res)%b[i]!=0)res += b[i] - (a[i]+res)%b[i];
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 1792
N = int(input())
B = [int(i) for i in input().split(" ")]

A = []

for i in range(N):
    # print("i:", i)
    if i == 0:
        A.append(B[i])
        # print("A:", A)
        # print("")
    elif i == N - 1:
        A.append(B[i - 1])
        # print("A:", A)
        # print("")
    else:
        if B[i-1] < B[i]:
            A.append(B[i-1])
            # print("A:", A)
            # print("")
        else:
            A.append(B[i])
            # print("A:", A)
            # print("")

print(sum(A))

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

typedef struct{
    int label[6];
}dice;

void roll_south( int* );
void roll_north( int* );
void roll_east( int* );
void roll_west( int* );
int match( int*, int*, int  );
int match_dice( dice ,dice );

int main(){
	int dice_num = 0;
    int i, j;
    dice* dice_box;
	int match_flg = 0;
	
	scanf( "%d", &dice_num );
	dice_box = ( dice* )malloc( sizeof( dice ) * dice_num );
	for( i = 0; i < dice_num; i++ ){
		for( j = 0; j < 6; j++ ){
			scanf( "%d", &dice_box[i].label[j] );
		}
	}
	
	for( i = 0; i < dice_num; i++ ){
		for( j = i + 1; j < dice_num; j++ ){
			if( match_dice( dice_box[i], dice_box[j] ) == 1 ){
				match_flg = 1;
				goto end;
			}
			else{
				/* 処理なし */
			}
		}
	}
	
end:
	
	if( match_flg == 0 ){
		printf( "Yes\n" );
	}
	else{
		printf( "No\n" );
	}
	
    return 0;
}

int match_dice( dice dice1, dice dice2 ){
    int i, j;
	int ans = 0;

	for( i = 0; i < 6; i++ ){
		for( j = 0; j < 4; j++ ){
			if( match( dice1.label, dice2.label, 6 ) == 1 ){
				ans = 1;
				goto end;
			}
			else{
				roll_north( dice1.label );
				roll_east( dice1.label );
				roll_south( dice1.label );
			}
		}
		if( i % 2 == 0 ){
			roll_north( dice1.label );
		}
		else{
			roll_east( dice1.label );
		}
	}

end:
    return ans;
}

int match( int* a,int* b, int num  )
{
	int i = 0;
	int match = 1;

	for( i = 0; i < num; i++ ){
		if( a[i] != b[i] ){
			match = 0;
			break;
		}
		else{
			/* 処理なし */
		}
	}

	return match;
}

void roll_south( int* dice )
{
    int work;
    
    work = dice[0];
    dice[0] = dice[4];
    dice[4] = dice[5];
    dice[5] = dice[1];
    dice[1] = work;
}
void roll_north( int* dice )
{
    int work;
    
    work = dice[0];
    dice[0] = dice[1];
    dice[1] = dice[5];
    dice[5] = dice[4];
    dice[4] = work;
}
void roll_east( int* dice )
{
    int work;
    
    work = dice[0];
    dice[0] = dice[3];
    dice[3] = dice[5];
    dice[5] = dice[2];
    dice[2] = work;
}
void roll_west( int* dice )
{
    int work;
    
    work = dice[0];
    dice[0] = dice[2];
    dice[2] = dice[5];
    dice[5] = dice[3];
    dice[3] = work;
}


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

int main()
{
    vector<int> a(9);
    for (int i = 0; i < 9; i++)
    {
        cin >> a[i];
    }
    int n;
    cin >> n;
    vector<int> b(n);
    vector<int> c(9, 0);
    for (int j = 0; j < n; j++)
    {
        cin >> b[j];
        for (int k = 0; k < 9; k++)
        {
            if (b[j] == a[k])
                c[k] = 1;
        }
    }
    if ((c[0] == 1 && c[1] == 1 && c[2] == 1) || (c[3] == 1 && c[4] == 1 && c[5] == 1) || (c[6] == 1 && c[7] == 1 && c[8] == 1) ||
        (c[0] == 1 && c[3] == 1 && c[6] == 1) || (c[1] == 1 && c[4] == 1 && c[7] == 1) || (c[2] == 1 && c[5] == 1 && c[8] == 1) ||
        (c[0] == 1 && c[4] == 1 && c[8] == 1) || (c[2] == 1 && c[4] == 1 && c[6] == 1))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {

            string[] input = Console.ReadLine().Split(' ');
            long N = long.Parse(input[0]);
            long D = long.Parse(input[1]);
            long count = 0;
            List<point> points = new List<point>();
            for (int i = 0; i < N; i++)
            {
                points.Add(new point(D, Console.ReadLine()));
            }
            for (long i = 0; i < N-1; i++)
            {
                for (long j = i + 1; j < N; j++)
                {
                    if (IsPerfectSquare(points[(int)i].getSqDistance(points[(int)j]))) count++;
                }
            }
            Console.WriteLine(count.ToString());
        }
        public class point
        {
            long[] num;
            public point (long D, string input_str)
            {
                num = new long[D];
                string[] input_div = input_str.Split(' ');
                for (int i = 0; i < D; i++)
                {
                    num[i] = long.Parse(input_div[i]);
                }
            }
            public long getSqDistance(point number)
            {
                long distance = 0;
                for (int i = 0; i < this.num.Count(); i++)
                {
                    distance += (this.num[i] - number.num[i]) * (this.num[i] - number.num[i]);
                }
                return distance;
            }
        }
        public bool isPerfectRoot(long input)
        {
            bool isPerfect = false;



            return isPerfect;
        }
        public static bool IsPerfectSquare(long num)
        {
            int root = (int)Math.Sqrt(num);
            return (int)Math.Pow(root, 2) == num;
        }
    }
}

Measured memory_bytes: 11220
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<string>
#include<map>
#include<set>
#include<functional>
#include<list>
#include<bitset>
#include<numeric>
#include<utility>
#define INF (int)1e9
#define DINF (double)1e9
#define MOD 1000000007
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> p;

//cout<<fixed<<setprecision(15)<<ans;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	int n, m, X, Y;
	cin >> n >> m >> X >> Y;
	vector<int> x(n), y(m);
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> y[i];
	}
	int z = 1+*max_element(x.begin(), x.end());
	int w = *min_element(y.begin(), y.end());
	bool q = false;
	if (X < z&&z <= Y && z <= w) {
		cout << "No War";
	}
	else {
		cout << "War";
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,k; cin>>n>>k;
	map<int,int> ct;
	for (int i=0; i<k; i++) {
		int d; cin>>d;
		for (int j=0; j<d; j++) {
			int a; cin>>a;
			ct[a]++;
		}
	}
	int ret=0;
	for (int i=1; i<=n; i++)
		if (ct[i]==0) ret++;
	cout<<ret<<endl; 
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	string s;
	cin >> s;
	cout << s.substr(0, 3) << endl;
	return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <iostream>

int n, k;
int main() {
	std::ios::sync_with_stdio(false), std::cin.tie(0), std::cout.tie(0);
	std::cin >> k;
	if (k == 1) { std::cout << "1\n1\n"; return 0; }
	std::cout << (n = k + 3 >> 2 << 1) << '\n';
	for (int i = 0; i < n; ++i, std::cout.put('\n'))
		for (int j = 0, t; j < n; ++j)
			t = (i + j) % n + 1 + (i & 1) * n,
			std::cout << (t > k ? t - n : t) << ' ';
	return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int a[1000000];
int b[1000000];
int main()
{
	int k,n,i;
	scanf("%d %d",&k,&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	for(i=0;i<n-1;i++)
	{
		b[i]=a[i+1]-a[i];
	}
	b[n-1]=abs(k-a[n-1]+a[0]);
	sort(b,b+n);
	printf("%d",k-b[n-1]);
}

Measured memory_bytes: 5120
N = int(input())
S = input()

b1,b2="",""

if N%2==1:
    print("No")
    exit()
else:
    for i in range(int(N/2)):
        b1=b1+S[i]
        b2=S[(len(S)-1)-i]+b2
if b1==b2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
int main(void)
{
    char S[150];
  int i,n;
    // 整数の入力
    scanf("%s\n",S);
  	n=strlen(S);
   for(i=0;i<n;i++){
     S[i]='x';
   }
    printf("%s\n",S);
  
    return 0;
}

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define ul unsigned long long

int main() {
        vector<int> v;
        int K,N,buf;
        cin >> N >> K;
        rep(i,N){
                cin >> buf;
                v.push_back(buf);
        }

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

        int result =0;

        rep(i,K) result += v.at(i);

        cout << result << endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

ll ret_sum(int x, vector<ll> &vs){
    ll res = 0;
    REP(i, x){
        res+=vs[i];
    }
    return res;
}

int main(){
    ll N, W;
    cin >> N >> W;
    vector<ll> ws(4, 0);
    vector< vector<ll> > vs(4);
    REP(i, N){
        ll w, v;
        cin >> w >> v;
        int j = 0;
        while(j<ws.size()){
            if(ws[j]==w || ws[j]==0) break;
            j++;
        }
        ws[j]=w;
        vs[j].push_back(v);
    }
    REP(i, 4) sort(vs[i].begin(), vs[i].end(), greater<int>());
    ll ma = 0;
    REP(i, vs[0].size()+1) REP(j, vs[1].size()+1) REP(k, vs[2].size()+1) REP(l, vs[3].size()+1){
        ll w_sum = ws[0]*i+ws[1]*j+ws[2]*k+ws[3]*l;
        ll v_sum = ret_sum(i, vs[0]) + ret_sum(j, vs[1]) + ret_sum(k, vs[2]) + ret_sum(l, vs[3]);
        if(w_sum<=W){
            ma = max(ma, v_sum);
        }
    }
    cout << ma << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 1e7+10, mod = 998244353;
int n;

inline int power(int a,int b){
	int ret=1;
	for (;b;b>>=1,a=1ll*a*a%mod) if (b&1) ret=1ll*ret*a%mod;
	return ret;
}
int fac[N],ifac[N],pw[N];
inline void init(int n){
	pw[0]=1;
	For(i,1,n) pw[i]=1ll*pw[i-1]*2%mod;
	fac[0]=1;
	For(i,1,n) fac[i]=1ll*fac[i-1]*i%mod;
	ifac[n]=power(fac[n],mod-2);
	Dow(i,n-1,0) ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
}
inline int C(int n,int m){
	return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}

int main(){
	n=read(),init(n);
	int ans=0;
	FOR(i,0,n/2) ans=(ans+2ll*C(n,i)*pw[i])%mod;
	printf("%d\n",(power(3,n)-ans+mod)%mod);
}

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

int main() {
  int N, M, T;
  cin >> N >> M >> T;
  int a[N];
  rep(i, N) cin >> a[i];
  a[N] = T + M;
  int ans = a[0] - M;
  for (int i = 0; i < N; i++)
    ans += max(0, a[i + 1] - a[i] - 2 * M);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3088
N, M, Q = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(Q)]

ans = 0
for a in range(M):
    for b in range(a, M):
        for c in range(b, M):
            for d in range(c, M):
                for e in range(d, M):
                    for f in range(e, M):
                        for g in range(f, M):
                            for h in range(g, M):
                                for i in range(h, M):
                                    for j in range(i, M):
                                        tmp = [a, b, c, d, e, f, g, h, i, j]
                                        tmp_ans = 0
                                        for q in range(Q):
                                                if tmp[L[q][1]-1] - tmp[L[q][0]-1] == L[q][2]:
                                                    tmp_ans += L[q][3]

                                        ans = max(ans, tmp_ans)

print(ans)

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

ll cal(ll n){
	if(n<5 || n%2==1)
		return 0;
	ll res=0;
	ll i=10;
	while((n/i)>=1){
		res=res+(n/i);
		i*=5;
	}

	return res;
}

int main(){
	ll n;
	cin>>n;
	assert(n>=0 && n<=pow(10,18));
	ll res = cal(n);
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
input = list(input())
s = [int(i) for i in input]

ans1 = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == 1:
            ans1 += 1
    else:
        if s[i] == 0:
            ans1 += 1

ans2 = 0
for j in range(len(s)):
    if j % 2 == 0:
        if s[j] == 0:
            ans2 += 1
    else:
        if s[j] == 1:
            ans2 += 1

print(min(ans1,ans2))


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

#define rep(i, a, b) for (int i = a, i##end = b; i <= i##end; ++i)
#define per(i, a, b) for (int i = a, i##end = b; i >= i##end; --i)
#define rep0(i, a) for (int i = 0, i##end = a; i < i##end; ++i)
#define per0(i, a) for (int i = (int)a-1; ~i; --i)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define chkmax(a, b) a = max(a, b)
#define chkmin(a, b) a = min(a, b)
#define x first
#define y second
#define enter putchar('\n')

typedef long long ll;
typedef double DB;

const DB eps = 1e-12;
const DB PI = acos(-1);

int sgn(DB x) { return fabs(x) < eps ? 0 : (x > 0 ? 1 : -1); }

struct Point {
	DB x, y;
	Point(DB x = 0, DB y = 0) : x(x), y(y) {}
	Point operator + (Point a) { return Point(x + a.x, y + a.y); }
	Point operator - (Point a) { return Point(x - a.x, y - a.y); }
	Point operator - () { return Point(-x, -y); }
	friend Point operator * (DB k, Point a) { return Point(k * a.x, k * a.y); }
	Point operator / (DB k) { return Point(x / k, y / k); }
	DB operator % (Point a) { return x * a.x + y * a.y; }
	DB operator / (Point a) { return x * a.y - y * a.x; }
	operator DB() { return sqrt(x*x + y*y); }
	bool operator < (const Point &a) const { int d1 = sgn(x-a.x), d2 = sgn(y-a.y); return d1 < 0 || (d1 == 0 && d2 < 0); }
};

struct Circle { Point P; DB r; };

Point Proj(Point P, Point P1, Point P2) {
	Point v = P2-P1; DB t = (P-P1)%v / (v%v);
	return P1 + t*v;
}

Point GetLineInter(Point P1, Point P2, Point Q1, Point Q2) {
	Point v = P2-P1, w = Q2-Q1; DB t = (Q1-P1)/w / (v/w);
	return P1 + t*v;
}

int Direct1(Point P, Point P1, Point P2) { return sgn((P1-P)%(P2-P)); }
int Direct2(Point P, Point P1, Point P2) { return sgn((P1-P)/(P2-P)); }

Point A, B, C;

Circle GetInnerCir(Point A, Point B, Point C) {
	Point v1 = B-A, v2 = C-A, v3 = C-B;
	v1 = v1/DB(v1), v2 = v2/DB(v2), v3 = v3/DB(v3);
	Point P = GetLineInter(A, A + (v1+v2), B, B + (v3-v1));
	return (Circle){P, DB(P-Proj(P, A, B))};
}

Circle GetOuterCir(Point A, Point B, Point C) {
	Point M = 0.5*(A+B), N = 0.5*(A+C), v = B-A, w = C-A;
	Point P = GetLineInter(M, M + Point(v.y, -v.x), N, N + Point(w.y, -w.x));
	return (Circle){P, DB(P-A)};
}

int main() {
	scanf("%lf%lf%lf%lf%lf%lf", &A.x, &A.y, &B.x, &B.y, &C.x, &C.y);
	Circle X = GetOuterCir(A, B, C);
	printf("%.10lf %.10lf %.10lf\n", X.P.x, X.P.y, X.r);
	return 0;
}


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

int main(void){
    int n; cin >> n;
    set<ll> a;
    ll cnt=0;
    for(int i=0;i<n;i++){
        ll tmp; cin >> tmp;
        if(a.find(tmp)!=a.end()){
            cnt++;
        }else{
            a.insert(tmp);
        }
    }

    cout << a.size() - (cnt%2) << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

int main(){
  string S,T; cin>>S>>T;
  rep(i,S.length()){
    if(S[i]!=T[i]){
      cout<<"No\n";
      return 0;
    }
  }
  cout<<"Yes\n";
  return 0;
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
#define double long double
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort(all(vec));
#define rever(vec) reverse(all(vec));
#define unsort(vec) sort(vec); rever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
  int n,m;
  cin>>n>>m;
  int A[m];
  int cnt=0;
  rep(i,m) A[i]=0;
  rep(i,n) {
    int k;
    cin>>k;
    rep(j,k) {
      int a;
      cin>>a;
      A[a-1]++;
    }
  }
  rep(i,m) {
    if(A[i]==n) cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
import * as fs from 'fs';

const input = fs.readFileSync("/dev/stdin", "utf8");
let a = input.trim().split(' ')
let seven = 0
let five = 0
if (a.filter(a => a == '7').length == 1
	&& a.filter(a => a == '5').length == 2) {
	console.log('YES')
} else {
	console.log('NO')
}


Measured memory_bytes: 29572
#include <iostream>
using namespace std;
int h,w,x[110],y[110];
char a[110][110];
int main(){
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
            if(a[i][j]=='#'){
                x[i]=1; y[j]=1;
            }
        }
    }
    for(int i=0;i<h;i++){
        if(x[i]==0) continue;
        for(int j=0;j<w;j++){
            if(y[j]==0) continue;
            cout<<a[i][j];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=2e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();	
 	
 	string a;
 	cin>>a;

 	cout<<string(sz(a),'x')<<endl;
 	
}		


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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define vec vector

int main(void)
{
    while(1) {
        int n, m;
        cin >> n >> m;
        if (n == 0 && m == 0) break;
        vec<int> x(11, 0);
        rep(i, n) {
            int p, q;
            cin >> p >> q;
            x[q] += p;
        }
        int ok = 0;
        int ans = 0;
        for (int i = 10; i >= 0; i--) {
            if (ok) {
                ans += x[i] * i;
                continue;
            }
            m -= x[i];
            if (m < 0) {
                ans += - m * i;
                ok = 1;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <deque>
#include <iomanip>


using namespace std;


typedef long long ll;


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

  int maxH = 0;
  int N;
  cin >> N;
  int curH;
  int ans = 0;
  for (int i = 1 ; i <= N ; i++) {
    cin >> curH;
    if (curH >= maxH) {
      ans++;
      maxH = curH;
    }
  }

  cout << ans;


  return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    ll res=0;
    vector<pair<int,int>> v(n);
    map<pair<int,int>,ll> mp;
    for(int i=0;i<n;i++){
        cin >> v[i].first >> v[i].second;
        ll w; cin >> w;
        mp[v[i]]+=w;
    }
    for(int i=0;i<n;i++){
        ll sum;
        sum=mp[v[i]];
        if(mp.count(make_pair(v[i].first-1,v[i].second))){
            sum+=mp[make_pair(v[i].first-1,v[i].second)];
        }
        if(mp.count(make_pair(v[i].first-1,v[i].second+1))){
            sum+=mp[make_pair(v[i].first-1,v[i].second+1)];
        }
        if(mp.count(make_pair(v[i].first,v[i].second+1))){
            sum+=mp[make_pair(v[i].first,v[i].second+1)];
        }
        res=max(res,sum);

        sum=mp[v[i]];
        if(mp.count(make_pair(v[i].first+1,v[i].second))){
            sum+=mp[make_pair(v[i].first+1,v[i].second)];
        }
        if(mp.count(make_pair(v[i].first+1,v[i].second+1))){
            sum+=mp[make_pair(v[i].first+1,v[i].second+1)];
        }
        if(mp.count(make_pair(v[i].first,v[i].second+1))){
            sum+=mp[make_pair(v[i].first,v[i].second+1)];
        }
        res=max(res,sum);

        sum=mp[v[i]];
        if(mp.count(make_pair(v[i].first+1,v[i].second))){
            sum+=mp[make_pair(v[i].first+1,v[i].second)];
        }
        if(mp.count(make_pair(v[i].first+1,v[i].second-1))){
            sum+=mp[make_pair(v[i].first+1,v[i].second-1)];
        }
        if(mp.count(make_pair(v[i].first,v[i].second-1))){
            sum+=mp[make_pair(v[i].first,v[i].second-1)];
        }
        res=max(res,sum);

        sum=mp[v[i]];
        if(mp.count(make_pair(v[i].first-1,v[i].second))){
            sum+=mp[make_pair(v[i].first-1,v[i].second)];
        }
        if(mp.count(make_pair(v[i].first-1,v[i].second-1))){
            sum+=mp[make_pair(v[i].first-1,v[i].second-1)];
        }
        if(mp.count(make_pair(v[i].first,v[i].second-1))){
            sum+=mp[make_pair(v[i].first,v[i].second-1)];
        }
        res=max(res,sum);
    }
    printf("%lld / 1\n",res);
}


Measured memory_bytes: 9936
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
   
// g++ -std=c++11 prac.cpp
        
int main(){
    int d,n,x,y=0,z,m,k,w,sum=0,ans=0,Max=-1e9,Min=1e9+1;
    string s,t;
    bool count=false,ok=false;
    VI a(4);
    rep(i,6){
        cin >> x;
        a[x-1]++;
    }
    if(a[0]<=2 && a[1]<=2 && a[2]<=2 && a[3]<=2)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define debug cerr << "-- " << __LINE__ << " --" << endl
#define MOD 1000000007
typedef long long int ll;

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template <typename T> string to_string(const vector<T> &xs) {string s="["; for(int i=0;i<xs.size();i++) s += (i>0 ? " " : "") + to_string(xs[i]); return s + "]";}
ll nextLL(){ll x; scanf("%lld", &x); return x;}
int nextInt(){int x; scanf("%ld", &x); return x;}


ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
ll gcd(ll a, ll b) { ll x, y; return extgcd(a, b, x, y);}

class llm{
	ll n;
public:
	llm(){n = 0;}
	llm(ll n){this->n = (n >= 0) ? (n % MOD) : (MOD - 1 - (-n-1 % MOD));}
	operator ll() const {return n;}
	llm operator+(const llm &y) const{ return llm((ll)*this + (ll)y);}
	llm operator+=(const llm &y) { *this = *this + y; return *this;}
	llm operator-(const llm &y) const{ return llm((ll)*this - (ll)y);}
	llm operator-=(const llm &y) { *this = *this - y; return *this;}
	llm operator-() const{ return llm(0) - *this;}
	llm operator*(const llm &y) const{ return llm((ll)*this * (ll)y);}
	llm operator*=(const llm &y) { *this = *this * y; return *this;}
	llm operator/(const llm &y) const{ return *this * y.inv();}
	llm operator/=(const llm &y) { *this = *this / y; return *this;}
	llm inv() const{
		ll x, y;
		if (extgcd(n, MOD, x, y) == 1) return llm(x);
  		return llm(0); // unsolvable
	}
	friend istream& operator >> (istream& os, llm& x);
	friend ostream& operator << (ostream& os, const llm& x);
};
istream& operator >> (istream& is, llm& x){ll n; is >> n; x = llm(n); return is;}
ostream& operator << (ostream& os, const llm& x){os << (ll)x; return os;}

template<typename T> T comb(ll n, ll k){
	T ret = 1;
	for(ll i=1;i<=k;i++) ret = ret * T(n - k + i) / T(i);
	return ret;
}

ll N, M;


int main(void){
	cin >> N >> M;
	vl deg(N);
	vvl adjList(N);

	for(int i=0;i<M;i++){
		ll a = nextLL() - 1, b = nextLL() - 1;
		deg[a]++; deg[b]++;
		adjList[a].pb(b); adjList[b].pb(a);
	}

	for(int i=0;i<N;i++) if (deg[i]%2) {cout << "No" << endl; return 0;}
	for(int i=0;i<N;i++) if (deg[i] >= 6) {cout << "Yes" << endl; return 0;}
	vl cross;
	for(int i=0;i<N;i++) if (deg[i] == 4) cross.pb(i);
	if (cross.size() <= 1) {cout << "No" << endl; return 0;}
	if (cross.size() >= 3) {cout << "Yes" << endl; return 0;}

	// 2 つの crossing
	for(ll next : adjList[cross[0]]){
		ll now = cross[0];
		while(deg[next] == 2){
			ll next2 = (adjList[next][0] != now) ? adjList[next][0] : adjList[next][1];
			now = next; next = next2;
		}
		if (next == cross[0]) {cout << "Yes" << endl; return 0;}
	}
	cout << "No" << endl; return 0;

    return 0;
}




Measured memory_bytes: 6528
n, k = map(int, input().split())
r, s, p = map(int, input().split())
T = str(input())
score = 0
lose = []
def janken(hand):
    if hand == 'r':
        return(p)
    if hand == 's':
        return(r)
    if hand == 'p':
        return(s)

for i in range(n):
    if i <= k - 1:
        score += janken(T[i])
    else:
        if T[i] == T[i - k]:
            if i - k not in lose:
                lose.append(i)
            else:
                score += janken(T[i])
        else:
            score += janken(T[i])
print(score)


Measured memory_bytes: 43632