akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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

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

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    int N;
    vector<int> primes;

    void input() {
        cin >> N;
        for (int i = 2; i < N; ++i) {
            bool flag = true;
            for (int j = 2; j * j <= i; ++j) {
                if (i % j == 0) flag = false;
            }
            if (flag) primes.push_back(i);
        }
    }

    int compute(int num, int div) {
        int ret = 0;
        while (num > 0) {
            ret += num / div;
            num /= div;
        }
        return ret;
    }

    void solve() {
        input();
        int ans = 0;

        for (auto ei: primes) {
            if (compute(N, ei) >= 74) ans++;
            for (auto treeone: primes) {
                if (ei == treeone) continue;
                if (compute(N, ei) >= 2 && compute(N, treeone) >= 24) {
                    ans++;
                }

                if (compute(N, ei) >= 4 && compute(N, treeone) >= 14) {
                    ans++;
                }

                for (auto tapione: primes) {
                    if (ei != tapione && treeone < tapione && compute(N, ei) >= 2 && compute(N, treeone) >= 4 &&
                        compute(N, tapione) >= 4) {
                        ans++;
                    }
                }
            }
        }
        cout << ans << endl;


    }
};


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

    Solve().solve();


    return 0;
}


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

int main() {
  int n;
  cin >> n;
  std::vector<int> vec(n);
  std::vector<int> d(n);
  rep(i,n) {
    int x;
    cin >> x;
    x--;
    vec.at(i) = x;
    d.at(i) = x;
  }
  sort(d.begin(), d.end());
  for (auto i : d) {
    auto num = find(vec.begin(), vec.end(), i);
    // イテレータだと1,2,3となってしまう
    const int wanted_index = std::distance(vec.begin(), num);
    cout << wanted_index+1 << " ";
  }
  cout << endl;

}


Measured memory_bytes: 4044
#include <iostream>

using namespace std;

int main(){
  int arr[13]={0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1}, x, y;
  cin >> x >> y;
  cout << (arr[x]==arr[y] ? "Yes": "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#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 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

signed main() {
  int n, x, y;
  cin >> n >> x >> y;
  Graph G(n);

  for(int i = 0; i < n - 1; i++) {
    G[i].push_back(i + 1);
    G[i + 1].push_back(i);
  }
  G[x - 1].push_back(y - 1);
  G[y - 1].push_back(x - 1);

  int d[n][n];

  for(int i = 0; i < n; i++) {
    vector<int> dist(n, -1);
    queue<int> que;

    dist[i] = 0;
    que.push(i);

    // BFS
    while(!que.empty()) {
      int v = que.front();
      que.pop();
      for(int nv : G[v]) {
        if(dist[nv] != -1) continue;
        dist[nv] = dist[v] + 1;
        que.push(nv);
      }
    }

    for(int j = 0; j < n; j++) d[i][j] = dist[j];
  }

  int cnt[n - 1] = {0};
  for(int i = 0; i < n; i++) {
    for(int j = i + 1; j < n; j++) {
      cnt[d[i][j] - 1]++;
    }
  }

  for(int k = 1; k < n; k++) {
    cout << cnt[k - 1] << endl;
  }
  return 0;
}


Measured memory_bytes: 16000
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll K;
string S;

/*
long long modpow(long long a, long long b) {
  a %= MOD;
  long long res = 1;
  while (b) {
    if (b & 1) {
      res = (res * a) % MOD;
    }
    a = (a * a) % MOD;
    b >>= 1;
  }
  return res;
}
*/

long long modpow(long long a, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return res;
}

const int MAX = 3010101;

long long fac[MAX], finv[MAX], inv[MAX];

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

long long binom(ll n, ll k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  //
  binom_init();
  cin >> K;
  cin >> S;
  ll ans = 0;
  for (ll x = 0; x <= K; ++x) {
    ll p = modpow(26, K - x) * modpow(25, x) % MOD;
    ll s = S.size();
    ll c = p * binom(s + x - 1, s - 1) % MOD;
    ans += c;
    ans %= MOD;
    // cout << ans << endl;
  }
  cout << ans << endl;
}


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

const int N=1e5+10;

int fa[N];

int find_fa(int u){
    return u==fa[u]?u:(fa[u]=find_fa(fa[u]));
}

int main(){
    for(int i=1;i<N;i++) fa[i]=i;
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        int u,v,w;
        scanf("%d%d%d",&u,&v,&w);
        u=find_fa(u);
        v=find_fa(v);
        fa[u]=v;
    }
    set<int>st;
    for(int i=1;i<=n;i++) st.insert(find_fa(i));
    cout<<st.size()<<endl;

    return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define N 100020
#define ll long long
using namespace std;
inline int read(){
  int x=0,f=1;char ch=getchar();
  while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
  while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
  return f?x:-x;
}

ll a[N], s[N], g[N];

ll calc(int n, int k) {
  for (int i = 1; i <= n; ++ i) {
    s[i] = s[i - 1] + a[i];
    g[i] = g[i - 1] + (a[i] > 0 ? a[i] : 0);
  }

  ll ans = 0;
  for (int i = k; i <= n; ++ i) {
    ll rm = g[n] - g[i] + g[i - k];
    ll rf = s[i] - s[i - k];
    ans = max(ans, rm + (rf > 0 ? rf : 0));
  }

  return ans;
}

int main(int argc, char const *argv[]) {
  int n = read(), k = read();
  for (int i = 1; i <= n; ++ i) {
    a[i] = read();
  }

  ll ans = calc(n, k);

  printf("%lld\n", ans);

  return 0;
}

Measured memory_bytes: 2560
class Dice(object):
    def __init__(self, s1, s2, s3, s4, s5, s6):
        self.s1 = s1
        self.s2 = s2
        self.s3 = s3
        self.s4 = s4
        self.s5 = s5
        self.s6 = s6
    def east(self):
        prev_s6 = self.s6
        self.s6 = self.s3
        self.s3 = self.s1
        self.s1 = self.s4
        self.s4 = prev_s6
    def west(self):
        prev_s6 = self.s6
        self.s6 = self.s4
        self.s4 = self.s1
        self.s1 = self.s3
        self.s3 = prev_s6
    def north(self):
        prev_s6 = self.s6
        self.s6 = self.s5
        self.s5 = self.s1
        self.s1 = self.s2
        self.s2 = prev_s6
    def south(self):
        prev_s6 = self.s6
        self.s6 = self.s2
        self.s2 = self.s1
        self.s1 = self.s5
        self.s5 = prev_s6
    def rotate(self):
        prev_s2 = self.s2
        self.s2 = self.s4
        self.s4 = self.s5
        self.s5 = self.s3
        self.s3 = prev_s2
    def top(self):
        return self.s1
    def front(self):
        return self.s2
    def right(self):
        return self.s3

    def isSameDice(self, anotherDice):
        if self.s1 == anotherDice.s1 and \
           self.s2 == anotherDice.s2 and \
           self.s3 == anotherDice.s3 and \
           self.s4 == anotherDice.s4 and \
           self.s5 == anotherDice.s5 and \
           self.s6 == anotherDice.s6:
            return True
        return False


s1, s2, s3, s4, s5, s6 = map(int, input().split())
dice1 = Dice(s1, s2, s3, s4, s5, s6)
s1, s2, s3, s4, s5, s6 = map(int, input().split())
dice2 = Dice(s1, s2, s3, s4, s5, s6)

flag = False
for j in range(6):
    if j % 2 == 0:
        dice2.north()
    else:
        dice2.west()

    for k in range(4):
        dice2.rotate()
        if dice2.isSameDice(dice1):
            flag = True
            break
    if flag:
        break

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 6804
#include <stdio.h>
int main()
{
	int a,b;
	scanf("%d %d", &a, &b);
	if (a > b){
		printf("a > b\n");
	}
	else if (a == b){
		printf("a == b\n");
	}
	else{
		printf("a < b\n");
	}
	return 0;
}


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

int main(){
    int n, m, ans = 0;
    cin >> n >> m;
    map<int, int> mp;
    for(int i = 0; i < m; i++){
        int l, r;
        cin >> l >> r;
        mp[l]++;
        mp[r + 1]--;
    }
    if(mp[1] == m) ans++;
    for(int i = 1; i <= n; i++){
        mp[i + 1] += mp[i];
        if(mp[i + 1] == m) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
N,X=map(int,input().split())
PILE=[2**(i+2)-3 for i in range(51)]
def dp(n,x):#レベルnバーガーのx層目まで
    if x==0:
        return 0
    if n==0 and x==1:
        return 1
    if n>=1:
        bp=PILE[n-1]
        if x==1:
            return 0
        elif x<=1+bp:
            return dp(n-1,x-1)
        elif x==2+bp:
            return 1+dp(n-1,bp)
        elif 2+bp<x<=2+2*bp:
            return 1+dp(n-1,bp)+dp(n-1,x-2-bp)
        elif x==3+2*bp:
            return 1+dp(n-1,bp)*2

print(dp(N,X))

Measured memory_bytes: 3064
N = int(input())
L = [ [] for _ in range(N)]
for i in range(N):
    num = int(input())
    for j in range(num):
        person, state = map(int,input().split())
        L[i].append([person - 1, state])

# 正直者の最大数の初期化
honest = 0

for i in range(1,2**N):
    flag = True
    for j in range(N):
        if (i>>j)&1 == 1: # j番目が正直者と仮定したとき
            for x, y in L[j]:
                if (i>>x)&1 != y: # 矛盾を発見(正直者のjといっていることが違う)
                    flag = False
                    break # 矛盾を見つけたので、それ以降のjの証言は無視
            if not flag:
                break
    if flag:
        honest = max(honest, bin(i).count("1"))

print(honest)

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

int main(){
  vector<char> S(6);
  
  for(int i=0;i<6;i++){
    cin >> S.at(i);
  }
  
  if(S.at(2)==S.at(3)){
    if(S.at(4)==S.at(5)){
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys

N = int(input())
*A, = map(int, input().split())


D = {}

for i in range(N):
    e = A[i]
    if not(e in D):
        D[e] = 1
    else:
        D[e] = D[e] + 1

for key in D:
    if D[key]>=2:
        print("NO")
        sys.exit()
print("YES")

Measured memory_bytes: 32948
#include<iostream>

using namespace std;

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

	int n; cin >> n;
	int a[n];
	bool ok = true;
	for(int i=0; i<n; i++){
		cin >> a[i];
		if(a[i]%2==0){
			if(!(a[i]%3==0 or a[i]%5==0)){
				ok = false;
				break;
			}
		}
	}
	if(ok) cout << "APPROVED";
	else cout << "DENIED";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  siz = N.size();
  N = "@" + N; // sentinel

  // dp[i][j][k] := i桁目まで見た時, smaller flagがjで,
  // 0でない数字がk個であるような数の総数
  long long dp[102][2][102] = {0};
  dp[0][0][0] = 1;

  for (int i = 1; i <= siz; i++) {
    for (int smaller = 0; smaller < 2; smaller++) {
      for (int k = 0; k <= i; k++) {
        // smaller が flag が立っている, すなわち
        // それまで見ていた数字が N より小さいならば
        if (smaller == 1) {
          // 現在の桁の数字は何でも良い
          for (int c = 0; c <= 9; c++) {
            // 0以外を選ぶと0出ない数の総数が増える
            if (c != 0) {
              dp[i][1][k + 1] += dp[i - 1][1][k];
            } else {
              dp[i][1][k] += dp[i - 1][1][k];
            }
          }
        }
        // smaller が flag が立っていない, すなわち
        // それまで見ていた数字が N と一致するならば
        if (smaller == 0) {
          int cur = N[i] - '0';
          if (cur == 0) {
            dp[i][0][k] += dp[i - 1][0][k];
          } else {
            for (int c = 0; c <= cur; c++) {
              if (c == 0) {
                dp[i][1][k] += dp[i - 1][0][k];
              } else if (c == cur) {
                dp[i][0][k + 1] += dp[i - 1][0][k];
              } else {
                dp[i][1][k + 1] += dp[i - 1][0][k];
              }
            }
          }
        }
      }
    }
  }

  cout << dp[siz][0][K] + dp[siz][1][K] << endl;

  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
  char s[100001];
  scanf("%s",s);
  
  int a=0;
  int x=0,y=0;
  
  while(s[a]!='\0')
  {
    if(a%2==0)
    {
      if(s[a]=='1')
        x++;
      else  if(s[a]=='0')
        y++;
    }
    else if(a%2==1)
    {
      if(s[a]=='0')
        x++;
      else  if(s[a]=='1')
        y++;
    }
    a++;
  }
    if(x>y)
      x=y;
    printf("%d",x);
    return 0;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

int t[100010];

int main(){
  int n;
  cin >> n;
  rep(i,n) {
    int a;
    cin >> a;
    t[a]++;
  }
  int res = 0;
  rep(i,100001) {
    res = max(res, t[i-1] + t[i] + t[i+1]);
  }
  cout << res << endl;
  return 0;
}

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

sys.setrecursionlimit(10**9)


def dfs(v, graph, memo):
    if v in memo:
        return memo[v]

    if graph[v]:
        res = float("-inf")
        for child in graph[v]:
            res = max(res, dfs(child, graph, memo) + 1)
        memo[v] = res
    else:
        res = 0
        memo[v] = 0

    return memo[v]


def solve(N: int, M: int, x: "List[int]", y: "List[int]"):
    graph = [[] for _ in range(N)]
    for i in range(M):
        graph[x[i]-1].append(y[i]-1)

    memo = {}

    res = float("-inf")
    for i in range(N):
        res = max(res, dfs(i, graph, memo))
    print(res)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    x = [int()] * (M)  # type: "List[int]"
    y = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, M, x, y)


if __name__ == '__main__':
    main()


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

int main() {
  int N ,count;
  int c = 0;
  cin >> N;
  
   for (int i = 0; i < N; i++) {
  string S;
  cin >> S;
    
 if (S == "Y") {
   count = 1;
 }
 else {
   count = 0;
 }
       
 c = c + count;
   }
 if (c >= 1) {
 cout << "Four" <<endl;
 }
 else if (c == 0) {
 cout << "Three" <<endl;
 }
}

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

using namespace std;


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

	string firstPart = "";
	string secondPart = "";

	firstPart += s[0];
	firstPart += s[1];
	secondPart += s[2];
	secondPart += s[3];

	int first = stoi(firstPart);
	int second = stoi(secondPart);

	bool isFirst = false;
	bool isSecond = false;

	if (first >= 0 && first <= 99 && second >= 1 && second <= 12) isFirst = true;

	if (first >= 1 && first <= 12 && second >= 0 && second <= 99) isSecond = true;

	if (isFirst && isSecond) cout << "AMBIGUOUS";
	else if (isFirst) cout << "YYMM";
	else if (isSecond) cout << "MMYY";
	else cout << "NA";
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        R: i32,
    }

    println!(
        "{}",
        if R < 1200 {
            "ABC"
        } else if R < 2800 {
            "ARC"
        } else {
            "AGC"
        }
    );
}


Measured memory_bytes: 4352
#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)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int A, B; string S;
//---------------------------------------------------------------------------------------------------
#define yes "Yes"
#define no "No"
int check(char c) { return '0' <= c and c <= '9'; }
string solve() {
    rep(i, 0, A) if (!check(S[i])) return no;
    if (S[A] != '-') return no;
    rep(i, A + 1, A + B + 1) if (!check(S[i])) return no;
    return yes;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> A >> B >> S;
    cout << solve() << endl;
}


Measured memory_bytes: 256
// Problem : B - 123 Triangle
// Contest : AtCoder - AtCoder Grand Contest 043
// URL : https://atcoder.jp/contests/agc043/tasks/agc043_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

void doOnce(const vector<int>& a, vector<int>& v) {
	for (int i = 0; i < a.size() - 1; i++) {
		v[i] = abs(a[i] - a[i + 1]);
	}
}

void computeTwos(vector<int>& twos) {
	int n = twos.size();
	for (int i = 2; i < n; i *= 2) {
		for (int j = i; j < n; j += i) {
			twos[j]++;
		}
	}
	for (int i = 1; i < n; i++) {
		twos[i] += twos[i - 1];
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N;
	cin >> N;
	string s;
	cin >> s;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		a[i] = s[i] - '0';
	}
	vector<int> v(N - 1);
	doOnce(a, v);
	
	vector<int> twos(N + 1);
	computeTwos(twos);
	
	auto chooseOdd = [&](int n) {
		return twos[N - 2] - twos[n] - twos[N - 2 - n] == 0;
	};
	
	auto getXored = [&](int d) {
		int xored = 0;
		for (int i = 0; i < N - 1; i++) {
			if (chooseOdd(i)) {
				xored ^= v[i]/d;
			} else {
				xored ^= 0;
			}
		}
		return xored;
	};
	
	if (getXored(1) & 1) {
		cout << "1\n";
		return 0;
	}
	
	for (int i = 0; i < N - 1; i++) {
		if (v[i] == 1) {
			cout << "0\n";
			return 0;
		}
	}
	
	if (getXored(2) & 1) {
		cout << "2\n";
	} else {
		cout << "0\n";
	}
}


























Measured memory_bytes: 16116
n,x,y=map(int,input().split())
ans=[0]*(n-1)
x-=1
y-=1

def d(i,j):
  return min(j-i, abs(x-i)+abs(y-j)+1)

for i in range(n-1):
  for j in range(i+1, n):
    ans[d(i,j)-1] +=1

for i in range(n-1):
  print(ans[i])
 

Measured memory_bytes: 3444
using System;
using System.IO;
using System.Text;
using static Scanner;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Solve();
        Console.Out.Flush();
    }
    static void Solve() {
        var N = ScanInt();
        var B = ScanIntArray(N - 1);
        var answer = B[0] + B[^1];
        for (int i = N - 2; i >= 1; i--) {
            answer += Math.Min(B[i], B[i - 1]);
        }
        Console.WriteLine(answer);
    }
}

public static class Scanner
{
    static readonly Stream stream = Console.OpenStandardInput();
    static readonly byte[] buffer = new byte[1024];
    static int length, p;
    static bool isEof;
    private static byte ConsoleIn() {
        if (isEof) return 0;
        if (p < length) return buffer[p++];
        p = 0;
        if ((length = stream.Read(buffer, 0, 1024)) > 0) return buffer[p++];
        isEof = true;
        return 0;
    }
    public static char GetChar() {
        var by = ConsoleIn();
        while ((by < '!' || '~' < by) && !isEof) by = ConsoleIn();
        return (char) by;
    }
    public static int ScanInt() {
        var temp = 0;
        for (var ch = GetChar(); '0' <= ch && ch <= '9'; ch = (char) ConsoleIn()) {
            temp = temp * 10 + ch - '0';
        }
        return temp;
    }
    public static int[] ScanIntArray(int len, int add = 0) {
        var array = new int[len];
        for (int i = 0; i < len; i++) array[i] = ScanInt() + add;
        return array;
    }
}

Measured memory_bytes: 23748
#include <stdio.h>
#include<string.h>
int main(void){
	int N,M;
	char s[100][11];
	char t[100][11];
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%s",&s[i]);
	}
	scanf("%d",&M);
	for(int i=0;i<M;i++){
		scanf("%s",&t[i]);
	}
	int max = 0;
	int X	= 0;
	for(int i=0;i<N;i++){
		X=1;
		for(int j=i+1;j<N;j++){
			if( strcmp(s[i],s[j])==0){
				X++;
			}
		}
		for(int j=0;j<M;j++){
			if( strcmp(s[i],t[j]) ==0){
				X--;
			}
		}
		if( max < X){
			max = X;
		}		
	}	
	printf("%d",max);	
	return 0;
}

Measured memory_bytes: 128
from collections import deque
k=int(input())
stack = deque([1,2,3,4,5,6,7,8,9])

def lunlun():
    cnt=0
    while True:
        now = stack.popleft()
        cnt += 1
        if cnt == k: return now
        s = str(now)
        for i in range(-1,2):
            temp=int(s[-1]) + i 
            if temp>=0 and temp<10: 
                temp1=int(s + str(temp))
                stack.append(temp1)
print(lunlun())

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

int gcd(int x, int y) {
    if (x < y) swap(x, y);
    int tmp;
    while (y) {
        tmp = y;
        y = x % y;
        x = tmp;
    }

    return x;
}

int n, k;
vector<int> a;

int main() {
    cin >> n >> k;
    a.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    sort(a.begin(), a.end(), greater<int>());

    if (k > a[0]) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    
    int g = gcd(a[0], a[1]);

    for (int i = 2; i < n; ++i) {
        g = gcd(g, a[i]);
    }

    if (k % g == 0) {
        cout << "POSSIBLE" << endl;
    }
    else {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}

Measured memory_bytes: 640
def main():
    N, Q = map(int, input().split())
    S = input()

    # maeshori
    count = [0] * len(S)

    for i in range(len(S)-1):
        if S[i]=="A" and S[i+1]=="C":
            count[i+1] = 1

    # calc cumsum
    for i in range(len(S)-1):
        count[i+1] += count[i]

    for i in range(Q):
        l, r = map(int, input().split())
        print(count[r-1] - count[l-1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 9460
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main() {
    unsigned long long a, b;
    cin >> a >> b;
    unsigned long long n = b;
    size_t digits = 0;
    while (n > 0) {
        n = n / 10;
        ++digits;
    }
    vector<unsigned long long> square_numbers;
    unsigned long long index = 1;
    unsigned long long square = 1;
    while (square <= 100100) {
        square_numbers.push_back(square);
        ++index;
        square = index * index;
    }
    unsigned long long sum = a * static_cast<unsigned long long>(pow(10, digits)) + b;
    bool is_square = false;
    for (const auto& v : square_numbers) {
        if (sum ==  v) {
            is_square = true;
            break;
        }
    }
    cout << (is_square ? "Yes" : "No") << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 384
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner input = new Scanner(System.in);
        
        int N = input.nextInt();
        int L = input.nextInt();
        
        String a[] = new String[N];
        String s;
        for(int i = 0; i <N; i++){
            s = input.next();
            if(s.length()==L)
                a[i]=s;
        }
        Arrays.sort(a);
        for(int i = 0; i <a.length; i++)
             System.out.print(a[i]);
        
        System.out.println();
    }
}


Measured memory_bytes: 29684
from heapq import heapify, heappush, heappop
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
ABs = [tuple(map(int, input().split())) for _ in range(N)]

ABs.sort()

PQ = []
iAB = 0
ans = 0
for rest in range(1, M+1):
    while iAB < N and ABs[iAB][0] <= rest:
        heappush(PQ, -ABs[iAB][1])
        iAB += 1
    if PQ:
        B = -heappop(PQ)
        ans += B

print(ans)


Measured memory_bytes: 20772
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n, m; cin >> n >> m;
    vi a(n);
    rep(i, m){
        ll x, y; cin >> x >> y; x--; y--;
        a[x]++; a[y]++;
    }

    for(auto p: a) cout << p << endl;
}

Measured memory_bytes: 256
def main():
    height, width, strawberries = map(int, input().split())
    cake = [list(input()) for _ in range(height)]
    answer = [[0 for _ in range(width)] for _ in range(height)]
    strawberry_num = 0
    for i in range(height):
        is_exist_strawberry = False
        for j in range(width):
            if cake[i][j] == "#":
                is_exist_strawberry = True
                strawberry_num += 1
                answer[i][j] = strawberry_num
            elif is_exist_strawberry:
                answer[i][j] = strawberry_num
    row_with_strawberry = -1
    for i in range(height):
        before_index = 0
        for j in range(-1, -width - 1, -1):
            if answer[i][j] == 0:
                answer[i][j] = before_index
            else:
                before_index = answer[i][j]
                if row_with_strawberry == -1:
                    row_with_strawberry = i
    for i in range(row_with_strawberry):
        answer[i] = answer[row_with_strawberry]
    for i in range(row_with_strawberry, height):
        if answer[i][0] == 0:
            answer[i] = answer[i - 1]
    for ans in answer:
        print(" ".join(map(str, ans)))


if __name__ == '__main__':
    main()



Measured memory_bytes: 7924
//author:luckYrat(twitter:@luckYrat_)
//<ここに一言>

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
	double L;cin>>L;
	cout << fixed << setprecision(10) << L/3.0*L/3.0*L/3.0 << endl;
}

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

int main(void)
{
	int n; //カードの枚数
	int taro_point=0,hanako_point=0;
	int com;
	char str_taro[99],str_hanako[99];
	
	scanf("%d", &n);
	
	for(int i=0;i<n;i++){
		scanf("%s %s", str_taro, str_hanako);
		com = strcmp(str_taro, str_hanako);
		if(com==0){
			taro_point += 1;
			hanako_point += 1;
		}else if(com>0){
			taro_point += 3;
		}else{
			hanako_point += 3;
		}
	}
	
	printf("%d %d\n", taro_point, hanako_point);
	
	return 0;
}


Measured memory_bytes: 2092
#include<cstdio>
#include<vector>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

const int INF=1<<29;

class union_find{
	vector<int> a;
public:
	union_find(int n):a(n,-1){}
	int find(int x){
		if(a[x]<0) return x;
		return a[x]=find(a[x]);
	}
	void unite(int x,int y){
		x=find(x),y=find(y);
		if(x!=y){ a[x]+=a[y]; a[y]=x; }
	}
};

int main(){
	int T; scanf("%d",&T);
	while(T--){
		int n,m,natsume,renon; scanf("%d%d%d%d",&n,&m,&natsume,&renon);

		static vector<int> G[100001]; // Natsume graph
		rep(u,n+1) G[u].clear();

		union_find U(n+1);
		rep(i,m){
			int u,v;
			char c; scanf("%d%d %c",&u,&v,&c);
			if(c=='N'){
				G[u].push_back(v);
				G[v].push_back(u);
			}
			else U.unite(u,v);
		}

		if(U.find(renon)==U.find(0)){ puts("0"); continue; }

		static int d1[100001]; // d1[u] := dist(Natsume,u)
		rep(u,n+1) d1[u]=INF;
		{
			int head=0,tail=0;
			static int Q[100001];
			d1[natsume]=0;
			Q[tail++]=natsume;
			while(head<tail){
				int u=Q[head++];
				rep(i,G[u].size()){
					int v=G[u][i];
					if(d1[v]==INF) d1[v]=d1[u]+1, Q[tail++]=v;
				}
			}
		}

		static int d2[100001]; // d2[u] := dist(Renon,u)
		rep(u,n+1) d2[u]=INF;
		{
			int head=0,tail=0;
			static int Q[100001];
			rep(u,n+1) if(U.find(u)==U.find(renon)) d2[u]=0, Q[tail++]=u;
			while(head<tail){
				int u=Q[head++];
				rep(i,G[u].size()){
					int v=G[u][i];
					if(d2[v]==INF) d2[v]=d2[u]+1, Q[tail++]=v;
				}
			}
		}

		static int d3[100001]; // d3[u] := dist(summer,u)
		rep(u,n+1) d3[u]=INF;
		{
			int head=0,tail=0;
			static int Q[100001];
			rep(u,n+1) if(U.find(u)==U.find(0)) d3[u]=0, Q[tail++]=u;
			while(head<tail){
				int u=Q[head++];
				rep(i,G[u].size()){
					int v=G[u][i];
					if(d3[v]==INF) d3[v]=d3[u]+1, Q[tail++]=v;
				}
			}
		}

		int ans=INF;
		rep(u,n+1) ans=min(ans,d1[u]+d2[u]+d3[u]);
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 9516
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

#define pb push_back
#define fi first
#define se second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int inf = 1e9;

template <class T>
istream& operator>>(istream& ss, vector<T>& v) {
    for (int i = 0; i < v.size(); i++) ss >> v[i];
    return ss;
}

template <class T> 
ostream& operator<<(ostream& ss, const vector<T>& v) {
    for (int i = 0; i < v.size(); i++) ss << v[i] << ' ';
    return ss;
}

void solve(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int t = min(a, k);
    a -= t;
    k -= t;
    int y = min(b, k);
    b -= k;
    k -= y;
    int r = min(c, k);
    cout << t - r;
}

int main(){
    int t = 1;
    //cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
}

Measured memory_bytes: 3632
def main():
    k,n=map(int,input().split())
    a=list(map(int,input().split()))
    d=[0]*n
    for i in range(1,n):
        d[i]=a[i]-a[i-1]
    d[0]=a[0]+k-a[n-1]
    d.sort()
    print(k-d[-1])

if __name__ == '__main__':
    main()

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

#define         eps         10e-9
#define         pi          2*acos(0.0)
#define         P1          1e9+7
#define         P2          1e9+9
#define         lli         long long int

using namespace std;

///ISNNJB

/**int fx[]={+1,-1,+0,+0};
int fy[]={+0,+0,+1,-1};
int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};*/

int main()
{
    /***freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    string s;
    cin>>n;
    cin>>s;

    if(n<3200)
        cout<<"red\n";
    else
        cout<<s<<"\n";

    return 0;
}


Measured memory_bytes: 256
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// #include<deque>
// #include<multiset>
// #include<bitset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n;
  cin >> n;
  multiset<int> mt;
  int a;
  for(int i = 0; i < n; i++) cin >> a, mt.emplace(a);
  int ans = 0;
  while(mt.size() >= 2) {
    int x = *--mt.end();
    mt.erase(--mt.end());
    int y = 2;
    while(y <= x) y <<= 1;
    if(mt.count(y - x)) mt.erase(mt.find(y - x)), ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9600
'use strict';

function Main(input) {
    const tmp = input.split("\n");
    let a = tmp[1].split(" ");
    const len = tmp[0];
    let cnt = 0;

    let i = 0;
    while (true) {
        if (a[i] % 2 == 1) {
            break;
        }
        i++;
        if (!(i < len)) {
            cnt++;
            i = 0;
            for (let j = 0; j < len; j++) {
                a[j] /= 2;
            }
        }
    }
    console.log(cnt);
}
//* この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
n, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
count = 0
for i in range(n):
    x -= a[i]
    if x>0:
        count += 1
    elif x==0:
        count += 1
        break
else :
    if x>0 :
        count -= 1   
        
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<pair<int, char>> v(1);
    v[0] = {1, s[0]};
    rep(i, 1, n)
    {
        if (s[i] == v.back().second)
        {
            v.back().first++;
        }
        else
        {
            v.push_back({1, s[i]});
        }
    }
    int ans = 0, now = 0, zero = 0;
    queue<pair<int, char>> que;
    rep(i, v.size())
    {
        pair<int, char> p = v[i];
        now += p.first;
        que.push(p);
        if (p.second == '0')
        {
            zero++;
        }
        if (zero > k)
        {
            while (que.front().second != '0')
            {
                now -= que.front().first;
                que.pop();
            }
            now -= que.front().first;
            que.pop();

            zero--;
        }
        ans = max(ans, now);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1528
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(std::vector<long long> x, std::vector<long long> y){

}

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll x = c-a, y = d-b;
    cout << c-y << " "<< d+x << " "<< a-y << " " << b+x << endl;
    return 0;
}


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

using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
//最終奥義 #define int long long
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; }
void put_double(double obj){printf("%.12f\n",obj);};
//lambda: [](int x, int y){return x<y;}

signed main(void){
    int d[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;cin>>k;
    cout << d[k-1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <sstream>
#include <set>
using namespace std;
using ll = long long;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

int main() {
  int N;
  while (scanf("%d", &N) != EOF) {
  //for (;;) {
    //N = 5;
    vector<int> v(N);
    for (int i : range(N)) {
      scanf("%d", &v[i]);
      //v[i]=rand()%5+1;
    }
    sort(v.begin(), v.end());
    /*
    for (int i : range(N)) {
      cout << v[i] << " ";
    }
    cout<<endl;

    int dp[20][20];
    for (int i = 0; i <= N; ++i) {
      for (int j = 19; j >= 0; --j) {
        if (i == 0) dp[i][j] = 1;
        else if (j >= v[i - 1]) dp[i][j] = 1;
        else dp[i][j] = 1 - min(dp[i - 1][j], dp[i][j + 1]);
      }
    }

    cout << dp[N][0] << endl;
    */

    int lo = 1, hi = N + 1;
    while (hi - lo > 1) {
      int m = (hi + lo) / 2;
      bool good = 1;
      for (int i = N - 1; i >= N - m; --i) {
        if (v[i] < m) good = 0;
      }
      if (good) lo = m;
      else hi = m;
    }

    int w = 0;
    for (int i = N - lo - 1; i >= 0; --i) {
      if (v[i] < lo) break;
      w++;
    }
    int h = v[N - lo] - lo;
    if (w % 2 || h % 2) puts("First");
    else puts("Second");
    //if (w % 2 || h % 2) assert(dp[N][0]);
    //else assert(dp[N][0] == 0);
  }
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

int main() {
	vector <int> h;
	int n ;
	cin >> n;
	for(int i = 0 ; i < n ; i++){
		int x;
		cin >> x;
		h.push_back(x);
	}
	int dp[n+1];
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for(int i = 2 ; i < n ; i++){
		dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]) , dp[i-2] + abs(h[i] - h[i-2]) );
	}
	cout << dp[n-1];
	return 0;
}

Measured memory_bytes: 1144
#include<stdio.h>

int main(){
	int tile[22][22],x,y,flag,W,H,i,j;
	char c;
	
	while(0<=scanf("%d%d",&W,&H)){
		if(W==0 && H==0){
			break;
		}
		
		for(i=0;i<22;i++){
			for(j=0;j<22;j++){
				tile[i][j]='#';
			}
		}
		
		for(i=1;i<=H;i++){
			for(j=1;j<=W;j++){
				scanf(" %c ",&tile[j][i]);
				if(tile[j][i]=='\n'){
					scanf("%c",&tile[j][i]);
				}
			}
		}
		
/* 		for(i=1;i<=H;i++){
			for(j=1;j<=W;j++){
				printf("%c ",tile[j][i]);
			}
			printf("\n");
		}
 */		
		flag=0;
		while(flag==0){
			flag=1;
			for(i=1;i<=H;i++){
				for(j=1;j<=W;j++){
					if(tile[j][i]=='.' && (tile[j+1][i]=='@' || tile[j-1][i]=='@' || tile[j][i-1]=='@' || tile[j][i+1]=='@')){
						tile[j][i]='@';
						flag=0;
					}
				}
			}
		}
		
		flag=0;
		for(i=1;i<=H;i++){
			for(j=1;j<=W;j++){
				if(tile[j][i]=='@') ++flag;
			}
		}
	
		printf("%d\n",flag);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

ll combi(ll n, ll k){
    ll res=1;
    ll cnt=1;
    while(k>0){
        res *= n-cnt+1;
        res /= cnt;
        k--;
        cnt++;
    }
    return res;
}

int main(void) {
    ll n,a,b;
    cin>>n>>a>>b;
    map<ll, ll, greater<ll> > mp;
    rep(i,n){
        ll tmp;cin>>tmp;
        mp[tmp]++;
    }
    ll cnt=0;
    ll cntres=0;
    double mean=0;
    DEBUG{
        for(auto x:mp){
            cout << "value : " << x.first << " cnt : "<< x.second<<endl;
        }
    }
    bool first=true;
    for(auto x:mp){
        if(x.second+cnt>=a){
            if(first){
                for(ll i=a;i<=min(x.second, b);i++){
                    cntres += combi(x.second,i);                    
                }
                mean = x.first;
            }else{
                DEBUG{cout << "sum : " << mean << endl;}
                mean += x.first*(a-cnt);
                mean /= a;
                cntres = combi(x.second, a-cnt);
            }
            break;
        }else{
            cnt += x.second;
            mean += x.second*x.first;
            first = false;
        }
    }
    printf("%lf\n",mean);
    cout << cntres << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

template<class T,class U>constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}
template<class T,class U>constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}
#define bit(n,k) ( (n>>k)&1 )

//デバッグ
template<class T>
void Vout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i]<<'\n';
    }
    cout<<"end\n"<<endl;
}

template<class T>
void VPout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i].first<<" "<<V[i].second<<'\n';
    }
    cout<<"end\n"<<endl;
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


constexpr int MAX=1<<30;
constexpr ll INF=1LL<<62;
constexpr int MOD=1e9+7;
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

//__builtin_popcount(S);
//#define int ll
//vector<vector<int>> data(3, vector<int>(4));
//vector.resize(a,vector<int>(b,-1));
//vector<vector<vector<要素の型>>> 変数名(要素数1, vector<vector<要素の型>>(要素数2, vector<要素の型>(要素数3, 初期値)));


//辺 fromあり
template<typename T >
struct Edge {
  int from, to;
  T cost;

  Edge()=default;
  Edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}

};

template<typename T>
using Edges=vector<Edge<T>>;


template<typename T>
vector<T> BellmanFord(Edges<T> &g,int v,int s,T inf,T _inf,T zero){
    vector<T> dist(v,inf);
    dist[s]=zero;
    for(int i=0;i<v-1;i++){ //v-1回のループ 不閉路を気にしない場合はここだけ
        for(auto &e:g){
            if(dist[e.from]==inf) continue;
            chmin(dist[e.to],dist[e.from]+e.cost); //Tの足し算、比較
        }
    }
    //不閉路の有無だけを気にする場合はこれを利用
    //不閉路がある場合は空を返す
    /*for(auto &e:g){
        if(dist[e.from]==inf) continue;
        if(dist[e.from]+e.cost<dist[e.to]) return vector<T>();
    }
    return dist;
    */
    
    //負の無限大になるところを調べる _infにする
    for(int i=0;i<v-1;i++){
        for(auto &e:g){
            if(dist[e.from]==inf) continue;
            if(dist[e.from]+e.cost<dist[e.to]) dist[e.to]=_inf; //_infを使用
        }
    }
    return dist;
} 


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr); 
    cout<<fixed<<setprecision(10);

    int n,m,p;
    cin>>n>>m>>p;
    Edges<ll> g;
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        a--; b--;
        c=p-c;
        g.emplace_back(a,b,c);
    }
    auto ans=BellmanFord<ll>(g,n,0,INF,-INF,0);
    if(ans[n-1]==-INF) cout<<-1<<endl;
    else cout<<max(-ans[n-1],0LL)<<endl;
}

Measured memory_bytes: 512