akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(x) memset(x,0,sizeof(x))
#define MINUS(x) memset(x,-1,sizeof(x))
#define UNIQUE(x) (x).erase(unique(ALL(x)), (x).end())
#define TOUPPER(x) transform(ALL(x), (x).begin(), ::toupper)
#define TOLOWER(x) transform(ALL(x), (x).begin(), ::tolower)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll qp(ll a,ll b){ll ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
ll qp(ll a,ll b,ll mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int INF = 1e9;
const ll INFL = 1e18;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5;

int main() {
    int K, N; cin >> K >> N;
    vector<int> A(N+1); rep(i,N) cin >> A[i];
    A[N] = A[0] + K;
    int mx = 0;
    rep(i,N) chmax(mx, A[i+1] - A[i]);
    cout << K - mx << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  int H,W,K;
  cin>>H>>W>>K;
  VS S(H);
  rep(i,H) cin>>S[i];
  VI A(H);
  VVI ans(H,VI(W));
  rep(i,H){
    int tmp=1;
    rep(j,W) tmp*=(S[i][j]=='.');
    if(tmp) A[i]=1;
  }
  int C=1;
  rep(i,H){
    if(A[i]) continue;
    int B=0;
    rep(j,W){
      if(S[i][j]=='.') ans[i][j]=C;
      else{
        if(!B){
          B=1;
          ans[i][j]=C;
        }else{
          C++;
          ans[i][j]=C;
        }
      }
    }
    C++;
  }
  int cnt=0;
  rep(i,H){
    if(!ans[i][0]) cnt++;
    else break;
  }
  rep(i,cnt){
    rep(j,W) cout<<ans[cnt][j]<<" ";
    cout<<endl;
  }
  int D=cnt;
  rep(i,H-cnt){
    if(!ans[i+cnt][0]){
      rep(j,W) cout<<ans[D][j]<<" ";
    }else{
      D=cnt+i;
      rep(j,W) cout<<ans[D][j]<<" ";
    }
    cout<<endl;
  }
}

Measured memory_bytes: 1280
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    LLONG H, W; cin >> H >> W;
    LLONG ans = 10e10;
    // あり得る分割方法をすべて試す：O(H+W)
    // 初めに横に切るとき
    for (int r = 1; r <= H / 3 + 1; ++r)
    {
        LLONG s1 = r * W;
        LLONG rem = H - r;
        // 残った部分を横になるべく均等に切るとき
        ans = min(ans,
            max({ s1, (rem / 2) * W, H * W - s1 - (rem / 2) * W })
            - min({ s1, (rem / 2) * W, H * W - s1 - (rem / 2) * W }));
        // 残った部分を縦になるべく均等に切るとき
        ans = min(ans, 
            max({ s1, rem * (W / 2), H * W - s1 - rem * (W / 2) })
            - min({ s1, rem * (W / 2), H * W - s1 - rem * (W / 2) }));
    }
    // 初めに縦に切るとき
    for (int c = 1; c <= W / 3 + 1; ++c)
    {
        LLONG s1 = H * c;
        LLONG rem = W - c;
        // 残った部分を横になるべく均等に切るとき
        ans = min(ans,
            max({ s1, (H / 2) * rem, H * W - s1 - (H / 2) * rem })
            - min({ s1, (H / 2) * rem, H * W - s1 - (H / 2) * rem }));
        // 残った部分を縦になるべく均等に切るとき
        ans = min(ans,
            max({ s1, H * (rem / 2), H * W - s1 - H * (rem / 2) })
            - min({ s1, H * (rem / 2), H * W - s1 - H * (rem / 2) }));
    }
    cout << ans << endl;
}

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

int main()
{
  long long A,B,C;
  scanf("%lld%lld%lld",&A,&B,&C);
  int ans=0;
  set<pair<pair<long long,long long>,long long> > S;
  while(A%2==0&&B%2==0&&C%2==0){
    if(S.find(make_pair(make_pair(A,B),C))!=S.end()){
      ans=-1;
      break;
    }
    S.insert(make_pair(make_pair(A,B),C));
    long long A2=A/2,B2=B/2,C2=C/2;
    A=B2+C2,B=C2+A2,C=A2+B2;
    ans++;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
const int maxn=1009;
int head[1009];
struct edge{
    int to,next;
}edges[1009];
void addedge(int from,int to,int no){
    edges[no].to=to;
    edges[no].next=head[from];
    head[from]=no;
}
int n;
bool xing;
int arr[maxn];
int mi[maxn],bian[maxn];
void sol(int o,int fa){
    for(int i=head[o];~i;i=edges[i].next){
        int to=edges[i].to;
        if(to==fa)continue;
        sol(to,o);
    }
    int ans=0;
    int tol=0;
    for(int i=head[o];~i;i=edges[i].next){
        int to=edges[i].to;
        if(to!=fa)ans+=mi[to],tol+=bian[to];
    }
    tol+=ans;
    if(ans>arr[o]){
        printf("IMPOSSIBLE\n");
        exit(0);
    }
    bool mark[5009]={0};
    mark[0]=1;
    for(int i=head[o];~i;i=edges[i].next){
        int to=edges[i].to;
        if(to==fa)continue;
        for(int j=arr[o]-ans;j>=bian[to];j--){
            mark[j]|=mark[j-bian[to]];
        }
    }
    for(int j=arr[o]-ans;j>-1;j--){
        if(mark[j]){
            tol+=arr[o]-j-ans;
            int tmp=tol-arr[o];
            mi[o]=min(tmp,arr[o]);
            bian[o]=max(tmp,arr[o])-mi[o];
            break;
        }
    }
}
int main(){
    scanf("%d",&n);
    int e;
    memset(head,-1,sizeof(head));
    for(int i=2;i<=n;i++){
        scanf("%d",&e);
        addedge(e,i,i);
    }
    for(int i=1;i<=n;i++)scanf("%d",&arr[i]);
    sol(1,-1);
    printf("POSSIBLE\n");
}


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

i64 get(i64 p, i64 n) {
    i64 mod = p * 2ll;
    i64 c = n % mod;
    i64 cnt = std::max(0ll, c - p + 1) + n / mod * p;
    return cnt;
}

int main() {
    i64 a, b;
    std::cin >> a >> b;
    i64 ret = 0;
    for (i64 i = 0; (1ll << i) <= b; i++) {
        if ((get(1ll << i, b) - get(1ll << i, a - 1)) % 2) ret += (1ll << i);
    }
    std::cout << ret << std::endl;

    return 0;
}


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

using namespace std;
  
int main() {
    int a, b;
    cin >> a >> b;

    if (a % 2 == 0 || b % 2 == 0) {
        cout << "Even" << endl;
    } else {
        cout << "Odd" << endl;
    }
}


Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    s = in_s()

    c = s.count('R')
    if c == 0:
        ans = 0
    if c == 1:
        ans = 1
    if c == 2:
        if s == "RSR":
            ans = 1
        else:
            ans = 2
    if c == 3:
        ans = 3

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9224
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    int N; cin >> N;

    int ans = 0;
    char arare[4] = {'P', 'W', 'G', 'Y'};
    for (int i = 0; i < N; i++) {
        char S; cin >> S;
        for (int j = 0; j < sizeof(arare); j++) {
            if (S == arare[j]) {
                ans |= (1<<j);
            }
        }
    }

    cout << ((ans == (1<<4)-1) ? "Four" : "Three") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[100005],s1[100005];
long long m,n,dp[3001][3001];
long long solve(long long i,long long j)
{
    if(i>=m || j>=n)
    return 0;
    if(dp[i][j]!=-1)
    return dp[i][j];
    if(s[i]==s1[j])
        dp[i][j]=1+solve(i+1,j+1);
    else
    dp[i][j]=max(solve(i+1,j),solve(i,j+1));
    return dp[i][j];
}
int main()
{
    for(int i=0;i<=3001;i++)
    {
        for(int j=0;j<=3001;j++)
        dp[i][j]=-1;
    }
    scanf("%s%s",s,s1);
    m=strlen(s);
    n=strlen(s1);
   // cout<<m<<" "<<n<<'\n';
    long long int k=solve(0,0);
    int p=-1;
    int l=0;
    char s2[100005];
    for(int i=0;i<m;i++)
    {
        for(int j=p+1;j<n;j++)
        {
            if(s[i]==s1[j]&&dp[i][j]==k)
            {
                s2[l]=s[i];
                l++;
                p=j;
                k--;
                break;
            }
        }
    }
    for(int i=0;i<l;i++)
    printf("%c",s2[i]);
    return 0;
}

Measured memory_bytes: 70912
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

using namespace std;

int main()
{
   int n;
   scanf("%d",&n);
   int x=0;
   int m=0;
   int y=1;
   int i;
   int t=0;
   for(i=1;i<=n;i++)
   {
       x=i;
       t=0;
       while(x>0)
       {
           x=x/10;
           t++;
       }
       if(t%2!=0)
       {
           m++;
       }
   }

   printf("%d\n",m);

    return 0;
}


Measured memory_bytes: 256
import sys
n=int(input())
h=list(map(int,input().split()))
if len(set(h))==1:
  print(h[0])
  sys.exit()
totl=0
for i in range(1,max(h)+1):
  cnt=0
  if i<=h[0]:
    cnt+=1
  for j in range(n-1):
    if h[j]<i:
      if i<=h[j+1]:
        cnt+=1
  totl+=cnt
print(totl)
        
       
    


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>

using namespace std;

int main()
{
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;

  vector<int> v;
  if (S[0] == '0') v.push_back(0);
  char ch = S[0];
  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    if (S[i] != ch) {
      v.push_back(cnt);
      cnt = 1;
      ch = ch == '0' ? '1' : '0';
    }
    else {
      ++cnt;
    }
  }
  v.push_back(cnt);
  if (S[N - 1] == '0') v.push_back(0);

  vector<int> cum(v.size() + 1);
  cum[0] = 0;
  for (int i = 0; i < (int)v.size(); ++i) {
    cum[i + 1] = cum[i] + v[i];
  }

  int ans = 0;
  for (int left = 0; left < (int)v.size(); left += 2) {
    int right = min(left + 2 * K, (int)v.size() - 1);
    int sum = cum[right + 1] - cum[left];
    ans = max(ans, sum);
  }

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


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

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

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

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

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

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

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

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




void solve() {
    int L, R, d; cin >> L >> R >> d;
    int res = 0;
    Rep1(i, L, R){
        if(i%d == 0) res++;
    }
    cout << res << endl;
}

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


Measured memory_bytes: 7704
import math

def main():
  a, b = input().split()
  a = int(a)
  b = b[0] + b[2]+ b[3]
  c = int(b)
  ans = a * c // 100
  ans = math.floor(ans)
  print(ans)
 
 
if __name__ == '__main__':
  main()

Measured memory_bytes: 9176
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    s = IS()
    n = len(s)
    l = r = 0
    for i,si in enumerate(s):
        if si == 'A':
            l = i
            break
    for i,si in enumerate(s[::-1]):
        if si == 'Z':
            r = n-i
            break
    print(r-l)

if __name__ == '__main__':
    main()

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

int V[101][10001];
int v[101];
int w[101];

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

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

  
  for(int i=0;i<=W;++i){
    V[0][i]=0;
  }
        
  for(int i=0;i<=N;++i){
    V[i][0]=0;
  }
  

  for(int c=1;c<=W;++c){
    for(int i=1;i<=N;++i){
      if(c>=w[i]) V[i][c]=max(v[i] + V[i-1][c-w[i]], V[i-1][c]);
      else V[i][c]=V[i-1][c];
    }
  }
  cout << V[N][W] << endl;
}

Measured memory_bytes: 5104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<string>> s(h, vector<string>(w));
    rep(i, h) rep(j, w) cin >> s[i][j];
    rep(i, h) rep(j, w)
    {
        if (s[i][j] == "snuke")
        {
            char c = 'A' + j;
            cout << c << i + 1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
as = gets.chomp.split.map(&:to_i)
cnt_4 = 0
cnt_2 = 0
cnt_odd = 0
as.each do |a|
  if a % 4 == 0
    cnt_4 += 1
  elsif a.odd?
    cnt_odd += 1
  else
    cnt_2 += 1
  end
end

cnt_odd += 1 if cnt_2.odd?

if cnt_odd <= cnt_4 + 1
  ans = "Yes"
else
  ans = "No"
end

puts ans

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

int main() {
    int i, n;
    cin >> n;
    vector<int> d(n);

    for(i=0; i<n; i++) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    d.erase(unique(d.begin(), d.end()), d.end());

    cout << d.size() << endl;
}

Measured memory_bytes: 3604
import java.util.*;

class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                for(int i = 0; i < n; i++){
                        double[][] ab = new double[2][3];
                        for(int j = 0; j < 2; j++){
                                for(int k = 0; k < 3; k++){
                                        ab[j][k] = sc.nextDouble();
                                }
                        }
                        System.out.println(judge(ab));
                }
                sc.close();
        }
        static int judge(double[][] ab){
                double distance = Math.pow((ab[0][0]-ab[1][0])*(ab[0][0]-ab[1][0])+(ab[0][1]-ab[1][1])*(ab[0][1]-ab[1][1]),0.5);
                if(distance+ab[0][2] < ab[1][2]){
                        return -2;
                }else if(distance+ab[1][2] < ab[0][2]){
                        return 2;
                }else if(distance > ab[0][2]+ab[1][2]){
                        return 0;
                }else{
                        return 1;
                }
        }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
signed main(){
  string a;
  int d=0;
  cin>>a;
  for(int i=1;i<a.size();i++){
    string b={};
    string c={};
    if((a.size()-i)%2==0){
      for(int j=0;j<(a.size()-i)/2;j++){
        b+=a[j];
      }
      //cout<<b<<"\n";
      for(int j=(a.size()-i)/2;j<a.size()-i;j++){
        c+=a[j];
      }
      if(b==c){
        d=b.size();
        break;
      }
      //cout<<c<<"\n";
      //cout<<i<<" "<<b<<" "<<c<<"\n";
    }
  }
  cout<<d*2<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

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

vector<pair<long long, long long>> prime_factorize(long long N)
{
    vector<pair<long long, long long>> res;
    for (long long a = 2; a * a <= N; ++a)
    {
        if (N % a != 0)
            continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0)
        {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1)
        res.push_back({N, 1});
    return res;
}

uintmax_t combination(unsigned int n, unsigned int r)
{
    if (r * 2 > n)
        r = n - r;
    uintmax_t dividend = 1;
    uintmax_t divisor = 1;
    for (unsigned int i = 1; i <= r; ++i)
    {
        dividend *= (n - i + 1);
        divisor *= i;
    }
    return dividend / divisor;
}

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    ll zen = 1;
    ll tou = 1;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        //zen *= A[i];
        if (i - K >= 0)
        {
            if(A[i] > A[i-K]){
                cout << "Yes" << endl;
            }
            else{
                cout << "No" << endl;
            }
        }
        //cout << zen << endl;
    }
}


Measured memory_bytes: 4836
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using namespace std;
char s[906][906];
bool dp[603][603][303];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s[i]+1;
		for(int j=1;j<=n;j++){
			s[i+n][j]=s[i][j];
			s[i][j+n]=s[i][j];
			s[i+n][j+n]=s[i][j];
		}
	}
	for(int i=1;i<=n*2;i++){
		for(int j=1;j<=n*2;j++){
			for(int z=0;z<n;z++){
				if(j+z>=2*n || i+z>=2*n)break;
				if(s[i][j+z]==s[i+z][j]){
					dp[i][j][z]=1;
				//	cout<<i<<" "<<j<<" "<<z<<endl;
				}else{
					break;
				}
			}
			
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			int flag=1;
			for(int z=n-1;z>=0;z--){
				int k=n-z-1;
				//cout<<k<<endl;
			//	cout<<i+k<<" "<<j+k<<" "<<z<<" -- "<<dp[i+k][j+k][z]<<endl;
				if(dp[i+k][j+k][z]==0){
					flag=0;break;
				}
			}
			if(flag)ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 107648
//Heaplax
//别让自己后悔
#include<bits/stdc++.h>
#define M 100001
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
const int mod=1000000007;
int n,m;
struct mat
{
	int s[3][3];
	mat(){memset(s,0,sizeof s);}
	int* operator [] (const int x)
	{
		return s[x];
	}
	const int* operator [] (const int x)const
	{
		return s[x];
	}
}ans,f1,f2,I;
mat operator * (const mat& a,const mat& b)
{
	mat res;
	for(int i=0;i<3;++i)
		for(int j=0;j<3;++j)
			for(int k=0;k<3;++k)
				res[i][k]=(res[i][k]+1ll*a[i][j]*b[j][k])%mod;
	return res;
}
mat mi(mat a,int b)
{
	mat res=I;
	while(b)
	{
		if(b&1)res=res*a;
		a=a*a;
		b>>=1;
	}
	return res;
}
int main()
{
	I[0][0]=I[1][1]=I[2][2]=1;
	f1[0][0]=2;f1[1][0]=1;f1[2][0]=1;
	f1[0][1]=2;f1[1][1]=1;
	f1[0][2]=1;f1[1][2]=1;f1[2][2]=1;
	f2[0][0]=1;
	f2[0][1]=2;f2[1][1]=1;
	f2[0][2]=1;f2[1][2]=1;f2[2][2]=1;
	ans[0][0]=1;
	re(n);re(m);
	int x=0,y=0;
	while(m--)
	{
		re(y);
		ans=ans*mi(f1,y-x-1)*f2;
		x=y;
	}
	ans=ans*mi(f1,n-x);
	printf("%d\n",ans[0][2]);
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

#define inf 10000000000 + 5

int n;
int h[22];
int answer = 0;
int tmp[22];

int main(){
  cin >> n;
  for(int i = 0; i < n; ++i){
    cin >> h[i];
  }
  //cout << n;
  for(int i = 0; i < n; ++i){
    tmp[i] = 0;
    for(int j = 0; j < i; ++j){
      if(h[i] >= h[j]){
        //return 0;
        tmp[i]++;
      }
    }
    //cout << tmp[i] << endl;
    if(tmp[i] == i){
      answer++;
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

def f(r):
    '''
    >>> f(399)
    0
    >>> f(400)
    1
    >>> f(401)
    1
    >>> f(3200)
    8
    >>> f(3201)
    8
    '''
    from bisect import bisect
    R = [400, 800, 1200, 1600, 2000, 2400, 2800, 3200]
    return bisect(R, r)

def solve(N: int, a: "List[int]"):
    '''
    >>> solve(1, [399])
    (1, 1)
    >>> solve(1, [3200])
    (1, 1)
    >>> solve(1, [399, 388])
    (1, 1)
    >>> solve(1, [399, 3200])
    (1, 2)
    >>> solve(1, [399, 3200, 3200, 3400])
    (1, 4)
    >>> solve(1, [399, 400, 3200, 3200, 3400])
    (2, 5)
    >>> solve(1, [399, 400, 800, 1200, 1600, 2000, 2400, 3200, 3200, 3400])
    (7, 10)
    '''
    from collections import Counter
    b = tuple(map(f, a))
    c = Counter(b)
    return max(1, len(c)-(1 if c[8] else 0)), len(c)+(c[8]-1 if c[8] else 0)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
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
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(*solve(N, a))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    test()
    main()


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


void solve(long long H,
           long long W,
           long long D,
           std::vector<std::vector<long long>> A,
           long long Q,
           std::vector<long long> L,
           std::vector<long long> R){
  vector<long long> x(H*W);
  vector<long long> y(H*W);
  for(auto i=0;i<H;++i){
    for(auto j=0;j<W;++j){
      x[A[i][j]-1]=i;
      y[A[i][j]-1]=j;
    }
  }

  vector<long long> accx(H*W);
  vector<long long> accy(H*W);
  for(auto i=0;i<H*W;++i){
    if(i<D){
      accx[i]=x[i];
      accy[i]=y[i];
    }else{
      accx[i]=accx[i-D]+abs(x[i-D]-x[i]);
      accy[i]=accy[i-D]+abs(y[i-D]-y[i]);
    }
  }

  for(auto i=0;i<Q;++i){
    cout << (accx[R[i]-1]-accx[L[i]-1])+(accy[R[i]-1]-accy[L[i]-1]) << endl;
  }
}

int main(){
  long long H;
  scanf("%lld",&H);
  long long W;
  scanf("%lld",&W);
  long long D;
  scanf("%lld",&D);
  std::vector<std::vector<long long>> A(H, std::vector<long long>(W));
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      scanf("%lld",&A[i][j]);
    }
  }
  long long Q;
  scanf("%lld",&Q);
  std::vector<long long> L(Q);
  std::vector<long long> R(Q);
  for(int i = 0 ; i < Q ; i++){
    scanf("%lld",&L[i]);
    scanf("%lld",&R[i]);
  }
  solve(H, W, D, std::move(A), Q, std::move(L), std::move(R));
  return 0;
}


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

#define MAXP 1299709
bool prime[MAXP+1];
void init(){
	prime[2]=true;
	for(int i=3;i<=MAXP;i++)prime[i]=true;
	for(int i=3;i<=MAXP;i++){
		if(!prime[i])continue;
		for(int j=2*i;j<=MAXP;j+=i)prime[j]=false;
	}
}

int main(){
	int n;
	init();
	while(cin>>n&&n){
		int low=n,high=n;
		while(!prime[low])low--;
		while(!prime[high])high++;
		cout<<high-low<<endl;
	}
	return 0;
}

Measured memory_bytes: 2428
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 
 
using namespace std;
long long mod = 1e9 + 7;
long long INF = 1e7;
double EPS = 1e-12;
typedef long long int lld;
long double tick(){static clock_t oldt; clock_t newt=clock();
    long double diff=1.0L*(newt-oldt)/CLOCKS_PER_SEC; oldt = newt; return diff; }
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
inline lld sc() { lld a; scanf("%lld", &a); return a; }
inline int scd() { int a; scanf("%d", &a); return a; }
inline double scf() { double a; scanf("%lf",&a); return a; }
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) (c).begin(), (c).end()
#define sz(a) ((int)a.size())
#define Error(x...) { cout << "(" << #x << ")" << " = ( "; printIt(x); }
template <typename T1> void printIt(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) { cout << t1 << " , "; printIt(t2...); }
#define errorpair(a) cout<<#a<<" = ( "<<((a).first)<<" , "<<((a).second)<<" )\n";
#define mset(a, v) memset(a, v, sizeof(a))
#define popcount __builtin_popcountll

typedef pair<lld,lld> PA;

lld powP(lld x, lld y) {
    lld ans = 1, po = x % mod;
    while(y > 0) {
        if(y & 1) ans = ans * po % mod;
        y >>= 1; po = po * po % mod;
    }
    return ans;
}
 
bool bitSet(lld n, lld bit){
    if((n & (1LL << bit)) != 0) return true;
    else return false;
}
 
lld findGcd(lld a, lld b){
    while(a != 0) { lld temp = b % a; b = a; a = temp; }
    return b;
}

#define lim 300010
#define lim2 200010
#define qqqqqq 210
// Ab :)
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

// vector<lld> G[lim];
// string S[lim];
// lld A[lim];

int main(){
    unordered_map<int,string> M;
    M[2] = M[4] = M[5] = M[7] = M[9] = "hon";
    M[3] = "bon";
    int n = scd();
    auto it = M.find(n % 10);
    if(it == M.end()) printf("pon\n");
    else printf("%s\n", it->second.c_str());
    return 0;
}


Measured memory_bytes: 3700
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
using namespace std;
struct edge{long long from ,to,cost;};
edge es[2005];

long long d[1005];
int V, E;
int N, M;
bool heiro = false;

void shortest_path(int s){
    for(int i=0;i<V;i++){
        d[i] = -1000000000000000005;
    }
    d[s] = 0;
    for(int i=0;i<V;i++){
        bool update = false;
        for (int j=0;j<E;j++){
            edge e = es[j];
            if(d[e.from] != -1000000000000000005 && d[e.to]<d[e.from]+e.cost){
                d[e.to] = d[e.from] +e.cost;
                update = true;
            }
        }
        if(!update){
            break;
        }
        if(i==V-1){
            heiro = true;
        }
    }
    
}
int main(){
    cin >> N >> M;
    V = N;
    E = M;
    for(int i=0;i<M;i++){
        long long a,b,c;
        cin >> a >> b >> c;
        es[i] = edge({a-1,b-1,c});
    }
    shortest_path(0);
    if(heiro){
        bool heiroN = false;
        long long c = d[N-1];
        for(int i=0;i<V;i++){
            for (int j=0;j<E;j++){
                edge e = es[j];
                if(d[e.from] != -1000000000000000005 && d[e.to]<d[e.from]+e.cost){
                    d[e.to] = d[e.from] +e.cost;
                }
            }
            if(c != d[N-1]){
                heiroN = true;
            }
        }
        if(heiroN){
        cout << "inf" << endl;
        return 0;
        } else {
            cout << d[N-1] << endl;
            return 0;
        }
    }
    cout << d[N-1] << endl;
    
}


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

int main(){
  int n,k;
  cin >> n >> k;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int num;
  if((n-1)%(k-1)==0)
    num=(n-1)/(k-1);
  else num=(n-1)/(k-1)+1;
  cout << num << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int fld[9][9];

bool judge(int x, int y){
	for(int i = 0; i < 9; ++i){
		if(i != x){
			if(fld[i][y] == fld[x][y]){
				return false;
			}
		}
	}
	
	for(int i = 0; i < 9; ++i){
		if(i != y){
			if(fld[x][i] == fld[x][y]){
				return false;
			}
		}
	}
	
	int _x = (x / 3) * 3;
	int _y = (y / 3) * 3;
	
	for(int i = 0; i < 3; ++i){
		for(int j = 0; j < 3; ++j){
			if(_x + i != x || _y + j != y){
				if(fld[_x + i][_y + j] == fld[x][y]){
					return false;
				}
			}
		}
	}
	
	return true;
}

int main(){
	int n;
	
	
	cin >> n;
	for(int i = 0; i < n; ++i){
		
		for(int x = 0; x < 9; ++x){
			for(int y = 0; y < 9; ++y){
				cin >> fld[x][y];
			}
		}
		
		if(i) cout << endl;
		for(int x = 0; x < 9; ++x){
			for(int y = 0; y < 9; ++y){
				cout << (judge(x, y) ? " " : "*") << fld[x][y];
			}
			cout << endl;
		}
	}
	
	return 0;
}

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

int main() {
	int A=0, B=0, tmp;
	for (int i=0; i<4; i++) {
		cin >> tmp;
		A += tmp;
	}
	for (int i=0; i<4; i++) {
		cin >> tmp;
		B += tmp;
	}
	int ans = max(A, B);
	cout << ans << endl;
}

Measured memory_bytes: 0
import bisect

n = int(input())
a = sorted(list(map(int, input().split())))
b = list(map(int, input().split()))
c = sorted(list(map(int, input().split())))

ans = 0
for i in b:
    a_pos = bisect.bisect_left(a, i)
    c_pos = n - bisect.bisect_right(c, i)
    ans += a_pos * c_pos

print(ans)


Measured memory_bytes: 23968
import sys
import math

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n = I()
    f = [0]*(n+1)
    n_sqrt = int(math.sqrt(n))
    for x in range(1, n_sqrt):
        for y in range(x, n_sqrt):
            for z in range(y, n_sqrt):
                cnt = 0
                if x == y == z:
                    cnt = 1
                elif x != y != z:
                    cnt = 6
                else:
                    cnt = 3
                idx = x*x + y*y + z*z + x*y + y*z + z*x
                if idx <= n:
                    f[idx] += cnt
    ans = '\n'.join(str(v) for v in f[1:n+1])
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 68428
#include <bits/stdc++.h>
using namespace std;
int main(void){
  string a, b;
	cin >> a >> b;

	if (a.at(0) == b.at(2) && a.at(1) == b.at(1) && a.at(2) == b.at(0)) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
}
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>



const int mod = 1000000007;

int main() {
	char S[200001];
	scanf("%s", S);
	int B = 0;
	long long r = 0;
	for (int i = 0; S[i]!=0; i++) {
		if (S[i] == 'B') {
			B++;
		}
		else {
			r += B;
		}
	}
	printf("%lld", r);
}





Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
    int A, B, C, times;
    scanf ("%d %d %d", &A, &B, &C);
    times = B/A;
    if (times > C)
        printf ("%d", C);
    else
        printf ("%d", times);
    return 0;
}


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

const int MAX = 1e5;

int cnt[MAX];
int dp[MAX];
int ex[MAX];

int dfs(int v, int prev, const vector<vector<int>>& G) {
	int res = 0;
	for (auto to : G[v]) if (to != prev) {
		int tmp = dfs(to, v, G);
		ex[v] += tmp != 0;
		res += tmp;
	}
	int chil = prev == -1 ? (int)G[v].size() - 1 : (int)G[v].size() - 2;
	if (ex[v] < chil) {
		cnt[v] = chil - ex[v];
		res += cnt[v];
	}
	return dp[v] = res;
}

int main()
{
	int N;
	cin >> N;
	vector<vector<int>> G(N);
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int rt = -1;
	for (int i = 0; i < N; i++) {
		if ((int)G[i].size() >= 2) {
			rt = i;
			break;
		}
	}
	if (rt == -1) {
		cout << 1 << endl;
		return 0;
	}
	dfs(rt, -1, G);
	int res = 0;
	for (int i = 0; i < N; i++) {
		res += cnt[i];
	}
	if ((int)G[rt].size() == 2 && ex[rt] == 1) {
		res++;
	}
	cout << max(1, res) << endl;
	return 0;
}


Measured memory_bytes: 14208
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = 100000000000;
const long long int Mod = 1000000007;
using ll = long long int; //long long int は64bit
using vi = vector<int>; using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
//       cin.tie(0);ios::sync_with_stdio(false);
void cinit(){cin.tie(0);ios::sync_with_stdio(false);}
typedef pair<ll,ll> Pair;
bool p_compare(const Pair& firstP, const Pair& secondP)
 { return firstP.first < secondP.first; }//sort(all(v),p_compare)で昇順ソート
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////

string s;

int main(){
	cin>>s;
	ll r=0,b=0;
	rep(i,s.size()){
		if(s[i]=='0'){
			r++;
		}else{
			b++;
		}
	}
	cout<<s.size()-abs(r-b)<<endl;
	return 0;
}

Measured memory_bytes: 512
a, b, k = map(int, input().split())
if a + k - 1 >= b - k + 1:
     for i in range(a, b+1):
         print(i)
else:
    for i in range(a, a+k):
        print(i)
    for i in range(b-k+1, b+1):
        print(i)


Measured memory_bytes: 3316
use proconio::input;

fn main() {
    input!(n: usize, a: [u32; n]);
    println!(
        "{}",
        a.into_iter()
            .enumerate()
            .filter(|&(i, x)| i % 2 == 0 && x % 2 == 1)
            .count()
    );
}


Measured memory_bytes: 2120
#include <bits/stdc++.h> 
#include <time.h>
#define F(i,a,b) for(long long i=a;i<=(b);++i)
#define dF(i,a,b) for(long long i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 1e5+10;
const int N = 1e5+10;
const int E = 2e5+10;  
ll n,k,a,b;

int main(){
	cin>>k;
	cin>>a>>b;
	bool flg = 0;
	F(i,a,b){
		if(i%k==0){
			flg = 1;
			break;
		}
	} 
	if(flg){
		printf("OK\n"); 
	} 
	else printf("NG\n"); 
}


Measured memory_bytes: 3636
import std.stdio, std.string, std.conv, std.algorithm;
void main()
{
	while(true) {
		auto input = readln.chomp.split(",");
		int[] hand;
		foreach(e; input)
			hand ~= e.to!int;

		if(!hand.length)
			break;
		hand.sort();
		(new PokerHand(hand)).hand.writeln;
	}
}

class PokerHand
{
	int[] cards;
	string hand;

	this(int[] cards)
	in
	{
		assert(cards.length == 5);
		assert(cards.isSorted);
	}
	body
	{
		this.cards = cards.dup;
		hand = getHandName();
	}

	private string getHandName()
	{
		if(isFourCard)
			return "four card";
		else if(isFullHouse)
			return "full house";
		else if(isStraight)
			return "straight";
		else if(isThreeCard)
			return "three card";
		else if(isTwoPair)
			return "two pair";
		else if(isOnePair)
			return "one pair";
		else
			return "null";
	}

	private bool isFourCard()
	{
		return maxNumOfSameCards == 4;
	}

	private bool isFullHouse()
	{
		return isThreeCard && isOnePair;
	}

	private bool isStraight()
	{
		static immutable bloadway = [1, 10, 11, 12, 13];
		bool _isStraight()
		{
			bool f = true;
			for(int i = 0; i < cards.length - 1 && f; i++)
				f = cards[i + 1] - cards[i] == 1;
			return f;
		}

		return _isStraight() || cards == bloadway;
	}

	private bool isThreeCard()
	{
		return maxNumOfSameCards == 3;
	}

	private bool isTwoPair()
	{
		return numOfPairs == 2;
	}
	
	private bool isOnePair()
	{
		return numOfPairs == 1;
	}

	private int numOfPairs()
	{
		int[14] nums;
		foreach(card; cards)
			nums[card]++;

		auto cnt = 0;
		foreach(num; nums)
			if(num == 2)
				cnt++;

		return cnt;
	}

	private int maxNumOfSameCards()
	{
		int[14] nums;
		foreach(card; cards)
			nums[card]++;
		return max(nums);
	}

	private int max(int[] arr...)
	{
		int max = 0;
		foreach(v; arr)
			max = v > max ? v : max;
		return max;
	}
}

Measured memory_bytes: 1088
n = int(input())
_ = [-2, -1]
a = list(map(int, input().split()))
a = _ + a
tmp = 0
ans = 0
for i in range(n+1):
  if(a[i] >= a[i+1]):
    tmp += 1
    if(i == n):
      ans = max(ans, tmp)
  else:
    ans = max(ans, tmp)
    tmp = 0
print(ans)

Measured memory_bytes: 14224
fn print_vec(arr: &Vec<u32>) {
    for i in 0..arr.len() {
        print!("{}", arr[i]);
        if i < arr.len() - 1 {
            print!(" ");
        }
    }
}
fn insersion_sort(arr: &Vec<u32>, n: u32) -> Vec<u32> {
    let mut sorted = arr.to_vec();
    print_vec(&sorted);
    println!();
    for i in 1..arr.len() {
        let si = sorted[i];
        let mut j = (i - 1) as i32;
        while j >= 0 && sorted[j as usize] > si {
            sorted[(j + 1) as usize] = sorted[j as usize];
            j -= 1;
        }
        sorted[(j + 1) as usize] = si;
        print_vec(&sorted);
        if i != arr.len() {
            println!();
        }
    }
    sorted
}

fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();
    let n: u32 = line.trim().parse().ok().unwrap();

    line.clear();
    std::io::stdin().read_line(&mut line).ok();
    let arr = line.split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect();

    insersion_sort(&arr, n);
}



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

Measured memory_bytes: 640
#include <iostream>
using namespace std;
 
int main() {
	int ans;
	int a, b, c;
	cin >> a >> b >> c;
	if (b / a > c) {
		ans = c;
	}
	else {
		ans = b / a;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <functional>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define endl "\n"
#define fi first
#define se second
typedef long long ll;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl
#define MOD 1000000007
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;}

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

  ll N; cin>>N;
  map<ll,ll> mp;
  rep(i,N-1) {
    ll A; cin>>A;
    mp[A]++;
  }

  rep(i,N) {
    cout<<mp[i+1]<<endl;
  }

  return 0;
}


Measured memory_bytes: 16164
#include <iostream>
#include <string>
#define INF 1<<30
using namespace std;

int cnt = 0, n;
class Node{
    private:
    char sign;
    unsigned int num;
    public:
    Node(): sign('O'), num(0){};
    Node(char sign, int num){
        this->sign = sign;
        this->num = num;
    };
    int getnum(){
        return this->num;
    };
    char getsign(){
        return this->sign;
    };
    void setnum(int n){
        this->num = n;
    }
    void setsign(char sign){
        this->sign = sign;
    }
};
void merge(Node *A, int left, int mid, int right){
    int n1 = mid - left, n2 = right - mid;
    Node L[n1+1], R[n2+1];
    for (int i = 0; i < n1; i++) L[i] = A[left + i];
    for (int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1].setnum(INF), R[n2].setnum(INF);

    int curL = 0, curR = 0;
    for (int k = left; k < right; k++){
        if (L[curL].getnum() <= R[curR].getnum()){
            A[k].setnum(L[curL].getnum());
            A[k].setsign(L[curL].getsign());
            curL++;
        }else{
            A[k] = R[curR];
            A[k].setnum(R[curR].getnum());
            A[k].setsign(R[curR].getsign());
            curR++;
        }
        cnt++;
    }
    return;
}

void mergeSort(Node *A, int left, int right){
    if (left+1 < right){
        int mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int partition(Node *array, int l, int r){
    int pivot = array[r].getnum();
    int i = l - 1;

    for (int j = l; j < r; j++){
        if (array[j].getnum() <= pivot){
            i++;
            swap(array[i], array[j]);
        }
    }
    swap(array[i+1], array[r]);
    return (i + 1);
}

void quicksort(Node *array, int l, int r){
    if (l < r){
        int pivot = partition(array, l, r);
        quicksort(array, l, pivot-1);
        quicksort(array, pivot+1, r);
    }
}

void display(Node * a){
    for (int i = 0; i < n; i++){
        printf("%c %d\n", a[i].getsign(), a[i].getnum());
    }
}

bool comapre(Node *s, Node *t){
    int i = n;
    bool flag = true;
    while(--i){
        //printf("s[%d] = %d%c, t[%d] = %d%c\n", i, s[i].getnum(), s[i].getsign(), i, t[i].getnum(), t[i].getsign());
        if ((s[i].getnum() == t[i].getnum()) &&
                (s[i].getsign() == t[i].getsign()))
                continue;
        else{
            flag = false;
            break;
        }
    }
    return flag;
}
int main(int argc, char* argv[]) {
    Node p;
    char c;
    int num;
    cin >> n;
    Node s[n], t[n];
    for (int i = 0; i < n; i++){
        cin >> c >> num;
        s[i].setsign(c);
        s[i].setnum(num);
        t[i].setsign(c);
        t[i].setnum(num);
    }
    quicksort(s, 0, n-1);
    mergeSort(t, 0, n);

    cout << (comapre(s, t)? "Stable": "Not stable") << endl;
    display(s);
    return 0;
}



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

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

int i, j;
string s;
const string ss = "YAKI";
int main() {
	cin >> s;
	if(s.length() < 4) {
		puts("No");
		return 0;
	}
	for(i = 0; i < 4; i++) {
		if(s[i] != ss[i]) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

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

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

    vector<int> a(n); bool flg = false;
    int g = 0;
    for (auto i = 0; i < n; i++) {
        cin >> a[i];
        if(k <= a[i]) flg = true;
        g = gcd(a[i],  g);
    }
    if(not flg) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    cout << ((k % g == 0) ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin >> n;
    vector<int> x(n);
    for (int i = 0; i < n; i++) cin >> x.at(i);
    sort(x.begin(), x.end());
    int ans = 100000000;
    for (int i = 0; i <= 100; i ++){
        int tmp = 0;
        for (int j = 0; j < n; j++){
            tmp = tmp + ((x.at(j) - i) * (x.at(j) - i));
        }
        ans = min(ans, tmp);
    }
    
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int sum;
int main() {
	int n,m;
	cin>>n;
	vector<int>t(n);
	for(int i=0;i<n;i++){
		cin>>t.at(i);
		sum+=t.at(i);
	}
	cin>>m;
	int p,x;
	for(int i=0;i<m;i++){
		cin>>p>>x;
		cout<<sum-(t.at(p-1)-x)<<endl;
	}
}

Measured memory_bytes: 256
#import copy as c
n=int(input())
lis=[int(a) for a in input().split()]
count=0
prev=False
for i in range(n):
	if lis[i]==i+1:
		if not prev:
			count+=1
			prev=True
			continue
	prev=False

print(count)
#wrong solutiuon

Measured memory_bytes: 13880
#include <stdio.h>

int main(void)
{
    int asub[4];
    int bsub[4];
    int asum, bsum;
    int i;

    scanf("%d %d %d %d", &asub[0], &asub[1], &asub[2], &asub[3]);
    scanf("%d %d %d %d", &bsub[0], &bsub[1], &bsub[2], &bsub[3]);

    asum = bsum = 0;
    for (i = 0; i < 4; i++){
        asum += asub[i];
        bsum += bsub[i];
    }

    if (asum > bsum || asum == bsum){
        printf("%d\n", asum);
    }
    else if (asum < bsum){
        printf("%d\n", bsum);
    }

    return (0);
}

Measured memory_bytes: 592