akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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













int main(){
    string s, t;
    cin >> s >> t;
    ll n = s.size(), m = t.size();
    vector<vector<ll>> c(n, vector<ll>(26, -1));
    for(ll i = n - 1; i >= 0; i--){
        if(i < n - 1){
            REP(j, 26){
                c[i][j] = c[i + 1][j];
            }
        }
        c[i][s[i] - 'a'] = i;
    }
    REP(i, m){
        if(c[0][t[i] - 'a'] == -1){
            cout << -1 << endl;
            return 0;
        }
    }
    ll ans = 0, idx = 0;
    REP(i, m){
        if(idx >= n) idx = 0;
        ll next = c[idx][t[i] - 'a'];
        if(next != -1){
            ans += next - idx;
            idx = next + 1;
            if(idx >= n) idx = 0;
            ans++;
        }
        else{
            ans += n - idx;
            idx = 0;
            i--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 24704
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define rep(i,N) For(i,0,N)
#define endl "\n"
#define print(v) cout<<v<<endl
const ll inf=1LL<<60;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
ll N;
vec v;
mat dp;
ll solve(ll now,ll path,ll cnt){
  if(now>=N)return (cnt!=N/2)*-inf;
  if(path>(N&1)+1)return -inf;
  if(dp[now][path]!=-inf)return dp[now][path];
  ll i,res=-inf;
  rep(i,2+(N&1))chmax(res,solve(now+i+2,path+i,cnt+1));
  return dp[now][path]=res+v[now];
}
int main(){
  ll i,ans=-inf;
  cin>>N;
  v.resize(N);
  dp.resize(N,vec(3,-inf));
  rep(i,N)cin>>v[i];
  rep(i,2+(N&1))chmax(ans,solve(i,i,0));
  print(ans);
}

Measured memory_bytes: 23584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
static const int INF (1<<30);

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

  char tmp;
  bool flag_bad = false;
  rep(i,3) {
    if (S[i+1] == S[i]) flag_bad = true;
  }

  if (flag_bad) cout << "Bad" << endl;
  else cout << "Good" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(){
    int n;
    while(scanf("%d",&n),n){
        int a[10] = {0};
        for(int i = 0;i < n; i++){
            int x;
            scanf("%d",&x);
            (x >= 60) ? a[0]++ : (x >= 50) ? a[1]++ : (x >= 40) ? a[2]++ : (x >= 30) ? a[3]++ : (x >= 20) ? a[4]++ : (x >= 10) ? a[5]++ : a[6]++;
        }
        for(int i = 6;i >= 0; i--)printf("%d\n",a[i]);
    }
    return 0;
}

Measured memory_bytes: 1028
#include<stdio.h>

int main(void){
 
 int N; int M;
 scanf("%d %d", &N, &M);

int i;
int s[M];
int c[M];

int d[N+1];
for(i=1; i<N+1; i++){
    d[i] = -1;
}

for(i=0; i<M; i++){
    scanf("%d %d", &s[i], &c[i]);
int sss = d[s[i]];
 // printf("%d\n", sss);
if(sss == -1){
    d[s[i]] = c[i];
}

   if((sss == -1) || sss == c[i]){
       d[s[i]] == c[i];
      // printf("%d", d[s[i]]);
   }else{
printf("-1");
return 0;
   }
}
 
 if(N==1){
    if(d[1]<=0){
        printf("0");
        return 0;
    }else{
        printf("%d", d[1]);
        return 0;
    }
}


if(d[1] == 0){
    printf("-1");
    return 0;
}




    if(d[1] == -1){
    printf("1");
    }else{
printf("%d", d[1]);
    }

for(i=2; i<N+1; i++){
    if(d[i] == -1){
    printf("0");
    }else{
printf("%d", d[i]);
    }
}

return 0;
}

Measured memory_bytes: 128
loop {
  suma = 0
  sumb = 0

  num = gets.to_i

  if num == 0
    break;
  end

  (1..num).each {
    a, b = gets.split(" ").map { |num|
      num.to_i
    }
    if a > b
      suma += a + b
    elsif a < b
      sumb += a + b
    else 
      suma += a
      sumb += b
    end
  }

  printf("%d %d\n",suma, sumb)

}

Measured memory_bytes: 6120
# 各マス自身とその周囲のぶんだけ変わるので,
# 周囲を1マスずつ取り除いたときに残っている部分は9回訪れることになる
# 端は4回、それ以外の外周は6回
# 裏->表->裏を繰り返すので奇数回訪れた場所を数える
# どちらも1 or いずれかが1の場合だけ気をつける

n, m = map(int, input().split())

if n == 1 and m == 1:
    print(1)
elif n == 1 or m == 1:
    print(max(n, m) - 2)
else:
    print((n-2)*(m-2))


Measured memory_bytes: 2940
s = str(input())
n = len(s)
x = "abcdefghijklmnopqrstuvwxyz"
mn = 101
for i in range(26):
  t = x[i]
  mx = 0
  c = 0
  for j in range(n):
    if s[j] == t:
      if mx < c:
        mx = c
      c = 0
    else:
      c += 1
  if mx < c:
    mx = c
  if mx < mn:
    mn = mx
print(mn)
    
    
    
    
  

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

long gcd(long m, long n){
  if(n>0)return gcd(n, m%n);
  else return m;
}

long lcm(long m, long n){
  return m/gcd(m, n)*n;
}

long cntnodiv(long m, long n, long a){
  return a-(a/m+a/n-a/lcm(m, n));
}

int main(){
  long a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << cntnodiv(c, d, b)-cntnodiv(c, d, a-1);
  return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
template<typename T> T gcd(T a,T b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int n, a;
bool b[35];
ll s;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    cin >> a;
    s ^= a;
    int f = 0;
    while(!(a&1)){
      f++;
      a >>= 1;
    }
    b[f] = true;
  }
  int ans = 0;
  FORR(i, 32, 0){
    if((s >> i) & 1){
      if(!b[i]){
        cout << -1 << endl;
        return 0;
      }
      s ^= (1ll << (i+1)) - 1;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n, m;
    std::cin >> n >> m;

    std::vector<std::string> b(n);
    for (int i = 0; i < n; i++) {
        std::cin >> b[i];
    }

    std::vector<std::vector<int>> v(n, std::vector<int>(m, 10000000));
    v[0][0] = 0;
    for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) {
        if (!i && !j) continue;
        if (i - 1 >= 0) {
            v[i][j] = std::min(v[i][j], v[i - 1][j] + (b[i][j] != b[i - 1][j] ? 1 : 0));
        }
        if (j - 1 >= 0) {
            v[i][j] = std::min(v[i][j], v[i][j - 1] + (b[i][j] != b[i][j - 1] ? 1 : 0));
        }
    }

    int ret = v[n - 1][m - 1];
    if (b[0][0] == '#') {
        if (b[n - 1][m - 1] == '#') ret = (ret + 2) / 2;
        else ret = (ret + 1) / 2;
    } else {
        if (b[n - 1][m - 1] == '#') ret = (ret + 1) / 2;
        else ret = ret / 2;
    }

    std::cout << ret << std::endl;

    return 0;
}


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


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

	bool hantei = false;
	rep(i, 9) {
		if (N % (i+1) == 0) {
			if (N / (i + 1) < 10) {
				hantei = true;
			}
		}
	}
	if (hantei == true)cout << "Yes"<<endl;
	else cout << "No" << endl;
return 0;
} 

Measured memory_bytes: 768
X,N=map(int,input().split())
if N!=0:
    p=list(map(int,input().split()))
else:
    print(X)
    exit()

ans=100
mindif=100000
for i in reversed(range(-200,200)):
    if i in p:
        continue
    if mindif>abs(i-X):
        ans=i
        mindif=abs(i-X)
    elif mindif==abs(i-X):
        ans=min(ans,i)
print(ans)

Measured memory_bytes: 9208
#!ruby -na
f=->n,m,a,b{s=a/m*n*~-n/2
x=b%m-m*y=(b%m+n*a%=m)/m
s+=y>0?f[y,a,m,x%a]+y*=n+x/a:0}
p f[*$F.map(&:to_i)]if$.>1

Measured memory_bytes: 14260
main=do
 n<-readLn
 let a=n`div`100
 let b=n`mod`100
 putStrLn$if 0<a&&a<13 then if 0<b&&b<13 then"AMBIGUOUS"else"MMYY"else if 0<b&&b<13 then"YYMM"else"NA"


Measured memory_bytes: 508
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <iomanip>
#include <set>
#include <sstream>
#include <cmath>
#include <deque>
#include <list>
#include <bitset>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long int64;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define FST first
#define SND second
const lint MOD = (lint)1e9 + 7;

signed main(){
    string S;
    cin >> S;
    int n = (int)S.size();
    vector<vector<lint> > DP(n+1, vector<lint>(4, 0));
    DP[n][3] = 1;
    REP(i, 3) DP[n][i] = 0;
    for(int j=3; j>=0; j--){
        for(int i=n-1; i>=0; --i){
            if(j==3){
                if(S[i]=='?') DP[i][j] = (DP[i+1][j] * 3)%MOD;
                else DP[i][j] = DP[i+1][j];
            }
            else{
                int m1, m2; //m1 reffers to case select S[i]
                if(S[i]=='?'){
                    m1 = 1;
                    m2 = 3;
                }
                else if(S[i]==(char)('A'+j) ){
                    m1 = 1;
                    m2 = 1;
                }
                else{
                    m1 = 0;
                    m2 = 1;
                }
                DP[i][j] = ((m1 * DP[i+1][j+1])%MOD + (m2 * DP[i+1][j])%MOD)%MOD;
            }
        }
    }
    cout << DP[0][0] << endl;
    return 0;
}


Measured memory_bytes: 7424
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;
int main(){
  ll n,a[5],minimum;
  cin >> n;
  minimum=n;
  for(int i=0;i<5;i++){
    cin >> a[i];
    minimum = min(minimum,a[i]);
  }
  ll count=0;
  cout << (n-1)/minimum+1+4;
}


Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    H, W, K = map(int, input().split())
    S = [list(map(int, list(input().strip("\n")))) for _ in range(H)]
    sumS = [[0] * (W + 1) for _ in range(H + 1)]
    for h in range(H):
        for w in range(W):
            sumS[h+1][w+1] = sumS[h+1][w] + sumS[h][w+1] - sumS[h][w] + S[h][w]
    minK = 1000000000000
    for h in range(2 ** (H - 1)):
        count = 0
        border = [0]
        k = h
        for i in range(H-1):
            if k % 2 == 1: 
                border.append(i+1)
                count += 1
            k //= 2
        border.append(H)
        bN = len(border)
        left = 0
        ng = False
        for right in range(1, W + 1):
            for i in range(bN - 1):  
                if sumS[border[i+1]][right] - sumS[border[i+1]][left] - sumS[border[i]][right] + sumS[border[i]][left] > K:
                    if right - 1 == left: ng = True
                    else: 
                        count += 1
                        left = right - 1
                    break
            if ng: break 
        else: minK = min(minK, count)
    print(minK)
    return 0

if __name__ == "__main__":
    solve()

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int t , n;
int a[MAXX];
string s;

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

    int k = s.size();
    if(s[k - 1] == 's'){
        cout << s + "es" << endl;
    }
    else{
        cout << s + "s" << endl;
    }
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define N 1000000007
#define M 998244353 
#define INF 1e9
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n,m,i,j,k,t,l;
    cin>>t>>k;
    k = 2*k + 1;
    ll ans;
    if(t%k == 0 ) ans = t/k;
    else ans = t/k + 1;
    cout<<ans;

 }

Measured memory_bytes: 256
def dist(a, b):
    return abs(a[0] - b[0]) + abs(a[1] - b[1])

def resolve():
    import sys
    input = sys.stdin.readline

    n = int(input().rstrip())
    ru = None
    rd = None
    lu = None
    ld = None

    for i in range(n):
        row = [int(x) for x in input().rstrip().split(" ")]
        if i == 0:
            ru = row
            rd = row
            lu = row
            ld = row
            continue

        if ru[0] + ru[1] < row[0] + row[1]:
            ru = row
        if rd[0] - rd[1] < row[0] - row[1]:
            rd = row
        if -lu[0] + lu[1] < -row[0] + row[1]:
            lu = row
        if -ld[0] - ld[1] < -row[0] - row[1]:
            ld = row

    ans = 0
    points = [ru, rd, lu, ld]
    for i in range(4):
        for j in range(i+1, 4):
            tmp = dist(points[i], points[j])
            if ans < tmp:
                ans = tmp

    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 73836
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iomanip>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define ll long long
#define Size(v) (int)v.size()

using namespace std;
// using namespace __gnu_pbds;

int n;

void solve() {
	cin >> n;
	vector<pair<int, int>> a(n + 1);

	for (int i = 1; i <= n; ++i) {
		cin >> a[i].first;
		a[i].second = i;
	}

	sort(a.begin() + 1, a.begin() + n + 1);

	for (int i = 1; i <= n; ++i) {
		cout << a[i].second << ' ';
	}
}

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

	int t = 1;
	while (t--) 
		solve();
	return 0;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int n;
    cin >> n;

    int cnt = 0;
    rep(i, 1, n + 1) {
        int x;
        cin >> x;
        if (x != i) { ++cnt; }
    }

    if (cnt == 2 || cnt == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
N=int(input())

if (N % 100 > 25 and N < 525):
    print("0")
    exit()
tmp1 = N % 100
tmp2 = int(N / 100)
if (tmp1 / 5 != 0):
    tmp3 = int(tmp1 / 5)
    tmp1 = tmp1 % 5
    tmp2 = tmp2 - tmp3
if (tmp1 / 4 != 0):
    tmp3 = int(tmp1 / 4)
    tmp1 = tmp1 % 4
    tmp2 = tmp2 - tmp3
if (tmp1 / 3 != 0):
    tmp3 = int(tmp1 / 3)
    tmp1 = tmp1 % 3
    tmp2 = tmp2 - tmp3
if (tmp1 / 2 != 0):
    tmp3 = int(tmp1 / 2)
    tmp1 = tmp1 % 2
    tmp2 = tmp2 - tmp3
if (tmp1 != 0):
    tmp2 = tmp2 - tmp1
    tmp1 = 0
if (tmp2 < 0):
    print("0")
else:
    print("1")
 

Measured memory_bytes: 3064
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    ps <- getIntList
    print . solve $ zipWith (/=) [1..n] ps

solve [] = 0
solve (x:[]) | not x = 1
             | otherwise = 0
solve (x:xs) | not x = 1 + solve (tail xs)
             | otherwise = solve xs

Measured memory_bytes: 2556
import sys
I = list(map(int, input().split()))
N = I[0]
M = I[1]
if not 1 <= N or not N <= 100:
    print("error")
    sys.exit()
if not 0 <= M or not M <= N:
    print("error")
    sys.exit()
if N == M:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn check(left: usize, central: usize, right: usize, is_sheeps: &Vec<bool>, s: &Vec<char>) -> bool {
    if s[central] == 'o' {
        if is_sheeps[central] {
            if is_sheeps[left] != is_sheeps[right] {
                return false;
            }
        } else {
            if is_sheeps[left] == is_sheeps[right] {
                return false;
            }
        }
    } else {
        if is_sheeps[central] {
            if is_sheeps[left] == is_sheeps[right] {
                return false;
            }
        } else {
            if is_sheeps[left] != is_sheeps[right] {
                return false;
            }
        }
    }
    true
}

fn main() {
    let n: usize = read();
    let s: String = read();
    let s = s.chars().collect::<Vec<_>>();

    let trials = [(true, true), (false, false), (false, true), (true, false)];
    for trial in trials.iter() {
        let mut is_sheeps = vec![false; n];
        is_sheeps[0] = trial.0;
        is_sheeps[1] = trial.1;

        for i in 1..n - 1 {
            if is_sheeps[i] && s[i] == 'o' {
                is_sheeps[i + 1] = is_sheeps[i - 1];
            } else if !is_sheeps[i] && s[i] == 'x' {
                is_sheeps[i + 1] = is_sheeps[i - 1];
            } else {
                is_sheeps[i + 1] = !is_sheeps[i - 1];
            }
        }
        let mut succeeded = true;
        succeeded &= check(n - 2, n - 1, 0, &is_sheeps, &s);
        succeeded &= check(n - 1, 0, 1, &is_sheeps, &s);
        for i in 1..n - 1 {
            succeeded &= check(i - 1, i, i + 1, &is_sheeps, &s);
        }
        if succeeded {
            println!(
                "{}",
                is_sheeps
                    .iter()
                    .map(|&x| if x { "S" } else { "W" })
                    .collect::<Vec<_>>()
                    .join("")
            );
            return;
        }
    }
    println!("-1");
}


Measured memory_bytes: 6396
#include<iostream>
#include<stdio.h>//printf("%.*f\n",*********);
#include<vector>//s.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char('a'=32+'A')
                //to_string,string,substr
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap

#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(a,n) rep(i,n)cin>>a[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int KETA(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}

bool KIBN(string s) {
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - 1 - i])return false;
	}
	return true;
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */

int main(void) {
	rapid_pleaseAC_fast;

	int n, k;
	cin >> n >> k;
	if (k == 1) {
		cout << 0 << rt;
	}
	else {
		cout << n - k << rt;
	}

	please AC;
}
//参考：---

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define DEC(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const ll LINF = (int)1e18;
const double EPS = 1e-9;

const int MAX_V = (int)200;
int d[MAX_V][MAX_V]; // d[u][v]は辺(u,v)のコスト。0-origin. 初期化忘れずに
int V;

void warshall_floyd() {
  REP(k, V)
    REP(i, V)
      REP(j, V) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int M,R;
  cin >> V >> M >> R;
  vector<int> r(R);
  REP(i,R) {
    cin >> r[i];
    --r[i];
  }
  sort(ALL(r));

  // 初期化
  REP(i, V) {
    fill(d[i], d[i] + V, LINF);
    d[i][i] = 0;
  }

  // コスト入力
  REP(i,M) {
    int a,b,c;
    cin >> a >> b >> c;
    --a; --b;
    // 有向・無向の区別注意
    d[a][b] = c;
    d[b][a] = c;
  }

  warshall_floyd();

  int ans = LINF;  
  do {
    int tmp = 0;
    REP(i,R-1) tmp += d[r[i]][r[i+1]];
    ans = min(ans,tmp);
  } while (next_permutation(ALL(r)));

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

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	static int[][] matrix;
	static int[][] time;
	static int t;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		matrix = new int[n][n];
		for (int i = 0; i < n; i++) {
			int u = sc.nextInt() - 1;
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				matrix[u][sc.nextInt() - 1] = 1;
			}
		}
		time = new int[n][2];
		
		// 1番は開始時間1
		t = 0;
		for(int i = 0; i < n; i++) {
			dfs(i);
		}
		
		for (int i = 0; i < n; i++) {
			System.out.printf("%1$d %2$d %3$d", i+1, time[i][0], time[i][1]);
			System.out.println();
		}
		
	}
	
	public static void dfs(int i) {
		// already visited
		if (time[i][0] > 0)
			return;
			
		time[i][0] = ++t;
			
		for (int j = 0; j < matrix[i].length; j++) {
			// linked
			if (matrix[i][j] == 1) {
				dfs(j);		
			}
		}
		
		// all search
		time[i][1] = ++t;
	}
}

Measured memory_bytes: 21208
#include <iostream>
#include <string>
#include <vector>

using namespace std;
int main(void){
    int N, Q;
    string S;
    cin >> N >> Q >> S;
    
    vector<int> v;
    v.push_back(0);
    for (int i = 0; i < N - 1; ++i) {
        if (S[i] == 'A' && S[i+1] == 'C') v.push_back(v[i] + 1);
        else v.push_back(v[i]);
    }
    
    int l, r;
    int res;
    for (int i = 0; i < Q; ++i) {
        cin >> l >> r;
        
        if (v[l-1] != v[l]) res = v[r-1] - v[l] + 1;
        else res = v[r-1] - v[l];
        
        cout << res << endl;
    }
}


Measured memory_bytes: 1528
// https://ei1333.github.io/luzhiled/
// http://beet-aizu.hatenablog.com/entry/2017/01/04/113233
// http://www.prefield.com/algorithm/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s)){in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------
int main(){
    init();
    inl(n,m);
    
    out(n*(n-1)/2+m*(m-1)/2);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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;}

int N,M; 
bool vis[55];
vi G[55];
bool edge[55][55];
void dfs(int n){
    if(vis[n]) return;
    vis[n]=true;
    for(auto a:G[n]){
        if(!vis[a] && edge[n][a]){
            dfs(a);
        }
    }
}
signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    cin >> N >> M;
    vc<pi> v;
    rep(i,M){
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].eb(b);
        G[b].eb(a);
        edge[a][b]=true;
        edge[b][a]=true;
        v.eb(a,b);
    }
    int ans=0;
    for(auto p:v){
        int a=p.fi,b=p.se;
        rep(i,N) vis[i]=false;
        edge[a][b]=false;
        edge[b][a]=false;
        dfs(0);
        bool can=false;
        rep(i,N){
            if(!vis[i]) {
                can=true;
                break;
            }
        }
        if(can) ans++;
        edge[a][b]=true;
        edge[b][a]=true;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  int n;
  cin>>n;
  ll l[n];
  for(int i=0;i<n;i++){
    cin>>l[i];
  }
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      for(int k=j+1;k<n;k++){
        if(l[i]!=l[j] and l[j]!=l[k] and l[k]!=l[i]){
          if(l[i]+l[j]>l[k] and l[j]+l[k]>l[i] and l[k]+l[i]>l[j]){
            ans++;
          }
        }
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0xff,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int m;
int frst;
int cnt[100010];
vector<int> vct;
vector<int> v[100010];
void dfs(int n,int p){
	cnt[n]=1;
	vct.pb(n);
	if(n==m){
		frst=vct[(vct.size()+1)/2];
	}
	rep(i,v[n].size()){
		if(v[n][i]==p)continue;
		dfs(v[n][i],n);
		cnt[n]+=cnt[v[n][i]];
	}
	vct.ppb();
}
int main(){
	cin>>m;
	rep(i,m-1){
		int a,b;
		cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	frst=-1;
	dfs(1,-1);
	bool win=cnt[frst]*2<m;
	string ans=win?"Fennec":"Snuke";
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long popcount(long long n){
    return __builtin_popcountll(n);
}

long long count_process(long long N){
    if(N == 1) return 1;
    if(N == 0) return 0;

    return count_process(N % popcount(N)) + 1;
}


int main(){
    int N;
    string X;
    cin >> N >> X;


    //Xに1が何個あるか求める
    long long one_counter = 0;
    for(int i=0; i<N; ++i){
        if( X[i] == '1' ) one_counter++;
    }

    vector<long long> original_mod_cumsum_plus_one(N + 1);
    vector<long long> original_mod_cumsum_minus_one(N + 1);

    //mod内でで合計を計算する
    for(int i=0; i<N; ++i){
        if(X[i] == '1'){
            long long keta = modpow(2, (N-1-i), one_counter+1);
            original_mod_cumsum_plus_one[N-1-i] = keta;
        }
    }
    long long original_m_plus = 0 ;
    for(int i=0; i<N; ++i){
        original_m_plus += original_mod_cumsum_plus_one[i];
        original_m_plus %= (one_counter+1);
    }

    long long original_m_minus = 0 ;
    //もし1が1つしかないとcount -1 が0 になってREになるので例外処理。
    // 1が一つもない場合はそもそもこのケースがありえないので, one_counter == 1の場合のみ処理する
    if(one_counter > 1){
        for(int i=0; i<N; ++i){
            if(X[i] == '1'){
                long long keta = modpow(2, (N-1-i), one_counter-1);
                original_mod_cumsum_minus_one[N-1-i] = keta;
            }
        }
        for(int i=0; i<N; ++i){
            original_m_minus += original_mod_cumsum_minus_one[i];
            original_m_minus %= (one_counter-1);
        }
    }

    //forで各桁に対して操作
    for(int i=0; i<N; ++i){
        long long res;
        long long tmp_m_minus = original_m_minus;
        long long tmp_m_plus = original_m_plus;

        //0に反転する
        if(X[i] == '1'){
            if(one_counter == 1){
                res = 0;
            }else{
                tmp_m_minus -= modpow(2, (N-1-i), one_counter-1);
                if(tmp_m_minus <= 0){
                    tmp_m_minus += (one_counter-1);
                    tmp_m_minus %= (one_counter-1);
                }
                long long tmp_one_counter = one_counter - 1 ;
                tmp_m_minus %= tmp_one_counter;

                res = count_process(tmp_m_minus) + 1;
            }

        }else{
            //1に反転
            tmp_m_plus += modpow(2, (N-1-i), one_counter+1);
            long long tmp_one_counter = one_counter+1;
            tmp_m_plus %= tmp_one_counter;

            res = count_process(tmp_m_plus) + 1;

        }
        cout << res << endl;
    }
}

Measured memory_bytes: 6792
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N, M;
  cin >> N >> M;

  unordered_map<long, vector<pair<long, long> > > LRD;

  rep (i, M) {
    long L, R, D;
    cin >> L >> R >> D;
    LRD[L].push_back(make_pair(R, D));
    LRD[R].push_back(make_pair(L, -D));
  }

  // set<pair<long, long> > considered;
  unordered_set<long> notyet;
  rep(i, N) notyet.insert(i+1);

  unordered_map<long, long> pos;
  queue<pair<long, long>> q;

  while (notyet.size() > 0) {
    long first = *(notyet.begin());
    // cout << "--- first: " << first << endl;
    q.push(make_pair(first, 0));
    while (q.size()) {
      pair<long, long> current = q.front();
      // cout << "--- q.front(): " << current.first << ", " << current.second << endl;
      q.pop();
      // for (auto it: pos) cout << "------------- " << it.first << ", " << it.second << endl;
      if (pos.count(current.first) == 0) pos[current.first] = current.second;
      // cout << "------------------" << endl;
      // for (auto it: pos) cout << "------------- " << it.first << ", " << it.second << endl;
      if (pos[current.first] != current.second) {
        cout << "No" << endl;
        return;
      }
      if (notyet.count(current.first) == 0) continue;
      notyet.erase(current.first);
      for (auto it: LRD[current.first]) {
        q.push(make_pair(it.first, current.second + it.second));
      }
    }
  }
  cout << "Yes" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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


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

    vector<int> v(N);
    rep(i, N) { cin >>v.at(i); }

    sort(v.begin(), v.end());
    
    cout << abs(v.at(N - 1) - v.at(0)) << endl;

}


Measured memory_bytes: 3576
from math import sqrt


def prime_factorization(x):
    li = []
    num = x
    for i in range(2, int(sqrt(x)) + 1):
        if num % i == 0:
            cnt = 0
            while num % i == 0:
                cnt += 1
                num //= i
            li.append((i, cnt))

    if num != 1:
        li.append((num, 1))

    #if not li:
    #    li.append((x, 1))

    return li


a, b = map(int, input().split())

a_pf = [(1, 1)] + prime_factorization(a)
b_pf = [(1, 1)] + prime_factorization(b)

ans = 0
for ap, at in a_pf:
    for bp, bt in b_pf:
        if ap == bp:
            ans += 1

print(ans)


Measured memory_bytes: 3064
A, B, C, D, E = io.read("*n", "*n", "*n", "*n", "*n")
S = {A, B, C, D, E}
T = {0, 0, 0, 0, 0}
U = 0
for i = 1, 5 do
    U = U + S[i]
    if S[i]%10 ~= 0 then
        T[i] = 10-S[i]%10
    end
end
table.sort(T)
for i = 1, 4 do
    U = U + T[i]
end
print(U)

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String A = sc.next();
		String B = sc.next();
		String C = sc.next();
		String endA = A.substring(A.length()-1);
		String startB = B.substring(0,1);
		String endB = B.substring(B.length()-1);
		String startC = C.substring(0,1);
		if(endA.equals(startB) && endB.equals(startC)) {
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 22608
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long n, k;
  string s;

  cin >> n >> s >> k;
  k--;

  char target = s[k];

  rep (i, s.size()) if (s[i] != target) s[i] = '*';

  cout << s << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d long double
#define pii pair<int,int>
#define pb push_back
#define pf push_front
#define cases int t;cin>>t;while(t--)
#define N 100003
#define M 103
#define inf LLONG_MAX
//int mod=1e9+7;
//int mod=998244353;

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

    int n;
    cin>>n;
    int ans=0,ma=0,i,x;
    for(i=1;i<=n;++i)
    {
        cin>>x;
        if(x>=ma)
            ++ans;
        ma=max(ma,x);
    }
    cout<<ans;



    return 0;
}


Measured memory_bytes: 256
W,H,N = map(int, input().split())
l,t,r,b = 0, H, W, 0
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        l = max(l, x)
    elif a == 2:
        r = min(r, x)
    elif a == 3:
        b = max(b, y)
    elif a == 4:
        t = min(t, y)
print(max(0, r - l) * max(0, t - b))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(a, b) for (int i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template <class T>inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> v(n,0);
    vector<bool> v1(n,false);
    REP(i,m){
        int s,c;
        cin >> s >> c;
        if (v[s - 1]!=c&&v1[s-1]){
            cout << -1 << endl;
            return 0;
        }
        v[s - 1] = c;
        if(s-1==0&&c==0&&n!=1){
            cout << -1 << endl;
            return 0;
        }
        v1[s-1]=true;
    }
    if (n != 1 && v[0] == 0)
    {
        v[0]=1;
    }
    REP(i,n){
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
/**
 *      AGC 27 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-25 15:20:25
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, x; cin >> n >> x;
    int a[n] = {};
    for (auto i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int cnt = 0;
    sort(a, a + n);

    for (auto i = 0; i < n - 1; ++i) {
        x -= a[i];
        if (x < 0){
            cout << cnt << endl; return 0;
        }
        else {
            ++cnt;
        }
    }

    if (x == a[n - 1]){
        cout << n << endl;
    }
    else {
        cout << n - 1 << endl;
    }

    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n; ++i) {
    if (i == 4) cout << " ";
    cout << s[i];
  }
  puts("");
  return 0;
}


Measured memory_bytes: 256
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
using namespace std;
signed main()
{
	fastio;
	string s;
	cin>>s;
	if(s=="ARC")
		cout<<"ABC";
	else
		cout<<"ARC";
}












Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}


int main() {
    ll x;
    cin >> x;
    for(ll i = -200;i<=200;i++) {
        for(ll j = -200;j<=200;j++) {
            if(pow(i,5) - pow(j,5) == x) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }    
}
    




Measured memory_bytes: 4052
N=int(input())
#A=1B=N-1にしてAとBの各位の和を出す
f_x=sum(map(int,str(N-1)))
count=int((f_x)+1)
for a in range(1,N):
    f_x_a=sum(map(int,str(a)))
    b=N-a
    f_x_b=sum(map(int,str(b)))
    ans=int((f_x_a)+(f_x_b))
#f_xより小さかったらcountに入れていきたい
    if count>=ans:
        count=ans
print(count)

Measured memory_bytes: 42344
/* ABC139-C
   Takatan */

#include<stdio.h>
#include<stdlib.h>
int main(void){
    int number, *hill, count, max, i, j;
    max = 0;

    scanf( "%d" , &number);
    hill = malloc(sizeof(int) * number);
    for(i=0; i < number; i++){
        scanf("%d" , &hill[i]);
    }

    for(i=0; i < number; i++){
        count = 0;
        if(i+max==number+2){ /* その位置から右に移動しても最大値を越さない時 */
            break;
        }else{
            for(j=i; j < number-1; j++){
                if(hill[j]<hill[j+1]){ /* 右のほうが高い時 */
                    break; /* 移動を中止 */
                }else{
                    count++; /* 移動をカウント */
                }
            }
        }
        if(max<count){
            max = count; /* 最大値更新 */
        }
    }

    printf( "%d\n" , max);
    return 0;
}


Measured memory_bytes: 512
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let h: usize = iterator.next().unwrap().parse().unwrap();
    let mut a: Vec<isize> = vec![0; h + 1];
    for i in 1..h + 1 {
        a[i] = iterator.next().unwrap().parse().unwrap();
    }

    build_max_heap(&mut a, h);

    let mut result = String::new();
    for i in 1..h + 1 {
        result.push_str(&format!(" {}", a[i]));
    }

    return result;
}

fn build_max_heap(a: &mut Vec<isize>, h: usize) {
    for i in (1..h / 2 + 1).rev() {
        max_heapify(a, i, h);
    }
}

fn max_heapify(a: &mut Vec<isize>, i: usize, h: usize) {
    let l = i * 2;
    let r = i * 2 + 1;

    let mut largest =
        if l <= h && a[l] > a[i] {
            l
        } else {
            i
        };
    if r <= h && a[r] > a[largest] {
        largest = r;
    }

    if largest != i {
        a.swap(i, largest);
        max_heapify(a, largest, h);
    }
}



Measured memory_bytes: 17864
n=gets.to_i-1
a=gets.split
b=*a
r=0..n
r.map{|i|n.downto(i+1){|j|a[k=j-1][1]>a[j][1]&&(a[k,2]=a[j],a[k])}}
r.map{|i|m=i
(m..n).map{|j|b[m][1]>b[j][1]&&m=j}
b[i],b[m]=b[m],b[i]}
puts a*" ",s=:Stable,b*" ",a==b ?s: 'Not stable'

Measured memory_bytes: 6112