akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
    iostream::sync_with_stdio(false);
    
    int N,K;
    cin >> N >> K;
    int l[50];
    for(int i=0; i<N; i++) cin >> l[i];
    sort(l, l+N);
    int ans = 0;
    for(int i=0; i<K; i++) ans += l[N-i-1];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }

int N;

signed main()
{
	cin >> N;

	if (N % 2 == 1)
	{
		cout << 0 << endl;
		return 0;
	}

	int ans = 0;

	int cur = N / 2;
	while (true)
	{
		ans += cur / 5;
		cur /= 5;
		if (cur < 5) break;
	}

	cout << ans << endl;
}



Measured memory_bytes: 3152
fun main() {
    val k = readLine()?.toInt() ?: return
    val (a, b) = readLine()?.split(" ")?.map(String::toInt) ?: return
    a.until(b + 1).forEach {
        if (it % k == 0) {
            println("OK")
            return
        }
    }
    println("NG")
}



Measured memory_bytes: 36728
mylist = []

for i in range(0, 5):
    val = int(input())
    if val<=40:
        val=40
        val1=str(val)
    else:
        val1=str(val)
    
    if val1:
        mylist.append(val1)

a0=int(mylist[0])
a1=int(mylist[1])
a2=int(mylist[2])
a3=int(mylist[3])
a4=int(mylist[4])


print((a1+a2+a3+a4+a0)//5)


Measured memory_bytes: 5600
N = int(input())
xu = []
for i in range(N):
    xu.append(list(input().split()))
#print(xu)

wa = 0
for i in range(N):
     if xu[i][1] == 'JPY':
         wa += int(xu[i][0])
     elif xu[i][1] == 'BTC':
         wa += float(xu[i][0]) * 380000
print(wa)

Measured memory_bytes: 38256
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let (n, k) = input_tuple();
    let mut h_vec = input_vec();
    h_vec.sort();
    if n <= k { 
        println!("0");
        return;
    }
    let mut sum = 0;
    // println!("{:?}", h_vec);
    for i in 0..(n-k) {
        sum += h_vec[i as usize];
    }
    println!("{}", sum);
}


Measured memory_bytes: 10492
#include <vector>
#include <iostream>
using namespace std;
class SegTree {
    using T = long long;
    static const T& op(const T& lhs, const T& rhs) { // binary operator
        return min(lhs, rhs);
    }
    constexpr static T unit = 1LL<<60; // unit element
    const int N;
    T *data;
    static int calc_size(int sz) {
        int n = 1;
        while (sz > n) n *= 2;
        return n;
    }
public:
    explicit SegTree(int sz) : N(calc_size(sz)) {
        data = new T[2*N-1];
        fill(data, data+2*N-1, unit);
    }
    ~SegTree() { delete[] data; }
    T query(int a, int b, int i = -1, int l = -1, int r = -1) const {
        if (i == -1) { i = 0; l = 0; r = N; }
        if (r <= a || b <= l) return unit; // need this if a query can be empty
        if (a <= l && r <= b) return data[i];
        int m = (l+r)/2;
        if (b <= m) return query(a, b, 2*i+1, l, m);
        if (m <= a) return query(a, b, 2*i+2, m, r);
        T v1 = query(a, b, 2*i+1, l, m),
          v2 = query(a, b, 2*i+2, m, r);
        return op(v1, v2);
    }
    T get(int i) const {
        return data[i + N - 1];
    }
    void update(int i, T v) {
        int x = i + N - 1;
        data[x] = v;
        while (x > 0) {
            x = (x-1)/2;
            data[x] = op(data[2*x+1], data[2*x+2]);
        }
    }
};

int main() {
    int n, m; cin >> n >> m;
    vector<int> L[n], C[n];
    for (int i = 0; i < m; i++) {
        int l, r, c; cin >> l >> r >> c;
        l--; r--;
        L[r].push_back(l);
        C[r].push_back(c);
    }
    const long long INF = 1LL<<60;
    SegTree dist(n);
    dist.update(0, 0);
    for (int x = 1; x < n; x++) {
        long long temp = INF;
        for (int i = 0; i < L[x].size(); i++)
            temp = min(temp, C[x][i] + dist.query(L[x][i], x));
        dist.update(x, temp);
    }
    long long ans = dist.get(n-1);
    cout << (ans == INF ? -1 : ans) << endl;
}


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

int main() {
  int N, K, d, A;
  cin >> N >> K;

  set<int> su;
  rep(i, K) {
    cin >> d;
    rep(j, d) {
      cin >> A;
      su.insert(A);
    }
  }
  cout << N - su.size() << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;

ll dp[41][1 << 17];

ll mod_pow(ll m, ll n, ll mod) {
    if (n == 0) {
        return 1;
    }

    ll rv = mod_pow(m * m % mod, n/2, mod);

    if (n % 2) {
        return (rv * m) % mod;
    } else {
        return rv;
    }
}

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

    ll N;
    ll X;
    ll Y;
    ll Z;
    cin >> N >> X >> Y >> Z;

    int mask = (1 << 17) - 1; // 17bit

    dp[0][0] = 1;

    for (ll i = 1; i <= N; ++i) {
        for (int s = 0; s < (1 << 17); ++s) {
            for (int d = 1; d <= 10; ++d) {
                int ns = ((s << 1) + 1) << (d-1);
                ns = mask & ns;

                if (((ns >> (Z-1)) & 1) && ((ns >> (Y+Z-1)) & 1) && ((ns >> (X+Y+Z-1)) & 1)) {
                } else {
                    dp[i][ns] = (dp[i][ns] + dp[i-1][s]) % MOD;
                }
            }
        }
    }

    ll ans = 0;
    for (int s = 0; s < (1 << 17); ++s) {
        //cout << s << " " << bitset<32>(s) << endl;
        ans = (ans + dp[N][s]) % MOD;
    }
    ans = (mod_pow(10, N, MOD) + (MOD - ans)) % MOD;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 41216
dp = 10.times.map{ [0]*1001 }
dp[0][0] = 1
(0..100).each do |i|
  8.downto(0) do |j|
    (0..1000).each do |k|
      break if k+i > 1000
      dp[j+1][k+i] += dp[j][k]
    end
  end
end

loop do
  n, s = gets.split.map(&:to_i)
  break if n == 0
  p dp[n][s]
end

Measured memory_bytes: 8744
n = int(input())
A = tuple(int(input()) for _ in range(n))
S = sum(A)
mod = 998244353
ans = pow(3, n, mod)
cnt = 0
dp = [[0]*(S+1) for _ in range(n+1)]
dp[0][0] = 1
for i, a in enumerate(A):
  for k in range(S+1):
    if k >= a:
      dp[i+1][k] = dp[i][k]*2 + dp[i][k-a]
    else:
      dp[i+1][k] = dp[i][k]*2
    dp[i+1][k] %= mod
for k in range((S+1)//2, S+1):
  ans -= dp[n][k]*3
  ans %= mod
if S%2 == 0:
  dp = [0]*(S//2+1)
  dp[0] = 1
  for i, a in enumerate(A):
    for k in range(S//2, -1, -1):
      if k >= a:
        dp[k] += dp[k-a]
  ans += dp[S//2]*3
  ans %= mod
print(ans)

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

using namespace std;

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.first <<","<<P.second <<")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int N = 200005, M = 1e9 + 7;

int n, a, b;
vector<int> V[N];
long long ans;

void DFS(int w, int par = -1) {
    if (par != -1) {
        if (par < w) {
            ans += (long long)(w - par) * (n - w + 1);
        } else {
            ans += (long long)(par - w) * w;
        }
    } else {
        ans += n;
    }
    for (int u : V[w]) {
        if (par == u) continue;
        DFS(u, w);
    }
}

int main() {
    
    scanf("%d", &n);
    
    for (int i = 1; i < n; i++) {
        scanf("%d %d", &a, &b);
        V[a].push_back(b);
        V[b].push_back(a);
    }
    
    DFS(1);
    
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 24028
n = int(input())
restaurants = []

for i in range(n):
    s, p = input().split()
    p = 100 - int(p)
    restaurants.append("%s %03d %03d" % (s, p, i + 1))
sorted_restaurants = sorted(restaurants)

for i in range(n):
    id = int(sorted_restaurants[i][-3:])
    print(id)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
using namespace std;
using Graph = vector<vector<int>>;
int cnt=1;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true;
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        cnt++;
        dfs(G, next_v); // 再帰的に探索
    }
}

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;
    int ansans=0;

    // グラフ入力受取
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // 全頂点が訪問済みになるまで探索
    int count = 0;
    seen.assign(N, false);
    for (int v = 0; v < N; ++v) {
        if (seen[v]) continue; // v が探索済みだったらスルー
        cnt=1;
        dfs(G, v); // v が未探索なら v を始点とした DFS を行う
        ansans=max(ansans,cnt);
        ++count;
    }
    cout << ansans << endl;
}




Measured memory_bytes: 23476
from functools import lru_cache

N, M, Q = map(int, input().split())

# trains[L][r]: L から r まで行く電車の本数 (1 <= L <= r <= N)
trains = [[0 for _ in range(N + 1)] for _ in range(N + 1)]
for m in range(M):
    L, r = map(int, input().split())
    trains[L][r] += 1

# スタック深くなるので DP 化
# @lru_cache(maxsize=None)
# def solve(L, r):
#     if L > r:
#         raise ValueError()
#     if L == r:
#         return trains[L][r]
#     if L + 1 == r:
#         return trains[L][L] + trains[r][r] + trains[L][r]
#     return trains[L][r] + solve(L + 1, r) + solve(L, r - 1) - solve(L + 1, r - 1)


# dp[L][r]: L から r に含まれる本数
dp = [[0 for _ in range(N + 1)] for _ in range(N + 1)]
for length in range(N + 1):
    L = 1
    r = L + length
    while r <= N:
        if length == 0:
            dp[L][r] = trains[L][r]
        elif length == 1:
            dp[L][r] = dp[L][L] + dp[r][r] + trains[L][r]
        else:
            dp[L][r] = dp[L + 1][r] + dp[L][r - 1] - dp[L + 1][r - 1] + trains[L][r]
        L += 1
        r += 1


def solve(L, r):
    return dp[L][r]


for q in range(Q):
    print(solve(*map(int, input().split())))


Measured memory_bytes: 12268
n, k = list(map(int, input().split()))
al = list(map(int, input().split()))
t = 1
for i in range(n):
    if i < k:
        continue
    else:
        t //= al[i-k]
        if al[i-k] < al[i]:
            print('Yes')
        else:
            print('No')


Measured memory_bytes: 105500
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#include <bits/stdc++.h>
using namespace std;

//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;

int n;
vi a,b;

int main(){
    I(n);
    a.resize(n);
    b.resize(n);
    REP(i,n) I(a[i]);
    REP(i,n) I(b[i]);
    int ret = 0;
    REPN(pw,28){
        int mask = 1 << pw;
        int mod = mask * 2;

        REP(i,n) {
            a[i] %= mod;
            b[i] %= mod;
        }
        sort(b.begin(),b.end());

        int kmod = 0;
        for (auto ai : a){
            kmod += (upper_bound(b.begin(),b.end(),2*mask-ai-1) - lower_bound(b.begin(),b.end(),mask-ai));
            kmod += (upper_bound(b.begin(),b.end(),4*mask-ai-1) - lower_bound(b.begin(),b.end(),3*mask-ai));
        }
        if (kmod & 1) ret |= mask;
    }
    cout << ret << endl;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    if(a*b < c*d){
      System.out.println(c*d);
    }else{
      System.out.println(a*b);
    }
  }
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string str;
	cin>>str;
	int ct=0,cs=0;
	int len=str.size();
	bool ans=false;
	for(int i=0;i<len;i++)
	{
		if(str[i]=='C'&&ct==0)
		{
			ct=1;
		}
		if(str[i]=='F'&&ct==1&&cs==0)
		{
			cs=1;
		}
		if(ct==1&&cs==1)
		{
			ans=true;
		}
	}
	if(ans)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int S, hour, min, sec;
    cin >> S;
    hour = S / 3600;
    min = (S % 3600) / 60;
    sec = S - (3600 * hour + 60 * min);
    cout << hour << ":" << min << ":" << sec << endl;
    return 0;
}

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

ll ncr[51][51];
ll v[51];

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

  ncr[0][0] = 1;
  for (int i = 1; i <= 50; i++) {
    ncr[i][0] = ncr[i][i] = 1;
    for (int j = 1; j < i; j++)
      ncr[i][j] = ncr[i - 1][j] + ncr[i - 1][j - 1];
  }

  int n, a, b;
  cin >> n >> a >> b;

  for (int i = 1; i <= n; i++)
    cin >> v[i];
  sort(v + 1, v + 1 + n);
  reverse(v + 1, v + 1 + n);

  double avg = 0;
  for (int i = 1; i <= a; i++)
    avg += v[i];
  avg /= a;

  ll ans = 0;
  if (v[1] == v[a]) {
    int cnt = 0;
    for (int i = 1; i <= n; i++)
      if (v[i] == v[1])
        cnt++;
    for (int i = a; i <= min(b, cnt); i++)
      ans += ncr[cnt][i];
  } else {
    int cnt = 0, need = 0;
    for (int i = 1; i <= n; i++) {
      if (v[i] == v[a])
        cnt++;
      if (v[i] == v[a] && i <= a)
        need++;
    }
    ans = ncr[cnt][need];
  }

  cout << fixed << setprecision(10) << avg << endl;
  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
A = [int(el) for el in input().split(' ')]

total = abs(A[0]) + abs(A[n-1]) + sum([abs(A[i+1] - A[i]) for i in range(n-1)])

D = []
D.append(abs(A[0]) + abs(A[1]-A[0]) - abs(A[1]))
for i in range(1, n-1):
    D.append(abs(A[i]- A[i-1]) + abs(A[i+1]-A[i]) - abs(A[i+1]-A[i-1]))
D.append(abs(A[n-1]-A[n-2]) + abs(A[n-1]) - abs(A[n-2]))

for i in range(n):
    print(total - D[i])


Measured memory_bytes: 14048
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;

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

    ans = max(A-2*B, 0);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename T, typename Can> T bsearch(T L, T R, Can&& can, bool left_feasible = true) {
    static_assert(is_convertible<decltype(can), function<bool(T)>>::value, "can must be bool(T)");
    T& feasible = left_feasible ? L : R;
    T& infeasible = left_feasible ? R : L;
    while(R - L > 1) {
        T M = L + (R - L) / 2;
        (can(M) ? feasible : infeasible) = M;
    }
    return feasible;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    map<int, int> counter;
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        counter[a]++;
    }
    priority_queue<int> pq;
    int total = 0;
    for(auto& p : counter) {
        pq.push(p.second);
        total += p.second;
    }
    vector<int> ans(n + 1);
    for(int ops = n, k = 0; ops >= 0; ops--) {
        while(pq.top() > ops) {
            total--;
            pq.push(pq.top() - 1);
            pq.pop();
        }
        int max_k = bsearch<int>(0, n + 1, [&](int k) {
            return total >= (ll) ops * k;
        });
        while(k <= max_k) {
            ans[k++] = ops;
        }
    }
    for(int k = 1; k <= n; k++) {
        cout << ans[k] << endl;
    }
    return 0;
}


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


using namespace std;

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

    vector< long > B(N);

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

    vector<long> ans;


    while(!B.empty()){
        int same=0;
        bool check=false;
        for(int i=0;i<B.size();++i){
            if(B[i]==i+1){
                same=i;
                check=true;
            }
        }

        if(check){
            ans.push_back(B[same]);
            B.erase(B.begin()+same);

        }else{
            cout<<-1<<endl;
            return 0;
        }


    }

    for(int i=ans.size()-1;i>=0;--i){
        cout<<ans[i]<<endl;
    }
    


}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int gcd(int x, int y) {
  return y ? gcd(y, x%y) : x;
}

int main() {
  int n;
  cin>>n;
  int g = 0;
  set<int> s;
  rep(i,n) {
    int a;
    cin>>a;
    set<int> p;
    swap(s, p);
    for (int x : p) s.insert(gcd(x, a));
    s.insert(g);
    g = gcd(g, a);
  }
  int ans = *(s.rbegin());
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define inf 1000000007
#define ll long long int
using namespace std;
int main()
{
    ll n,k;
    cin>>n>>k;
    vector<ll> h(n+2);
    vector<ll> cost(n+2,inf);
    cost[0]=0;
    cost[1]=0;
    
    for(ll i=1;i<=n;i++)
         cin>>h[i];
         
    for(ll i=1;i<=n;i++)
    { for(ll j=1;j<=k;j++)
        if(i+j<=n)
        
            cost[i+j]=min(cost[i+j],abs(h[i+j]-h[i])+cost[i]);
        
        
    }
         
    cout<<cost[n]<<"\n";
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(void)

{

int W,H,x,y,r;

scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

if(H>=y+r&&W>=x+r&&x-r>=0&&y-r>=0) {printf("Yes\n");}
else{ printf("No\n");}
 return 0;}

Measured memory_bytes: 580
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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! {
        n: usize,
        k: isize,
        q: usize,
        a: [usize; q]
    }
    let mut v = vec![0; n];
    for ai in &a {
        v[ai - 1] += 1;
    }
    for vi in &v {
        let ans = if k - (q as isize) + vi > 0 { "Yes" } else { "No" };
        println!("{}", ans);
    }
}


Measured memory_bytes: 6908
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty |) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty | $n:expr) => {
        (0..$n).map(|_| get!($t |)).collect::<Vec<_>>()
    };
}

macro_rules! tern {
    ($condition: expr, $_true: expr, $_false: expr) => {
        if $condition {
            $_true
        } else {
            $_false
        }
    };
}

fn main() {
    let N = get!(usize);
    let Hs = get!(u64 | );
    let mut prev = 0;
    for H in Hs {
        if H == prev {
            prev = H;
        } else if H > prev {
            prev = H - 1;
        } else {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 8444
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <vector>
#define MAXN 1010
int n;
long long a[MAXN];
inline std::pair<std::vector<int>, long long> calcAns(int start) {
    long long result = 0, max = start;
    std::vector<int> indexes;
    for (int i = start; i <= n; i += 2) {
        if (a[i] > 0LL) result += a[i], indexes.push_back(i);
        if (a[i] > a[max]) max = i;
    }
    if (!result) result = a[max], indexes.push_back(max);
    return {indexes, result};
}

std::vector<int> result;

inline std::list<int> fill(std::vector<int> v) {
    std::list<int> result;
    static int tmp[MAXN];
    memset(tmp, 0, sizeof(tmp));
    for (auto i : v) tmp[i] = 1;
    for (int i = 1; i <= n; i++) result.push_back(tmp[i]);
    return result;
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
    auto l = calcAns(1), r = calcAns(2);

    if (l.second < r.second) std::swap(l, r);
    printf("%lld\n", l.second);
    auto status = fill(l.first);
    while (!status.back()) result.push_back(status.size()), status.pop_back();
    while (!status.front()) result.push_back(1), status.pop_front();
    while (status.size() > 2) {
        auto c = status.begin();
        auto a = c++;
        auto b = c++;
        int pos = 2;
        while (c != status.end()) {
            if (!(*a ^ *c)) {
                result.push_back(pos);
                status.insert(a, *a);
                status.erase(a);
                status.erase(b);
                status.erase(c);
                break;
            }
            a = b, b = c, c++;
            pos++;
        }
    }
    printf("%lu\n", result.size());
    for (auto i : result) printf("%d\n", i);
    return 0;
}

Measured memory_bytes: 256
(k, s),  = [list(map(int, s.split())) for s in open(0)]
flag = 0 
for i in range(k + 1):
    for j in range(k - i + 1):
        l = k - i - j
        if 10000 * i + 5000 * j + 1000 * l == s:
            print(i, j, l)
            flag += 1 
            break
    else:
        continue 
    break

if not flag:
    print("-1 -1 -1")

Measured memory_bytes: 3064
class Dice:
    def __init__(self, num, dire):
        self.num = num
        self.dir = dire

    def rotate(self):
        for hou in self.dir:
            if hou == "S":
                self.num[0], self.num[4], self.num[5], self.num[1] = self.num[4], self.num[5], self.num[1], self.num[0]
                tile = self.num[0]
            if hou == "W":
                self.num[0], self.num[2], self.num[5], self.num[3] = self.num[2], self.num[5], self.num[3], self.num[0]
                tile = self.num[0]
            if hou == "N":
                self.num[0], self.num[1], self.num[5], self.num[4] = self.num[1], self.num[5], self.num[4], self.num[0]
                tile = self.num[0]
            if hou == "E":
                self.num[0], self.num[3], self.num[5], self.num[2] = self.num[3], self.num[5], self.num[2], self.num[0]
                tile = self.num[0]
        return tile


s = list(map(int, input().split()))
t = list(input())
idice = Dice(s, t)
print(idice.rotate())



Measured memory_bytes: 5612
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

h, w = MAP()
a = [input() for _ in range(h)]
y = 0
x = 0
dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]
while y < h and x < w:
    flag = [False for _ in range(4)]
    for i in range(4):
        if 0 <= y + dy[i] < h and 0 <= x + dx[i] < w and a[y + dy[i]][x + dx[i]] == '#':
            flag[i] = True
    if x == y == 0:
        flag[2] = True
    if x == w - 1 and y == h - 1:
        flag[0] = True
    if flag[0]:
        y += 1
    else:
        x += 1
    if not len(set(flag[0:2])) == len(set(flag[2:4])) == 2:
        print('Impossible')
        exit()
print('Possible')


Measured memory_bytes: 59664
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(void){
  ll n,sum=0;
  cin>>n;
  vector<ll> arr(n),ans(n);
  for(int i=0;i<n;i++){
    cin>>arr[i];
    sum+=arr[i];
  }
  for(int i=1;i<n;i+=2){
    sum-=arr[i]*2;
  }
  ans[0]=sum;
  for(int i=1;i<n;i++){
    ans[i]=arr[i-1]*2-ans[i-1];
  }
  for(int i=0;i<n;i++) cout<<ans[i]<<" ";
  cout<<endl;
  return 0;
}

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

int main(){
  int A, B;
  cin >> A >> B;
  for(int i=1; i<=1000; i++){
    if(floor(i*0.08)==A && floor(i*0.1)==B){
      cout << i << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
  return 0;
}

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

#define int long long
#define double long double
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int pow2[20];
double pow1_2[20];

signed main() {
    pow2[0] = 1;
    rep(i, 19) {
        pow2[i + 1] = 2 * pow2[i];
    }
    pow1_2[0] = 1;
    rep(i, 19) {
        pow1_2[i + 1] = pow1_2[i] / 2;
    }
    int n, k;
    cin >> n >> k;
    double ans = 0;
    for (int i = n; i >= 1; --i) {
        for (int j = 0; j < 20; ++j) {
            if (i * pow2[j] >= k) {
                ans += pow1_2[j];
                break;
            }
        }
    }
    ans /= n;
    printf("%.20Lf\n", ans);
    return 0;
}


Measured memory_bytes: 256
MOD = 10**9+7
MAXN = 2*10**6+5
f = [1]
for i in range(MAXN):
    f.append(f[-1] * (i+1) % MOD)
def nCr(n, r, mod=MOD):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod

K = int(input())
S = input()
R = len(S)
N = K + R
ans = 0
for r in range(R,N+1):
    power = pow(25, N-r, MOD)
    ans += nCr(N, r) * power % MOD
    ans %= MOD
print(ans)

Measured memory_bytes: 163412
#include <bits/stdc++.h>
using namespace std;
unsigned long long lcs[3], n;
int main() {
    cin >> n;
    lcs[0] = 2;
    lcs[1] = 1;
    if (n < 2) {
        cout << lcs[n] << endl;
        return 0;
    }
    for (int i = 2; i <= n; ++i) {
        lcs[2] = lcs[0] + lcs[1];
        lcs[0] = lcs[1];
        lcs[1] = lcs[2];
    }
    cout << lcs[2] << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	S := getStdin() // 文字列入力
	T := getStdin() // 文字列入力

	if S == T[:len(S)] {
		fmt.Printf("Yes\n")
	} else {
		fmt.Printf("No\n")
	}
}

var sc = bufio.NewScanner(os.Stdin)

func getStdin() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1772
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n").map(Number);
while(true){
var d=arr.shift();
if(d==0)break;
var n=arr.shift()-1;
var m=arr.shift();
var N=[0,d];
for(var i=0;i<n;i++){
   var x=arr.shift();
   N.push(x,x+d,x-d);
}
var M=[];
for(var i=0;i<m;i++)M.push(arr.shift());
N.sort(function(a,b){return a-b;});
M.sort(function(a,b){return a-b;});
var sum=0;
M.forEach(function(value){
   var min=Infinity;
   var L=0;
   var R=N.length-1;
   while(true){
      var i=Math.floor((L+R)/2);
      if(N[i]==value){
         min=Math.min(min,Math.abs(N[i]-value));
         break;
      }else if(N[i]>value){
         min=Math.min(min,Math.abs(N[i]-value));
         R=i-1;
      }else if(N[i]<value){
         min=Math.min(min,Math.abs(N[i]-value));
         L=i+1;
      }
      if(L>R){
         min=Math.min(min,Math.abs(N[i]-value));
         break;
      }
   }
   sum+=min;
});
console.log(sum);
}

Measured memory_bytes: 36488
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

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

    ll N;
    cin >> N;

    ll ans = 0;
    map<ll, ll> cnt;
    for (ll x = 1; x <= 200; x++) {
        for (ll y = 1; y <= 200; y++) {
            for (ll z = 1; z <= 200; z++) {
                cnt[x*x+y*y+z*z+x*y+y*z+z*x]++;
            }
        }
    }

    for (ll i = 1; i <= N; i++) {
        cout << cnt[i] << "\n";
    }
}

Measured memory_bytes: 14180
const line = require('fs').readFileSync('/dev/stdin', 'utf-8').split('\n');

const fib = n => {
    const memo = [];
    const helper = x => {
        if (x <= 1) return 1;
        if (memo[x] !== undefined) return memo[x];
        memo[x] = helper(x-1) + helper(x-2);
        return memo[x];
    }

    return helper(n);
};

console.log(fib(parseInt(line[0])));



Measured memory_bytes: 19212
import java.util.*;

/**
 * Copyright © 2018 Chris. All rights reserved.
 *
 * @author Chris
 * 2018/7/5 22:51
 *
 */
public class Main {

    private static void solve(Scanner sc) {
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        int max = -200;
        int min = 200;
        for (int i = 0; i < n; i++) {
            max = Math.max(max, sc.nextInt());
        }
        for (int i = 0; i < m; i++) {
            min = Math.min(min, sc.nextInt());
        }
        if (max < min && max < y && min > x) {
            System.out.println("No War");
        } else {
            System.out.println("War");
        }
    }

    public static void main(String args[]) {

        solve(new Scanner(System.in));
    }
}


Measured memory_bytes: 23508
#include <iostream>

using namespace std;

int main() {
  int N, X;
  cin >> N >> X;
  int res = 1;
  int height = 0;
  for (int n = 0; n < N; ++n) {
    int L;
    cin >> L;
    height += L;
    if (X < height) {
      break;
    }
    ++res;
  }
    
  cout << res << endl;
    
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll W,H,x,y;
int main()
{
	scanf("%lld%lld%lld%lld",&W,&H,&x,&y);
	printf("%.6f %d\n",(1.0*W*1.0*H)/2,(x*2==W&&y*2==H)?1:0);
	return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  string s;
  cin >> n;
  cin >> s;
  VVI num(10,VI(30001,0));
  
  rep(i,n){
    int nn = (s[i]) - '0';
    num[nn][i] ++;
  }

  rep(i,10){
    FOR(j,1,30001){
      num[i][j] += num[i][j-1];
    }
  }
  // cout << "hi" << endl;
  ll ans = 0;
  rep(i,10){
    rep(j,10){
      rep(k,10){
        auto tmp = lower_bound(all(num[i]),1);
        if(tmp == num[i].end()) continue;
        int idx = tmp - num[i].begin();
        auto tmp2 = lower_bound(all(num[j]),num[j][idx] + 1);
        if(tmp2 == num[j].end()) continue;
        idx = tmp2 - num[j].begin();
        
        auto tmp3 = lower_bound(all(num[k]),num[k][idx] + 1);
        if(tmp3 == num[k].end()) continue;
        ans++;
        // cout << i << j << k << "add" << endl;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1664
import numpy as np
mod=10**9+7
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
A=np.array(A)

def cmb(n, k, mod, fac, ifac): #calc nCk under mod
    if n < k or n < 0 or k < 0:
        return 0
    else: 
        k = min(k, n-k)
        return fac[n] * ifac[k] * ifac[n-k] % mod
 
def make_tables(mod, n): #Make factorial and inverse tables under mod 
    fac = [1, 1] # factorial table
    ifac = [1, 1] #factorial of inverse table
    inverse = [0, 1] #inverse
 
    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac
  
fac,ifac = make_tables(mod,N+1)
MAX=0
MIN=0

for i,a in enumerate(A):
  MAX+=cmb(i, K-1, mod, fac, ifac)*a
  MAX%=mod
  MIN+=cmb(N-i-1, K-1, mod, fac, ifac)*a
  MIN%=mod
print((MAX-MIN)%mod)

Measured memory_bytes: 26140
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef deque<int> DI;
typedef deque<LL> DLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

LL gcd(LL a, LL b) {
	if(a == 0 || b == 0)	return a+b;
	return gcd(b, a%b);
}

int main() {
	sll(n);
	LL As[n], preGs[n], suffGs[n];
	rep(i, 0, n)	As[i] = scanLong();
	rep(i, 0, n)	preGs[i] = gcd((i > 0 ? preGs[i-1] : 0), As[i]);
	rep(i, n, 0)	suffGs[i] = gcd((i+1 < n ? suffGs[i+1] : 0), As[i]);
	LL ans = preGs[n-1];
	rep(i, 0, n) {
		LL g = gcd((i > 0 ? preGs[i-1] : 0), (i+1 < n ? suffGs[i+1] : 0));
		ans = max(g, ans);
	}
	pll(ans); nl;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
using namespace std;
struct NODE{
  vector<int> to;
  vector<int> cost;
  vector<int> man;
  int den;
  bool done;
  NODE(){done = false;den = 10000000;}
};
int main(){
  int n,m,l;
  while(cin >>n>>m>>l,n||m||l){
    NODE city[101][101];
    for(int i=0,a,b,d,e; i<m; i++){
      cin >>a>>b>>d>>e;
      for(int j=0; j<=l; j++){
	city[a-1][j].to.push_back(b-1);
	city[a-1][j].cost.push_back(d);
	city[a-1][j].man.push_back(e);
	city[b-1][j].to.push_back(a-1);
	city[b-1][j].cost.push_back(d);
	city[b-1][j].man.push_back(e);
      }
    }
    city[0][l].den = 0;
    for(;;){
      int n_a = -1,n_b,next_den = 10000000;
      for(int i=0; i<n; i++){
	for(int j=0; j<=l; j++){
	  if(city[i][j].done) continue;
	  if(next_den > city[i][j].den){next_den = city[i][j].den; n_a = i; n_b = j;}
	}
      }
      if(n_a == -1) break;
      city[n_a][n_b].done = true;
      for(int i=0; i<city[n_a][n_b].to.size(); i++){
	int next_to = city[n_a][n_b].to[i];
	int next_cost = city[n_a][n_b].cost[i];
	int next_man = city[n_a][n_b].man[i];
	if(n_b-next_cost>=0) city[next_to][n_b-next_cost].den = min(city[next_to][n_b-next_cost].den, next_den);
	city[next_to][n_b].den = min(city[next_to][n_b].den,next_den+next_man);
      }
    }
    int ans = 10000000;
    for(int i=0; i<=l; i++) ans = min(ans,city[n-1][i].den);
    cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 10012
#include "bits/stdc++.h"
using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REP1(i, n) for(ll i = 1;i < n;i++)
#define REPR(i, n) for(ll i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)

#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())

#define ll long long
#define ALL(a)  (a).begin(),(a).end()

#define pb(a) push_back(a)

int now,n,k;

int main(){
  ll ans=0;
  cin >> n;
  if (n==3){cout<<61<<endl;return 0;}

  
  vector<ll> a(64,1),b(256,0),c(256,0);//C0 G1 A2 T3
  
  REP(i,4){
    REP(j,4){
      REP(k,4){
        if (((i==2)&(j==1))&(k==0))
          a[i*16+j*4+k]--;
        if (((i==2)&(j==0))&(k==1))
          a[i*16+j*4+k]--;
        if (((i==1)&(j==2))&(k==0))
          a[i*16+j*4+k]--;
      }
    }
  }
  
  
  
  REP(qqqqqqq,n-3){
  //n=4のとき、a→bに更新
  REP(i,4){
    REP(j,4){
      REP(k,4){
        //b[i*64+j*16+k*4]=0LL;
      	REP(l,4){
          if (((j==2)&(k==1))&(l==0)) continue;
          if (((j==1)&(k==2))&(l==0)) continue;
          if (((j==2)&(k==0))&(l==1)) continue;
          if (((i==2)&(j==1))&(l==0)) continue;
          if (((i==2)&(k==1))&(l==0)) continue;
          b[i*64+j*16+k*4+l]=a[i*16+j*4+k]%1000000007;
        }
      }
    }
  }
  
  ans=0LL;
  REP(i,4){
    REP(j,4){
      REP(k,4){
        a[i*16+j*4+k]=0LL;
        REP(l,4){
          a[i*16+j*4+k]=(a[i*16+j*4+k]+b[i*16+j*4+k+l*64])%1000000007;
        }
        ans=(ans+a[i*16+j*4+k])%1000000007;
      }
    }
  }
  }
  
  

  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ind(i, n) i >= n ? i - n : i

int main() {
  int n;
  char tb[300][300];

  std::cin >> n;

  rep(i, n) rep(j, n) std::cin >> tb[i][j];

  int cnt = 0;
  rep(b, n) {
    for (int r = 0; r < n; r++)
      for (int c = 1 + r; c < n; c++)
        if (tb[r][ind(c + b, n)] != tb[c][ind(r + b, n)]) goto next;
    cnt += n;
  next:;
  }

  std::cout << cnt << std::endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n,k,a,s;
  cin>>n>>k>>a>>s;
  ll i=max(n,a);
  ll j=min(k,s);
  if(j-i<0) COUT(0);
  else COUT(j-i);
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int r, d, x; cin >> r >> d >> x;

    V<ll> ans(11);
    ans[0] = x;
    for(int i = 0; i < 10; i++){
        ans[i + 1] = ans[i] * r - d;
    }
    for(int i = 1; i <= 10; i++){
        cout << ans[i] << endl;

    }

    return 0;
}


Measured memory_bytes: 256
N = int(input())
L = list(map(int,input().split()))
L.sort()
flag = True
if N % 2 == 0:
  for i in range(N//2):
    if L[i*2] == L[i*2+1] == 2*i+1:
      None
    else:
      flag = False
      break
else:
  if L[0] != 0:
    flag = False
  else:
    for i in range(1,N//2+1):
      if L[i*2-1] == L[i*2] == 2*i:
        None
      else:
        flag = False
        break
if flag:
  print(2**(N//2) % (7+10**9))
else:
  print(0)

Measured memory_bytes: 14008
import java.util.*;

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

    int n = sc.nextInt();
    long[] a = new long[n];
    long[] b = new long[n];
    long[] c = new long[n];
    long[] d = new long[n];

    for (int i = 0; i < n; i++) {
      a[i] = sc.nextLong();
      b[i] = sc.nextLong();
      c[i] = sc.nextLong();
      d[i] = sc.nextLong();
    }

    for (int i=0; i < n; i++) {
      int ans = 1; // true

      if (a[i] < b[i]) {
        ans = -1; // false
      } else if (d[i] < b[i]) {
        ans = -1; // false
      } else if ((a[i]%b[i]) > c[i]) {
        ans = -1; // false
      } else if (b[i] > c[i] + (long)1) {
        long tmp = d[i] % b[i];
        long init = a[i] % b[i];
        long diff = b[i] - c[i];
        if (diff > tmp && tmp != (long)0) {
          ans = -1; // false
        } else if (tmp != (long)0) {
          if (gcd(b[i], tmp) < diff) {
            ans = -1; // false
          }
        }
      }

      if (ans == 1) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    }
  }

  private static long gcd(long m, long n) {
    if(m < n) return gcd(n, m);
    if(n == 0) return m;
    return gcd(n, m % n);
  }
}


Measured memory_bytes: 25544
#include <iostream>
#include <cstdio>

int main(){
	double x, y;
	
	while( scanf(" %lf %lf", &x, &y) != EOF ){
		if(x<35.5 && y<71) printf("AAA\n");
		else if(x<37.5 && y<77) printf("AA\n");
		else if(x<40 && y<83) printf("A\n");
		else if(x<43 && y<89) printf("B\n");
		else if(x<50 && y<105) printf("C\n");
		else if(x<55 && y<116) printf("D\n");
		else if(x<70 && y<148) printf("E\n");
		else printf("NA\n");
	}

	return 0;
}

Measured memory_bytes: 1196