akhauriyash/Code-Regression huggingface dataset:
// AOJ CGL_2_B Intersection
// 2018.5.2 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

typedef struct { double x, y; } PP;
typedef struct { PP s, e; } SEG, LINE;

#define INF			1e8
#define EPS			1e-8
#define EQ(a,b)		(fabs((a)-(b))<EPS)
#define PPeQ(a,b)	(EQ(a.x,b.x)&&EQ(a.y,b.y))

int dcmp(double x) { if (fabs(x) < EPS) return 0; return x <= 0 ? -1 : 1; }
PP vset(double x, double y) { PP r; r.x = x, r.y = y; return r; }
PP vadd(PP p1, PP p2) { PP r; r.x = p1.x + p2.x, r.y = p1.y + p2.y; return r; }
PP vsub(PP p1, PP p2) { PP r; r.x = p1.x - p2.x, r.y = p1.y - p2.y; return r; }
PP vsmul(PP p, double k) { PP r; r.x = p.x * k, r.y = p.y * k; return r; }
PP vmul(PP p1, PP p2) { PP r;
	r.x = p1.x * p2.x - p1.y * p2.y, r.y = p1.x * p2.y + p1.y * p2.x; return r; }
double vabs(PP a) { return hypot(a.x, a.y); }
double dist(PP p1, PP p2) {	return hypot(p1.x-p2.x, p1.y-p2.y); };
double cross(PP a, PP b) { return a.x * b.y - a.y * b.x; }
double dot(PP a, PP b) { return a.x * b.x + a.y * b.y; }
double norm(PP a) { return a.x * a.x + a.y * a.y; }

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int ccw(PP p0, PP p1, PP p2)
{
	PP a, b;
	double t;

	a = vsub(p1, p0), b = vsub(p2, p0), t = cross(a, b);
	if (t >  EPS) return 1;	if (t < -EPS) return -1;
	if (dot(a, b) < -EPS) return 2;	if (norm(a) < norm(b)) return -2;
	return 0;
}

int is_intersectSS(SEG s1, SEG s2)
{
	return ccw(s1.s, s1.e, s2.s) * ccw(s1.s, s1.e, s2.e) <= 0 &&
		   ccw(s2.s, s2.e, s1.s) * ccw(s2.s, s2.e, s1.e) <= 0;
}

int main()
{
	int q, x, y;
	PP p0, p1, p2, p3;
	SEG s1, s2;

	q = in();
	while (q--) {
		x = in(), y = in(), p0 = vset(x, y);
		x = in(), y = in(), p1 = vset(x, y);
		x = in(), y = in(), p2 = vset(x, y);
		x = in(), y = in(), p3 = vset(x, y);
		s1.s = p0, s1.e = p1;
		s2.s = p2, s2.e = p3;
		putchar('0' + is_intersectSS(s1, s2)), putchar('\n');
	}
	return 0;
}



Measured memory_bytes: 2128
while True:
    a,b = map(int,input().split())
    
    if a == 0 and b == 0:
        break
    
    for i in range(a):
        for j in range(b):
            if i == 0 or j == 0 or j == b-1 or i == a-1:
                print("#", end="")
            else:
                print(".",end="")
                
        print()
    print()


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

int main() {
    long long S, K, N;
    cin >> N >> K >> S;
    for(long long i = 0; i<N; i++) {
        if(i<K) {
            cout << S << " ";
        }
        else {
            if(100000000> S) {
                cout << "100000000 ";
            } else {
                cout << "1 ";
            }
        };
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 1280
#include<cstdio>
#include<cmath>

int main(){
    int n;
    double m,sum,s,dev,S[1000]={};

    while(1){
        scanf("%d",&n);
        if (n == 0) break;
        else{
            sum = 0,dev = 0;
            for (int i = 0; i < n; i++){
                scanf("%lf",&s);
                S[i] = s;
                sum += S[i];
            }
            m = sum/n;
            for (int i = 0; i < n; i++){
                dev += (S[i] - m)*(S[i] - m);
            }
            printf("%.8lf\n",sqrt(dev/n));    
        }
    }
    return 0;
}


Measured memory_bytes: 2772
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  ll d[n][n];
  mem(d);
  rep(i,n) {
    REP(j,i+1,n) {
      d[i][j]=d[j][i]=1;
      REP(k,1,10) {
        if(i%(1<<k)==j%(1<<k)) d[i][j]=d[j][i]=k+1;
      }
    }
  }
  rep(i,n-1) {
    bool f=0;
    REP(j,i+1,n) {
      if(f) cout << " ";
      f=1;
      cout << d[i][j];
    }
    ln;
  }
}

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


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

struct mint {
    long long x;
    mint(long long x=0):x(x % MOD + (0 <= x ? 0 : MOD)) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint& a) { if ((x += a.x) >= MOD) x -= MOD; return *this; }
    mint& operator-=(const mint& a) { if ((x -= a.x) < 0) x += MOD; return *this; }
    mint& operator*=(const mint& a) { (x *= a.x) %= MOD; return *this; }
    mint operator+(const mint& a) const { return mint(x) += a; }
    mint operator-(const mint& a) const { return mint(x) -= a; }
    mint operator*(const mint& a) const { return mint(x) *= a; }

    // for prime mod
    mint inv() const {
        long long a = x, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        return mint(u);
    }
    mint& operator/=(const mint& a) { return *this *= a.inv(); }
    mint operator/(const mint& a) const { return mint(x) /= a; }
};
istream& operator>>(istream& is, const mint& a){ return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a){ return os << a.x; }

ll fac[MAX], finv[MAX], inv[MAX];
void init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// グラフ
vector<int> G[MAX];

// データの構造体
struct Data {
    mint a;
    int s;
};

Data f(Data x, Data y) {
    mint res = x.a * y.a;
    res *= fac[x.s+y.s];
    res /= fac[x.s] * fac[y.s];
    return Data{res, x.s + y.s};
}

// dp[i][j]:=頂点iの結果
vector<Data> dp[MAX];

// deg[i]:=頂点iの子の数
int deg[MAX];

// pi[i]:=頂点iの親の index
int pi[MAX];

// ans[i]:=頂点iの解
mint ans[MAX];

Data dfs1(int v, int p=-1) {
    deg[v] = G[v].size();
    dp[v].resize(deg[v]);

    Data res = {1, 0};
    rep(i, deg[v]) {
        int u = G[v][i];
        if (u == p) {
            pi[v] = i;
            continue;
        }
        dp[v][i] = dfs1(u, v);
        res = f(res, dp[v][i]);
    }
    res.s++;
    return res;
}

void dfs2(int v, Data p_res=Data{1, 0}, int p=-1) {
    if (p != -1) dp[v][pi[v]] = p_res;

    vector<Data> dpl(deg[v] + 1);
    dpl[0].a = 1;
    rep(i, deg[v]) dpl[i+1] = f(dpl[i], dp[v][i]);

    vector<Data> dpr(deg[v] + 1);
    dpr[deg[v]].a = 1;
    repr(i, deg[v]) dpr[i] = f(dpr[i+1], dp[v][i]);

    ans[v] = dpr[0].a;

    rep(i, deg[v]) {
        int u = G[v][i];
        if (u == p) continue;
        Data d = f(dpl[i], dpr[i+1]);
        d.s++;
        dfs2(u, d, v);
    }
}

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

    rep(i, N-1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    init();
    dfs1(0);
    dfs2(0);

    rep(i, N) {
        cout << ans[i] << endl;
    }
}

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

int main(){
	
	int n;
	cin >> n;
	vector<int> x(n);
	for(int i = 0; i < n; i++)
	{
		cin >> x[i];
	}

	vector<int> sortx = x;
	sort(sortx.begin(), sortx.end());
	int ans1 = sortx[n/2-1], ans2 = sortx[n/2];
	for(int i = 0; i < n; i++)
	{	
		
		
		if(ans1 < x[i]) cout << ans1 << endl;
		else if(ans2 >= x[i]) cout << ans2 << endl;
		
	}
	
		
	
	
	return 0;
}

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

int InsertionSort(vector<int> &A, int g){
    int N = A.size();
    int cnt = 0;
    
    for(int i = g; i < N; ++i){
        int v = A[i];
        int j = i - g;
        while(j >= 0 && A[j] > v){
            A[j + g] = A[j];
            j = j - g;
            ++cnt;
        }
        A[j + g] = v;
    }
    
    return cnt;
}

int main(void){
    int cnt = 0;
    int N;
    cin >> N;
    vector<int> A(N, 0);
    for(int i = 0; i < N; ++i)
        cin >> A[i];
    
    
    vector<int> G;
    int g = 1;
    while(g <= N){
        G.push_back(g);
        g = 3 * g + 1;
    }
    int m = G.size();
    cout << m << endl;
    for(int i = m - 1; i >= 0; --i){
        cout << G[i];
        if(i != 0)
            cout << " ";
    }
    cout << endl;
    
    for(int i = m - 1; i >= 0; --i){
        cnt += InsertionSort(A, G[i]);
    }
    cout << cnt << endl;
    
    for(int i = 0; i < N; ++i){
        cout << A[i];
        if(i != N - 1)
            cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 6656
from collections import defaultdict
from math import factorial

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

memo = defaultdict(int)
def frac(n, k):
    global memo
    if memo[n] == 0:
        memo[n] = factorial(n)
    if memo[k] == 0:
        memo[k] = factorial(k)
    if memo[n-k] == 0:
        memo[n-k] = factorial(n - k)
    return memo[n] // memo[k] // memo[n-k]

factor = defaultdict(int)

ps = m
for i in range(2, int(m ** 0.5)+1):
    while ps % i == 0:
        ps  = ps // i
        factor[i] += 1
if ps !=1:
    factor[ps] += 1
mod = 10**9+7
result = 1
for i, v in factor.items():
    result = result * frac(n+v-1, v) % mod

print(result)

Measured memory_bytes: 66268
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int N = std.nextInt();
        int K = std.nextInt();
        String text = std.next();
        String[] splitText = text.split("");

        String result = IntStream.range(0, N).mapToObj(it -> {
            if (it == K - 1) {
                return splitText[it].toLowerCase();
            } else {
                return splitText[it];
            }
        }).collect(Collectors.joining());

        System.out.println(result);
    }
}


Measured memory_bytes: 29140
n=int(input())
p=list(map(float,input().split()))
dp=[[0 for j in range(n+1)] for i in range(n+1)]

dp[0][0]=1
for i in range(n):
  for j in range(i+1):
    dp[i+1][j+1]+=dp[i][j]*p[i]
    dp[i+1][j]+=dp[i][j]*(1-p[i])
ans=0
for i in range(n,-1,-1):
  if i>n-i:
    ans+=dp[-1][i]
  else:
    break
print(ans)


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

const int INF = 1e9;

int main()
{
	int H, W;
	char sc, tc;
	cin >> H >> W >> sc >> tc;
	int s = sc - 'A', t = tc - 'A';
	vector<string> S(H);
	vector<vector<int>> G(26);
	for (int i = 0; i < H; i++) {
		cin >> S[i];
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S[i][j] == '-') {
				int u = S[i][j - 2] - 'A';
				int p = j;
				while (S[i][p] == '-') {
					S[i][p] = '.';
					p++;
				}
				int v = S[i][p + 1] - 'A';
				G[u].push_back(v);
				G[v].push_back(u);
			}
			if (S[i][j] == '|') {
				int u = S[i - 2][j] - 'A';
				int p = i;
				while (S[p][j] == '|') {
					S[p][j] = '.';
					p++;
				}
				int v = S[p + 1][j] - 'A';
				G[u].push_back(v);
				G[v].push_back(u);
			}
		}
	}
	queue<int> q;
	vector<int> d(26, INF);
	q.push(s);
	d[s] = 0;
	while (!q.empty()) {
		auto v = q.front(); q.pop();
		for (auto to : G[v]) if (d[to] == INF) {
			q.push(to);
			d[to] = d[v] + 1;
		}
	}
	cout << d[t] << endl;
	return 0;
}



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

int main() {
	int a, b; cin >> a >> b;

	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)cout << "Possible" << endl;
	else cout << "Impossible" << endl;

	return 0;
}


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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;
using pii=pair<int,int>;using pll=pair<ll,ll>;using pil=pair<int,ll>;using pli=pair<ll,int>;
using vs=vector<string>;using vvs=vector<vs>;using vvvs=vector<vvs>;
using vb=vector<bool>;using vvb=vector<vb>;using vvvb=vector<vvb>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template<class T,class U>istream&operator>>(istream&is,pair<T,U>&P){is>>P.fst;is>>P.snd;return is;}
template<class T>T read(){T t;cin>>t;return t;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<'('<<p.fst<<", "<<p.snd<<')';}
template<class T>ostream&operator<<(ostream&o,const vector<T>&t){o<<"{";rep(i,sz(t))o<<t[i]<<",";o<<"}"<<endl;return o;}
#ifdef LOCAL
vs s_p_l_i_t(const string&s,char c){vs v;stringstream ss(s);string x;while(getline(ss,x,c))v.emplace_back(x);return move(v);}
void e_r_r(vs::iterator it){cerr<<endl;}
template<class T,class... Args>void e_r_r(vs::iterator it,T a,Args... args){cerr<<it->substr((*it)[0]==' ',it->length())<<" = "<<a<<", ";e_r_r(++it,args...);}
#define out(args...){vs a_r_g_s=s_p_l_i_t(#args,',');e_r_r(a_r_g_s.begin(),args);}
#else
#define out(args...)
#endif

void Main() {
  int n = read<int>();
  int a = read<int>();
  vector<int> A(n);
  rep(i, n) A[i] = read<int>();

  vvl dp(n+1, vl(50 * (n + 1)));
  dp[0][0] = 1;

  rep(i, n) {
    rrep(j, i+1) {
      rrep(k, 50 * j + 1) if (dp[j][k]) {
        dp[j+1][k+A[i]] += dp[j][k];
      }
    }
  }


  ll ans = 0;
  rep(i, 1, n+1) {
    int s = a * i;
    ans += dp[i][s];
  }
  cout << ans << endl;
}
int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 1280
mod=1000000007
n=int(input())
#print(0 if n==1 else pow(10,n,mod)-pow(9,n,mod)-pow(9,n,mod)+pow(8,n,mod))
print(0 if n==1 else (pow(10,n)-pow(9,n)-pow(9,n)+pow(8,n))%mod)

Measured memory_bytes: 85856
def main():
    K = int(input())

    if K % 2 == 0:
        print(-1)
        return

    r = 7 % K
    idx = 1
    while r:
        r = (r * 10 + 7) % K
        idx += 1
        if idx > K:
            print(-1)
            return

    print(idx)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9164
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

S = list(input())
T = list(input())

cnt = 0
for s, t in zip(S, T):
    cnt += 1 if s != t else 0

print(cnt)


Measured memory_bytes: 12576
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  ll N,answer=0;
  cin>>N;
  ll count=0;
  vector<ll> vec(N);
  for(ll i=0;i<N;i++){
    cin>>vec.at(i);
  }
  for(ll i=1;i<N;i++){
    if(vec.at(i-1)>=vec.at(i)){count++;}
    else{answer=max(answer,count);count=0;}
    answer=max(answer,count);
  }
  cout<<answer<<endl;
}

Measured memory_bytes: 1024
module Main (main) where

import           Control.Monad
import qualified Data.ByteString.Char8     as C8
import           Data.Maybe

main :: IO ()
main = do
  [[n],[a]] <- replicateM 2 readInts  -- 複数行
  print . showAnswer $ solve (n,a)

type Input  = (Int, Int)
type Output = Int

solve :: Input -> Output
solve (n,a) = n^2-a

showAnswer :: Output -> Answer
showAnswer = Number

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

data Answer
  = YesNo Bool
  | AB Bool
  | Number Int

instance Show Answer where
  show (YesNo b)  = if b then "Yes" else "No"
  show (AB b)     = if b then "A"   else "B"
  show (Number i) = show i

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int main()
{
    string s;
    stack<char> ans;
    cin>>s;
    int hoge=0;
    rep(i,s.size()){
        char temp= s[i];
        if(s[i]=='B'){
            if(ans.empty()==true) continue;
            else ans.pop();
        } else ans.push(temp);
    }
    stack<char > buf;
    while(ans.empty()!=true) {
        buf.push(ans.top());
        ans.pop();
    }
    while(buf.empty()!=true){
        cout<<buf.top();
        buf.pop();
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np

def main():
    S = input()
    S_np = np.array([int(S[i]) for i in range(len(S))])
    final_0_origin = np.array([i % 2 for i in range(len(S))])
    final_1_origin = np.array([(i+1) % 2  for i in range(len(S))])

    ans = min(cal_dist(S_np, final_0_origin), cal_dist(S_np, final_1_origin))
    print(ans)

def cal_dist(S_np, T_np):
    return np.sum(S_np ^ T_np)

main()



Measured memory_bytes: 19744
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

int main(){
ll N;
cin >> N ;
vector<int> s(N);
for(int i = 0 ; i < N-1 ; i ++){
  int a;
  cin >> a;
  s[a-1]+=1;
}
for(int i = 0 ; i < N ; i++){
  cout << s[i] << endl;
}
}


Measured memory_bytes: 3996
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include<unordered_map>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	int n;
	cin >> n;
	int count4 = 0;
	int count2 = 0;
	int count = 0;
	rep(i, n) {
		int a;
		cin >> a;
		if (a % 4 == 0) {
			count4++;
		}
		else if (a % 2 == 0) {
			count2++;
		}
		else {
			count++;
		}
	}
	bool flag = true;
	count4++;
	if (count > count4) {
		flag = false;
	}
	else if (count2 > 0&&count == count4) {
			flag = false;
	}
	
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

bool comp(int c1, int c2) {
  return ceil(c1 / 10.0) * 10 - c1 > ceil(c2 / 10.0) * 10 - c2;
}

int main(){
  vector<int> cookTime(5);
  for(int i=0; i<5; i++)
    cin >> cookTime[i];
  sort(cookTime.begin(), cookTime.end(), comp);
  int ans = cookTime[0];
  for(int i=1; i<5; i++)
    ans += ceil(cookTime[i] / 10.0) * 10;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 10e8;
const int MAX_V = 201;
int a[4];
int c[10];
bool use[10];
int t[10][10];
void Shiftonly() {
	int n;
	cin >> n;
	int a[201];
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	int res = 0;
	while (true)
	{
		bool dived = true;
		for (size_t i = 0; i < n; i++)
		{
			if (a[i] % 2 != 0) {
				dived = false;
				break;
			}
			a[i] /= 2;
		}
		if (!dived) break;
		res++;
	}
	cout << res << endl;
}

int main() {
	Shiftonly();
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; 
	cin >> N;
	int nums[N][2];
	for(int i = 0; i < N; ++i){
		cin >> nums[i][0] >> nums[i][1];
	}
	for(int i = 0; i < N-2; ++i){
		if (nums[i][0] == nums[i][1] && nums[i+1][0] == nums[i+1][1] && nums[i+2][0] == nums[i+2][1]){
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
}


Measured memory_bytes: 3648
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> Q;
//ll longinf=1ll<<60;
int inf=1<<29;
int dn[4]={-1,1,0,0};
int dm[4]={0,0,-1,1};
ll longinf=(1ll<<60);
int main(){
  	  cin.tie(0);
      ios::sync_with_stdio(false);
      int N,K;
      cin>>N>>K;
  	  int D=2*K;
      int x[N],y[N];
      char c[N];
      rep0(i,N) cin>>x[i]>>y[i]>>c[i];
      auto mod = [](int a,int b){
            return (b+a%b)%b;
      };
      rep0(i,N){
            x[i]%=D;
            y[i]%=D;
            if(c[i]=='W'){
                  y[i]=mod(y[i]+K,D);
            }
      }
      int field[D][D];
      rep0(i,D){
            rep0(j,D){
                  field[i][j]=0;
            }
      }
      rep0(i,N){
            if((x[i]<K&&y[i]<K)||(x[i]>=K&&y[i]>=K)){
                  x[i]%=K;
                  y[i]%=K;
                  field[0][0]++;
                  field[0][y[i]]--;
                  field[0][y[i]+K]++;
                  field[x[i]][0]--;
                  field[x[i]][y[i]]+=2;
                  field[x[i]][y[i]+K]-=2;
                  field[x[i]+K][0]++;
                  field[x[i]+K][y[i]]-=2;
                  field[x[i]+K][y[i]+K]+=2;
            }
            else{
                  x[i]=max(x[i],mod(x[i]+K,D));
                  y[i]=min(y[i],mod(y[i]+K,D));
                  field[0][y[i]]++;
                  field[0][y[i]+K]--;
                  field[x[i]-K][0]++;
                  field[x[i]-K][y[i]]-=2;
                  field[x[i]-K][y[i]+K]+=2;
                  field[x[i]][0]--;
                  field[x[i]][y[i]]+=2;
                  field[x[i]][y[i]+K]-=2;
            }
      }
      rep0(i,D){
            rep1(j,D-1){
                  field[i][j]+=field[i][j-1];
            }
      }
      rep1(i,D-1){
            rep0(j,D){
                  field[i][j]+=field[i-1][j];
            }
      }
      int ans=0;
      rep0(i,D){
            rep0(j,D){
                  ans=max(ans,field[i][j]);
            }
      }
      cout<<ans<<endl;
      return 0;
}


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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,k;
	cin>>n>>k;
	deque<int> dq;
	string s;
	cin>>s;
	for(auto it:s)
		dq.emplace_back(it-'A');
	int flip=0;
	while(k){
		k--;
		int cur = dq[0]^(flip&1);
		if(cur==0){
			dq[0]^=1;
		}
		else{
			dq.pop_front();
			flip++;
			dq.emplace_back(flip&1);
		}
		if(flip==n)	break;
	}
	if(k)if(n&1)if(k&1)	dq[0]^=1;
	for(auto it:dq){
		it ^= (flip&1);
		cout<<char(it+'A');
	}
	cout<<endl;
}


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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

string s;
lli k;

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


Measured memory_bytes: 256
<?php
define('ROAD', '#');
define('WALL', '.');
list($h, $w) = ints();
for ($i = 0; $i < $h; ++$i) list($a[]) = strs();
$c = 0;
for ($i = 0; $i < $h; ++$i) {
    for ($j = 0; $j < $w; ++$j) {
        if ($a[$i][$j] === WALL) continue;
        if ($i < $h - 1 && $a[$i + 1][$j] === ROAD) ++$c;
        if ($j < $w - 1 && $a[$i][$j + 1] === ROAD) ++$c;
    }
}
echo $c === $h - 1 + $w - 1 ? 'Possible' : 'Impossible';
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 16264
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
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;}
constexpr long long INF = 1e18;

void pr(bool f){
	if(f)cout<<"Yay!"<<endl;
	else cout<<":("<<endl;
}

int dp[100010];

signed main(){
	int N;
	cin>>N;
	vector<int>v(6);
	REP(i,6)v[i]=100+i;
	dp[0]=1;
	REP(i,N+1){
		if(dp[i]==0)continue;
		REP(j,6){
			if(i+v[j]>N)continue;
			dp[i+v[j]]=dp[i];
		}
	}
	cout<<dp[N]<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    int A, B, K;
    cin >> A >> B >> K;
    if(B - A + 1 >= 2 * K){
        for(int i = 0; i < K; i++)
            cout << A + i << endl;
        for(int i = K - 1; i >= 0; i--)
            cout << B - i << endl;
    }else{
        for(int i = A; i <= B; i++)
            cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#define fi(p) for(int i=0;i<(p);i++)
using namespace std;
int N;
int L;
int P;
const int MAX_N = 100000;
const int MAX_W = 100000;


int A[MAX_N+1];
int B[MAX_N+1];

void solve() {
	int a;
	int b;
	cin >> a >> b;
	int plus=a+b;
	int minus=a-b;
	int multi=a*b;

	cout << max({ plus,minus,multi }) << endl;
}

int main()
{
	solve();


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int> A(n),B(n),C(n);
  for(int i = 0; n > i; i++){
    cin>>A[i];
    C[i] = i+1;
  }
  for(int i = 0; n > i; i++){
    cin>>B[i];
  }
  int a = 0;
  int b = 0;
  int z = 0;
  do{
    bool aa = true;
    bool bb = true;
    for(int i = 0; n > i; i++){
      if(C[i]!=A[i])aa=false;
      if(C[i]!=B[i])bb=false;
    }
    if(aa)a=z;
    if(bb)b=z;
    z++;
  }while(next_permutation(C.begin(),C.end()));
  cout << abs(a-b) << endl;
}

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

using namespace std;

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

  string s, t;
  cin >> s >> t;

  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  
  cout << (s < t ? "Yes" : "No") << endl;

  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
    int a;
    int b;
    int z;
    int min;
    int max;
    long int sum;
    min = 1000000;
    max = -1000000;
 
    sum = 0;
 
    scanf("%d",&a);
 
    for(b=0; b<a; b++)
    {
        scanf("%d",&z);
         
        if(min > z)
        {
            min = z;
        }
        if(max < z)
        {
            max =z;
        }
        sum = sum + z;
    }
     
    printf("%d %d %ld\n",min,max,sum);
 
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);
typedef pair<int,int> P;
const int INF = 1001001001;


int main() {
  vector<int> a(5);
  rep(i,5) cin >> a[i];
  rep(i,5){
    if(a[i]==0){
      cout << i+1 << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
//#pragma gcc optimize("O3")
//#pragma gcc optimize("unroll-loops")
#ifdef EVAH
    #define _WIN32_WINNT 0x0500
    #include<windows.h>
#endif
#define openFile(n) ShellExecute(nullptr,"open",n,nullptr,nullptr,SW_SHOWNORMAL);
#define closeP(n) system((string("taskkill /im ")+n+" /f").c_str());
#define closeConsole PostMessage(GetConsoleWindow(), WM_CLOSE, 0, 0);
#define opf "output.txt"
#define ipf "input.txt"
#define mem(n,x) memset(n,x,sizeof(n));
#define sf scanf
#define pf printf
#define ff first
#define ss second
#define pb push_back
#define PII pair<int,int>
#define For(x,n) for(int i=x; i<n; i++)
#define stv v+2*(mid-tl+1)
#define LL long long int
#define PI acos(-1.0)
#define N 100000000


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    #ifdef EVAH
        //freopen(ipf,"r",stdin);
        //openFile(ipf);
        //closeConsole;
        //freopen(opf,"w",stdout);
    #endif

    int n,red=0,ans=0;
    string s;
    cin >> n >> s;
    for(int i=0; i<n; i++) {
        if(s[i]=='R') red++;
    }
    for(int i=0; i<red; i++) {
        if(s[i]=='W') ans++;
    }
    cout << ans << "\n";

    #ifdef EVAH
        //openFile(opf);
        //Sleep(3000);
        //closeP("notepad.exe");
        //closeConsole;
    #endif
}


Measured memory_bytes: 3720
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

typedef pair<int,int> pii;
int n,m;
int s,t;
pii ps[101];
// »ê¼êÌÀW©çêÔß¢RrjÖÌ£
int dists[101][101];
const int INF=1000000000;
pii cand[101];
bool used[101][101];
bool noSet[101][101];

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

int updateMinDist(int sx,int sy,bool isSearch=true){
    memset(used,0,sizeof(used));
    queue<pii> q[2];
    int cur=0;
    int nxt=1;
    int cnt=0;
    pii sp=pii(sy,sx);
    used[sp.first][sp.second]=true;
    int res=0;
    q[cur].push(sp);
    while(q[cur].size()){
        while(q[cur].size()){
            pii p=q[cur].front();q[cur].pop();
            if(isSearch)dists[p.first][p.second]=min(dists[p.first][p.second],cnt);
            else if(dists[p.first][p.second]>cnt)res++;
            for(int i=0;i<6;i++){
                int ny=dy[p.first%2][i]+p.first;
                int nx=dx[p.first%2][i]+p.second;
                if(ny>=0&&nx>=0&&ny<n&&nx<m&&!used[ny][nx]){
                    q[nxt].push(pii(ny,nx));
                    used[ny][nx]=true;
                }
            }
        }
        cnt++;
        swap(cur,nxt);
    }
    return res;
}

int main(){
    while(cin>>m>>n&&(m|n)){
        memset(noSet,0,sizeof(noSet));
        cin>>s;
        for(int i=0;i<101;i++)for(int j=0;j<101;j++)dists[i][j]=INF;
        for(int i=0;i<s;i++){
            cin>>ps[i].second>>ps[i].first;
            ps[i].second--;
            ps[i].first--;
            noSet[ps[i].first][ps[i].second]=true;
        }
        for(int k=0;k<s;k++)updateMinDist(ps[k].second,ps[k].first);
        cin>>t;
        for(int i=0;i<t;i++){
            cin>>cand[i].second>>cand[i].first;
            cand[i].second--;
            cand[i].first--;
        }
        int res=0;
        for(int i=0;i<t;i++){
            int cnt=0;
            cnt=updateMinDist(cand[i].second,cand[i].first,false);
            res=max(res,cnt);
        }
        cout<<res<<endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define INF (1LL << 60)
typedef long long LL;
using namespace std;

int main() {
	int n, k;	cin >> n >> k;
	vector<LL> h(n);
	for (auto &x : h) {
		cin >> x;
	}

	vector<LL> dp(n, INF);	//dp[i]:i番目の足場に行くための最短コスト
	dp[0] = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = 1; j <= min(k ,n - 1 - i) ; j++) {
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
		}
	}
	cout << dp[n - 1];
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#pragma GCC optimize(2)
#define ll long long
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,n,a) for(int i=n;i>=a;i--)
#define endl '\n'
#define eps 0.000000001
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define IO ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const int INF=0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int maxn=2e5+5;
int n,m,fa[maxn];
int find(int x){
	while(fa[x]!=x) x=fa[x]=fa[fa[x]];
	return x;
}
int d[maxn];
int main(){
	scanf("%d%d",&n,&m);
	rep(i,1,n) fa[i]=i;
	rep(i,1,m){
		int u,v;scanf("%d%d",&u,&v);
		int eu=find(u),ev=find(v);
		if(eu!=ev) fa[ev]=eu;
	}
	map<int,int> mp;
	int cnt=0;
	rep(i,1,n){
		if(!mp[find(i)]) ++cnt,mp[find(i)]=cnt,d[cnt]++;
		else d[mp[find(i)]]++;
	}
	int ans=0;
	rep(i,1,cnt){
		ans=max(ans,d[i]);
	}
	cout<<ans<<endl;
}

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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))
const int N = 1e5 + 1;
int dp[N];
int arr[N];
int calc(int idx){
    if(idx == 0){
        return 0;
    }
    if(dp[idx] != -1){
        return dp[idx];
    }
    int op1 = 1e9; int op2 = 1e9;
    if(idx >= 1){
        op1 = abs(arr[idx] - arr[idx - 1]) + calc(idx - 1);
    }
    if(idx >= 2){
        op2 = abs(arr[idx] - arr[idx - 2]) + calc(idx - 2);
    }
    return dp[idx] = min(op1, op2);
}
int main(){
    FAST
    int n; cin >> n;
    for(int i = 0; i < n; i++)cin >> arr[i];
    memset(dp, -1, sizeof(dp));
    cout << calc(n - 1) << endl;
    return 0;
}


Measured memory_bytes: 8992
#include"bits/stdc++.h"


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 200010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}


int n,K;

char s[310];

int f[305][305][305];

int main(){
	scanf("%s",s+1);n=strlen(s+1);
	read(K);
	REP(k,0,K)
		RREP(i,n,1){
			f[i][i][k]=1;
			REP(j,i+1,n){
				f[i][j][k]=max(f[i+1][j][k],f[i][j-1][k]);
				if(s[i]==s[j])f[i][j][k]=max(f[i][j][k],f[i+1][j-1][k]+2);
				if(k)f[i][j][k]=max(f[i][j][k],f[i+1][j-1][k-1]+2);
			}
		}
	iout(f[1][n][K]);
	return 0;
}


Measured memory_bytes: 110592
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define ll long long
using namespace std;
int mmin(int &a, int b) {
	a = min(a, b);
	return a;
}
ll mmin1(ll &a,ll b) {
	a = min(a, b);
	return a;
}
int mmax(int &a, int b) {
	a = max(a, b);
	return a;
}
ll mmax1(ll &a,ll b) {
	a = max(a, b);
	return a;
}
ll po(ll  a, int n,ll p) {
	if (n == 0) {
		return 1 % p;
	}
	ll x = po(a, n / 2, p);
	if (n % 2 == 0) {
		return (x*x) % p;
	}
	return (((x*x) % p)*a) % p;
}
ll inve(ll a, ll p) {
	return po(a, p - 2, p);
}

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	cout << b + min(c, a + b+1) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		long[] height = new long[N];
		for(int i = 0; i < N; i++) {
			height[i] = sc.nextLong();
		}
		sc.close();
		int count = 0;
		int max = 0;
		
		for(int i = 0; i < N - 1; i++) {
			if(height[i] >= height[i+1]) {
				count++;
				max = Math.max(max, count);
			}
			else {
				count = 0;
			}
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 62612
number = gets.to_i
string = gets.chomp.split('')

if number%2 == 0
  a = string[0..(number/2)-1]
  b = string[(number/2)..string.length-1]
  if a==b
    puts "Yes"
  else
    puts "No"
  end
else
  puts "No"
end

Measured memory_bytes: 3836
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(n)]

cnt = 0

for i in range(n):
    sum = c
    for j in range(m):
        sum += b[j]*a[i][j]
    if(sum > 0):
        cnt += 1

print(cnt)


Measured memory_bytes: 62152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M = 998244353;

int main() {
    int N;
    cin >> N;
    vector<ll> a(N);
    ll ans = 1LL, sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        sum += a[i];
        ans *= 3LL;
        ans %= M;
    }

    vector<vector<ll>> dp(500, vector<ll>(100000, 0));
    vector<vector<ll>> dp2(500, vector<ll>(100000, 0));
    dp[0][0] = dp2[0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= sum; j++) {
            dp[i + 1][j + a[i]] += dp[i][j];
            dp[i + 1][j + a[i]] %= M;
            dp[i + 1][j] += 2 * dp[i][j];
            dp[i + 1][j] %= M;

            dp2[i + 1][j + a[i]] += dp2[i][j];
            dp2[i + 1][j + a[i]] %= M;
            dp2[i + 1][j] += dp2[i][j];
            dp2[i + 1][j] %= M;
        }
    }

    ll x = 0;
    for (int i = (sum + 2 - 1) / 2; i <= sum; i++) {
        x += dp[N][i];
        x %= M;
    }

    ans -= 3 * x;
    if (sum % 2 == 0) ans += 3 * dp2[N][sum / 2];

    cout << (ans % M + M) % M << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

int lcm(int a, int b)
{return a * b / gcd(a, b);}

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}
string f(ll n){
  if (n==0) return "";
  n--;
  return f(n/26) + string(1, 'a' + n%26);
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  cout << f(n) << endl;
  return 0;
}



Measured memory_bytes: 3652
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo()
	defer io.Flush()

	n, m, k := io.Int(), io.Int(), io.Int()

	u := NewUnionFind(n)

	edges := map[int][]int{}
	for i := 0; i < m; i++ {
		a, b := io.Int()-1, io.Int()-1
		edges[a] = append(edges[a], b)
		edges[b] = append(edges[b], a)
		u.Unite(a, b)
	}

	blockEdges := map[int][]int{}
	for i := 0; i < k; i++ {
		c, d := io.Int()-1, io.Int()-1
		blockEdges[c] = append(blockEdges[c], d)
		blockEdges[d] = append(blockEdges[d], c)
	}

	anss := make([]int, n)

	groups := u.Groups()
	for _, g := range groups {
		for _, idx := range g {
			anss[idx] = len(g) - len(edges[idx]) - 1
			for _, v := range blockEdges[idx] {
				if u.Same(idx, v) {
					anss[idx]--
				}
			}
		}
	}

	io.PrintIntLn(anss)

}

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) Int() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}
func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

type UnionFind struct {
	parents []int
}

func NewUnionFind(n int) *UnionFind {
	parent := make([]int, n)
	for i := 0; i < n; i++ {
		parent[i] = i
	}
	return &UnionFind{
		parents: parent,
	}
}

func (u *UnionFind) Root(x int) int {
	if u.parents[x] == x {
		return x
	}
	u.parents[x] = u.Root(u.parents[x])
	return u.parents[x]
}

func (u *UnionFind) Unite(x, y int) {
	rx := u.Root(x)
	ry := u.Root(y)
	if rx == ry {
		return
	}
	if rx < ry {
		u.parents[rx] = ry
	} else {
		u.parents[ry] = rx
	}
}

func (u *UnionFind) Same(x, y int) bool {
	rx := u.Root(x)
	ry := u.Root(y)
	if rx == ry {
		return true
	}
	return false
}

func (u *UnionFind) Size(x int) int {
	root := u.Root(x)
	size := 0
	for _, p := range u.parents {
		if u.Root(p) == root {
			size++
		}
	}
	return size
}

func (u *UnionFind) Groups() map[int][]int {
	groups := map[int][]int{}

	for i, p := range u.parents {
		groups[u.Root(p)] = append(groups[u.Root(p)], i)
	}
	return groups
}


Measured memory_bytes: 35968
#include<cmath>
#include<cstdlib>
#include<string>
#include<sstream>
#include<vector>
#include<iostream>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<algorithm>
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if(a * b == 15) cout << "*" << endl;
    else if(a + b == 15) cout << "+" << endl;
    else cout << "x" << endl;
}


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

#define F(i, a, b) for (int i = a; i <= b; i ++)
#define G(i, a, b) for (int i = a; i >= b; i --)
#define min(a, b) ((a) < (b) ? (a) : (b))
#define mem(a, b) memset(a, b, sizeof a)
#define mn(a, b) ((a) = min(a, b))

const int inf = 1e9;
const int N = 1e3 + 10;
const int M = 5e3 + 10;

using namespace std;

int n, x, p[N], w[N], f[N], g1[M], g2[M];
int tov[N], nex[N], las[N], tot;

void ins(int x, int y) {
	tov[++ tot] = y, nex[tot] = las[x], las[x] = tot;
}

void Dfs(int k) {
	for (int x = las[k]; x; x = nex[x])
		Dfs(tov[x]);
	g1[0] = 0;
	F(i, 1, w[k]) g1[i] = inf;
	for (x = las[k]; x ; x = nex[x]) {
		F(i, 0, w[k]) g2[i] = inf;
		G(i, w[k] - w[tov[x]], 0)
			mn(g2[i + w[tov[x]]], g1[i] + f[tov[x]]);
		G(i, w[k] - f[tov[x]], 0)
			mn(g2[i + f[tov[x]]], g1[i] + w[tov[x]]);
		F(i, 0, w[k]) g1[i] = g2[i];
	}
	f[k] = inf;
	F(i, 0, w[k])
		mn(f[k], g1[i]);
}

int main() {
	scanf("%d", &n);
	F(i, 2, n) scanf("%d", &p[i]), ins(p[i], i);
	F(i, 1, n) scanf("%d", &w[i]);

	Dfs(1);

	puts(f[1] == inf ? "IMPOSSIBLE" : "POSSIBLE");
}

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

struct Rectangle {
  int height;
  int pos;
};
 

#include <stdio.h>
#define SIZ 1400
int m[SIZ+1][SIZ+1];
int st[SIZ];
char z[9999999];
int get(){
	static int input_count=0;
	int r=0;
	for(;'0'<=z[input_count]&&z[input_count]<='9';)r=r*10+z[input_count++]-'0';
	input_count++;
	return r;
}
int main(){
	fread(z,1,sizeof(z),stdin);
	int i,j,k,y=get(),x=get(),r,ptr;
	for(j=0;j<y;j++)for(r=i=0;i<x;m[j][i]=r,i++){
		int t=get();
		r=t==0?r+1:0;
	}
	r=0;
/*
	for(i=0;i<x;i++)for(ptr=j=0;j<=y;j++){
		//printf("%d %d %d %d\n",i,j,ptr,m[j][i]);
		if(!ptr || st[ptr-1]<m[j][i])st[ptr++]=m[j][i];
		else{
			for(;ptr && st[ptr-1]>m[j][i];){
				int _y=(j-(ptr-1)),_x=st[--ptr];
				//printf("%d %d\n",_x,_y);
				if(r<_x*_y)r=_x*_y;
			}
			st[ptr++]=m[j][i];
		}
	}
*/
	Rectangle rect;
	for(int i=0;i<x;i++){
		stack<Rectangle> stk;
		//rect.height = 0;
		//rect.pos = 0;
		//stk.push(rect);
		int pop=0;
		for(int j=0;j<=y;j++){
			rect.height = m[j][i];
			rect.pos = j;
			if(stk.empty() || stk.top().height < rect.height){
				stk.push(rect);
			}else{
				//printf("[-] %d %d\n",i,j);
				for(;!stk.empty() && stk.top().height >= rect.height;){
					pop++;
					Rectangle pre = stk.top(); stk.pop();
					//pre.pos=stk
					int area = pre.height * (j - pre.pos);
					r = max(r, area);
					//printf("%d %d\n",target,pre.pos);
					rect.pos = pre.pos;
				}
				stk.push(rect);
			}
			if(rect.height==0)pop=0;
		}
	}

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

Measured memory_bytes: 14312