akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
template<class V> struct BIT {
    BIT() {}  // [L, R)
    int NV;vector<V> bit;
    BIT(int n){ init(n); }
    void init(int n) { NV = 1; while (NV < n)NV *= 2; bit.resize(NV); clear(); }
    V operator[](int e) { V s = 0; e++; while (e) s += bit[e - 1], e -= e&-e; return s; }
    void add(int e, V v) { e++; while (e <= NV) bit[e - 1] += v, e += e&-e; }
    int lower_bound(V val) { 
        V tv = 0; int i, ent = 0; for (i = NV - 1; i >= 0; i--)
        if(tv+bit[ent+(1<<i)-1]<=val)tv+=bit[ent+(1<<i)-1],ent += (1 << i);return ent;
    }
    V get(int L, int R) {
        assert(0 <= L); assert(R <= NV); assert(L <= R);
        V res = 0; if(R) res += operator[](R - 1); if (L) res -= operator[](L - 1);return res;
    }
    void clear() { rep(i, 0, NV) bit[i] = 0; }
	void update(int e, V v) { add(e, v - get(e, e + 1)); }
};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, M, V, P, A[101010];
BIT<ll> bit(101010);
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M >> V >> P;
	rep(i, 0, N) cin >> A[i];

	sort(A, A + N);


	A[N] = inf*2;
	rep(i, 0, N) bit.add(i, A[i]);

	int ans = 0;
	int nxt = 0;
	int same = 0;
	rep(i, 0, N) {
		while (A[nxt] <= A[i] + M) nxt++;
		while (A[same] <= A[i]) same++;
		
		int cnt_bck = i + (same - i - 1);
		int cnt_nxt = N - nxt;

		if (P <= cnt_nxt) continue;
		int rest = V - 1 - cnt_bck - cnt_nxt;
		
		if (rest <= 0) {
			//printf("%d %d %d\n", i, cnt_bck, cnt_nxt);
			ans++;
			continue;
		}

		// 残りを[same, nxt)で分割
		int ok = same, ng = nxt + 1;
		while (ok + 1 != ng) {
			// [same, md)は超えないよう頑張る
			int md = (ng + ok) / 2;
			int ng_man = nxt - md;
			ll tot = bit.get(same, md);
			if (1LL * (M + A[i]) * (md - same) - tot >= 1LL * M * (rest - ng_man)) ok = md;
			else ng = md;
		}

		if (1 + cnt_nxt + (nxt - ok) <= P) {
			//cout << i << endl;
			ans++;
		}
	}
	cout << ans << endl;
}







Measured memory_bytes: 1664
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

char change(char s){
	if(s=='A')return 'a';
	if(s=='B')return 'b';
	if(s=='C')return 'c';
}

int main(){
	string str;
	int a,k;
	scanf("%d %d",&a,&k);
	cin>>str;

	str[k-1]=change(str[k-1]);

	cout<<str;

	return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $n, $m);
$a = explode(' ', trim(fgets(STDIN)));
$t = array_count_values($a);
while ($m--) {
	fscanf(STDIN, "%d %d", $b, $c);
	if (isset($t[$c])) {
		$t[$c] += $b;
	} else {
		$t[$c] = $b;
	}
}
krsort($t);
$x = 0;
foreach ($t as $c => $b) {
	$y = min($n, $b);
	$x += $c * $y;
	$n -= $y;
	if (!$n) break;
}
echo $x;

Measured memory_bytes: 23540
package main

import (
  "fmt"
)

func main() {
  var s string
  annwer := "YES"
  divide := [4]string{"dream", "dreamer", "erase", "eraser"}
  fmt.Scanf("%s", &s)

  // リバース
  for i :=0; i < len(divide); i++ {
    divide[i] = getReverse(divide[i])
  }
  reverse := getReverse(s)
  j := 0
  for j < len(reverse) {
    annwer = "NO"
    for i := 0; i < 4; i++ {
      var str string
      for k := j; k < j + len(divide[i]); k++ {
        if k >= len(reverse) {
          continue
        }
        str += string(reverse[k])
      }
      if str == divide[i] {
        j += len(divide[i])
        annwer = "YES"
        break
      }
    }
    if annwer == "NO" {
      break
    }
  }
  fmt.Println(annwer)
}

func getReverse(s string) string {
  rs := []rune(s)
  for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
    rs[i], rs[j] = rs[j], rs[i]
  }
  return string(rs)
}

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

#define ll long long

struct item
{
  int wt;
  int val;
};

ll solve(vector<item> arr, int n, int W)
{
  ll dp[n + 1][W + 1];
  for (int w = 0; w <= W; w++)
  {
    dp[1][w] = 0;
  }
  dp[1][arr[1].wt] = arr[1].val;
  for (int i = 2; i <= n; i++)
  {
    for (int w = 0; w <= W; w++)
    {
      dp[i][w] = dp[i - 1][w];
      if (arr[i].wt > w)
        continue;
      dp[i][w] = max(dp[i][w], arr[i].val + dp[i - 1][w - arr[i].wt]);
    }
  }
  return *max_element(dp[n], dp[n] + W + 1);
}

int main()
{
  int n, w;
  cin >> n >> w;
  vector<item> arr(n + 1);
  for (int i = 1; i <= n; i++)
  {
    cin >> arr[i].wt >> arr[i].val;
  }
  cout << solve(arr, n, w);
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

int calc(string s,int l){
  int res=0;
  for(int i=0;i<l;i++) res=res*10+(s[i]-48);
  return res;
}

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

int l;string a;
  while(true){
    cin >> a >> l;
    while((int)a.length()<l) a = "0"+a;
    if(l==0) break;
    int log[1000001];for(int i=0;i<1000001;i++)log[i]=-1;
    log[calc(a,l)]=0;
    for(int i=1;i<21;i++){
      std::vector<char> vmax,vmin;
      for(int i=0;i<l;i++){
        vmax.push_back(a[i]);
        vmin.push_back(a[i]);
      }
      sort(vmin.begin(),vmin.end());
      sort(vmax.begin(),vmax.end(),greater<char>());
      string ma="",mi="";
      for(int i=0;i<l;i++){
        mi+=vmin[i];
        ma+=vmax[i];
      }
      int ans=calc(ma,l)-calc(mi,l);
      if(log[ans]<0) log[ans]=i;
      else{
        cout << log[ans] <<" " << ans << " " << i-log[ans]<< endl;
        break;
      }
      a=to_string(ans);
      while((int)a.length()<l) a = "0"+a;
    }
  }
}

Measured memory_bytes: 7076
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000000000000


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


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

int main() {
    long long L, R, x, y,ans;
    cin>>L>>R;
    ans=(L*R)%2019;
    if (R-L>2019) {
        ans=0;
    } else {
    for(x=L;x<=R;x++){
        for(y=x+1;y<=R;y++){
            ans=min((x*y)%2019,ans);
        }
    }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main () {
	string s;
	cin >> s;
	int j=0;
	long long ans=0;
	for (int i=0; i<(int)s.length(); i++) {
		if (s[i] == 'W') {
			ans += i-j;
			j++;
		}
	}
	cout << ans;
} 

Measured memory_bytes: 3740
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn main() {
    input! {
        x:usize,
        a:usize,
        b:usize,
    }
    if b <= a {
        println!("delicious");
    } else if b <= a + x {
        println!("safe");
    } else {
        println!("dangerous");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>

using namespace std;

int n, mini = 10000, w[1000], A[1000], T[10001];
bool used[1000];

int solve() {
	int res = 0;
	for (int i = 0; i < n; ++i) A[i] = w[i];
	sort(A, A + n);
	for (int i = 0; i < n; ++i) T[A[i]] = i;
	for (int i = 0; i < n; ++i) {
		if (used[i]) continue;
		int now = i, S = 0, m = 10000, an = 0;
		while (true) {
			used[now] = true;
			an++;
			int v = w[now];
			m = min(m, v);
			S += v;
			now = T[v];
			if (used[now]) break;
		}
		res += min(S + (an - 2) * m, m + S + (an + 1) * mini);
	}
	return res;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> w[i];
		mini = min(mini, w[i]);
	}
	cout << solve() << endl;

	return 0;
}


Measured memory_bytes: 3164
import numpy as np
MOD = 10**9+7
n = input()
a = list(map(int, input().split()))
ans = 0
cum_a = np.cumsum(a[::-1])
cum_a = cum_a[::-1]
for i, ai in enumerate(a):
  if i == len(a)-1:
    continue
  sum_aj = cum_a[i+1]
  ans += ((ai%MOD)*(sum_aj%MOD))%MOD

print(ans%MOD)

Measured memory_bytes: 50000
def ddcc2020q_c():
    H, W, _ = map(int, input().split())
    stable = [[s for s in str(input())] for _ in range(H)]
    atable = [[0] * W for _ in range(H)]
    num = 1  # '#'につけるラベル
    for i in range(H):
        for j in range(W):  # 左から右へ
            if stable[i][j] == '#':
                atable[i][j] = num
                num += 1
            if j == 0: continue
            if atable[i][j] == 0 and atable[i][j-1] > 0:
                atable[i][j] = atable[i][j-1]
    for i in range(H):
        for j in range(W-2, -1, -1):  # 右から左へ
            if atable[i][j] == 0 and atable[i][j+1] > 0:
                atable[i][j] = atable[i][j+1]
    for i in range(1, H):  # 上から下へ
        for j in range(W):
            if atable[i][j] == 0 and atable[i-1][j] > 0:
                atable[i][j] = atable[i-1][j]
    for i in range(H-2, -1, -1):  # 下から上へ
        for j in range(W):
            if atable[i][j] == 0 and atable[i+1][j] > 0:
                atable[i][j] = atable[i+1][j]
    # 出力
    for row in atable:
        print(*row, sep=' ')
    return

ddcc2020q_c()

Measured memory_bytes: 8144
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

int n, K;

void solve()
{
    scanf("%d%d", &n, &K);

    vector<ll> a(K + 1);
    int i;
    for (i = 1; i <= K; i++) {
        a[i] = (a[i] + i) % MOD;
        int curr = i + i;
        while (curr <= K) {
            a[curr] = (a[curr] - a[i] + MOD) % MOD;
            curr += i;
        }
    }    

    ll ans = 0;
    for (i = 1; i <= K; i++) {
        int tmp = K / i;
        ll ans0 = mpow(tmp, n);
        ans = (ans + ans0 * a[i]%MOD) % MOD;
    }
    printf("%lld\n", ans);

    return;
}

void solve2()
{
    ll s = 0;
    int i,j,k;
    map<int, int> z;
    for (i = 1; i <= K; i++) {
        for (j = 1; j <= K; j++) {
            for (k = 1; k <= K; k++) {
                ll tmp = gcd(gcd(i, j), k);
                s = (s + tmp) % MOD;
                z[tmp]++;
            }
        }
    }
    printf("%lld\n", s);
    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
    //solve2();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 3556
#include <iostream>

using namespace std;

int main(void)
{
	char alpha;
	
	cin >> alpha;
	
	if ( ('A' <= alpha) & (alpha <= 'Z') )
	{
		cout << 'A' << endl;
	}
	else if( ('a' <= alpha) & (alpha <= 'z') )
	{
		cout << 'a' << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
long long N,M,n,a,b;
cin>>N>>M;
long long H[N];
for(long long i=0;i<N;++i){
    cin>>n;
    H[i]=n;
}
vector<vector<long long>> v(N);
for(long long i=0;i<M;++i){
    cin>>a>>b;
    a--;
    b--;
    v[a].push_back(b);
    v[b].push_back(a);
}

long long ans=0;
bool judge=true;
for(long long i=0;i<N;++i){
    judge=true;
    for(long long j=0;j<v[i].size();++j){
        if(H[v[i][j]]>=H[i]){
            judge=false;
            break;
        }
    }
    if(judge){
        ans+=1;
    }
}
cout<<ans<<"\n";
return 0;
}


Measured memory_bytes: 9856
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))


flag = False
index = 0
count = 0
for i in range(n):
    index = a[index] - 1
    count += 1
    if index == 1:
        flag = True
        break

if flag == True:
    print(count)
else:
    print(-1)


Measured memory_bytes: 7084
n=int(input())
a=list(map(int,input().split()))
mount=[0]*n
minus=0
for i in range(0,n-1,2):
        minus=minus+a[i]-a[i+1]
mount[0]=minus+a[-1]
for j in range(1,n):
        mount[j]=a[j-1]*2-mount[j-1]
print(*mount)

Measured memory_bytes: 14616
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  for(int i=0;i<N;i++) cin >> v[i];
  sort(v.begin(), v.end(), greater<int>());
  int a=0,b=0;
  for(int i=0;i<v.size();i+=2) {a += v[i]; if (i+1<v.size()) b += v[i+1];}
  cout << a - b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;

int v[101];

int main(){
    int n,q;

    while(cin >> n >> q){
        if((n|q) == 0) break;
        memset(v, 0, sizeof(v));
        int num,tmp,ret=0,maxi=q-1;

        for(int i=0;i<n;++i){
            cin >> num;
            for(int j=0;j<num;++j){
                cin >> tmp;
                v[tmp]++;
            }
        }
        for(int i=0;i<101;i++){
            if(v[i] > maxi){
                ret = i;
                maxi = v[i];
            }
        }
        cout << ret << endl;
    }
}

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

typedef long long ll;

template<class T> inline void chmin(T &a, T b) {if(a > b) a = b;}

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

    ll n,k;
    cin >> n >> k;
    ll h[110000];
    for(ll i=1;i<=n;i++) cin >> h[i];
    const ll INF = 1LL<<60;
    vector<ll> dp(110000,INF);
    dp[1] = 0;
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=k;j++){
            if(i+j<=n) chmin(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int n,m,q,mx_sum;
vector<int> a,b,c,d;

void dfs(vector<int> A){
   if(A.size() == n+1){
       int sum = 0;
       rep(i,q){
           if(A[b[i]] - A[a[i]] == c[i]) sum += d[i];
       }
       mx_sum = max(sum, mx_sum);
       return;
   }
   //同じかそれ以上を追加する
   A.pb(A.back());
   while(A.back() <= m){
       dfs(A);
       A.back()++;
   }

}

int main()
{
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    rep(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];

    //数列を作る。得点を出す。最大を出す。
    dfs(vector<int> (1,1));
    cout << mx_sum << endl;
    return 0;
}

/*
g++ c.cpp
./a.out

oj d https://atcoder.jp/contests/abc169/tasks/abc169_b
oj t
*/


Measured memory_bytes: 3620
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, K;
    scan(N, K);
    foreach (i; 1 .. K + 1)
    {
        assert(N - K + 1 <= i);
        long a = combination_mod(N - K + 1, i, MOD);
        long b = combination_mod(K - 1, i - 1, MOD);
        writeln((a * b) % MOD);
    }
}

T combination_mod(T = long)(T n, T k, T m)
{
    if (n < k)
        return 0;
    long a = 1;
    long b = 1;
    long c = 1;
    foreach (i; 1 .. n + 1)
    {
        a = (a * i) % m;
        if (i == k)
            b = a;
        if (i == (n - k))
            c = a;
    }
    T powmod(T = long)(T x, T n, T m)
    {
        if (n < 1)
            return 1;
        if (n & 1)
        {
            return x * powmod(x, n - 1, m) % m;
        }
        T tmp = powmod(x, n / 2, m);
        return tmp * tmp % m;
    }

    long bc = b * c % m;
    long bc_inv = powmod(bc, m - 2, m);
    return a * bc_inv % m;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include <limits.h>
int main()
{
	long long int n, i, k, min;
	scanf("%lld %lld", &n, &k);

	long long int a[n], dp[n+1];
	memset(dp,-1,sizeof(dp));
	for (i = 0; i < n; ++i)
		scanf("%lld", a+i);
//	printf("%lld\n", n);
	dp[0] = 0;
//	printf("%lld\n", n);
	for (i = 1; i < k && i < n; ++i)
	{
		min = INT_MAX;
		for (int j = 0; j < i; ++j)
		{
//			printf("%lld %lld %lld\n", n,i,j);
			if(dp[j] + fabs(a[i] - a[j]) < min)
				min = dp[j] + fabs(a[i] - a[j]);
		}
		dp[i] = min;
	}
//	printf("%lld\n", n);
	for (i = k; i < n; ++i)
	{
		min = INT_MAX;
		for (int j = i - k; j < i; ++j)
		{
			if(dp[j] + fabs(a[i] - a[j]) < min)
				min = dp[j] + fabs(a[i] - a[j]);
		}
		dp[i] = min;
	}
//	for (int i = 0; i < n; ++i)
//		printf("%lld ", dp[i]);
//	printf("\n");
//	printf("%lld %lld\n",n,dp[n-1] );
	printf("%lld\n", dp[n-1]);
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MAXN = 1e5+10;

int n;
ll v[MAXN];

vector<P> calculateLength(vector<ll>& vec) {
  sort(vec.begin(), vec.end());
  vector<P> ret;
  ll tmp = 1;
  for (int i=0;i<vec.size()-1;i++) {
    if (vec[i+1] == vec[i]) {
      tmp++;
    } else {
      ret.push_back(P(tmp, vec[i]));
      tmp = 1;
    }
  }
  ret.push_back(P(tmp, vec[vec.size()-1]));
  sort(ret.begin(), ret.end(), greater<P>());
  return ret;
}

void solve() {
  vector<ll> even, odd;
  for (int i=0;i<n;i++) {
    if (i & 1) {
      odd.push_back(v[i]);
    } else {
      even.push_back(v[i]);
    }
  }
  vector<P> evenVec = calculateLength(even);
  vector<P> oddVec = calculateLength(odd);
  int cnt = 0;
  if (evenVec[0].second == oddVec[0].second) {
    cnt = min(n - evenVec[0].first - oddVec[1].first, n - evenVec[1].first - oddVec[0].first);
  } else {
    cnt = n - evenVec[0].first - oddVec[0].first;
  }
  cout << cnt << endl;
}

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


Measured memory_bytes: 4080
#include <iostream>
#include <map>

using namespace std;
int main(){
    string s;
    int64_t K;
    int i=0;
    cin>>s;
    cin>>K;
    while(K!=0){
        if(i<s.length()){
            if(s[i]!='a' && s[i]+K>'z'){
                K-=('z'+1-s[i]);
                s[i]='a';
            }
            i++;
        }
        else{
            s[i-1]=(s[i-1]+K%26);
            if(s[i-1]>'z')
                s[i-1]-=26;
            K=0;
        }
    }
    cout<<s;
    return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<numeric>
#define int long long
#define ld long double
#define all(x) x.begin(),x.end()
const int maxn=1000000;
#define what_is(x) cerr << #x << " is " << x << endl;
const int MOD = 1e9 + 7;
using namespace std;
string abc="abcdefghijklmnopqrstuvwxyz";
int powmod(int a, int b, int MOD = MOD){
    if(!a and !b)    return 1ll;
    if(!a)    return a;
    int res = 1ll;
    b %= (MOD - 1ll), a %= MOD;
    while(b){
        if(b%2 == 1)    res = (res * a) % MOD;
        a = (a * a) % MOD;
        b /= 2;
    }
    return res;
}
int popcount(uint32_t n)
{
    n = n - ((n >> 1) & 0x55555555);
    n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
    return ((n + (n >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}
bool check(int n) {return (((double)sqrt(n)-floor((double)sqrt(n)))==0);}
vector<bool> sieve(maxn + 1, true);
void fillprime() {
    sieve[0] = sieve[1] = false;
    for (int i = 2; i <= maxn; ++i) {
        if (sieve[i] && (int) i * i <= maxn) {
            for (int j = i * i; j <= maxn; j += i) {
                sieve[j] = false;
            }
        }
    }
}
void solve() {
   int x,y;
   cin>>x>>y;
   double n=(double)(y-(2*x))/2;
   if(ceil(n)-floor(n)!=0) {
       cout << "No";
       return;
   }
   int m=x-n;
   if(n>=0 and m>=0) cout<<"Yes";
   else cout<<"No";
}
int32_t main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    //cout<<"Hello World"<<"\n";
    //int t;cin>>t;while(t--)
    solve();
}

Measured memory_bytes: 3744
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <valarray>
#include <utility>
#include <set>

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP2(i,m,n) for(int i=m+1;i<=(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<=(int)(n);i++)
#define INF 500000000  //
#define INFLL 1000000000000000000  //
#define MOD (1e9)+7

typedef long long int ll;

// a 0x61  z 0x7a  0 0x30

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

    char c0[h][w];
    rep(i, h) rep(j, w) cin >> c0[i][j];

    char c1[2 * h][w];
    rep(i, 2 * h) rep(j, w) c1[i][j] = c0[i / 2][j];

    rep(i, 2 * h) {

        rep(j, w) {
            cout << c1[i][j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;

int main (void) {
  int n, m, l;
  cin >> n >> m >> l;
  
  int a[n][m],b[m][l];
  
  for (int i=0; i<n; i++) {
    for (int j=0; j<m; j++) {
      cin >> a[i][j];
    }
  }
  
  for (int i=0; i<m; i++) {
    for (int k=0; k<l; k++) {
      cin >> b[i][k];
    }
  }
  
  long long c[n][l];
  memset(c,0,sizeof(c));
  
  for (int i=0; i<n; i++) {
    for (int j=0; j<m; j++) {
      for (int k=0; k<l; k++) {
        c[i][k] += a[i][j]*b[j][k];
      }
    }
  }
  
  for (int i=0; i<n; i++) {
    for (int k=0; k<l; k++) {
      if (k != 0) {
        cout << " " << flush;
      }
      cout << c[i][k] << flush;     
    }
    cout << endl;
  }
}

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

typedef long double     lf;

using namespace std;

const lf EPS = 1e-9;

struct pt {
  lf x, y;
  pt( ) { }
  pt( lf x, lf y ) : x( x ), y ( y ) { }
};

inline lf x( pt P ) { return P.x; }
inline lf y( pt P ) { return P.y; }

istream& operator >> ( istream& in, pt& p ) {
  lf x,y; in >> x >> y;
  p = pt(x,y); return in;
}

ostream& operator << ( ostream& out, const pt& p ) {
  out << double(p.x) << " " << double(p.y);
  return out;
}

pt operator + ( const pt& A, const pt& B ) {
  return pt( x(A)+x(B), y(A)+y(B) );
}

pt operator - ( const pt& A, const pt& B ) {
  return pt( x(A)-x(B), y(A)-y(B) );
}


pt operator * ( const lf& B, const pt& A ) {
  return pt( x(A)*B, y(A)*B );
}

inline lf dot( pt A, pt B ) {
  return x(A)*x(B) + y(A)*y(B);
}

inline lf norm( pt A ) {
  return x(A)*x(A) + y(A)*y(A);
}

pt projection (pt p, pt A, pt B) {
  lf u = dot( p-A , B-A ) / norm( B-A );
  return A + u*( B-A );
}

pt p1,p2,p;
int n;

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

  cin >> p1 >> p2 >> n;
  for( int i = 0; i < n; ++i ) {
    cin >> p;
    cout << projection( p, p1, p2 ) << '\n';
  }
}

Measured memory_bytes: 3300
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

bool dp[2][60000];

bool check(int pos, vector<int> vec){
    memset(dp, 0, sizeof(dp));
    dp[0][30000] = true;//原点
    for(int i = 0; i < vec.size(); ++i){
        for(int j = 0; j < 60000; ++j){
            if(dp[i%2][j] == 0) continue;
            if(j - vec[i] >= 0)     dp[(i+1)%2][j - vec[i]] |= dp[i%2][j];
            if(j + vec[i] < 60000)  dp[(i+1)%2][j + vec[i]] |= dp[i%2][j];
        }
        for(int j = 0; j < 60000; j++){
            dp[i%2][j] = false;
        }
    }
    return dp[vec.size() % 2][pos + 30000];
}

int main(){
    string s; cin >> s;
    int x, y; cin >> x >> y;
    /*
    {
        //一回もTがないとき->のみ
        int cntT = 0;
        int cntF = 0;
        for(auto c : s) {
            if(c == 'T') cntT++;
            else cntF++;
        }
        if(cntT == 0){
            if(x == cntF && y == 0) cout << "Yes" << endl;
            else cout << "No" << endl;
            return 0;
        }
    }
    */
    vector<int> vecx, vecy;
    int id = 0;
    int cnt = 0;
    s += 'T';
    bool goright = true;
    int offset = 0;
    for(auto c : s){
        if(c == 'F') cnt++;
        else {
            if(id%2==0){
                if(goright){
                    goright = false;
                    offset = cnt;
                    id++;
                    cnt = 0;
                    //vecx.push_back(0);
                }else{
                    vecx.push_back(cnt);
                    id++;
                    cnt = 0;
                }
            }else{
                vecy.push_back(cnt);
                id++;
                cnt = 0;
            }
        }
    }
    /*
    for(auto elem : vecx) cout << elem;
    cout << endl;
    for(auto elem : vecy) cout << elem;
    cout << endl;
    cout << vecx.size() << endl;
    cout << vecy.size() << endl;
    */
    if(check(x-offset,vecx) && check(y, vecy)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
int quadratic_function(int factor){
	return factor*factor;
}
int main(){
	int divisor[10000];
	int temp,j,i;
	int area[10000];
	
	for(temp=0;scanf("%d",&divisor[temp])!=EOF;temp++);
	
	for(j=0;j<temp;j++){
		for(i=1;i<=(600-divisor[j])/divisor[j];i++){
			area[j]=area[j]+divisor[j]*quadratic_function(i*divisor[j]);
		}
		printf("%d\n",area[j]);
	}
	return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

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

int main() {
  ll n;
  cin >> n;
  vector<ll> dp(n + 1, 1e18);
  dp[0] = 0;
  REP(i, n) {
    chmin(dp[i + 1], dp[i] + 1);
    ll c = 6;
    while (i + c <= n) {
      chmin(dp[i + c], dp[i] + 1);
      c *= 6;
    }
    c = 9;
    while (i + c <= n) {
      chmin(dp[i + c], dp[i] + 1);
      c *= 9;
    }
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include "iostream"
#include "sstream"
#include "string"
#include "cstring"
#include "cstdio"
#include "cstdlib"
#include "cmath"
#include "algorithm"
#include "utility"
#include "vector"
#include "map"
#include "unordered_map"
#include "set"
#include "bitset"
#include "unordered_set"
#include "list"
#include "deque"
#include "functional"
#include "ctime"
#include "cctype"
#include "tuple"
#include "memory"
#include "limits"
#include "climits"
#include "stack"
#include "forward_list"
#include "iterator"
#include "array"
#include "random"
#include "queue"


using namespace std;

// Functions
vector<string> StrSplit(string work, char delim, int rep);

template <typename T, typename Display> 
void print_vector(const vector<T>& vec, Display disp);

vector<string> StrSplit(string work, char delim, int rep = 0) {
    // rep == 1: Also insert empty strings
    vector<string> flds;
    if (!flds.empty()) flds.clear();  // empty vector if necessary
    string buf = "";
    int i = 0;
    while (i < work.size()) {
        if (work[i] != delim)
            buf += work[i];
        else if (rep == 1) {
            flds.push_back(buf);
            buf = "";
        } else if (!buf.empty()) {
            flds.push_back(buf);
            buf = "";
        }
        i++;
    }
    if (!buf.empty())
        flds.push_back(buf);
    cout << flds.size() << endl;
    return flds;
}

template <typename T, typename Display> 
void print_vector(const vector<T>& vec, Display disp) {
    for (const auto& val:vec) {
        disp(val);
    }
}

class Point {
public:
    typedef int pos_type;
    pos_type x,y;
    explicit Point(pos_type x_in, pos_type y_in):x(x_in), y(y_in) {}
    explicit Point():x(), y() {}
    bool operator < (const Point& other) const {
        if (x != other.x) return x < other.x;
        return y < other.y;
    }
    bool operator == (const Point& other) const {
        return x == other.x && y == other.y;
    }
    void print() {
        // for debug
        cout << "(" << x << "," << y << ")";
    }
};

#define MP make_pair
#define debug false
#define UNM unordered_map
#define UNS unordered_set
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define FOR_REV(i, a, b) for(int i = a; i >= b; --i)

typedef vector<int> VI;
typedef vector<VI> Mat;
typedef pair<int,int> PI;

class Solution {
public:
    void solve() {
        string str;
        while (cin >> str) {
            auto cpos = str.find('C');
            if (cpos == string::npos) {
                cout << "No" << endl;
                continue;
            }
            auto substr = str.substr(cpos + 1);
            auto fpos = substr.find('F');
            if (fpos == string::npos) {
                cout << "No" << endl;
                continue;
            }
            cout << "Yes" << endl;
        }
    }
};


int main() {
    Solution sol;
    sol.solve();
    return 0;
}


Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*, ops::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,q:usize,
      mut   stx:[(i64,i64,i64);n],
        d:[i64;q],
    }
    let mut rng = vec![];
    for (s, t, x) in stx {
        rng.push((s - x, 0, x));
        rng.push((t - x, -1, x));
    }
    for &d in d.iter() {
        rng.push((d, 1, 999999999i64));
    }
    rng.sort();
    let mut st = BTreeSet::new();
    for &(x, typ, val) in rng.iter() {
        if typ == 0 {
            st.insert(val);
        } else if typ == -1 {
            st.remove(&val);
        } else {
            println!(
                "{}",
                if let Some(x) = st.iter().next() {
                    *x
                } else {
                    -1
                }
            );
        }
    }
}


Measured memory_bytes: 30104
N = int(input())
A = list(map(int,input().split()))

A.sort()

M = 1000005
cnt = [0] * M

for i in range(N):
	if cnt[A[i]] != 0:
		cnt[A[i]] = 2
		continue
	for j in range(A[i],M,A[i]):
		cnt[j] += 1


ans = 0

for i in range(N):
	if cnt[A[i]] == 1:
		ans += 1

print(ans) 

Measured memory_bytes: 32240
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
    ll t=1;
//    cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        if(s[s.size()-1]=='s')
            s+="es";
        else
            s+='s';
        cout<<s<<endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int c,d,e,f,g;
    int i,j=0;
    for(i=a;i<=b;i++)
    {
        c=i%10;
        d=(i-c)%100/10;
        e=(i-c-(d*10))%1000/100;
        f=(i-c-(d*10)-e*100)%10000/1000;
        g=(i-c-(d*10)-e*100-f*1000)%100000/10000;
        if((c==g)&&(d==f))
            j++;
    }
    cout<<j<<endl;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  
  if ( a%3 == 0 || b%3 == 0 || (a+b)%3 == 0){
    cout << "Possible" << endl;
  }
  
  else {
    cout << "Impossible" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 1e9+7;

int main() {
	ll n,m;
	cin>>n>>m;
	vector < vector < ll > > dp(n, vector < ll > (m,0));
	vector < string > path(n);
	for(int i = 0 ; i < n ; i++)
		cin>>path[i];
		
	if(path[0][0] == '.')
		dp[0][0] = 1;
	
	for(int i = 0 ; i < n ; i++) {
		for(int j = 0 ; j < m ; j++) {
			if(path[i][j]=='.') {
				if(i>0 and j>0)
					dp[i][j] = dp[i-1][j]+dp[i][j-1];
				else if(i>0)
					dp[i][j] = dp[i-1][j];
				else if(j>0)
					dp[i][j] = dp[i][j-1];
			}
			else {
				dp[i][j] = 0;
			}
			dp[i][j]%=mod;
		}
	}
	
	cout<<dp[n-1][m-1];
	return 0;
}


Measured memory_bytes: 9088
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

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

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

int n, a[200001];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	for(int i = n-1; i >= 0; i -= 2){
		cout << a[i] << " ";
	}
	for(int i = n%2; i < n; i += 2){
		cout << a[i];
		if(i < n - 2)
			cout << " ";
	}
	cout << endl;
	
	return 0;
}

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

using namespace std;

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);

  int n; cin >> n;
  double p[n];
  for(int i = 0; i<n; ++i) {
    cin >> p[i];
  }

  // dp[i] represents the probability that after x rolls,
  // there are i heads
  vector<double> dp(n+1, 0), dpswap(n+1);
  dp[0] = 1-p[0];
  dp[1] = p[0];

  for(int x = 1; x<n; ++x) {
    dpswap.assign(n+1, 0);

    for(int i = 0; i<n; ++i) {
      dpswap[i] += dp[i] * (1-p[x]);
      dpswap[i+1] += dp[i] * (p[x]);
    }

    swap(dp, dpswap);
  }

  double ret = 0;
  for(int i = (n+1)/2; i<=n; ++i) {
    ret += dp[i];
  }
  cout << fixed << setprecision(10) << ret << endl;
}


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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<int> B(N);
  for (int i = 0; i < N; i++) {
    int cnt = 0;
    while (A[i] > 0) {
      if (A[i] % 2 == 1)
        break;
      A[i] /= 2;
      cnt++;
    }
    B[i] = cnt;
  }
  int ans = INT_MAX;
  for (int i = 0; i < N; i++) {
    ans = min(ans, B[i]);
  }
  cout << ans << endl;
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a){cout<<((a)?"Yes":"No")<<endl;}
void YESNO(int a){cout<<((a)?"YES":"NO")<<endl;}
void AorB(int a,string b,string c){cout<<((a)?b:c)<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

bool comp(tuple<string,int,int> a, tuple<string,int,int> b) {
        if(get<0>(a)==get<0>(b)) return get<1>(a) > get<1>(b);
        else return get<0>(a) < get<0>(b);
}

signed main(){start();
    int n;
    cin>>n;
    vector<tuple<string,int,int>> v;
    REP(i,0,n){
        string s;
        int a;
        cin>>s>>a;
        v.pb(mt(s,a,i+1));
    }
    sort(ALL(v),comp);
    REP(i,0,n) cout<<(get<2>(v[i]))<<endl;
    return 0;
}


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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
typedef vector<int> vi;typedef vector<vi> vvi;typedef pair<int,int> pii;typedef vector<pii> vpii;
typedef long long ll;

void Main() {
  int a, b;
  scanf("%d%d", &a, &b);
  if (a <= 0 && 0 <= b) {
    puts("Zero");
    return;
  }

  if (a < 0) {
    b = min(b+1, 0);
    if ((b + a) % 2) {
      puts("Negative");
    }
    else {
      puts("Positive");
    }
  }
  else {
    puts("Positive");
  }
}
int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }


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

using namespace std;
using ll = long long;

int main()
{
    int n,k = 0;
    cin >> n >> k;
    
    int s[n] = {0};
    int cnt = 0;
    rep(i,k){
        int d = 0;
        cin >> d;
        rep(i,d){
            int t;
            cin >> t;
            if(s[t-1] == 0) cnt++;
            s[t-1]++;
        }
    }

    // 出力
    cout << n-cnt << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007
#define ll long long int
#define pi pair <ll,ll>
#define vi vector <ll>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define SQ(a) (a)*(a)
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>       //greater_equal<ll> or less<ll>
// find_by_key()   order_of_key()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
/*bool comp(string a, string b) {
if (a.size() != b.size()) return a.size() < b.size();
return a < b;
}*/


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    /*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll i,j,k,n,m,t,l=0,x,prev=0,max1=0,flag=0,cnt=0,y,min1,q;
    string s;
    cin>>s;
    if(s[1]=='B'){
        cout<<"ARC"<<endl;
    }
    else{
        cout<<"ABC"<<endl;
    }






    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define int             long long
#define no_of_test(x)        int x; cin>>x; while(x--)
#define inf             1e18
const int mod = 1e9 + 7;
void very_fast()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int gcd(int a, int b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}
int binary_exponentation(int a, int b)
{
	int ret = 1;
	while (b)
	{
		if (b & 1) ret = (ret * a) % mod;
		b >>= 1;
		a = (a * a) % mod;
	}
	return ret;
}


int32_t main()
{
	very_fast();
	//no_of_test(x)
	{
		int d, t, s;
		cin >> d >> t >> s;
		if (t * s >= d)
		{
			cout << "Yes" << "\n";
		}
		else
		{
			cout << "No" << "\n";
		}
	}
	return 0;
}


Measured memory_bytes: 3648
while 1:
        c=list(raw_input())
        o=""
        if c[0]=="-" and len(c)==1:
                break
        m=int(raw_input())
        for i in range(m):
                h=int(raw_input())
                c=list(c[h:]+c[:h])
        for i in range(len(c)):
                o+=c[i]
        print o

Measured memory_bytes: 4228
def main():
    n = int(input())
    s = input()
    # Positions for each character.
    rs = s.count('R')
    gs = s.count('G')
    bs = s.count('B')
    ans = rs * gs * bs

    # `i, j` を決めれば， `k = j + (j-i)`。 `j-i = k-j` の組合わせを引く。
    for j in range(n):
        for i in range(j):  # i < j
            k = j + (j - i)
            if k >= n:
                continue
            if s[i] == s[j]:
                continue
            if s[i] == s[k]:
                continue
            if s[j] == s[k]:
                continue

            # `j-i = k-j` かつRGB。
            ans -= 1

    return ans


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


Measured memory_bytes: 73604
#include <bits/stdc++.h>
#define re return
#define pb push_back
#define po pop_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define ss second.second
#define sf second.first
#define ff first.first
#define fs first.second
#define si size
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define pi 3.14159265359
#define er erase
#define in insert
#define em empty
#define ft front
#define fo(i,n) for(i = 0; i < n; i++)
#define ro(i,n) for(i = n - 1; i >= 0; i--)
#define fr(i,j,n) for(i = j; i < n; i++)
#define rf(i,j,n) for(i=n-1;i>=j;i--)
typedef std::vector<int> vi;
typedef std::vector<vi> vvi;
typedef std::pair<int,int> ii;
typedef std::vector<ii> vii;
typedef std::vector<std::string> vs;
typedef double dl;
typedef long double ld;
typedef long long ll;
typedef std::pair<ll, ll> pll;
typedef std::vector<ll> vll;
#define filename ""
using namespace std;
    int a[(int)1e5],n;
bool check(ll c)
{
    int i;
    fo(i,n)
    {
        c-=c%a[i];
    }
    if (c>=2) re 1;
    re 0;
}
bool check1(ll c)
{
    int i;
    fo(i,n)
    {
        c-=c%a[i];
    }
    if (c<=2) re 1;
    re 0;
}
int main()
{
    /*
    freopen(filename".in","r",stdin);
    freopen(filename".out","w",stdout);
    */
    /*
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    */
    int i;
    cin>>n;
    fo(i,n)
    {
        scanf("%d",&a[i]);
    }
    ll z=0,x=(ll)1e18,o1=-1,c;
    while(z<=x)
    {
        c=(z+x)/2;
        if (check(c))
        {
            o1=c;
            x=c-1;
        }
        else
        {
            z=c+1;
        }
    }
    z=0;
    ll o2=-1;
    x=(ll)1e18;
    while(z<=x)
    {
        c=(z+x)/2;
        if (check1(c))
        {
            o2=c;
            z=c+1;
        }
        else
        {
            x=c-1;
        }
    }
    if (o1>o2) {cout<<-1<<'\n';re 0;}
    cout<<o1<<' ';
    cout<<o2<<'\n';
    re 0;
}


Measured memory_bytes: 640
/**
 *		author:  zvm
 *		created: 25.09.2020 17:23:20
**/

#include <bits/stdc++.h>

using namespace std ;

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

	string s ;
	cin >> s ;

	auto evaluate = [&]( string s ) {
		stringstream ss{s.substr(1)};
		char op ;
		int val, res = s[0]-'0' ;
		while( ss >> op >> val ) {
			res = ( op == '+' ? res+val : res-val );
		}
		return !res ;
	};

	for( int i = 0 ; i < 8 ; ++i ) {
		string t{s[0]};
		for( int j = 0 ; j < 3 ; ++j ) {
			if( i&(1<<j) ) {
				t += "-" ;
			}
			else {
				t += "+" ;
			}
			t.push_back(s[j+1]);
		}
		t += "=7" ;
		if( evaluate(t) ) {
			cout << t << endl ;
			return 0 ;
		}
	}
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reve(a) reverse(a.begin(), a.end())
#define PI 3.14159265359
typedef long long ll;
const ll MOD = 1e9+7;

/*ll gcd(ll a, ll b){
  if(b==0) return a;
  return gcd(b, a%b);
}*/
/*ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}*/

/*ll lcm(ll a, ll b){
  ll g = gcd(a, b);
  b /= g;
  a *= b;
  return a;
}*/
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


int main(){
  int n, m, a, b; cin >> n >> m;
vector<vector<int>> D(n, vector<int>(n));
  rep(i, m){
    cin >> a >> b;
    D[a-1][b-1]=1; D[b-1][a-1] = 1;
  }
  vector<int> A(n);
  rep(i, n) A[i]=i;
  int ans=0;
  do{
    for(int i=1; i<n; i++){
      if(A[0]!=0) break;
      if(D[A[i-1]][A[i]]!=1) break;
      else if(i==n-1) ans++;
    }
  }while(next_permutation(A.begin(), A.end()));
  cout << ans << endl;
}

Measured memory_bytes: 256