akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n, m; cin>>n>>m;
    vector<vector<int>> G(n);
    for(int i=0; i<m; i++){
        int a, b; cin>>a>>b;
        a--, b--;
        G[a].emplace_back(b);
    }

    vector<int> ans;
    int sz = inf;
    for(int i=0; i<n; i++){
        vector<int> prev(n, -1), dist(n, -1);
        dist[i] = 0;
        queue<int> que;
        que.emplace(i);
        while(que.size()){
            int cv = que.front(); que.pop();
            for(auto nv : G[cv]){
                if(dist[nv] == -1){
                    dist[nv] = dist[cv] + 1;
                    prev[nv] = cv;
                    que.emplace(nv);
                }
            }
        }

        for(int j=0; j<n; j++){
            if(i == j || dist[j] == -1) continue;

            for(auto nv : G[j]){
                if(nv == i){
                    vector<int> tmp;
                    for(int k=j; ; k=prev[k]){
                        tmp.emplace_back(k);
                        if(k == i) break;
                    }

                    if(sz > tmp.size()){
                        ans = tmp;
                        sz = tmp.size();
                    }
                }
            }
        }
    }

    if(sz == inf){
        cout << -1 << endl;
    }
    else{
        cout << sz << endl;
        sort(ans.begin(), ans.end());
        for(auto i : ans){
            cout << i + 1 << endl;
        }
    }

    return 0;
}

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    ll n,k;
    cin>>n>>k;
    ll ans;
    if(n>k)
    {
        ans=min(n%k,k-(n%k));
    }
    else
    {
        ans=min(n,k-n);
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 256
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for ai in A:
    a.append(a[-1] + ai)

for bi in B:
    b.append(b[-1] + bi)

# print(a, b)
ans = 0
bs = M
for i in range(N+1):
    if a[i] > K:
        break
    for j in reversed(range(bs+1)):
        if a[i] + b[j] <= K:
            ans = max(ans, i + j)
            bs = j
            break

print(ans)

Measured memory_bytes: 47560
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1 << 30 - 1;
constexpr long long LLINF = 1LL << 60;
constexpr long long MOD = 1000000007;

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


int main()
{
  int A, B;
  cin >> A >> B;
  int ans = 0;
  if (A > B) {
    ans += A;
    A--;
  } else {
    ans += B;
    B--;
  }
  if (A > B) {
    ans += A;
    A--;
  } else {
    ans += B;
    B--;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag,
		tree_order_statistics_node_update> ordered_set;

long long mem[100005][105];
bool vis[100005][105];
long long arr[105];
int n , k;
const long mod = 1e9 + 7;
long long sol(long long rem , int idx){
	if(rem==0)
		return 1;
	if(rem < 0 || idx == n)
		return 0;
	if(vis[rem][idx])
		return mem[rem][idx];
	vis[rem][idx] =true;
	long long ret = (((sol(rem-1,idx)%mod)+(sol(rem,idx+1)%mod) - sol(rem-arr[idx]-1,idx+1)%mod)+mod)%mod;
	return mem[rem][idx] = ret;
}
int main(){
	cin>>n>>k;
	for(int i = 0; i < n ; i++)
		cin>>arr[i];
	cout<<sol(k,0);
	return 0;
}


Measured memory_bytes: 98816
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <stdarg.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <iomanip>

#define ll long long

using namespace std;

double dp[301][301][301];
bool vis[301][301][301];

double
get(ll n, ll a, ll b, ll c) {
  if (!vis[a][b][c]) {
    double v = 0;
    if (a == 0 && b == 0 && c == 0) {
      v = 0;
    }
    else {
      v = n - a - b - c;
      if (a > 0) v += (get(n, a-1, b, c) + 1) * a;
      if (b > 0) v += (get(n, a+1, b-1, c) + 1) * b;
      if (c > 0) v += (get(n, a, b+1, c-1) + 1) * c;
      v /= a + b + c;
    }

    dp[a][b][c] = v;
    vis[a][b][c] = true;
  }

  return dp[a][b][c];
}

void
solve() {
  ll n;
  cin>>n;

  ll a = 0, b = 0, c = 0;
  ll x;
  for (ll i=0; i<n; i++) {
    cin>>x;
    if (x == 1)
      a++;
    else if (x == 2)
      b++;
    else if (x == 3)
      c++;
  }

  cout<<fixed<<setprecision(15)<<get(n, a, b, c)<<endl;
}

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

  ll t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}



Measured memory_bytes: 125684
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void solve() {
        map<string, string> tapi;
        tapi["Sunny"] = "Cloudy";
        tapi["Cloudy"] = "Rainy";
        tapi["Rainy"] = "Sunny";

        string s;
        cin >> s;
        cout << tapi[s] << endl;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
// In The Name Of God
#include <bits/stdc++.h>

#define sqr(A) ((A) * (A))
#define X first
#define Y second
#define MP make_pair
#define bsz  __builtin_popcount
#define all(A) A.begin(), A.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
const int MOD2 = 1e9 + 9;
const int PR = 727;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;

const int N = 1e5 + 20;
ll a[N], n, p[N], fac[N], ans;

ll powmod(ll x, ll y, ll MODD = MOD) {
    if (y == 0) return 1LL;
    ll tmp = powmod(x, y / 2, MODD);
    tmp = sqr(tmp) % MODD;
    return (tmp * (y % 2 ? (x % MODD) : 1LL)) % MODD;
}

ll divmod(ll x, ll y, ll MODD = MOD) {
	return ((x % MODD) * powmod(y, MODD - 2, MODD)) % MODD;
}

ll C(ll r, ll n, ll MODD = MOD) {
    return divmod(fac[n], (fac[r] * fac[n - r]) % MODD, MODD);
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	fac[0] = 1;
	for (ll i = 1; i < N; i++)
		fac[i] = (i * fac[i - 1]) % MOD;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (ll i = 1; i <= n; i++)
		p[i] = (p[i - 1] + ((C(i, n) * fac[i - 1]) % MOD) * fac[n - i]) % MOD;
	for (int i = 1; i <= n; i++)
		ans = (ans + a[i] * (p[n - i + 1] + p[i] - p[1])) % MOD;
	cout << ans << endl;
}



































Measured memory_bytes: 2560
class Solution:
    def solve(self, H: int, W: int) -> int:

        if H == 1 or W == 1:
            return 1
        else:
            return (H*W + 1) // 2


if __name__ == '__main__':

    # standard input
    H, W = map(int, input().split())

    # solve
    solution = Solution()
    print(solution.solve(H, W))


Measured memory_bytes: 2940
N = int(input())
li_A = list(map(int, input().split()))
li_B = list(map(int, input().split()))
li_C = list(map(int, input().split()))
total = 0
total += sum(li_B)
for i in range(N-1):
    if li_A[i+1] - li_A[i] == 1:
        total += li_C[li_A[i]-1]
print(total)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

struct UnionFind {
  vector<int> par; // par[i]が親を表す
  vector<int> _size; // _size[i]でそのノードの属しているサイズを返す
  vector<int> blockVec;
  vector<int> friendVec;

  // コンストラクタ
  UnionFind(int n) {
    _size = vector<int>(n);
    par = vector<int>(n);
    blockVec = vector<int>(n);
    friendVec = vector<int>(n);
    for (int i = 0; i < n; i++) {
      par[i] = i;
      _size[i] = 1;
    }
  }

  // データxの根を求める
  int root(int x) {
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]); // 木構造の縮約を行っている
  }

  // xとyの親が違うとき、マージする。そのときyの根がxの根の子になる
  void merge(int x, int y) {
    friendVec[x]++;
    friendVec[y]++;
    int rootx = root(x);
    int rooty = root(y);
    if (rootx == rooty)
      return;
    par[rooty] = rootx;
    int s = _size[rooty] + _size[rootx];
    _size[rooty] = s;
    _size[rootx] = s;
  }

  // xの属している集団のサイズ
  int size(int x) { return _size[x]; }

  // 同じグループに属しているか
  bool isSame(int x, int y) { return root(x) == root(y); }

  // 同じグループにいるけどブロック関係にある場合は加算する
  void block(int x, int y) {
    if (isSame(x, y)) {
      blockVec[x]++;
      blockVec[y]++;
    }
  }
};

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  UnionFind uf(n);
  REP(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    uf.merge(a, b);
  }
  REP(i, k) {
    int c, d;
    cin >> c >> d;
    c--;
    d--;
    uf.block(c, d);
  }
  REP(i, n) {
    cout << uf.size(uf.root(i)) - 1 - uf.friendVec[i] - uf.blockVec[i]
         << (i == n - 1 ? "\n" : " ");
  }
  return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

vector<ll> v;
ll a6[] = {6,36,216,1296,7776,46656};
ll a9[] = {9,81,729,6561,59049};

void func(ll N, ll cnt)
{
        bool flag = true;
        //a6
        for(int i = 5; i >= 0; --i)
        {
                if(N >= a6[i])
                {
                        ++cnt;
                        flag = false;
                        if(N - a6[i] == 0)
                        {
                                v.push_back(cnt);
                                return;
                        }
                        func(N-a6[i], cnt);
                        --cnt;
                        break;
                }
        }
        //a6
        for(int i = 4; i >= 0; --i)
        {
                if(N >= a9[i])
                {
                        ++cnt;
                        flag = false;
                        if(N - a9[i] == 0)
                        {
                                v.push_back(cnt);
                                return;
                        }
                        func(N-a9[i], cnt);
                        --cnt;
                        break;
                }
        }
        //a1
        if(flag == true)
        {
                ++cnt;
                if(N-1 == 0)
                {
                        v.push_back(cnt);
                        return;
                }
                func(N-1, cnt);
                return;
        }
        return;
}

int main()
{
        ll N;
        cin >> N;
        ll cnt = 0;
        func(N, cnt);

        ll minval = v[0];
        for(int i = 1; i < v.size(); i++)
        {
                if(minval > v[i]) minval = v[i];
        }

        cout << minval << endl;

        return 0;
}

Measured memory_bytes: 17512
#include<algorithm>
#include<vector>
#include<stack>
#include<deque>
#include<iostream>
#include<cstdio>
#define F first
#define S second
#define LIM 1000000010
#define pb push_back
#define all(n) n.begin(),n.end()
using namespace std;
typedef pair<int,int> P;
int dp[5002][5002];
int main(){
  int n,m;
 
  vector<int> X,Y;
  
  while(cin >> n >> m){
    for(int i=0;i<5000;i++)for(int j=0;j<5000;j++)dp[j][i] = 0;
    for(int i=0;i<n;i++){
      int x,y;
      cin >> x >> y;
      X.pb(x); Y.pb(y);
    }
    vector<int> x,y;
    x = X;
    y = Y;
    X.pb(-LIM); X.pb(LIM); Y.pb(-LIM); Y.pb(LIM);
    sort(all(X)); sort(all(Y));
    X.erase(unique(all(X)),X.end());
    Y.erase(unique(all(Y)),Y.end());
    for(int i=0;i<n;i++){
      x[i] = lower_bound(all(X),x[i])-X.begin();
      y[i] = lower_bound(all(Y),y[i])-Y.begin();
      dp[y[i]][x[i]]++;
    }
    for(int i=0;i<=n;i++){
      for(int j=0;j<=n;j++){
	dp[i+1][j+1] += dp[i+1][j]+dp[i][j+1]-dp[i][j];

      }

    }
    for(int i=0;i<m;i++){
      int sx,sy,gx,gy;
      cin >> sx >> sy >> gx >> gy;
      sx = lower_bound(all(X),sx)-X.begin();
      sy = lower_bound(all(Y),sy)-Y.begin();
      gx = upper_bound(all(X),gx)-X.begin()-1;
      gy = upper_bound(all(Y),gy)-Y.begin()-1;
      cout << dp[gy][gx]-dp[gy][sx-1]-dp[sy-1][gx]+dp[sy-1][sx-1] << endl;

    }



  }
  return 0;
}

Measured memory_bytes: 99048
package main

import (
   "fmt"
)

func solution(s string, k int) string {
   i := 0
   for i = 0; i < len(s); i++ {
        if s[i] != '1' {
                break
        }
   }
   if k < i+1 {
        return "1"
   }
   return string(s[i])
}

func main() {
   var s string
   var k int
   fmt.Scan(&s, &k)
   fmt.Println(solution(s, k))
}

Measured memory_bytes: 1768
import sys
n,k=map(int,input().split())
alist=list(map(int,input().split()))

posilist=[]
negalist=[]
zeronum=0

for a in alist:
    if a == 0:
        zeronum+=1
    elif a > 0:
        posilist.append(a)
    else:
        negalist.append(-a)
posilist.sort()
negalist.sort()

posinum=len(posilist)
neganum=len(negalist)

def shakutori(x,alist,blist,flag):
    sum=0
    alen=len(alist)
    blen=len(blist)

    a=0
    b=blen-1

    while a <= alen-1 and b >= 0:
        if flag and a == b:
            return sum
        if alist[a]*blist[b] <= x:
            if flag:
            	sum+= (b+1)-(a+1)
            else:
            	sum+= (b+1)
            a += 1
        else:
            b -=1
    return sum

if k <= posinum*neganum:
    k=posinum*neganum+1-k
    pnflag=False
elif k > n*(n-1)/2-posinum*(posinum-1)/2-neganum*(neganum-1)/2:
    k=k-(n*(n-1)/2-posinum*(posinum-1)/2-neganum*(neganum-1)/2)
    pnflag=True
else:
    print(0)
    sys.exit()

llim=0
ulim=10**19+1


while True:
    mid=(llim+ulim)//2
    if pnflag:
        d1=shakutori(mid,posilist,posilist,True)+shakutori(mid,negalist,negalist,True)
        d2=shakutori(mid+1,posilist,posilist,True)+shakutori(mid+1,negalist,negalist,True)
    else:
        d1=shakutori(mid,posilist,negalist,False)
        d2=shakutori(mid+1,posilist,negalist,False)
    if d1 < k <= d2:
        if pnflag:
            print(mid+1)
        else:
            print(-(mid+1))
        sys.exit()
    elif k <= d1:
        ulim = mid
    else:
        llim = mid



Measured memory_bytes: 96724
<?php

[$N, $K] = fscanf(STDIN, "%d%d");
$list = fscanf(STDIN, str_repeat("%d", $N));
$min = 0;
$max = max($list);
$target = $min + intdiv($max - $min + 1, 2);

while($max - $min > 1){
    $count = 0;
    foreach($list as $value){
        $count += intdiv($value + $target - 1, $target) - 1;
    }
    if($count <= $K){
        $max = $target;
    }else{
        $min = $target;
    }
    $target = $min + intdiv($max - $min + 1, 2);
}

echo $max;


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

int main(void){
   string s;
   string substr;
   cin >> s;
   if(s[0] !='A'){
       cout << "WA" << endl;
       return 0;
   }else s[0]='a';
   substr = s.substr(2, s.size()-3);  //部分抽出
   //cout << substr << endl;
   if(substr.find('C')==-1){
       cout << "WA" << endl;
       return 0;
   }else s[substr.find('C')+2] ='c';
   
   rep(i, s.size()){
       if(islower(s[i])==0){  //小文字:非0 小文字でない:0
           //cout << s[i] << endl;
           cout << "WA" << endl;
           return 0;
       }
   }
   cout << "AC" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	int l, r;
	int lmax = 0, rmin = 100000000;
	REP(i, m) {
		cin >> l >> r;
		if (l > lmax) {
			lmax = l;
		}
		if (r < rmin) {
			rmin = r;
		}
	}
	if (rmin < lmax) {
		cout << 0 << endl;
		return 0;
	}
	if (n >= rmin) {
		cout << rmin - lmax + 1 << endl;
	}
	else {
		cout << n - lmax + 1 << endl;
	}
	return 0;
}

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

using ull = unsigned long long;
using ll = long long;

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

    vector<int> L(n*2);

    for(auto&& x : L)
    {
        cin >> x;
    }

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

    if(L.size() % 2 == 1)
    {
        L.erase(L.begin());
    }

    int sum = 0;
    for(int i = 0; i < L.size(); i += 2)
    {
        sum += L.at(i);
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
  public static void main(String[] args) throws Exception
  {
	Scanner sc= new Scanner(System.in);
	 String S= sc.next();
   	 String T= sc.next();
  	  if(S.length()+1==T.length() && S.equals(T.substring(0,S.length())))
  	    System.out.println("Yes");
 	   else
 	     System.out.println("No");

}
 
  
}




Measured memory_bytes: 35692
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int INF = 10e8;
const int maxN = 100010;
const int maxM = 100010;
const int N = 5000; 
const int MOD = 1000000007;


int n,m; 
int a[maxN];
int b[maxN];
int c[maxN];
int main()
{
	scanf("%d %d",&n,&m);
	if(n<=8 && m <=8)
	{
		puts("Yay!");
	}
	else
	{
		puts(":(");
	}
	return 0;
}  

Measured memory_bytes: 256
M, D = map(int, input().split())

ans = 0
for d in range(22, D+1):
    d1 = d % 10
    if d1 < 2: continue
    d10 = d // 10
    if d10 < 2: continue
    if d1 * d10 <= M:
        ans += 1

print(ans)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <numeric>
#include <array>
#include <float.h>
#include <memory>
#include <functional>
#include <iomanip>
#include <random>
#include <map>
#include <set>
#include <boost/lexical_cast.hpp>

using namespace std;


using ULL = decltype(0ull);
constexpr auto DIV = 1000000007ull;
constexpr auto MAX = numeric_limits<ULL>::max();

int dp[1000000 + 5];

int main() {
  set<int> a;
  for (int i = 0; i < 3; ++i) {
    int v;
    cin >> v;
    a.insert(v);
  }
  cout << a.size() << endl;
  return 0;
}


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

 

using namespace std;

 

typedef long long LL;

const LL MO=1e9+7;

 

LL qmi(LL a,LL b) {

    LL res=1;

    while(b) {

        if (b&1) {

            res=res*a%MO;

        }

        a=a*a%MO;

        b>>=1;

    }

    return res;

}

 

int main() {

    LL n;

    cin>>n;

 

    cout<<((qmi(10ll,n)-2*qmi(9ll,n)+qmi(8ll,n))%MO+MO)%MO<<"\n";

 

    return 0;

}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit
#include <cstdio>	// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define DEBUG 0

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
string FILE_NAME = "testcase.lunch";
string NAME;
string itos (int n )
{
	stringstream ss;
	ss << n;

	return ss.str();
}

int main()
{
//	cut here before submit 
#if DEBUG
	NAME = FILE_NAME;
	int CNT = 1;
	NAME += itos (CNT );
	while (freopen (NAME.c_str() , "r", stdin ) != NULL ) {
#endif
	vector<int> pasta (3, 0 );
	rep (i, 3 ){
		cin >> pasta[i];
	} // end rep
	sort (ALL (pasta ) );
	vector<int> juice (2, 0 );
	rep (i, 2 ){
		cin >> juice[i];
	} // end rep
	sort (ALL (juice ) );
	cout << pasta[0] + juice[0] - 50 << endl;

#if DEBUG
	CNT++;	// cut here before submit
	NAME = FILE_NAME;
	NAME += itos (CNT );
	} // end loop; cut here before submit
#endif			
	return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void){
	char str[201];
	int i, len;
	
	gets(str);
	
	len = strlen(str);
	
	for (i = 0; i < len; i++){
		str[i] = toupper(str[i]);
	}
	
	puts(str);
	
    return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#define ll long long
using namespace std;
int main(){
	string a,b;
	cin >> a >> b;
	if(a==b){
		cout << "EQUAL" << endl;
	}else if(a.size()>b.size()){
		cout << "GREATER" << endl;
	}else if(a.size()<b.size()){
		cout << "LESS" << endl;
	}else{
		for(int i=0;i<a.size();i++){
			if(a[i]>b[i]){
				cout << "GREATER" << endl;
				return 0;
			}else if(a[i]<b[i]){
				cout << "LESS" << endl;
				return 0;
			}
		}
	}
}


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

using namespace std;

long long power(long long x, long long t, long long P) {
	long long ret = 1 % P;
	for(; t; t >>= 1, x = x * x % P) {
		if(t & 1) {
			ret = ret * x % P;
		}
	}
	return ret;
}

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

	int n;
	cin >> n;

	string s;
	cin >> s;

	int one = 0;
	for(char c : s) {
		if(c == '1') {
			one += 1;
		}
	}

	if(one == 1) {
		if(s[n - 1] == '1') {
			for(int i = 0; i < n; ++i) {
				if(i == n - 1) {
					cout << 0 << '\n';
				} else if(i != n - 1) {
					cout << 2 << '\n';
				} 
			}
		} else {
			for(int i = 0; i < n; ++i) {
				if(s[i] == '1') {
					cout << 0 << '\n';
				} else if(i == n - 1) {
					cout << 2 << '\n';
				} else {
					cout << 1 << '\n';
				}
			}
		}
		exit(0);
	}

	if(one == 0) {
		for(int i = 0; i < n; ++i) {
			cout << 1 << '\n';
		}
		exit(0);
	}

	long long suma = 0;
	long long sumb = 0;
	for(int i = 0; i < n; ++i) {
		suma = (suma * 2 + s[i] - '0') % (one + 1);
		sumb = (sumb * 2 + s[i] - '0') % (one - 1);
	}

	for(int i = 0; i < n; ++i) {
		if(s[i] == '0') {
			long long tmp = (suma + power(2, n - 1 - i, one + 1)) % (one + 1);
			int ans = 1;
			while(tmp > 0) {
				int div = __builtin_popcount(tmp);
				tmp = tmp % div;
				ans += 1;
			}
			cout << ans << '\n';
		} else {
			long long tmp = (sumb - power(2, n - 1 - i, one - 1) + one - 1) % (one - 1);
			int ans = 1;
			while(tmp > 0) {
				int div = __builtin_popcount(tmp);
				tmp = tmp % div;
				ans += 1;
			}
			cout << ans << '\n';
		}
	}	

	return 0;
}


Measured memory_bytes: 3888
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    string s;
    cin>>s;
    int m=stoi(s.substr(5,2)),d=stoi(s.substr(8,2));
    if (m<4)
        cout<<"Heisei\n";
    else if (m==4 && d<=30)
        cout<<"Heisei\n";
    else
        cout<<"TBD\n";
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.parent = [-1] * n
        self.rank = [1] * n
        self.count = [1] * n
 
    def get_root(self, i):
        while self.parent[i] != -1:
            i = self.parent[i]
        return i
 
    def is_same_tree(self, i, j):
        return self.get_root(i) == self.get_root(j)
 
    def merge(self, i, j):
        i = self.get_root(i)
        j = self.get_root(j)
        if i == j:
            return
 
        if self.rank[i] > self.rank[j]:
            self.parent[j] = i
            self.rank[i] = max(self.rank[i], self.rank[j] + 1)
            self.count[i] += self.count[j]
        else:
            self.parent[i] = j
            self.rank[j] = max(self.rank[j], self.rank[i] + 1)
            self.count[j] += self.count[i]
n, m = map(int, input().split())
uf = UnionFind(n)
for _ in range(m):
  a, b = [int(i) - 1 for i in input().split()]
  uf.merge(a, b)
print(max(uf.count))

Measured memory_bytes: 16492
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long n;	
cin>>n;
	long long ans=n-1;
	for(long long i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			ans=min(ans,i-1+((n/i)-1));
		}
	}
	cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fst ios_base::sync_with_stdio(false); cin.tie(NUint); cout.tie(NUint);
#define chk(x) cout << (#x) << " is " << (x) << endl
#define ll long long
using namespace std;
int main() {
    int n,i,j,k;
    cin >> n >> k;
    int h[n],dp[n];
    for(i=0;i<n;++i) cin >> h[i];
    for(i=0;i<n;++i) dp[i] = abs(h[i]-h[0]);
    for(i=2;i<n;++i) {
        dp[i] = abs(h[i] - h[i-1]) + dp[i-1];    
        for(j=2;j<=min(k,i);++j) dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
    }
    cout << dp[n-1];
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::cerr;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::stack;
using std::priority_queue;
using std::pair;
using std::make_pair;

using std::min;
using std::max;
using std::sort;
using std::abs;

using std::fixed;
using std::setprecision;
using std::setw;

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 314;

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

    if (m % 1000 != 0) {
        cout << "-1 -1 -1" << endl;
        return 0;
    }
    m /= 1000;

    for (int x = 0; x <= n; x++) {
        for (int y = 0; y <= n; y++) {
            int z = m - 10 * x - 5 * y;
            if (x >= 0 && y >= 0 && z >= 0 && x + y + z == n &&
                10 * x + 5 * y + z == m) {
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;

    return 0;
}


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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int n, k;
	cin >> n >> k;
	int ans = k;
	while (--n) ans *= (k - 1);
	cout << ans << '\n';  
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<iomanip>
#include<complex>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef stack<int> SI;
typedef queue<int> QI;
typedef list<int> LI;
typedef pair<int,int> PII;
typedef long long LL;

#define d(x)  cout<<#x<<" = "<<(x)<<endl;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EMP empty()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).rbegin()) i=(c).rbegin(); i!=(c).rend(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c,n) sort(c,c+n)
#define VSORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define DFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define DREP(i,n) DFOR(i,n,0)
#define INF 1000000000
#define PI  acos(-1.0)
////////////////////////////////////////////////
int main()
{
	int n;cin>>n;
	for(;sqrt(n)!=(int)sqrt(n);n--);
	cout<<n<<endl;
	return 0;
}

Measured memory_bytes: 256
r, g, b, n = gets.split.map(&:to_i)

ans = 0

0.upto(n / r) do |x|
  balls = r * x
  next if balls > n
  if balls == n
    ans += 1
    next
  end

  0.upto((n - (r * x)) / g) do |y|
    balls = r * x + g * y
    next if balls > n
    if balls == n
      ans += 1
      next
    end

    rest = n - balls
    ans += 1 if rest % b == 0
  end
end

puts ans


Measured memory_bytes: 1788
#include <stdio.h>

int main(void) {
	int i;
	char s[100001];
	int k, len;

	scanf("%s%n %d", s, &len, &k);

	for (i = 0; i < len; i++) {
		const int x = (26 - (s[i] - 'a')) % 26;
		if (x <= k) {
			s[i] = 'a';
			k -= x;
		}
	}
	s[len - 1] = (s[len - 1] - 'a' + k) % 26 + 'a';

	puts(s);

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long ll ;
typedef double db;
typedef long double ldb;
typedef unsigned long long ull ;
const double PI = acos(-1) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define for0(i,n)          for(int i=0;i<n;i++)
#define for1(i,n)          for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
//#define gcd(a, b)     __gcd(a, b)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
//#define abs(x)		fabs(x)
#define pcase(z,x)     cout<<"Case "<<z<<": "<<x<<"\n"
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define max 1000000007

using namespace std;
int n,m,y,x,h,e,l,o,i,j;

int main()
{
	CIN;
	cin>>n>>m;
	int arr[n];
	for(i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	sort(arr,arr+n);
	ll sum=0;
	for(i=0;i<m;i++)sum+=arr[i];
	cout<<sum<<nw;

	//cout<<t<<nw;


	
}


Measured memory_bytes: 3548
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>
#include <map>   
#include <stdio.h>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807
#define sortR(a,b) sort(a, b, greater<int>())

using namespace std;

//最大公約数
	long long GCD(long long a, long long b) {
		if (a < b)
			swap(a, b);
		if (b == 0) return a;
		else return GCD(b, a % b);
	}
	//素数判定
	bool sosuu_check(int num) {
		int i;
		for (i = 2; i <= sqrt(num); ++i) {
			if (num%i == 0)
				return false;
		}
		return (num < 2) ? false : true;
	}
	
	int check(int N, int a, int b) {
		int A,B,i;
		if (a > b) {
			A = a;
			B = b;
		}
		else {
			A = b;
			B = a;
		}
		for (i = N / b; i > 0; i--) {
			if ((N - b * i) % a == 0) {
				return i;
			}
		}
		return 0;
	}


int main() {
	int A,B,K,count=0;
	vector<int> vec(100);
	cin >> A >> B >> K;
	for (int i = 1; i <= min(A, B); i++) {
		if ((A%i == 0) && (B%i == 0)) {
			vec[count] = i;
			count++;
		}
	}
	cout << vec[count  - K] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9 + 5;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
using namespace std;
int n,m,u,v;
int memo[110000];
bool fl[110000];
vector<int> eg[110000];
int dp(int v){
    if(fl[v]){
        return memo[v];
    }
    int ans = 0;
    for(int to: eg[v]){
        ans = max(ans, dp(to) + 1);
    }
    fl[v] = true;
    memo[v] = ans;
    return ans;
}
struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n,-1){}
    int Find (int x){//根の番号を探す
        if(d[x] < 0) return x;
        return d[x] = Find(d[x]);
    }
    bool unite (int x, int y){
        x = Find(x); y = Find(y);
        if(x == y ) return false;
        if(d[x] < d[y]){
            swap(x,y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    } 
    bool same(int x, int y){
        return Find(x) == Find(y);
    }
    int size(int x) {
        return (-d[Find(x)]);
    }
};
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    UnionFind uf(n+1);
    REP(i,m){
        int a,b;
        cin >> a >> b;
        uf.unite(a,b);
        uf.unite(b,a);
    }    
    set<int> st;
    for(int i = 1;i<=n;i++){
        st.insert(uf.Find(i));
    }
    cout << st.size()-1 <<endl;
}

Measured memory_bytes: 10084
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int c = 0;
        for (int i = 0 ; i < n - 2 ; i++) {
            if (s.subSequence(i, i + 3).equals("ABC")) {
                c++;
            }
        }
        System.out.println(c);
    }

}


Measured memory_bytes: 23764
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) x.begin(), x.end()

#define mp make_pair
#define in insert
#define er erase
#define con continue
#define pb push_back
#define sc scanf
#define pr printf
#define ub upper_bound
#define lb lower_bound
#define s second
#define f first
#define int long long

const long long infl = 1e18; 
const int N = 3e5 + 300, N2 = 2e3, inf = 1e9 + 200;

set <int> S;
vector <int> g;
int n, m, k;
int a[N];
string ss;

main (){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	double x;
	cin >> x;
	printf("%.9lf", (x / 3) * (x / 3) * (x / 3));
	return 0;
}












Measured memory_bytes: 256
#include <stdio.h>

int data[100];
int sp=0;
int top(){
    return data[sp-1];
}

void pop(){
    sp--;
}
void push(int n){
    if(n>0){
        data[sp]=n;
        sp++;
    }
}

int main(){
    int n;
    while(scanf("%d",&n)!=EOF){
        if(n==0){
            printf("%d\n",top());
            pop();
        }else{
            push(n);
        }
    }
    return 0;
}

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

int main(){
  long long n,k,i;
  cin >> n >> k;
  vector<long long> a(n),looked(n,0);
  for(i=0;i<n;i++){
    cin >> a.at(i);
    a.at(i)--;
  }
  
  long long j=0;
  while(looked.at(j)==0){
    looked.at(j)=1;
    j=a.at(j);
  }
  
  long long in,roop,s;
  s=j;
  in=0;
  roop=1;
  j=0;  
  while(j!=s){
    in++;
    j=a.at(j);
  }
  j=a.at(s);
  while(j!=s){
    roop++;
    j=a.at(j);
  }
  
  if(k>in){
    k=(k-in)%roop;
    j=s;
    for(i=0;i<k;i++){
      j=a.at(j);
    }
    j++;
    cout << j << endl;
  }else{
    j=0;
    for(i=0;i<k;i++){
      j=a.at(j);
    }
    j++;
    cout << j << endl;
  }
}

Measured memory_bytes: 6428
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);

		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		//寝て起きての周期が60の倍数または約数でない
		/*
		 * 降車できるとき、最大でも山手線は119週しかしない(寝て起きての周期、60)の最小公倍数を60で割ったときの最大値が119であるから
		 */
		if(a+b==0) {
			pl(-1);
			System.exit(0);
		}
		else {
			for(int i=0; i<=120; i++) {
				int when=60*i+c;
				int roop=when/(a+b);
				if(roop*(a+b)<=when && when<=roop*(a+b)+a) {
					pl(when);
					System.exit(0);
				}
			}
		}
		pl(-1);
		System.exit(0);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	private static int gcd(int m, int n) {
		if(m < n) return gcd(n, m);
		if(n == 0) return m;
			return gcd(n, m % n);
		}
}


Measured memory_bytes: 24480
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(n: int, p: "List[int]"):

    counter = 0
    for i in range(n-2):
        if p[i] < p[i+1] < p[i+2]:
            counter += 1
        elif p[i+2] < p[i+1] < p[i]:
            counter += 1
    print(counter)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(n)]  # type: "List[int]"
    solve(n, p)


if __name__ == '__main__':
    main()


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

int k,flag=0;
int arr[5];

int main()
{
  	for(int i=0;i<5;i++)
        cin>>arr[i];
    cin>>k;

    for(int i=0;i<4;i++)
    {
        for(int j=i+1;j<5;j++)
        {
            if(arr[j]-arr[i]>k)
            {
                flag=1;
                break;
            }
        }
    }

    if(flag==0)
        cout<<"Yay!";
    else
        cout<<":(";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
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; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    string S;
    cin >> S;
    rep(i,S.size()){
        if(i%2==0){
            if(S[i]!='h'){
                cout<< "No" << endl;
                return 0;
            }
        }
        else{
            if(S[i]!='i'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    if(S.size()%2!=0){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#define NMAX 100000 
bool move(int N,bool a,bool b,char *C,bool *T){
	T[0] = a;
	T[1] = b;
	bool ans = false;
	for(int i=1;i<N-1;i++){
		if((T[i-1] == T[i] && C[i] == 'o') || (T[i-1] != T[i] && C[i] == 'x')){
			T[i+1] = true;
		}else{
			T[i+1] = false;
		}
	}
	if((T[N-2] == T[N-1] && C[N-1] == 'o') || (T[N-2] != T[N-1] && C[N-1] == 'x')){
		if(T[0] && ((C[0] == 'o' && T[1] == T[N-1]) || (C[0] == 'x' && T[1] != T[N-1])) ){
			ans = true;
		}
	}else{
		if(!T[0] && ((C[0] == 'o' &&T[1] != T[N-1]) || (C[0] == 'x' && T[1] == T[N-1])) ){
			ans = true;
		}
	}
	return ans;
}

//O(n)まで
int main(){
	int N;
	cin >> N;
	char C[N];
	bool T[N];
	bool ans = false;
	cin >> C;
	if(move(N,true,true,C,T)) ans = true;
	else if(move(N,true,false,C,T)) ans = true;
	else if(move(N,false,true,C,T)) ans = true;
	else ans = move(N,false,false,C,T);
	if(ans){
		for(int i=0;i<N;i++){
			if(T[i]){
				cout << "S";
			}else{
				cout << "W";
			}
		}
		cout << endl;
	}else{
		cout << "-1" << endl;
	}

	return 0;
}

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

using namespace std;

int minn[300010];

int main(void){
    // freopen("aaa.in","r",stdin);
    int n;
    int ans = 0;
    scanf("%d",&n);
    minn[0] = n+1;
    for (int i=1,a;i<=n;i++){
        scanf("%d",&a);
        minn[i] = min(minn[i-1],a);
        if (a<=minn[i]) ans++; 
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
from collections import defaultdict

N = int(input())
X, Y = N-1, N
dic = defaultdict(int)
for p in range(2, int(N**0.5)+1):
    if X % p == 0:
        cnt = 0
        while X % p == 0:
            X //= p
            cnt += 1
        dic[p] = cnt
    if Y % p == 0:
        cnt = 0
        while Y % p == 0:
            Y //= p
            cnt += 1
        dic[p] = cnt
if X > 1:
    dic[X] = 1
if Y > 1:
    dic[Y] = 1
f = [1]
for p in dic.keys():
    f += [x*pow(p, c) for x in f for c in range(1, dic[p]+1)]
ans = 0
for x in f:
    if x == 1:
        continue
    y = N
    while y % x == 0:
        y //= x
    if y % x == 1:
        ans += 1
print(ans)

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

int main(){
	int n,m,x[10000][2],y[10000][2],x2,y2,c,a;
	while(true){
		cin>>m;
		if(m==0){
			break;
		}
		for(int i=0;i<m;i++){
			cin>>x[i][0]>>y[i][0];
		}
		cin>>n;
		for(int i=0;i<n;i++){
			cin>>x[i][1]>>y[i][1];
		}
		for(int i=0;i<m;i++){
			for(int j=0;j<n;j++){
				a=0;
				x2=x[j][1]-x[i][0];
				y2=y[j][1]-y[i][0];
				for(int k=0;k<m;k++){
					c=0;
					for(int l=0;l<n;l++){
						if(x[k][0]+x2==x[l][1] && y[k][0]+y2==y[l][1]){
							c++;
							goto Exit1;
						}
					}
Exit1:;
					if(c==0){
						goto Exit2;
					}
					a++;
				}
Exit2:;
				if(a==m){
					goto Exit3;
				}
			}
		}
Exit3:;
		cout<<x2<<' '<<y2<<endl;
	}
	return 0;
}

Measured memory_bytes: 1188
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
 
int main(int argc, char const *argv[]) {
  std::vector<int> v(100),costs(201);
  int n,i,k;
 
  cin>>n;
  for(i=0;i<n;i++){
    cin>>v[i];
  }
 
  for (i=-100; i <= 100; i++) {
    for (k = 0; k < n; k++) {
      costs[i+100]+=((i-v[k])*(i-v[k]));
    }
  }
 
  cout<<*min_element(costs.begin(),costs.end());
  return 0;
}

Measured memory_bytes: 256