akhauriyash/Code-Regression huggingface dataset:
class fibNum():
    def __init__(self):
        self.arr = [1, 1]
    def fib(self, n):
        return_num = 1
        if n > 1:
            if len(self.arr) <= n:
                self.arr.append( self.fib(n-1) + self.fib(n-2) )
            return_num = self.arr[n]
        return return_num

def main():
    n = int( input() )
    fn = fibNum()
    print( fn.fib(n) )

if __name__ == '__main__':
    main()



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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { cout << p.first << ' ' << p.second; return os; }

void solve() {
  int N; cin >> N;
  vector<vi32> dist(N, vi32(N));
  rep(i, N) cin >> dist[i];

  {
    auto d = dist;
    rep(k, N) rep(i, N) rep(j, N) amin(d[i][j], d[i][k] + d[k][j]);
    if (d != dist) {
      cout << -1 << '\n';
      return;
    }
  }
  i64 ans = 0;
  {
    rep(i, N) rep(j, N) ans += dist[i][j];
  }

  rep(i, N) rep(j, N) {
    bool f = true;
    rep(k, N) {
      if (i == j || j == k || k == i) continue;
      if (dist[i][j] == dist[i][k] + dist[k][j]) f = false;
    }
    if (!f) ans -= dist[i][j];
  }

  cout << ans / 2 << '\n';
}


Measured memory_bytes: 1024
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,t = inpl()
wv = [inpl() for _ in range(n)]
wv.sort(key = lambda x:x[1],reverse = True)
res = 0
tmp = min(n,4)
for i in range(tmp):
    dp = [[0] * (t+5) for _ in range(n+5)]
    for j in range(n):
        w,v = wv[j]
        for k in range(t):
            if k < w or i == j:
                dp[j+1][k] = dp[j][k]
            else:
                dp[j+1][k] = max(dp[j][k], dp[j][k-w] + v)
    # print(dp[n][t-1])
    res = max(dp[n][t-1] + wv[i][1], res)
print(res)

Measured memory_bytes: 330348
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  vector<int>p(N);
  for(int i=0;i<N;i++)cin>>p[i];
 
  long s=0;
  for(int i=0;i<K;i++)s+=p[i];
  double P=s;
  for(int i=1;i<=N-K;i++){
   
    s=s+p[i+K-1]-p[i-1];
    if(P<=s)P=s;
    
  }
  P+=K;
  cout << fixed << setprecision(10);
  P/=2;
  cout<<P<<endl;
}




Measured memory_bytes: 1024
def main():
    N = int(input())
    a = [int(input()) for _ in range(N)]
    cnt = 0
    tmp = 1
    while cnt<=100001:
        tmp = a[tmp-1]
        cnt += 1
        if tmp == 2:
            return cnt
        elif tmp == 1:
            return -1

    return -1

print(main())


Measured memory_bytes: 13016
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
typedef     unsigned long long  ull;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define	       MEM(a,b)         memset(a,(b),sizeof(a))
#define	       CLR(p)           memset(p,0,sizeof(p))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
#define	       ff               first
#define	       sc              second
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll> >      vpll;
typedef		vector<ll>      vll;
typedef		map<string,ll>      msl;
typedef		map<ll,ll>      mll;
#define yes cout << "YES\n"
#define no cout<<"NO\n"
//memset(ar,-1,sizeof(ar));
//#define sort(x) sort(x.begin(), x.end())
//sort(a,a+n,greater<ll>())
//for (auto it = mp.begin(); it != mp.end(); ++it){}
// string x(w.size(),'1');
#define MAX 1000005
#define precision(a) fixed << setprecision(a)

#define mod 1000000007



int main()
{
 //O_O ;
        string s,t;cin>>s>>t;
   ll l=s.size(),l2=t.length();
   ll ans=INT_MAX;
   for(ll i=0;i<l;i++)
   {
       ll cnt=0;
       ll k=i;
       for(ll j=0;j<l2&&(i+l2-1<l);j++,k++)
       {

           if(s[k]==t[j]){
               cnt++;
           continue;
           }
       }
       ans=min(ans,l2-cnt);
   }

    cout<<ans<<nn;


    return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    // if (abs(a-b)<EPS) return 0;
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
  L() {}
};
typedef vector<P> G;
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}


P crosspoint(const L &l, const L &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0] + B / A * (m[1] - m[0]);
}

G convex_cut(const G& g, const L& l) {
  G Q;
  REP(i, g.size()) {
    P A = curr(g, i), B = next(g, i);
    if (ccw(l[0], l[1], A) != -1) Q.push_back(A);
    if (ccw(l[0], l[1], A)*ccw(l[0], l[1], B) < 0)
      Q.push_back(crosspoint(L(A, B), l));
  }
  return Q;
}

int main() {
  int n;
  while(cin>>n,n) {
    G g(n);
    REP(i,n) cin >> g[i].real() >> g[i].imag();
    G res(g);
    REP(i,n) {
      res = convex_cut(res, L(curr(g,i),next(g,i)));
    }
    cout << (res.size()!=0) << endl;
  }
}

Measured memory_bytes: 1260
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int R,G,B,N; cin >> R >> G >> B >> N;

    for(int r = 0; r*R <= N; r++){
        for(int g = 0; r*R + g*G <= N; g++){
            if((N-r*R-g*G)%B == 0){
                res++;
            }
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    //solve<ll>(0);
    cout << fixed << setprecision(12) << solve<ll>() << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <algorithm>
#include <iostream>
#include <vector>

int main()
{
    int h, w;
    std::cin >> h >> w;

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

    std::vector<std::string> t;
    for (int i = 0; i < h; i++) {
        if (std::count(s[i].begin(), s[i].end(), '#')) {
            t.push_back(s[i]);
        }
    }

    std::vector<std::string> u(t.size());
    for (int i = 0; i < w; i++) {
        std::string str;
        for (int j = 0; j < t.size(); j++) {
            str.push_back(t[j][i]);
        }

        if (std::count(str.begin(), str.end(), '#')) {
            for (int j = 0; j < t.size(); j++) {
                u[j].push_back(t[j][i]);
            }
        }
    }

    for (auto str : u) {
        std::cout << str << std::endl;
    }
}


Measured memory_bytes: 256
import java.util.*;

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int list[] = {A + B, A - B, A * B};
        int max = list[0];

        for(int i=1; i<3; i++){
            max = Math.max(max, list[i]);
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 22740
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n, k = map(int, input().split())
    v = list(map(int, input().split()))

    max = 0

    for i in range(k):
        if i <= n:
            for j in range(i + 1):
                candidate = v[0:j + 1]
                candidate.extend(v[n - i + j:n])
                candidate.sort()
                for d in range(k - i):
                    tmp = sum(candidate[d:n])
                    if tmp > max:
                        max = tmp
        else:
            candidate = v
            candidate.sort()
            for d in range(k - i):
                tmp = sum(candidate[d:n])
                if tmp > max:
                    max = tmp
    print(max)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n;
    cin >> n;
    vector<ll> a(n+1), b(n);
    REP(i, n+1) cin >> a[i];
    REP(i, n) cin >> b[i];

    ll ret = 0;
    for(ll i=n-1; i>=0; --i) {
        ll tmp = min(a[i+1], b[i]);
        ret += tmp;
        a[i+1] -= tmp;
        b[i] -= tmp;
        tmp = min(a[i], b[i]);
        ret += tmp;
        a[i] -= tmp;
        b[i] -= tmp;
    }
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 1792
<?php
    $num = trim(fgets(STDIN));
    $a = strlen($num);
    $num = str_split($num);
    // var_dump($num,$a);

    for($i=0; $i<=$a-1; $i++){
        if($i %2 == 0){
            echo $num[$i];
        }else{
            continue;
        }
    }
    

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

int main(){
    int n;
    cin >> n;
    vector<int> a1(n),a2(n);
    for(int i=0; i<n; i++){
        cin >> a1.at(i);
    }
    for(int i=0; i<n; i++){
        cin >> a2.at(i);
    }

    int candies,ans=0;

    for(int i=0; i<n; i++){
        candies=0;
        for(int j=0; j<=i; j++){
            candies+=a1.at(j);
        }
        for(int j=i; j<n; j++){
            candies+=a2.at(j);
        }
        ans=max(ans,candies);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3604
S = list(input())
A = int("".join([S[0],S[1]]))
B = int("".join([S[2],S[3]]))


if 1 <= A <= 12:
    if 1 <= B <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= B <= 12:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
int a,n,f[100001],s;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		if(a>n)s++;
		else f[a]++;
	}
	for(int i=1;i<=100000;i++)
	{
		if(!f[i])continue;
		else
		{
			s+=f[i];
			if(f[i]>=i)s-=i;
		}
	}
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/arc084/tasks/arc084_a
# 真ん中固定すれば良い
# そうすれば自分より小さい(大きい)範囲は二分探索で求まる。

N = read_a_int()
A = read_ints()
B = read_ints()
C = read_ints()

A.sort()
B.sort()
C.sort()

ans = 0
for b in B:
    i = bisect_left(A, b)  # [0,i)のi個がbより小さい
    k = bisect_right(C, b)
    ans += i * (N - k)
print(ans)


Measured memory_bytes: 92644
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
   int n; cin >> n;
   ll res = 1;
   rep(i, n){
       res = (res * (i+1))% MOD;
   }
   cout << res << ln;
}


Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#define INF 1000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef pair<ll, double> PD;
ll mod = 1000000007;
bool dp[100010];

int main() {
	int n;
	cin >> n;
	dp[0] = true;
	for (int i = 0; i <= n; i++) {
		for (int j = 100; j <= 105; j++) {
			if (i >= j && dp[i - j]) dp[i] = true;
		}
	}
	cout << (dp[n] ? 1 : 0) << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <stack>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <vector>
#include <cmath>
#define ll long long
using namespace std;
int gcd(int a,int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

int main() {
    int n,k,res;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++){
        int m,num;
        scanf("%d",&m);
        num=abs(m-k);
        if(i==0)
            res=num;
        else
            res=gcd(num,res);
    }
    printf("%d",res);
}


Measured memory_bytes: 256
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
pragma(inline, true) T[] Reads(T)() { return readln.split.to!(T[]); }
alias reads = Reads!int;
pragma(inline, true) void scan(Args...)(ref Args args) {
    string[] ss = readln.split;
    foreach (i, ref arg ; args) arg = ss[i].parse!int;
}

void main() {
    int n; scan(n);
    int[] h = reads();

    bool can() {
        // dp[i][j] := i まで見たときの h の最大値
        // -1 は不可
        auto dp = new int[][](100010,2);
        foreach(i;0..100010) foreach(j;0..2) dp[i][j]=-1;

        dp[0][0] = dp[0][1] = 0;
        foreach (i; 1..n+1) {
            if (dp[i-1][0] >= 0) {
                dp[i][0] = max(dp[i-1][0], h[i-1]);
                dp[i][1] = max(dp[i-1][0], h[i-1] - 1);
            }
            if (dp[i-1][1] >= 0) {
                dp[i][0] = max(dp[i-1][1], h[i-1]);
                dp[i][1] = max(dp[i-1][1], h[i-1] - 1);
            }
            if (dp[i][0] > h[i-1])
                dp[i][0] = -1;
            if (dp[i][1] > h[i-1] - 1)
                dp[i][1] = -1;
        }
        return ~dp[n][0] || ~dp[n][1];
    }

    writeln(can() ? "Yes" : "No");
}

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	stack<string> stk;
	string cur;
	for (const char &ch : s) {
		if(cur.empty()) cur+=ch;
		else {
			if(!stk.empty()&&cur==stk.top()) cur+=ch;
		}
		if(!cur.empty()&&(stk.empty()||(!stk.empty()&&cur!=stk.top()))) {
			stk.push(cur);
			cur.clear();
		}
	}
	cout<<stk.size()<<"\n";
	return 0;
}

Measured memory_bytes: 11028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

void solve() 
{
    ll n;cin>>n;
    ll p[n];
    REP(i,n)cin>>p[i];
    ll ans=1,now=p[0];
    rep(i,1,n){
        if(p[i]<=now){
            ans++;
            now=p[i];
        }
    }cout<<ans<<endl;


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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for (int i = (a); i >= (b); i--)
#define REP(i,a) FOR(i,0,(int)(a)-1)
#define reset(a,b) memset(a,b,sizeof(a))
#define BUG(x) cout << #x << " = " << x << endl
#define PR(x,a,b) {cout << #x << " = "; FOR (_,a,b) cout << x[_] << ' '; cout << endl;}
#define CON(x) {cout << #x << " = "; for(auto i:x) cout << i << ' '; cout << endl;}
#define mod 1000000007
#define pi acos(-1)
#define eps 0.00000001
#define pb push_back
#define sqr(x) (x) * (x)
#define _1 first
#define _2 second

int n;

int main() {
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  if (a == 1) a += 100;
  if (b == 1) b += 100;
  if (a < b) cout << "Bob";
  else if (a == b) cout << "Draw";
  else cout << "Alice";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define LL long long
#define st first
#define nd second
#define endl '\n'
using namespace std;

const int MAXN=100005;
int n,a,b,dep[MAXN],mx,r2,sub[MAXN];
bool ok=1;
vector<int> v[MAXN];

int check(int x,int y,int z) {

	int add;
	sub[x]=1;
	dep[x]=dep[y]+1;
	//cout<<x<<" "<<dep[x]<<" "<<mx<<" "<<dep[mx]<<" "<<y<<" "<<dep[y]<<endl;
	if(z&&dep[x]>dep[mx])
		mx=x;
	int cnt=0;
	for(int i=0;i<v[x].size();++i) {
		if(v[x][i]==y)
			continue;
		add=check(v[x][i],x,z);
		if(add>1) ++cnt;
		sub[x]+=add;
	}
	if(cnt>1) ok=0;
	return sub[x];

}

void solve(int x,int y,int cr,vector<int> &vx) {

	int cur=cr;
	bool ok=0;
	for(int i=0;i<v[x].size();++i) {
		if(v[x][i]==y) continue;
		if(sub[v[x][i]]==1)
			vx.pb(++cur);
		else ok=1;
	}
	if(!ok&&v[x].size()>1) {
		vx.pop_back();
		vx.pb(cr);
		vx.pb(cur);
		return;
	}
	vx.pb(cr);
	for(int i=0;i<v[x].size();++i){
		if(v[x][i]!=y&&sub[v[x][i]]>1)
			solve(v[x][i],x,cur+1,vx);
	}

}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	for(int i=0;i<n-1;++i) {
		cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	check(1,0,1);
	r2=mx;
	ok=1;
	mx=0;
	check(r2,0,1);
	if(!ok) {
		cout<<-1<<endl;
		return 0;
	}
	//cout<<r2<<" "<<mx<<endl;
	vector<int> v1,v2;
	check(r2,0,0);
	solve(r2,0,1,v1);
	check(mx,0,0);
	solve(mx,0,1,v2);
	v1=min(v1,v2);
	for(int i=0;i<n;++i) {
		cout<<v1[i]<<" ";
	}
	cout<<endl;

}

Measured memory_bytes: 18936
n = int(input())
a = [int(i) for i in input().split()]
num = int(sum(a) / len(a))
check = [num -3, num - 2, num -1, num, num + 1, num + 2, num +3]
ans = float('inf')
for i in check:
    cnt = 0
    for j in a:
        cnt += (i - j) ** 2

    ans = min(ans, cnt)
print(ans)

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  int ans = inf;
  reps(i, 1, n) {
    string a = to_string(i);
    string b = to_string(n-i);
    int sum = 0;
    rep(j, a.size()) sum += a[j]-'0';
    rep(j, b.size()) sum += b[j]-'0';
    chmin(ans, sum);
  }
  cout << ans << endl;

  return 0;
}


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define SPACEREP(lst,itr) for(auto itr=lst.begin(); itr!=lst.end();++itr){cout<<*itr<<(++itr!=lst.end()?" ":"\n");itr--;}
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

int main(){
    while(1){
        int n,k,m;
        cin >> n >> k >> m;

        if(n==0 && k==0 && m==0) break;
        vector<int> seq;
        REP(i,0,n) seq.push_back(i+1);

        int now=m-1;
        while(seq.size()>1){
            seq.erase(seq.begin()+now);
            now+=k-1;
            now=now%seq.size();
        }
        cout << seq.front() << endl;
    }
}


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

int main(){
  int n;
  cin >> n;
  int d[n];
  rep(i,n) cin >> d[i];
  int ans = 0;
  rep(i,n) {
    for(int j = i+1; j < n; j++) {
      ans += d[i]*d[j];
    }
  } 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LOCAL
#pragma region Macros
typedef long long ll;
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

const int MAX=1e5+10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<ll> cnt(MAX,0);
    for (int i=1;i<=100;++i){
        for (int j=1;j<=100;++j){
            for (int k=1;k<=100;++k){
                int n=i*i+j*j+k*k+i*j+j*k+k*i;
                ++cnt[n];
            }
        }
    }
    for (int i=1;i<=N;++i) cout << cnt[i] << '\n';
}

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second

ll gcd(ll a,ll b){//最大公約数を求める
    if(a<b){
        swap(a,b);
    }

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

int main(){
    int n;
    ll x,ans;
    cin >> n >> x;
    vector<ll> v(n+1),u(n);
    for(int i=0;i < n;i++)
    {
        cin >> v.at(i);
    }
    v.at(n)=x;
    sort(v.begin(),v.end());

    for(int i=0;i < n;i++)
    {
        u.at(i)=v.at(i+1)-v.at(i);
        
        if(i!=0){
            ans = gcd(u.at(i),ans);
        }else{
            ans=u.at(0);
        }
    }

    cout << ans << endl;
}
//都市間距離のgcd



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    if (!(n&1)) n--;
    cout << n/2 << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  ll mae;
  cin>>mae;
  ll ans=0;
  for(int i=0;i<n-1;i++){
    ll a;cin>>a;
    ans+=(a>mae);
    mae=a;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3136
#include<iostream>
#include<string>

int main(){
    std::string S;
    std::cin >> S;
    int num = 0;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == '+') num++;
        else num--;
    }
    std::cout << num << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

//power_mod
inline int Pow_mod(int x, int pow){
    if(pow==0) return 1;
    int a=Pow_mod(x, pow/2);
    a=a*a%mod;
    if(pow%2==1) a*=x;
    return a%mod;
}

signed main(void){
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);

    string l; cin>>l;
    reverse(all(l));
    int pl=0;
    while(1){
        if(pl>=l.size()){
            l+='1'; break;
        }
        if(l[pl]=='0'){
            l[pl]='1'; break;
        }else{
            l[pl]='0';
        }
        pl++;
    }

    int cnt=0;
    rep(i,l.size()){
        if(l[i]=='1')cnt++;
    }

    int ans=0,num=1;
    rep(i,l.size()){
        if(l[i]=='1'){
            ans=(ans+num*Pow_mod(2,--cnt)%mod)%mod;
        }
        num=num*3%mod;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 512
//
//  respect the past, embrace the future
//

#include  <algorithm>
#include  <iostream>
#include  <climits>
#include  <cstdlib>
#include  <cstring>
#include  <cmath>
#include  <cstdio>
#include  <unordered_map>
#include  <map>
#include  <set>
#include  <stack>
#include  <string>
#include  <vector>
#include  <queue>

using namespace :: std;

using vpll = vector <pair <long long, long long> >;
using pll = pair <long long, long long>;
using vll = vector <long long>;
using ll = long long;

#define W (long long) (5e3 + 7)
#define N (long long) (2e6 + 7)
#define M (long long) (1e9 + 7)
#define INF (long long) (2e18)
#define F first
#define S second

inline void fastInputOutput () {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
}

inline void ReadWriteFromFile () {
  freopen("../in.txt", "r", stdin);
  freopen("../out.txt", "w", stdout);
}

int n, m, a[W][W], s[]{0, 1, 1, 0};
vector <pair <pll, pll> > v;

int32_t main (int argc, char *argv[]) {
  fastInputOutput();
  // ReadWriteFromFile();
  
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      cin >> a[i][j];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      if (a[i][j] & 1)
        for (int k = 0; k < 2; k++)
          if (i + s[k * 2] >= 1 && i + s[k * 2] <= n && j + s[k * 2 + 1] >= 1 && j + s[k * 2 + 1] <= m) {
            v.push_back({{i, j}, {i + s[k * 2], j + s[k * 2 + 1]}});
            a[i + s[k * 2]][j + s[k * 2 + 1]]++;
            a[i][j]--;
            break;
          }
    }
  cout << v.size() << '\n';
  for (auto i : v)
    cout << i.F.F << ' ' << i.F.S << ' ' << i.S.F << ' ' << i.S.S << '\n';
}

Measured memory_bytes: 15088
x, y = map(int, input().split())
ans = 0
if x*y > 0:
  if x > y:
    ans = abs(x-y)+2
  else:
    ans = abs(x-y)
elif x*y < 0:
  ans = abs(abs(x)-abs(y))+1
else:
  if x == 0:
    if y < 0:
      ans = abs(x-y)+1
    else:
      ans = abs(x-y)
  else:
    if x < 0:
      ans = abs(x-y)
    else:
      ans = abs(x-y)+1
print(ans)

Measured memory_bytes: 61700
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long K = sc.nextLong();
		long ans = K;
		for (int i = 1; i < N; i++) {
			ans *= K-1;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;


//素因数分解し、mapに<素数、個数>で格納
map<ll,ll> primes(ll n){
    map<ll, ll> r;
    for(int i=2; i*i<=n; i++){ 
        while(n % i ==0){
            r[i]++;
            n /= i;
        }
    }

    if(n != 1) r[n] = 1;
    return r;
}

int main(){FIN

    ll n; cin>>n;
    ll ans=0;
    vll a(n); REP(i,n) {
        cin>>a[i];
        while(a[i]%2==0){
            a[i] /= 2;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

#define fi first
#define se second
#define show(x) cerr << #x << "=" << "\n"
typedef long long ll;
typedef unsigned long long ull;

using namespace std;
const ll llinf = LLONG_MAX;
const ull ullinf = ULLONG_MAX;

int n;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1 = freopen("in.txt", "r", stdin);
  //stream2 = freopen("out.txt", "w", stdout);
  if (stream1 == NULL) return 0;
  //if (stream2 == NULL) return 0;
#endif
  cin >> n;
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < 15; j++) {
      if (n == 4 * i + 7 * j) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct{
	char t[2];
	char d[2];
} magic;

//check life
int life(int N,int Q,char ss[],magic x[],int point){
	int i;
	for(i=0;i<Q;i++){
		if(ss[point]!=x[i].t[0]){
			continue;
		}
		if(x[i].d[0]=='L'){
			point--;
			if(point<0){
				return 0;
			}
		}else{
			point++;
			if(point==N){
				return N;
			}
		}
	}
	return -1;
}

int main(){
	int N,Q,i,alive,dead,mid,right,left;
	scanf("%d",&N);
	scanf("%d",&Q);
	char ss[200001];
	scanf("%s",ss);

	magic x[200001];

	for(i=0;i<Q;i++){
		scanf("%s",x[i].t);
		scanf("%s",x[i].d);
	}

	dead=0;
	alive=N;
	while(abs(alive-dead)>1){
		mid=(alive+dead)/2;
		if(life(N,Q,ss,x,mid)==0){
			dead=mid;
		}else{
			alive=mid;
		}
	}
	left=dead;

	dead=N;
	alive=0;
	while(abs(alive-dead)>1){
		mid=(alive+dead)/2;
		if(life(N,Q,ss,x,mid)==N){
			dead=mid;
		}else{
			alive=mid;
		}
	}
	right=dead;

	printf("%d\n",right-left-1);
	return 0;
}

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


using namespace std;


#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()


ll sum(int n);

bool is_even(string s, int n) {
	string f1=s.substr(0,n/2);
	string f2=s.substr(n/2,n);
	return f1==f2;
}
void go(){
	string s;cin>>s;
	s.pop_back();
	int n=sz(s);
	
	while(!is_even(s, n)) {
		s.pop_back();
		n=sz(s);
	}
	cout << sz(s);
}
int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}

ll sum(int n){                
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}


Measured memory_bytes: 384
#include<stdio.h>
#include <iostream>
using namespace std;

int main() {
	long long N, K;
	static long long A[200001];

	cin >> N >> K;

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

	for (int i = K; i < N; i++) {
		if (A[i] > A[i - K])
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}


	return 0;
}

Measured memory_bytes: 4660
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 1000005
const int mod=1e9+7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
#define mp make_pair
#define ff first
#define ss second
 
int n,d,h;
int f[maxn];
 
inline int read(){
    int x=0,f=1; char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x*f;
}
 
int power(int a,int k){
	int ret=1;
	for (;k;k>>=1,a=1ll*a*a%mod) if (k&1) ret=1ll*ret*a%mod;
	return ret;
}
 
int main(){
	n=read(),h=read(),d=read(); int fac=1,val=0;
	for (int i=1;i<=n;i++) fac=1ll*fac*i%mod,val=(val+fac)%mod;
	f[0]=1; int sum=f[0];
	for (int i=1,j=0;i<=h;i++){
		f[i]=1ll*sum*val%mod;
		sum=(sum+f[i])%mod; if (i-j==d) sum=(sum-f[j])%mod,++j;
	}
	int ans=1ll*f[h]*fac%mod*power(val,mod-2)%mod;
	ans=(ans+mod)%mod;
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4096
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int a,b;
  cin>>a>>b;
  
  if(a<=8 && b<=8) cout<<"Yay!"<<endl;
  else cout<<":("<<endl;  
  
  return 0; 
}

Measured memory_bytes: 3584
'''
dp[i] = number of way to go from cell 0 to cell i
dp[0] = 1
for i in range(1, N):
    dp[i] = sum(dp[i - d] for d in seg for seg in segs)
Store dp in BIT
'''

mod = 998244353


class BIT:
    '''
    All methods use 0-based index while the internal use 1-based index
    '''

    def __init__(self, N, val=0):
        self.data = [val] * (N + 1)
        self.N = N

    def add_at(self, idx, val):
        i = idx + 1
        while i <= self.N:
            self.data[i] += val
            self.data[i] %= mod
            i += i & (-i)

    def sum_to(self, idx):
        res = 0
        i = idx + 1
        while i > 0:
            res += self.data[i]
            res %= mod
            i -= i & (-i)
        return res

    def range_sum(self, l, r):  # [l, r]
        return ((self.sum_to(r) - self.sum_to(l - 1)) + mod) % mod

    def __str__(self):
        data = [self.range_sum(i, i) for i in range(self.N)]
        return '[ ' + ' '.join(map(str, data)) + ' ]'


N, K = map(int, input().split())
segs = [list(map(int, input().split())) for _ in range(K)]

bit = BIT(N, 0)
bit.add_at(0, 1)
for i in range(N):
    for (l, r) in segs:
        lb = max(i - r, 0)
        ub = i - l
        if ub >= 0:
            val = bit.range_sum(lb, ub)
            bit.add_at(i, val)
print(bit.range_sum(N - 1, N - 1))



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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int K, X; cin >> K >> X;

	vector<int>ans;
	for (int i = max(X - K + 1, -1000000ll); i < min(X + K, 1000000ll + 1); i++) {
		ans.eb(i);
	}

	rep(i, 0, ans.size()) {
		cout << ans[i] << (i == ans.size() - 1 ? '\n' : ' ');
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
using namespace std;

int n, m, k;
vector<vector <int>> p;
bool f[500];

void party(int i, int j) {
	if (!f[j]) {
		f[j] = 1;
		k++;
	}

	if (i < 2 && p[j].size() > 0) {
		for (int u = 0; u < p[j].size(); u++)
			party(i + 1, p[j][u]);
	}
}

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

	while (n > 0 || m > 0) {
		p.clear();
		p.resize(n);

		for (int i = 0; i < m; i++) {
			int a, b;
			cin >> a >> b;
			p[a - 1].push_back(b - 1);
			p[b - 1].push_back(a - 1);
		}

		k = 0;
		memset(f, 0, sizeof(f));
		f[0] = 1;
		party(0, 0);
		cout << k << endl;

		cin >> n >> m;
	}

	return 0;
}



Measured memory_bytes: 3264
m, f, r = map(int, input().split())
while m != -1 or f != -1 or r != -1:
	if m == -1 or f == -1:
		print("F")
	elif m + f >= 80:
		print("A")
	elif m + f >= 65:
		print("B")
	elif m + f >= 50:
		print("C")
	elif m + f >= 30:
		if r >= 50:
			print("C")
		else:
			print("D")
	else:
		print("F")
	m, f, r = map(int, input().split())

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 10

int N, M;
vector<int> graph[MAX_N];
int comp = 0;

// 今 i 番目の頂点にいて、 visited の頂点に訪れているときの
// パターン数
int dfs(int i = 0, int visited = 0) {
    visited |= (1 << i);
    if((visited & comp) == comp) { return 1; }
    int res = 0;
    for(auto& v : graph[i]) {
        if(((visited >> v) & 1) == 0) { res += dfs(v, visited); }
    }
    return res;
}

signed main()
{
    cin >> N >> M;
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    comp = ((1 << N) - 1);
    printf("%lld\n", dfs());
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] a = new int[n];
		int max = -1;
		for(int i = 0 ; i < n ; i++) {
			a[i] = sc.nextInt();
			max = Math.max(max, a[i]);
		}
		int gcd = max;
		for(int i = 0 ; i < n ; i++) {
			gcd = gcd(gcd, a[i]);
		}
		while(max > 0) {
			if(max == k) {
				System.out.println("POSSIBLE");
				return;
			}
			max -= gcd;
		}
		System.out.println("IMPOSSIBLE");
	}

	static int gcd(int x, int y) {
		if(x < y) {
			x ^= y;
			y ^= x;
			x ^= y;
		}
		if(x % y == 0) return y;
		else return gcd(y, x % y);
	}

}


Measured memory_bytes: 48976
try:
    while True:
        s = input().split()
        a = []
        now = 0
        for i in range(0, len(s)) : a.append(0)
        for i in range(0, len(s)) :
            if not (s[i] in ['+', '-', '*', '/']) : 
                a[now] = int(s[i])
                now += 1
            else :
                a[now - 2] = eval(str(a[now - 2]) + s[i] + str(a[now - 1]))
                now -= 1
        print(a[0])
except EOFError:
    pass



Measured memory_bytes: 5620