akhauriyash/Code-Regression huggingface dataset:
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n, n != -1) {
    int cost = 1150;
    n        = max(0LL, n - 10);
    cost += min(10LL, n) * 125;
    n = max(0LL, n - 10);
    cost += min(10LL, n) * 140;
    n = max(0LL, n - 10);
    cost += n * 160;
    cout << 4280 - cost << endl;
  }
}

Measured memory_bytes: 3068
def main():
    from itertools import accumulate as ac
    n,k=map(int,input().split())
    kk=2*k
    xyc=[input().split() for _ in [0]*n]
    b=[[0]*(k+1) for _ in [0]*(kk+1)]
    for x,y,c in xyc:
        if c=="B":
            if int(y)%kk<k:
                b[int(x)%kk+1][int(y)%k+1]+=1
            else:
                b[(int(x)+k)%kk+1][int(y)%k+1]+=1
        else:
            if int(y)%kk<k:
                b[(int(x)+k)%kk+1][int(y)%k+1]+=1
            else:
                b[int(x)%kk+1][int(y)%k+1]+=1
    b=[list(ac(i)) for i in b]
    for i in range(1,kk+1):
        for j in range(k+1):
            b[i][j]+=b[i-1][j]
    ans=0
    for i in range(kk):
        if i==0:
            a_t=((i,i+k,0),(i+k,kk,1))
        elif i<k:
            a_t=((0,i,-1),(i,i+k,0),(i+k,kk,1))
        elif i==k:
            a_t=((0,i,-1),(i,kk,0))
        else:
            a_t=((0,i-k,-2),(i-k,i,-1),(i,kk,0))
        for j in range(k):
            if j==0:
                b_t=((0,k,0),)
            else:
                b_t=((0,j,-1),(j,k,0))
            black=[]
            for i,j,l in a_t:
                for x,y,z in b_t:
                    if (l+z)%2==0:
                        black.append((i,x,j,y))
            ret=0
            for tx1,ty1,tx2,ty2 in black:
                ret+=b[tx1][ty1]+b[tx2][ty2]-b[tx1][ty2]-b[tx2][ty1]
            ans=max(ans,ret)
    print(ans)
main()


Measured memory_bytes: 115800
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=200005,inf=0x7f7f7f7f;
int n,u,v,cnt,head[N],fa[N],siz[N],f[N][5],to[N*2],nxt[N*2];
bool flag;
char s[N];
long long ans;
void adde(int u,int v){
	to[++cnt]=v;
	nxt[cnt]=head[u];
	head[u]=cnt;
}
void dfs1(int u){
	siz[u]=s[u]-'0';
	if(siz[u]){
		flag=true;
	}
	if(!head[u]){
		f[u][0]=f[u][1]=0;
		f[u][3]=s[u]=='1'?0:inf;
	}
	int v;
	f[u][0]=f[u][1]=0;
	f[u][3]=inf;
	for(int i=head[u];i;i=nxt[i]){
		v=to[i];
		if(v!=fa[u]){
			fa[v]=u;
			dfs1(v);
			siz[u]+=siz[v];
			if(f[v][0]+1>f[u][0]){
				f[u][1]=f[u][0];
				f[u][0]=f[v][0]+1;
			}else if(f[v][0]+1>=f[u][1]){
				f[u][1]=f[v][0]+1;
			}
			if(f[v][3]<inf){
				f[u][3]=min(f[u][3],f[v][0]+1);
			}
		}
	}
	if(s[u]=='1'){
		f[u][3]=min(f[u][3],f[u][0]);
	}
}
void dfs2(int u){
	if(fa[u]){
		f[u][4]=max(f[u][4],f[u][2]-1);
	}
	int v;
	for(int i=head[u];i;i=nxt[i]){
		v=to[i];
		if(v!=fa[u]){
			if(f[v][0]+1==f[u][0]){
				f[v][2]=max(f[u][2],f[u][1])+1;
			}else{
				f[v][2]=max(f[u][2],f[u][0])+1;
			}
			dfs2(v);
		}
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		scanf("%d%d",&u,&v);
		adde(u,v);
		adde(v,u);
	}
	scanf("%s",s+1);
	dfs1(1);
	dfs2(1);
	if(!flag){
		puts("0");
		return 0;
	}
	for(int i=1;i<=n;i++){
		int up=min(max(f[i][0],f[i][2])-1,f[i][0]+1),down=s[i]=='1'?0:min(f[i][3],siz[i]==siz[1]?inf:f[i][2]);
		for(int j=head[i];j;j=nxt[j]){
			if(to[j]!=fa[i]){
				up=min(up,f[to[j]][4]+1);
			}
		}
		if(up>=down){
			ans+=up-down+1;
		}
	}
	printf("%lld\n",ans+1);
	return 0;
}

Measured memory_bytes: 16896
#include <cstdio>


int main(){
int i,n;
int c[100];

scanf("%d",&n);
for(i=0;i<n;i++) scanf("%d",&c[i]);
for(i=n;i>0;i--){
if(i!=n)printf(" ");
printf("%d",c[i-1]);
}
puts("");
return 0;
}

Measured memory_bytes: 1044
def is_prime(n):
  i = 2
  while i * i <= n:
    if n % i == 0:
      return False
    i += 1
  return True

N = int(input())

primes = []

for i in range(2,55556):
  if is_prime(i) == True:
    if i % 5 == 1:
      primes.append(i)
  if len(primes) == N:
    break

print(*primes)

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

signed
main(){
		ll b;
		while(cin >> b && b!=0)
		{
				//初期化
				ll cnt = 1, sum = 1;
				ll left = 1, right = 2;

				while(1)
				{
						if(sum > b)
						{
								sum -= left;
								left++;
								cnt--;
						}
						else if(sum < b)
						{
								sum += right;
								right++;
								cnt++;
						}
						else
						{
								break;
						}

				}

				cout << left << " " << cnt << endl;
		}
}


Measured memory_bytes: 3068
from collections import defaultdict
N = int(input())
D = list(map(int, input().split()))
if D[0] > 0:
    print(0)
    exit()

D = D[1:]
for d in D:
    if d == 0:
        print(0)
        exit()

mod = 998244353
X = defaultdict(int)

for d in D:
    X[d] += 1

M = max(D)
ans = 1
for i in range(1, M):
    if X[i] == 0:
        ans = 0
        break
    ans *= pow(X[i], X[i+1], mod)
    ans %= mod
print(ans%mod)

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

using ll = long long;
using namespace std;

int main() {
    ll N, ans = 0;
    cin >> N;
    
    if(N%2 == 0) {
        ll p = 5*2;
        while(p <= N) {
            ans += N/p;
            p*= 5;
        }
    }
    
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
/**         (buri nazar wale tera muh kala 😑)
 *
 * @Author   : rudraksh
 * @Created  : Tuesday, May 12th 2020, 2:34:16 pm
 * @Email    : rudrakshk@iitbhilai.ac.in
 *
 *  WARNING  : Don't look at my code, i write shit.
 *             You won't be able to understand anything and may end up wasting time.
 *
 */


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

typedef long long int ll;
typedef unsigned long long ull;
typedef double db;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef map<int,int> MI;
typedef vector<vector<int,int>> VII;
typedef pair<int,pair<int,int>> PII;

#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define mp make_pair
#define repa(i,a,n) for(ll i=a;i<n;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define pera(i,a,n) for(ll i=a;i>=n;i--)
#define per(i,n) for(ll i=n;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define MS0(x) memset((x), 0, sizeof((x)))
#define MS1(x) memset((x), -1, sizeof((x)))
#define MEM(a, b) memset(a, b, sizeof(a))
#define SZ(x) ((ll)(x).size())
#define TIME    cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";

const ll mod=1e9+7;
const double pi=acos(-1);

ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll power(ll a,ll b,ll p) //log(n)
{
    if(b==0) return 1;
    ll c = power(a,b/2,p);
    if(b%2==0) return (c*c)%p;
    else return (((c*c)%p)*a)%p;
}
ll inv(ll n, ll p){ return power(n,p-2, p); }
bool isPrime(ll n) {
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (ll i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
            return false;
    return true;
}


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

    int n;
    cin>>n;
    int a[n],d[n];
    rep(i,n) cin>>a[i];
    d[0]=0;
    d[1]=abs(a[1]-a[0]);
    repa(i,2,n)
    {
        d[i]=min(abs(a[i]-a[i-1])+d[i-1],abs(a[i]-a[i-2])+d[i-2]);
    }
    cout<<d[n-1];

    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N,c=0, tt=0,tc=-1;
	vector<int>X;
	set<int>S;
	map<int,int>C,D;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int t;
		cin>>t;
		X.push_back(t);
		S.insert(t);
		C[t]++;
	}
	for(auto it:S)
	{
		tt+=C[it];
		D[it]=tt;
		if(tc==-1&&tt>=N/2)tc=it;
	}
	for(int i=0;i<N;i++)
	{
		if(X[i]<=tc&&D[tc]==N/2)
		{
			auto it=S.find(tc);
			it++;
			cout<<*it<<endl;
		}
		else
			cout<<tc<<endl;
	}

}

Measured memory_bytes: 30708
n,k=map(int,input().split())
x=list(map(int,input().split()))
if k==1:
    ans=1000000000
    for i in range(n):
        now=abs(x[i])
        if now<ans:
            ans=now
    print(ans)
else:
    ans=1000000000
    for i in range((n-1)-k+1+1):
        l=x[i]
        r=x[i+(k-1)]
        if l<0 and r<0:
            check=abs(l)
            if check<ans:
                ans=check
        if 0<=l and 0<=r:
            check=abs(r)
            if check<ans:
                ans=check
        if l<0 and 0<=r:
            check_l=abs(l)
            check_r=abs(r)
            min_c=min(check_l,check_r)
            max_c=max(check_l,check_r)
            check=min_c*2+max_c
            if check<ans:
                ans=check
    print(ans)

Measured memory_bytes: 14568
//                        Bismillahir Rahmanir Rahim
//ALGO:
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define FILL(a, x) memset(a, x, sizeof(a))
#define ll long long
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define INF INT_MAX
#define mx 1000010
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<pair<int, int>, null_type,less<pair<int, int> >, rb_tree_tag,tree_order_statistics_node_update>
*/
const double Pi=acos(-1);
using namespace std;
int debug=01;
vector<int>v[100010];
int w[100010];
int dfs(int x){
    if(~w[x]) return w[x];
    int ret=0;
    for(auto y:v[x]) ret=max(ret, dfs(y)+1);
    return w[x]=ret;
}
int main() {
    int n, m, ans=0;
    cin>>n>>m;
    while(m--){
        int x, y;
        cin>>x>>y;
        v[x].pb(y);
    }
    FILL(w, -1);
    for(int i=1; i<=n; i++) ans=max(ans, dfs(i));
    cout<<ans;
}


Measured memory_bytes: 7680
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll=long long;
using P=pair<int,int>;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl '\n'
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

int n;
string s;
int main(){
    cin >> n >> s;
    int ans = 0;
    rep(i, 2, n){
        if(s[i] != 'C') continue;
        if(s[i-1] != 'B') continue;
        if(s[i-2] != 'A') continue;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3108
fun main(args: Array<String>) {
  val (wCount, bCount) = readLine()!!.split(" ").map(String::toInt)
  var wRemaining = wCount - 1
  var bRemaining = bCount - 1
  
  println("98 99")
  
  for (y in 0 until 49) {
    if (y % 2 == 0) {
      println(String(CharArray(99, { '#' })))
    } else {
      val chars = CharArray(99, { '#' })
      for (x in 0 until 99) {
        if (x % 2 == 1) {
          if (wRemaining > 0) {
            chars[x] = '.'
            wRemaining--
          }
        }
      }
      println(String(chars))
    }
  }

  for (y in 0 until 49) {
    if (y % 2 == 0) {
      println(String(CharArray(99, { '.' })))
    } else {
      val chars = CharArray(99, { '.' })
      for (x in 0 until 99) {
        if (x % 2 == 1) {
          if (bRemaining > 0) {
            chars[x] = '#'
            bRemaining--
          }
        }
      }
      println(String(chars))
    }
  }
}

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

#define mp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;

const int maxn = 1e5+1;
const int mod = 1e9+7;
vector<ll> init_pw(ll base)
{
  vector<ll> v(maxn);
  v[0] = 1;
  for (int i = 1; i < v.size(); ++i)
    v[i] = v[i-1] * base % mod;
  return v;
}

int main()
{
  auto pw3 = init_pw(3);
  auto pw2 = init_pw(2);
  string s; cin >> s;
  ll ans = 0;
  int cnt = 0;
  for (int i = 0; i < s.size(); ++i)
    if (s[i] == '1')
      {
	// not picking
	int left = s.size() - i - 1;
	ans = (ans + pw2[cnt] * pw3[left] % mod) % mod;
	++cnt;
      }
  ans = (ans + pw2[cnt]) % mod;
  printf("%lld\n", ans);
}


Measured memory_bytes: 2048
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(int a, int b){
   return b ? GCD(b, a%b) : a;
}

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

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

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

   bool is_ok = true;
   for(int i = 0; i < s.size()-1; i++){
      if(s[i] == s[i+1]){
         is_ok = false;
      }
   }

   cout << (is_ok ? "Good":"Bad") << endl;

   return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int v_num = pow(10,5)+1;

int main()
{
	int n,v;
	cin >> n;
	vector<int> even(v_num, 0), odd(v_num + 10, 0);
	for(int i(0);i<n;++i){
		cin >> v;
		if(i%2 == 0)even[v]++;
		else odd[v]++;
	}
	bool same(false);
	vector<int>::iterator evenMaxIt = max_element(even.begin(), even.end());
	vector<int>::iterator oddMaxIt = max_element(odd.begin(), odd.end());
	if(distance(even.begin(), evenMaxIt) == distance(odd.begin(), oddMaxIt)) same = true;

	sort(even.begin(), even.end(), greater<int>() );
	sort(odd.begin(), odd.end(), greater<int>() );
	if(same){
		if(even[0] == odd[0]){
			if (even[1] < odd[1])cout << n - even[0] - odd[1] << endl;
			else cout << n - even[0] - even[1] << endl;
		}else if(even[0] > odd[0]) {cout << n - even[0] - odd[1] << endl;}
		else cout << n - odd[0] - even[1] << endl;
	}else{
		cout << n-even[0]-odd[0] << endl;
	}
	return 0;
}

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

using namespace std;

typedef pair<int, int> P_ii;
typedef pair<string, int> P_si;
typedef long long int ll;

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

const int MOD = 1000000007;
const ll MAX = 100010;

struct Edge {
    /* Parameters     *
     * (int) to : 辺の行き先
     * (int) weight : 辺の重み
    */

    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};


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

    int ans = 100 * (N - M) + 1900 * M;
    for (int i = 0; i < M; ++i) {
        ans *= 2;
    }
    printf("%d\n", ans);
    return 0;
}



Measured memory_bytes: 256
//2017-10-25
//miaomiao
//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define N (4000+5)

const int P = 924844033;

int f[N][N][2], g[N], fac[N];
bool vis[N][2], ban[N];

int main(){
	int n, k;
	scanf("%d%d", &n, &k);

	int nn = 0;
	For(i, 1, n) For(j, 0, 1) if(!vis[i][j]){
		int x = i, y = j, len = 0;
		while(x <= n){
			vis[x][y] = true;
			++len; x += k; y ^= 1;
		}
		ban[nn+=len] = true;
	}

	f[1][0][0] = 1;
	For(i, 1, nn) For(j, 0, n){
		f[i+1][j][0] = (f[i][j][0] + f[i][j][1]) % P;
		if(!ban[i]) f[i+1][j+1][1] = f[i][j][0];
	}

	For(i, 0, n) g[i] = (f[nn][i][0] + f[nn][i][1]) % P;
	
	fac[0] = 1;
	For(i, 1, n) fac[i] = 1ll * fac[i-1] * i % P;

	int ans = fac[n];
	for(int i=1, j=-1; i <= n; ++i, j=-j) ans = ((ans + 1ll*j*g[i]*fac[n-i]%P)%P + P) % P;
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 124544
A,B,C,X,Y = map(int,input().split())

ans = 0
if C*2<A+B:
    ans += min(X,Y)*C*2
    T = min(X,Y)
    X -= T
    Y -= T

if C*2<A:
    A = C*2
if C*2<B:
    B = C*2
ans += X*A + Y*B
print(ans)

Measured memory_bytes: 3060
n,m = map(int,input().split())
ab = []
for _ in range(m):
    a, b = (int(x) for x in input().split())
    ab.append([a, b])
ab = sorted(ab, key=lambda x: x[1])
#print(ab)
count = 1
memo = ab[0][1]
for i in range(m):
    if i == 0:
        continue
    if memo <= ab[i][0]:
        count += 1
        memo = ab[i][1]
print(count)

Measured memory_bytes: 65032
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #C
    #input
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
     
    #output
    #A[i]の電球は i-A[i] から i+A[i]までを照らす。
    import itertools
    K = min(K, 42)
    for _ in range(K):
        dp = [0]*N
        for i in range(N):
            p = max(0, i-A[i])
            dp[p] += 1
            if i+A[i]+1 <= N-1:
                dp[i+A[i]+1] -= 1
        dp = list(itertools.accumulate(dp))
        A = dp
     
    print(" ".join(repr(d) for d in dp))

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

Measured memory_bytes: 182756
#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false); cin.tie(0)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define REYNA(i,a,b) for(int i=(a);i<(b);++i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long int ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PLL, int> PLLI;
typedef pair <PLL, PLL> PP;
typedef pair <PII, int> PPI;
typedef pair <int, PII> PIP;
typedef pair <ll, int> PLI;
typedef unsigned int ui;
const int mod = 1e9+7;
const int inf = 1e9+9;
const ll MOD = 1e9+696969;
const long long INF = 1e18+3;
const int maxn = 200100;
const int R = (1 << 18);
int dr[2 * R + 5];
int pref[maxn], dp[maxn];
inline int getSum(int a, int b) {
	if (a > b) return 0;
	return pref[b] - pref[a-1];
}

inline int comp(int x, int y) {
	return max(x, y);
}

inline void update(int x, int val) {
	x += R-1;
	dr[x] = val;
	x >>= 1;
	while (x) {
		dr[x] = comp(dr[2 * x], dr[2 * x + 1]);
		x >>= 1;
	}
}

inline int query(int x, int y) {
	if (x > y) return 0;
	x += R-1; y += R-1;
	int ret = comp(dr[x], dr[y]);
	while (x + 1 < y) {
		if (!(x & 1)) ret = comp(ret, dr[x + 1]);
		if (y & 1) ret = comp(ret, dr[y - 1]);
		x >>= 1; y >>= 1;
	}
	return ret;
}
vector <int> queries[maxn];
int n, b[maxn];
vector <PII> que;
int main()
{
	boost;
	dp[0] = 0;
	cin >> n;
	int ones = 0;
	FOR(i, 1, n) {
		cin >> b[i];
		if (b[i] == 0) pref[i] = pref[i-1] - 1;
		else pref[i] = pref[i-1] + 1;
		if (b[i] == 1) ++ones;
	}
	int q;
	cin >> q;
	while (q--) {
		int xx, yy;
		cin >> xx >> yy;
		que.pb(mp(yy, xx));
	}
	
	int mx = 0;
	sort(que.begin(), que.end());
	for (auto &u : que) swap(u.e1, u.e2);
	
	set <PII> depek, d2;
	for (int i=0; i<(int)que.size(); ++i) {
		int a = que[i].e1, b = que[i].e2;
		dp[i] = getSum(a, b) + query(1, a - 1);
		int cc = 0;
		for (set<PII>::iterator it = depek.begin(); it != depek.end(); ++it) {
			++cc;
			if (cc > 500) break;
			int h = (*it).e2;
			if (a <= que[h].e1 && b >= que[h].e2) continue; //z takich nie bierzemy
			dp[i] = max(dp[i], dp[h] + getSum(max(que[h].e2 + 1, a), b));
		}
		
		cc = 0;
		for (set<PII>::iterator it = d2.begin(); it != d2.end(); ++it) {
			++cc;
			if (cc > 500) break;
			int h = (*it).e2;
			if (a <= que[h].e1 && b >= que[h].e2) continue; //z takich nie bierzemy
			dp[i] = max(dp[i], dp[h] + getSum(max(que[h].e2 + 1, a), b));
		}
		
		update(b, dp[i]);
		depek.insert(mp(-(dp[i] - pref[i]), i));
		d2.insert(mp(-dp[i], i));
		mx = max(dp[i], mx);
	}
	
	cout << ones - mx;
}


Measured memory_bytes: 31088
require 'prime'
MAX = 10000
dp = [0] * 10001
primes = Prime.each.take_while{ |p| p < MAX }
(1..1/0.0).each do |i|
  break if primes[0,i].reduce(:+) > MAX
  primes.each_cons(i) do |ps|
    break if (sum = ps.reduce(:+)) > MAX
    dp[sum] += 1
  end
end

while n = gets.to_i
  break if n == 0
  puts dp[n]
end

Measured memory_bytes: 9468
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")

#include <cstdio>
#include <stdint.h>
#include <algorithm>
#include <functional>

#ifdef _MSC_VER
//#include <__msvc_all_public_headers.hpp>
#define getchar_unlocked getchar
#define putchar_unlocked putchar
#endif // VS

#define long long long
using namespace std;

void read(uint32_t& x)
{
	x = 0;
	int k;
	while (true)
	{
		k = getchar_unlocked();
		if (k < '0')	break;
		x = x * 10 + k - '0';
	}
}

void sread(int32_t& x)
{
	bool flag;
	x = 0;
	int k = getchar_unlocked();
	if (flag = (k == '-')) k = getchar_unlocked();

	while (true)
	{
		if (k < '0')	break;
		x = x * 10 + k - '0';
		k = getchar_unlocked();
	}
	if (flag) x *= -1;
}

void sprint(int64_t x) {
	if (x == 0) {
		putchar_unlocked('0');
		return;
	}
	if (x < 0) {
		putchar_unlocked('-');
		x *= -1;
	}
	int s = 0;
	char f[15];
	while (x) {
		f[s++] = x % 10;
		x /= 10;
	}
	while (s--)
		putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}

int32_t a[200000];
int main() {
	uint32_t n;
	read(n);
	for (size_t i = 0; i < n; i++) sread(a[i]);
	int64_t res;
	if (n & 1) {
		//Odd
		int64_t sum = 0;
		for (size_t i = 0; i < n - 1; i += 2) sum += a[i];
		res = sum;
		int64_t tailDiff = 0, tailDiffMax = 0;
		for (int i = n - 3; i >= 0; i -= 2)
		{
			sum -= a[i]; sum += a[i + 1];
			tailDiff += a[i + 2]; tailDiff -= a[i + 1];
			tailDiffMax = max(tailDiffMax, tailDiff);
			res = max(res, sum + tailDiffMax);
		}
	}
	else {
		//Even
		int64_t sum = 0;
		for (size_t i = 0; i < n; i += 2) sum += a[i];
		res = sum;
		for (int i = n - 1; i >= 0; i -= 2)
		{
			sum += a[i]; sum -= a[i - 1];
			res = max(res, sum);
		}
	}
	sprint(res);
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  ll N, P;
  cin >> N >> P;
  if(N!=1){
    ll ans = 0;
    ll i = 1;
    while(P>=pow(i,N)){
      if(P%(ll)pow(i,N)==0){
        ans = i;
      }
      i++;
    }
    cout << ans << endl;
  }else{
    cout << P << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int d[3];
    for(int i=0;i<3;i++){
        cin>>d[i];
    }
    sort(d,d+3);
    int a,b,c;
    a=d[0];
    b=d[1];
    c=d[2];
    int ans=0;
    if((c-a)%2!=(c-b)%2){
        b++;
        c++;
        ans++;
    }
    if((c-a)%2==1 and (c-b)%2==1){
        ans+=1+(c-(a+1))/2+(c-(b+1))/2;
    }else if((c-a)%2==0 and (c-b)%2==0){
        ans+=(c-a)/2+(c-b)/2;
    }
    cout<<ans<<endl;
 return 0;   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
typedef long long ll;
using Graph =vector<int>;
typedef pair<int,int> P;
const ll MAX_N=131072;
const ll INF=1000000;
const ll MOD=1000000007;
vector<bool> IsPrime;

void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    }
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}

int main(){
  int N;cin>>N;
  sieve(N);
  ll ans=1;
  rep(i,N+1){
      if(!IsPrime[i]) continue;
      ll res=0;
      int j=1;
      while(N/pow(i,j)){
          res+=(ll) N/(pow(i,j));
          ++j;
      }
      ans*=(res+1);
      ans%=MOD;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector <int> a(n);
    for(int i = 0; i < n; i++)
        cin >> a[i];
    int cnt(0);
    for(int i = 1; i < n; i++)
        if(a[i] == a[i - 1])
            cnt++, i++;
    cout << cnt;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define hash dhsjakhd
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;

ll n,m,T,k,q;
ll DEG[4] = {0};

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);
    int a,b;
    bool ans = 1;
    for(int c1 = 0; c1 < 3; c1++){
        cin >> a >> b;
        a--;
        b--;
        DEG[a]++;
        DEG[b]++;
        if(DEG[a] > 2)ans = 0;
        if(DEG[b] > 2)ans = 0;
    }
    if(ans){
        cout << "YES\n";
    }
    else{
        cout << "NO\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int n; cin >> n;
  bool check = false;
  for (int i = 1; i <= 9; i ++) {
    for (int j = 1; j <= 9; j ++) {
      if (i * j == n) {
        check = true;
        break;
      }
    }
    if (check) break;
  }

  if (check) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
S = list(input())
if len(S) == 2 and S[0] == S[1]:
    print("%d %d" % (1, 2))
    sys.exit()

for i in range(len(S) - 2):
    subset = S[i:i+3]
    if subset[0] == subset[2] or subset[1] == subset[2]:
        print("%d %d" % (i+1, i+3))    
        sys.exit()

print("-1 -1")

Measured memory_bytes: 3956
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;

string r = "AIZUNYAN";
int main() {
	string a;
	int b;
	cin >> a;
	for (b = 0; b <= (int)(a.length()) - 8; b++) {
		int A, N, I, Z, Y, U; A = N = I = Z = Y = U = 0;
		for (int c = 0; c < 8; c++) {
			switch (a[b+c])
			{
			case 'A':A++; break;
			case 'N':N++; break;
			case 'I':I++; break;
			case 'D':Z++; break;
			case 'Y':Y++; break;
			case 'U':U++; break;
			}
		}
		if (A == 2 && N == 2 && I == 1 && Z == 1 && Y == 1 && U == 1) {
			for (int i = 0; i < 8; i++) {
				a[b + i] = r[i];
			}
			b += 7;
		}
	}
	cout << a << endl;
}

Measured memory_bytes: 3176
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    
    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        var input0 = Reads();
        var input1 = Reads();
        var h = input0[0];
        var n = input0[1];
        var a = new long[n];
        bool b = false;
        for (int i = 0; i < n; i++)
        {
            a[i] = input1[i];
            h -= a[i];
            if (h <= 0)
                b=true;

        }
        if (b)
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");

        Console.Out.Flush();
    }
}


Measured memory_bytes: 21600
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define rep(index,num) for(int index=0;index<num;index++)
#define eps 1e-15
typedef long long ll;
int main(){
	int a,b,c,syurui;
	scanf("%d %d %d",&a,&b,&c);
	if(a==b&&b==c) syurui=1;
	else if(a==b||b==c||c==a) syurui=2;
	else syurui=3;
	printf("%d\n",syurui);
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}

ll a,p;

int main(){
	cin >> a >> p;
	cout << (a*3+p)/2 << endl;
}

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

int main()
{
    int A, B;
    cin >> A >> B;

    int ans = -1;
    if ((A >= 1 && A <= 9) && (B >= 1 && B <= 9)) {
        ans = A * B;
    }

    cout << ans << endl;

    return 0;
}

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Set = std::set<T>;
template<class T, class U>
using Map = std::map<T, U>;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

int main() {
    int N;
    cin >> N;
    
    vll As(N);
    rep(i, N) {
        cin >> As[i];
        if (As[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    ll prod = 1;
    rep(i, N) {
        if (As[i] > 1000000000000000000ll / (ld)prod) {
            cout << -1 << endl;
            return 0;
        }
        prod *= As[i];
        
    }
    
    cout << prod << endl;
}

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

#define int long long

int n;
vector<string> s;

bool check(int x) {
  set<string> all;
  
  for ( int i = 0; i < n; i++ ) {
    string t = 'a'+s[i];    
    string code = "";
    int j = 1;
    while ( (int)code.size() < x && j < (int)t.size() ) {
      if ( 'a' == t[j-1] || 'i' == t[j-1] ||
	   'u' == t[j-1] || 'e' == t[j-1] || 'o' == t[j-1] ) {	
	code += t[j];	
      }
      j++;      
    }
    all.insert(code);    
  }
  
  if ( (int)all.size() == n ) return true;
  else return false;  
}

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

  while ( cin >> n, n ) {
    s = vector<string>(n);    
    for ( int i = 0; i < n; i++ ) cin >> s[i];
    
    int l = -1, r = 51;    
    while ( r-l > 1 ) {
      int mid = (r+l)/2;
      if ( check(mid) ) r = mid;
      else l = mid;      
    }

    if ( r == 51 ) cout << -1 << endl;
    else cout << r << endl;    
  }  
  
  return 0;
}



Measured memory_bytes: 3228
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N, K;
	cin >> N >> K;
	VLL A(N);
	for (LL n = 0; n < N; n++)cin >> A[n];
	LL ans = 1e15;
	for (LL code = 0; code < ((LL)1 << N); code++) {
		VLL AA(A);
		LL color = 0;
		LL temp = 0;
		LL prev = 0;
		for (LL n = 0; n < N; n++) {
			if (code & ((LL)1 << n)) {
				if (prev >= AA[n]) {
					temp += (prev + 1) - AA[n];
					AA[n] = prev + 1;
				}
				color++;
			}
			prev = max(prev, AA[n]);
		}
		if (color < K)continue;
		ans = min(ans, temp);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
 
using namespace std;
int N, M;
string S;

int main()
{
  int n;
  int ret=0;

  cin >> S;

  if (S[2] == S[3] && S[4] == S[5])
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(void)
{
        int N, R;
        std::cin >> N >> R;

        if(N >= 10)
        {
                std::cout << R << std::endl;
        }
        else
        {
                /*
                 * ans - 100+(10-N) = R
                 * <-> ans = -(100 + (10-N) + R
                 * */
                std::cout << (R + (100 * (10-N))) << std::endl;
        }

        return 0;

}


Measured memory_bytes: 256
def main():
    N = input_int()
    h = input_int_list_in_line()

    DP = [0] * N

    DP[1] = abs(h[0] - h[1])

    for i in range(2, N):
        one_hop = abs(h[i] - h[i - 1])
        two_hop = abs(h[i] - h[i - 2])

        if DP[i - 1] + one_hop < DP[i - 2] + two_hop:
            DP[i] += DP[i - 1] + one_hop
        else:
            DP[i] += DP[i - 2] + two_hop

    print(DP[-1])


def input_int():
    return int(input())


def input_ints():
    return map(int, input().split())


def input_int_list_in_line():
    return list(map(int, input().split()))


def input_int_tuple_list(n: int, q: int):
    return [tuple(map(int, input().split())) for _ in range(n)]


main()


Measured memory_bytes: 20472
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
int main(){
    ll n; cin >> n;
	ll arr[n];
	for(ll i = 0; i < n; ++i){
		cin >> arr[i];
	}
	ll ans = 0, truer = 0;
	for(ll i = 1; i < n; ++i){
		if(truer == 1 && arr[i] >= arr[i - 1])continue;
		else if(truer == 2 && arr[i] <= arr[i - 1])continue;
		if(truer == 0){
			if(arr[i] > arr[i - 1])truer = 1;
			else if(arr[i] < arr[i - 1])truer = 2;
			else truer = 0;
		}else{
			ans++;
			truer = 0;
		}
	}
	cout << ans + 1;
    return 0;
}


Measured memory_bytes: 4404
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  ll x;
  cin>>x;
  if(x>=30){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3612
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (ql:quickload '(:cl-debug-print :fiveam))
  #-swank (set-dispatch-macro-character #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)
#-swank (disable-debugger) ; for CS Academy

;; BEGIN_INSERTED_CONTENTS
(declaim (ftype (function * (values fixnum &optional)) read-fixnum))
(defun read-fixnum (&optional (in *standard-input*))
  (declare #.OPT
           #-swank (sb-kernel:ansi-stream in))
  (macrolet ((%read-byte ()
               `(the (unsigned-byte 8)
                     #+swank (char-code (read-char in nil #\Nul))
                     #-swank (sb-impl::ansi-stream-read-byte in nil #.(char-code #\Nul) nil))))
    (let* ((minus nil)
           (result (loop (let ((byte (%read-byte)))
                           (cond ((<= 48 byte 57)
                                  (return (- byte 48)))
                                 ((zerop byte) ; #\Nul
                                  (error "Read EOF or #\Nul."))
                                 ((= byte #.(char-code #\-))
                                  (setf minus t)))))))
      (declare ((integer 0 #.most-positive-fixnum) result))
      (loop
        (let* ((byte (%read-byte)))
          (if (<= 48 byte 57)
              (setq result (+ (- byte 48) (* 10 (the (integer 0 #.(floor most-positive-fixnum 10)) result))))
              (return (if minus (- result) result))))))))

(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(define-modify-macro minf (new-value)
  (lambda (x y) (min x y)))

(defun main ()
  (declare #.OPT)
  (let* ((n (read))
         (k (read))
         (hs (make-array n :element-type 'uint32))
         (dp (make-array n :element-type 'uint32 :initial-element #xffffffff)))
    (declare (uint31 n k))
    (setf (aref dp 0) 0)
    (dotimes (i n)
      (setf (aref hs i) (read-fixnum)))
    (dotimes (i n)
      (loop for dest from (+ i 1) to (min (+ i k) (- n 1))
            do (minf (aref dp dest)
                     (+ (aref dp i) (abs (- (aref hs i) (aref hs dest)))))))
    (println (aref dp (- n 1)))))

#-swank (main)


Measured memory_bytes: 14176
#include<stdio.h>
int main(void)
{
    int n,a[100005],i,c=1,b[100005];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++)
    {
        b[a[i]-1] = i+1;
    }
    for(i=0;i<n;i++)
        printf("%d ",b[i]);
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>

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

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::min;
using std::max;
using std::fill;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
#define int long long

const long long MOD = 1e9 + 7;
ll n, m;
ll a[505][505];

void solve(vector<int> v, int kek)
{
    if (v.size() <= 1) return;
    vector<int> v1, v2;
    for (int i = 0; i < v.size(); i++)
    {
        if (i % 2) v2.push_back(v[i]);
        else v1.push_back(v[i]);
    }
    solve(v1, kek + 1);
    solve(v2, kek + 1);
    for (int i = 0; i < v1.size(); i++)
    {
        for (int j = 0; j < v2.size(); j++)
        {
            a[v1[i]][v2[j]] = kek;
            a[v2[j]][v1[i]] = kek;
        }
    }
    return;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    vector<int> v;
    for (int i = 1; i <= n; i++)
        v.push_back(i);
    solve(v, 1);
    for (int i = 1; i <= n; i++)
    {
        for (int j = i + 1; j <= n; j++)
            cout << a[i][j] << " ";
        cout << "\n";
    }
}


Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC125_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strs = Console.ReadLine().Split(' ');
            int a = int.Parse(strs[0]);
            int b = int.Parse(strs[1]);
            int t = int.Parse(strs[2]);

            Console.WriteLine("{0}", t / a * b);
        }
    }
}


Measured memory_bytes: 11220
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;
typedef vector<char> vchar;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<string>> vvstring;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================




int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================



	int N;
	cin >> N;

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

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

	double max_A = A[N - 1];

	double partner = A[0];
	for (int i = 0; i < N-1; i++)
	{
		if (abs((max_A / 2) - A[i]) < abs((max_A / 2) -partner))
		{
			partner = A[i];
		}
	}

	cout << ll(max_A) << " " << ll(partner) << endl;




}



Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s, ans = "No";
  cin >> n >> s;
  if (n % 2 == 0) {
    for (int i = 0; i < n/2; i++) {
      if (s[i] != s[i+n/2]) break;
      if (i == n/2-1) ans = "Yes";
    }
  }
  cout << ans << endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N+1),B(N);
  for(int i=0;i<N+1;i++){
    cin >> A.at(i);
  }
  for(int i=0;i<N;i++){
    cin >> B.at(i);
  }
  int64_t ans=0;
  for(int i=N-1;i>=0;i--){
    if(A.at(i+1)>B.at(i)){
      ans+=B.at(i);
      A.at(i+1)-=B.at(i);
      B.at(i)=0;
    }else{
      ans+=A.at(i+1);
      B.at(i)-=A.at(i+1);
      A.at(i+1)=0;
    }
    if(A.at(i)>B.at(i)){
      ans+=B.at(i);
      A.at(i)-=B.at(i);
      B.at(i)=0;
    }else{
      ans+=A.at(i);
      B.at(i)-=A.at(i);
      A.at(i)=0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D: Christmas
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 50;

/* typedef */

typedef long long ll;

/* global variables */

ll bls[MAX_N + 1], pns[MAX_N + 1];

/* subroutines */

ll pn_range(ll x, int n, ll i0) {
  if (x <= i0) return 0;
  if (i0 + bls[n] <= x) return pns[n];

  return
    pn_range(x, n - 1, i0 + 1) +
    pn_range(x,     0, i0 + 1 + bls[n - 1]) +
    pn_range(x, n - 1, i0 + 1 + bls[n - 1] + bls[0]);
}

/* main */

int main() {
  int n;
  ll x;
  scanf("%d%lld", &n, &x);

  bls[0] = pns[0] = 1;
  for (int i = 0; i < n; i++) {
    bls[i + 1] = bls[i] * 2 + 3;
    pns[i + 1] = pns[i] * 2 + 1;
  }
  //for (int i = 0; i <= n; i++) printf("%d: %lld %lld\n", i, bls[i], pns[i]);

  printf("%lld\n", pn_range(x, n, 0));
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, m;
vii g[200005];

bool dfs(int p, int cnt) {
    if (cnt == 2) return p == n-1;
    bool res = false;
    for (auto x : g[p]) {
        res |= dfs(x, cnt+1);
    }
    return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> m;
    rep(i, 0, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].pb(b); g[b].pb(a);
    }
    if (dfs(0, 0)) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

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


def solve(A: int, op: str, B: int):
    if op == "+":
        print(A+B)
    else:
        print(A-B)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    op = next(tokens)  # type: str
    B = int(next(tokens))  # type: int
    solve(A, op, B)


if __name__ == '__main__':
    main()


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

int main() {
  
  int N, count;
  cin >> N;
  count = 30;
  for (int i = 0; i < N; i++){
    int A, countA;
    cin >> A;
    countA = 0;
    while (A%2 == 0){
      A /= 2;
      countA++;
    }
    //cout << countA << endl;
    if (countA < count){
      count = countA;
    }
  }
  cout << count << endl;
      
}


Measured memory_bytes: 256