akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;
const int MAX_M = 100;
const int MAX_GN = MAX_N + MAX_M + 2;

const int INF = 1 << 30;

/* typedef */

struct Pt {
  double x, y;
};

struct Edge {
  int i, c;
  double t;

  Edge() {}
  Edge(int _i, int _c, double _t): i(_i), c(_c), t(_t) {}
};

typedef vector<Edge> ve;

/* global variables */

int n, m;
Pt spts[MAX_N], gpts[MAX_M];
double vs[MAX_N];
ve nbrs[MAX_GN];
int gn, st, gl;
int minfs[MAX_GN], flows[MAX_GN][MAX_GN], prvs[MAX_GN];

/* subroutines */

int maxflow(double max_t) {
  memset(flows, 0, sizeof(flows));
  int max_flow = 0;

  for (;;) {
    //printf("max_flow = %lld\n", max_flow);

    memset(prvs, -1, sizeof(prvs));
    prvs[st] = st;
    minfs[st] = INF;

    queue<int> q;
    q.push(st);

    while (! q.empty()) {
      int ui = q.front(); q.pop();

      if (ui == gl) break;
      ve& nbru = nbrs[ui];
      for (ve::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
	int vi = vit->i;
	int vc = vit->c - flows[ui][vi];
	double vt = vit->t;
	if (vt <= max_t && prvs[vi] < 0 && vc > 0) {
	  prvs[vi] = ui;
	  minfs[vi] = (minfs[ui] < vc) ? minfs[ui] : vc;
	  q.push(vi);
	}
      }
    }

    if (prvs[gl] < 0) break;

    int min_flow = minfs[gl];
    for (int j = gl; j != st;) {
      int i = prvs[j];
      flows[i][j] += min_flow;
      flows[j][i] -= min_flow;
      j = i;
    }

    max_flow += min_flow;
  }

  return max_flow;
}

/* main */

int main() {
  for (;;) {
    cin >> n >> m;
    if (n == 0) break;

    for (int i = 0; i < n; i++) cin >> spts[i].x >> spts[i].y >> vs[i];
    for (int i = 0; i < m; i++) cin >> gpts[i].x >> gpts[i].y;

    gn = n + m + 2;
    st = n + m;
    gl = st + 1;

    for (int i = 0; i < gn; i++) nbrs[i].clear();

    double max_t = 0.0;
    
    for (int i = 0; i < n; i++) {
      Pt& spt = spts[i];
      for (int j = 0; j < m; j++) {
	Pt& gpt = gpts[j];
	double dx = gpt.x - spt.x, dy = gpt.y - spt.y;
	double t = sqrt(dx * dx + dy * dy) / vs[i];
	if (max_t < t) max_t = t;

	nbrs[i].push_back(Edge(n + j, 1, t));
	nbrs[n + j].push_back(Edge(i, 0, t));
      }
    }

    for (int i = 0; i < n; i++) nbrs[st].push_back(Edge(i, 1, 0.0));
    for (int i = 0; i < m; i++) nbrs[n + i].push_back(Edge(gl, 1, 0.0));

    //printf("max_t=%.8lf\n", max_t);
    double t0 = 0.0, t1 = max_t;

    for (int i = 0; i < 50; i++) {
      double mt = (t0 + t1) / 2;
      if (maxflow(mt) >= m) t1 = mt;
      else t0 = mt;
    }

    printf("%.8lf\n", t1);
  }

  return 0;
}

Measured memory_bytes: 1832
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(int i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(int i=(a);i<(n);i++)cout<<(arr)[i]<<' ';

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}

int main(){
	fast;
	ll n, k;
	cin>>n>>k;
	ll a[n], c[2], x = 0;
	scan(a, 0, n);
	for(ll j = 42;j>=0;j--){
		c[0] = 0, c[1] = 0;
		forn(i, 0, n){
			c[(a[i]>>j)&1ll]++;
		}
		if((c[0]>c[1]) && (x + (1ll << j)<=k)){
			x+=(1ll << j);
		}
	}
	ll s = 0;
	forn(i, 0, n){
		s+=(x ^ a[i]);
	}
	cout<<s<<endl;
}

Measured memory_bytes: 4392
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  int a, b; cin >> a >> b;
  int ans = 0;
  REP(_, 2) {
    if (a > b) {
      ans += a;
      a--;
    } else {
      ans += b;
      b--;
    }
  }
  cout << ans << endl;
}


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

vector<int> g[110000];
int dp[110000];

int solve(int v) {
    if(dp[v] != -1) {
        return dp[v];
    }
    int res = 0;
    for (int i = 0; i < g[v].size() ; ++i) {
        res = max(res,solve(g[v][i]) + 1);
    }

    return dp[v] = res;
}

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

    for (int i = 0; i < m ; ++i) {
        int x,y;
        scanf("%d%d",&x,&y);
        x --; y--;
        g[x].push_back(y);
    }

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

    int res = 0;
    for (int k = 0; k <n; ++k) {
        res = max(res,solve(k));
    }

    printf("%d\n",res);

    return 0;
}




Measured memory_bytes: 8448
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <numeric>
#include <cmath>

using namespace std;

template<class T>
class Input {
public:
    auto operator()() const {
        T v;
        cin >> v;
        return v;
    }
};

template<class L, class R>
class Input<pair<L, R>> {
public:
    auto operator()() const {
        L l;
        R r;
        cin >> l >> r;
        return make_pair(l, r);
    }
};

template<class U>
class Input<vector<U>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        return (*this)(n);
    }
    auto operator()(size_t n) const {
        vector<U> v;
        v.reserve(n);
        Input<U> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in();
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class U>
class Input<vector<vector<U>>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        auto m = in();
        return (*this)(n, m);
    }
    auto operator()(size_t n, size_t m) const {
        vector<vector<U>> v;
        v.reserve(n);
        Input<vector<U>> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in(m);
            v.emplace_back(move(u));
        }
        return v;
    }
};

class InputType
{
public:
    template<class T>
    operator T() const {
        Input<T> i{};
        return i();
    }
};

class InputType2
{
public:
    InputType2(size_t n)
        : n_(n)
    {}
    template<class T>
    operator T() const {
        Input<T> i{};
        return i(n_);
    }
private:
    size_t n_;
};

auto input() {
    return InputType();
}

auto input(size_t n) {
    return InputType2(n);
}

size_t bitcount(size_t n) {
    size_t c = 0;
    while (n) {
        if (n & 1ull)
            ++c;
        n >>= 1;
    }
    return c;
}

auto make_order(size_t n) {
    vector<size_t> a(n, 0);
    iota(begin(a), end(a), 0);
    return a;
}

template<class T>
auto next_permutation(T&& x) {
    using std::begin;
    using std::end;
    return next_permutation(begin(x), end(x));
}

using ll = long long;
using ull = unsigned long long;

int main() {
    size_t l = input();
    auto x = l / 3.0;
    auto y = x * x * x;
    printf("%.8f", y);
    return 0;
}


Measured memory_bytes: 256
import sys
from fractions import gcd
from functools import reduce
from itertools import combinations

import numpy as np

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def is_MM(s):
    num = int(s)
    return 0 < num <= 12


def solve():
    N, M = il()
    KS = iml(M)
    p = il()

    ans = 0
    for i in range(1 << N):
        for j in range(M):
            swi = 0
            for s in KS[j][1:]:
                swi += 2 ** (s - 1)
            if (bin(i & swi).count("1") % 2) != p[j]:
                break
        else:
            ans += 1
    return ans


if __name__ == "__main__":
    print(solve())

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


Measured memory_bytes: 128
/*
h3110_fr13nd,
 
AUTHOR : @sam_jn
*/
 
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
using namespace std;
// using namespace __gnu_pbds;
// typedef tree<pair<int, int>, null_type, less_equal<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define MOD 1000000007
#define pb push_back
#define ff first
#define ss second
#define in(a, n) for(int i = 0; i < n; i++) cin >> a[i];
#define ot1(a, n) for(int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define ot2(a, n) for(int i = 0; i < n; i++) cout << a[i] << "\n";
ll pwr(ll a, ll b);
ll pwr(ll a, ll b, ll m);
int baap[200002];
int find(int i);  
bool Union(int x, int y);
ll inv(ll x) {return pwr(x, MOD - 2, MOD);}

//----------------------------------SOLUTION-BELOW-------------------------------------------// 

void solve(){ 
    // return; 
    ll n, k;
    cin >> n >> k;
    ll a[n + 1], hash[n + 1] = {0};
    for(int i = 0; i <= n; i++) hash[i] = -1;
    
    for(int i = 1; i <= n; i++) cin >> a[i];
    ll loop = 0, prev = 0, pos = 1, i = 0;
    hash[1] = 0;
    while(true){
        if(i == k){
            cout << pos;
            return;
        }
        pos = a[pos];
        i++;
        if(hash[pos] == -1){
            hash[pos] = i;
        }
        else{
            loop = i - hash[pos];
            prev = hash[pos];
            break;
        }
    }
    // cout << loop << prev;
    k -= prev;
    k = k % loop;
    // cout << " " << k << endl;
    // return;
    i = 0;
    while(true){
        if(i == k){
            cout << pos;
            return;
        }
        pos = a[pos];
        i++;
    }
    
}
int main(){


                                                            // #ifndef ONLINE_JUDGE    
                                                            // freopen("/home/samyak/Desktop/CP/input.txt", "r", stdin);
                                                            // freopen("/home/samyak/Desktop/CP/output2.txt", "w", stdout);
                                                            // #else
                                                            // // online submission
                                                            // #endif


    boost
    int _ = 1;
    // cout << 0 << endl;
    // cin >> _;
    while(_--){
        solve();
        cout << endl;
    }
}
 
 
//--------------------------------------DEFININTIONS---------------------------------------
ll pwr(ll a, ll b){
    if(b == 0)
        return 1 ;
    ll c = pwr(a, b/2) ;
    c = c * c;
    if(b % 2)
        return c*a;
    return c ;
}
ll pwr(ll a, ll b, ll m){
    if(b == 0)
        return 1;
    ll c = pwr(a, b/2, m) % m ;
    c = (c * c) % m;    
    if(b % 2)
        return (c * a%m) % m;
    return c ;
}
int find(int i)  
{  
    if (baap[i] != i)  
        baap[i] = find(baap[i]);  
  
    return baap[i];  
}
 
bool Union(int x, int y)
{
    x = find(x);
    y = find(y);
    if(x == y) return false;
    baap[x] = y;
    return true;
}

Measured memory_bytes: 6772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 2e18;
const ll amt = 1e15;
struct edge{ll to, cost;};
vector<edge> G1[100010], G2[100010];
ll d1[100010], d2[100010];

void dijkstra(ll s, ll *d, vector<edge> *G, ll V) {
  priority_queue<P, vector<P>, greater<P>> que;
  fill(d, d + V + 1, INF);
  d[s] = 0;
  que.push(P(0, s));
  while (!que.empty()) {
    P p = que.top();
    que.pop();
    ll v = p.second;
    if (d[v] < p.first) continue;
    for (ll i = 0; i < G[v].size(); i++) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }
}

int main(){
  ll n, m, s, t;
  cin >> n >> m >> s >> t;
  for (int i = 0; i < m; i++) {
    ll u, v, a, b;
    cin >> u >> v >> a >> b;
    G1[u].push_back((edge){v, a});
    G2[u].push_back((edge){v, b});
    G1[v].push_back((edge){u, a});
    G2[v].push_back((edge){u, b});
  }
  dijkstra(s, d1, G1, n);
  dijkstra(t, d2, G2, n);
  priority_queue<P, vector<P>, greater<P>> que;
  for (int i = 1; i <= n; i++) {
    que.push(P(d1[i] + d2[i], i));
  }
  for (int i = 1; i <= n; i++) {
    P top = que.top();
    while (top.second < i) {
      que.pop();
      top = que.top();
    }
    cout << amt - top.first << endl;
  }
  return 0;
}


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

int e()
{
    int n;
    std::cin >> n;
    
    std::vector<long long> ha_a(n, 0);
    std::vector<long long> hb_b(n, 0);
    for(int i = 0; i < n; i++)
    {
        long long temp;
        std::cin >> temp;
        ha_a[i] = i + 1 - temp;
        hb_b[i] = i + 1 + temp;
    }
    
    std::sort(hb_b.begin(), hb_b.end());
    
    long long ans = 0;
    for(int i = 1; i <= n; i++)
    {
        std::vector<long long>::iterator it = std::lower_bound(hb_b.begin(), hb_b.end(), ha_a[i]);
        std::vector<long long>::iterator it2 = std::upper_bound(hb_b.begin(), hb_b.end(), ha_a[i]);
        if(*it == ha_a[i])
        {
            ans += std::distance(it, it2);
        }
    }
    
    std::cout << ans << std::endl;
    
    return 0;
}

int main(int argc, const char * argv[])
{
    e();
    return 0;
}


Measured memory_bytes: 6340
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int A, B, C, D;
int f[3005][3005];
int main() {
	scanf("%d%d%d%d", &A, &B, &C, &D);
	f[A][B] = 1;
	for (int i = A + 1; i <= C; i++) {
		int sc = 0;
		for (int j = B; j <= D; j++) {
			sc = 1ll * sc * (i - 1) % mod;
			f[i][j] = (1ll * f[i - 1][j] * j + sc) % mod;
			sc = (sc + f[i - 1][j]) % mod;
		}
	}
	int sc = 0;
	for (int j = B; j <= D; j++) {
		sc = (1ll * sc * C + f[C][j]) % mod;
	}
	printf("%d\n", sc);
	return 0;
}

Measured memory_bytes: 38856
import sys, os, math, bisect, itertools, collections, heapq, queue
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    X = il()
    print(X.index(0) + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 37516
#include<cstdio>
#include<algorithm>
#define itn int
#define tin int
#define nti int
#define tni int
#define nit int
using namespace std;
#define maxn 100002
long long x[4]={0};
itn main()
{
	scanf("%lld%lld%lld",&x[1],&x[2],&x[3]);
	sort(x+1,x+4);
	printf("%lld",x[1]+x[2]);
	return 0;
}

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

const long long mod = 1000000007;
vector<long long>fac, fac_inv, inv;

void init_combination(long long n) {
	fac.resize(n);
	fac_inv.resize(n);
	inv.resize(n);
	fac[0] = fac[1] = 1;
	fac_inv[0] = fac_inv[1] = 1;
	inv[1] = 1;
	for (long long i = 2; i < n; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fac_inv[i] = fac_inv[i - 1] * inv[i] % mod;
	}
}

long long f_combination(long long n, long long r) {
	if (n < r)return 0;
	if (n < 0 || r < 0)return 0;
	return fac[n] * (fac_inv[r] * fac_inv[n - r] % mod) % mod;
}

void solve() {
	long long n, k; cin >> n >> k;
	init_combination(5000);
	for (long long i = 1; i <= k; i++) {
		cout << f_combination(n - k + 1, i)*f_combination(k - 1, i - 1) % mod << endl;
	}
}

int main() {
	solve();
}

Measured memory_bytes: 384
while True:
    money=int(input())
    
    if money==0:
        break
    
    a=1000-money
    A=a//500
    b=a-500*A
    B=b//100
    c=b-100*B
    C=c//50
    d=c-50*C
    D=d//10
    e=d-D*10
    E=e//5
    F=e-E*5
    
    print(A+B+C+D+E+F)


Measured memory_bytes: 5592
n, a, b, c = map(int,input().split())
l = [0]*8
for i in range(n): l[i] = int(input())
ans = float("inf")
for i in range(65536):
    tmp = [[] for i in range(3)]
    for j in range(8):
        shift = (i >> j*2) & 3
        if shift == 0:
            continue
        elif shift == 1: # Aに追加
            tmp[0].append(l[j])
        elif shift == 2: # B
            tmp[1].append(l[j])
        elif shift == 3: # C
            tmp[2].append(l[j])
    if tmp[0] and tmp[1] and tmp[2]: #いずれも1要素以上
        tmpans = 0
        tmpans += (abs(a-sum(tmp[0]))+10*(len(tmp[0])-1))
        tmpans += (abs(b-sum(tmp[1]))+10*(len(tmp[1])-1))
        tmpans += (abs(c-sum(tmp[2]))+10*(len(tmp[2])-1))
        ans = min(ans,tmpans)
print(ans)

Measured memory_bytes: 49240
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;
// typedef long long int 
typedef long long int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
// typedef pair<ll,ll> pll;
const int modi = 1e9+7;

void solve(){
	int n,k;
	cin >> n >> k;
	ll a[n],fact[n+1],inv[n+1],ifact[n+1];
	for(int i =0;i<n;i++)
		cin >> a[i];
	sort(a,a+n);
	ll ans = 0;
	fact[0] = fact[1] = 1;
	inv[1] = 1;
	ifact[0] = ifact[1] = 1;
	for(int i =2;i<=n;i++){
		fact[i] = fact[i-1]*i%modi;
		inv[i] = (modi - modi/i*inv[modi%i]%modi)%modi;
		ifact[i] = ifact[i-1]*inv[i]%modi;
	}
	auto ncr = [&](int n,int r){
		if(r>n) return 0LL;

		return (fact[n]*ifact[n-r]%modi)*ifact[r]%modi;
	};
	for(int i =n-1;i>=0;i--){
		ans = (ans+a[i]*ncr(i,k-1)%modi)%modi;
	}

	for(int i =0;i<n;i++){
		ans = (modi +ans-a[i]*ncr(n-i-1,k-1)%modi)%modi;
	}

	cout << ans << endl;
 }
int main(){
	fast;
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("output.txt","w",stdout);
	// #endif

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 3328
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };
const int dx2[] = { -2, -2, -1, 0, 1, 2, 2, 2, 1, 0, -1, -2 }; const int dy2[] = { 0, -1, -2, -2, -2, -1, 0, 1, 2, 2, 2, 1 };
int main() {
	int x, y;
	while (cin >> x >> y, x | y){
		bool sur = true;
		int n;
		cin >> n;
		bool qi[100] = {};
		qi[x * 10 + y] = true;
		REP(i, n){
			bool b = false;
			bool qi2[100] = {};
			int x2, y2;
			cin >> x2 >> y2;
			REP(m, 10){
				REP(p, 10){
					if (qi[m * 10 + p]){
						REP(j, 3){
							REP(k, 3){
								if (x2 + j - 1 >= 0 && x2 + j - 1 < 10 && y2 + k - 1 >= 0 && y2 + k - 1 < 10){
									REP(l, 12){//*-ぴょん基地-*
										if (x2 + j - 1 == m + dx2[l] && y2 + k - 1 == p + dy2[l]){
											qi2[(m + dx2[l]) * 10 + p + dy2[l]] = true;
											b = true;
										}
									}
								}
							}
						}
					}
				}
			}

			if (b){
				REP(o, 100)qi[o] = qi2[o];
			}
			else{
				sur = false;
			}
		}

		if (sur)
			cout << "OK" << endl;
		else
			cout << "NA" << endl;
	}
}

Measured memory_bytes: 1156
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn main() {
   input! {
      n: usize,
      _s: [String; n],
   }
   let mut map = std::collections::BTreeMap::new();
   for i in 0..n {
      let mut b = _s[i].as_bytes().to_vec();
      b.sort();
      let s =b.iter().map(|&s| s as char).collect::<String>();
      let flag = map.contains_key(&s);
      if flag {
         let v = map.get_mut(&s).unwrap();
         *v += 1;
      } else {
         map.insert(s, 1);
      }
   }
   let mut ans = 0usize;
   for (_, &v) in map.iter() {
      ans += v*(v-1)/2;
   }
   println!("{}", ans);
}


Measured memory_bytes: 16636
import numpy as np
N = int(input())
A = list(map(int, input().split()))

npA = np.array(A)
npi = np.arange(1,N+1)
diff = npA - npi
diff = np.sort(diff)

if N%2 == 0:
    bi = int(N / 2 - 1)
    b = (diff[bi] + diff[bi+1])//2
else:
    bi = int((N-1) / 2)
    b = diff[bi]
tmp = diff - b
ans = np.sum(abs(tmp))
print(ans)


Measured memory_bytes: 34224
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

int x,y,ans;

int main()
{
	scanf("%d%d",&x,&y);
	if(abs(x)<abs(y))
	{
		if(x<0)ans++;
		ans+=(abs(y)-abs(x));
		if(y<0)ans++;
	}
	else
	{
		if(x>0)ans++;
		ans+=(abs(x)-abs(y));
		if(y>0)ans++;
	}
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;
#define ff(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define rep(i, a, b) for(int i = (a), _b = (b); i < _b; ++i)
#define fd(i, a, b) for(int i = (a), _b = (b); i >= _b; --i)
#define SZ(x) ((int)(x).size())
#define db(x) cout << #x << " == " << x << endl
#define _ << ", " << 
#define X first
#define Y second
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define endl '\n'
#define pc putchar
#define gc getchar 
#define bit(i) (1<<(i))

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

const int N=1e5+5;
int n;
vector<int> adj[N];
int tr[N],cnt[N];

void enter(){
	cin>>n;
	int u,v;
	ff(i,1,n-1){
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
}

void dfs(int u,int p){
	cnt[u]=1;
	rep(i,0,SZ(adj[u])){
		int v=adj[u][i];
		if (v!=p){
			tr[v]=u;
			dfs(v,u);
			cnt[u]+=cnt[v];
		}
	}
}

void process(){
	dfs(1,-1);
	
	vector<int> trail;
	
	for(int T=n;T;T=tr[T]){
		trail.pb(T);
	}
	
	reverse(trail.begin(),trail.end());
	
	// rep(i,0,SZ(trail)) cout<<trail[i]<<' ';cout<<endl;

	int p=SZ(trail)/2-(SZ(trail)%2==0);
	if (cnt[1]>2*cnt[trail[p+1]]) cout<<"Fennec"<<endl;
	else cout<<"Snuke"<<endl;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	//freopen("test.inp","r",stdin);
	//freopen("test.out","w",stdout);

	enter();
	process();	

	return 0;
}

Measured memory_bytes: 14972
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,b;
  cin>>a>>b;
  rep(i,a*2-2){
    cout<<i+b-a+1<<" ";
  }
  cout<<b+a-1;
}

Measured memory_bytes: 256
s = input()
odds = [s[i] for i in range(len(s)) if i % 2 == 0]
evens = [s[i] for i in range(len(s)) if  i % 2 == 1]
if odds.count('L') > 0:
  print('No')
elif evens.count('R') > 0:
  print('No')
else:
  print('Yes')


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 200005

int n;
int s[MAXX];

int main()
{
    _FastIO;
    cin >> n;
    for(int i = 0; i < n - 1; i++){
        int x;
        cin >> x;
        s[x]++;
    }
    for(int i = 1; i <= n; i++){
        cout << s[i] << endl;
    }
    return 0;
}


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

int main() {
	int n;

	std::cin >> n;
	std::vector<int> d;

	for (int i = 0; i < n; i++) {
		int in;
		std::cin >> in;
		d.push_back(in);
	}

	for (int i = 1; i < d.size(); i++) {
		int key = d[i];

		//???????????¨???
		for (int i = 0; i < d.size(); i++) {
			printf("%d%c", d[i], (i == d.size() - 1)? '\n': ' ');
		}
		

		int j = i - 1;
		while (j >= 0 && d[j] > key) {
			d[j + 1] = d[j];
			j--;
		}
		d[j + 1] = key;
	}

	//???????????¨???
	for (int i = 0; i < d.size(); i++) {
		printf("%d%c", d[i], (i == d.size() - 1) ? '\n' : ' ');
	}

	return 0;
}

Measured memory_bytes: 3184
#include <stdio.h>

void merge_sort(int x[], int n)
{
	static int y[1001] = {};
	if (n <= 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p] < x[q])? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, N, K, p[1001];
	scanf("%d %d", &N, &K);
	for (i = 0; i < N; i++) scanf("%d", &(p[i]));
	merge_sort(p, N);
	for (i = 0, N = 0; i < K; i++) N += p[i];
	printf("%d\n", N);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1712
import java.util.Scanner;

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

        for(int i=1;;i++){
            int x = sc.nextInt();

            if(x==0){
                break;
            }else{
                System.out.printf("Case %d: %d\n",i,x);
            }
        }
    }
}


Measured memory_bytes: 62348
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
typedef long long ll;

using namespace std;

int main(){
    ll n;
    cin >> n;
    ll amari = n % 10;
    if (amari==2 || amari==4 || amari==5 || amari==7 || amari==9){
        cout << "hon" << endl;
    }
    else if (amari==0 || amari==1 || amari==6 || amari==8){
        cout << "pon" << endl;
    }
    else if (amari==3){
        cout << "bon" << endl;
    }
}

Measured memory_bytes: 3636
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{

    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var ans = -1;
        for (int i = 1; i <= 8; i++)
        {
            var low = i * 100 + i * 10 + i * 1;
            var high = (i + 1) * 100 + (i + 1) * 10 + (i + 1) * 1;
            if (low == N || high == N)
            {
                ans = N;
                break;
            }
            if (N < low)
            {
                ans = low;
                break;
            }
            if (low < N && N < high)
            {
                ans = high;
                break;
            }
        }

        Console.WriteLine(ans);
    }



}



Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,M;
  cin >> N >> M;
  vector<int> k(N);
  int a,b;
  for(int i = 0; i < M; i++){
    cin >> a >> b;
    k.at(a-1)++;
    k.at(b-1)++;
  }
  for(int p = 0; p < N; p++){
    cout << k.at(p) << endl;
  }
}

Measured memory_bytes: 3584
import itertools

n = int(input())
p = tuple(int(x) for x in input().split())
q = tuple(int(x) for x in input().split())

nlst = list(itertools.permutations(range(1, n+1)))
qlst = list(itertools.permutations(q))

nnum = 1
for i in nlst:
    if i == p:
        break
    else:
        nnum += 1

qnum = 1
for i in nlst:
    if i == q:
        break
    else:
        qnum += 1

if nnum >= qnum:
    print(nnum - qnum)
else:
    print(qnum - nnum)

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

double dist(pair<int, int> p, pair<int, int> q) {
  return sqrt((p.first-q.first)*(p.first-q.first)+(p.second-q.second)*(p.second-q.second));
}

int factor(int n) {
  if (n==0) {
    return 1;
  }
  else {
    return factor(n-1)*n;
  }
}

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> loc(N);
  for (int i=0; i<N; i++) {
    cin >> loc.at(i).first >> loc.at(i).second;
  }
  double sum = 0;
  // (N-1)!*2通り, 同じ経路(1→2, 2→1)が出てくる
  for (int i=0; i<N; i++) {
    for (int j=1; j<N-i; j++) {
      sum += dist(loc.at(i), loc.at(i+j))*2*factor(N-1);
    }
  }
  double ave = sum/(factor(N));
  cout << setprecision(10);
  cout << ave << endl;
}

Measured memory_bytes: 256
// AOJ 0638 Kingdom of JOIOI
// 2018.1.7 bal4u

#include <stdio.h>

#define INF 1000000001

int H, W;
int a[2002][2002];
int min, max;

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int check(int x)
{
	int r, c;
	int f = 0;
	for (r = 0; r < H; r++) {
		for (c = 0; c < W; c++) {
			if (a[r][c] < max - x) if (f < c+1) f = c+1;
		}
		for (c = 0; c < W; c++) {
			if (a[r][c] > min + x) if (c < f) return 0;
		}
	}
	return 1;
}

void flip_row()
{
	int r, c, t, h2;
	h2 = H >> 1;
	for (r = 0; r < h2; r++) for (c = 0; c < W; c++) {
		t = a[r][c], a[r][c] = a[H-1-r][c], a[H-1-r][c] = t;
	}
}

void flip_col()
{
	int r, c, t, w2;
	w2 = W >> 1;
	for (r = 0; r < H; r++) for (c = 0; c < w2; c++) {
		t = a[r][c], a[r][c] = a[r][W-1-c], a[r][W-1-c] = t;
	}
}

int solve()
{
	int lo, hi, mi;
	
	lo = 0, hi = max - min;
	while (hi-lo > 1) {
		mi = (lo + hi) >> 1;
		if (check(mi)) hi = mi; else lo = mi;
	}
	return hi;
}

int main()
{
	int r, c, v, t, ans;

	H = in(), W = in();
	min = INF, max = 0;
	for (r = 0; r < H; r++) for (c = 0; c < W; c++) {
		a[r][c] = v = in();
		if (min > v) min = v;
		if (max < v) max = v;
	}
	ans = solve();
	flip_row();	t = solve(); if (t < ans) ans = t;
	flip_col();	t = solve(); if (t < ans) ans = t;
	flip_row();	t = solve(); if (t < ans) ans = t;
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 17496
#include <iostream>

using namespace std;

int main(){
    int a[10000];
    int n=0;
    cin>>a[n];
    while(a[n]!=0)
    {
        ++n;
        cin>>a[n];
    }
    for(int i=0;i<n;++i)
    {
        cout<<"Case "<<i+1<<": "<<a[i]<<endl;
    }
    return 0;
}



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

//.define
// #define FILE_IN_OUT
#define RET(_x)                       return cout << (_x) << '\n', 0;
#define all(_obj)                     std::begin(_obj), std::end(_obj)
#define loop(_n)                      for (int i = 0; i < (_n); ++i)
#define ceilDiv(_dividend, _divider)  (((_dividend) - 1LL + (_divider)) / (_divider))
#define has(_obj, _val)               ((_obj).find(_val) != (_obj).end())
#define sz(_obj)                      static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)                     std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)                     {}
#endif
#define endl "\n"
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data
int dp[3005][3005];

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    string s, t;
    cin >> s >> t;
    for (int i = 0; i < sz(s); ++i) {
        for (int j = 0; j < sz(t); ++j) {
            if (s[i] == t[j]) {
                dp[i + 1][j + 1] = dp[i][j] + 1;
            }
            dp[i + 1][j + 1] = max({dp[i + 1][j + 1],
                                    dp[i][j + 1],
                                    dp[i + 1][j]});
        }
    }
    string ans;
    for (int i = sz(s), j = sz(t); i > 0 && j > 0;) {
        if (dp[i][j - 1] == dp[i][j]) {
            --j;
        } else if (dp[i - 1][j] == dp[i][j]) {
            --i;
        } else {
            ans += s[i - 1];
            --i;
            --j;
        }
    }
    reverse(all(ans));
    cout << ans << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define MOD 1000000007

int main() {
    int N; cin >> N;
    vector<ll> L(88, 2);
    L[1] = 1;
    for (int i = 2; i <= N; i++) {
        L[i] = L[i - 1] + L[i - 2];
    }
    cout << L[N] << endl;
}



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

using namespace std;

#define INF ((1<<30)-1)  //int32_t
#define MOD 1000000007
#define MOD2 

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

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


#define mkf(n,mod)  int *fact=(int *)malloc((n+1)*sizeof(int)); mfac((n),fact,(mod)) //enables to let x!=fact[x]
#define mkfiv(n,mod)  int *finv=(int *)malloc((n+1)*sizeof(int)); mfiv((n),finv,fact[n],(mod)) // 1/x! = finv[x]

int mmul(int p,int q,int m){ //O(1)?
    ll lp=p,lq=q; return ((lp%m)*(lq%m))%m;}

int mpow(int x,int n,int m){ //O(logN)
    ll res=x,ans=1;
    while(n!=0){
        if(n%2==0){ res = mmul(res,res,m);n>>=1;
        }else{      ans = mmul(ans,res,m);--n;}}return ans;}

int mdiv(int p,int q,int m){ //O(logMOD)
    return mmul(p,mpow(q,m-2,m),m);}

void mfac(int x,int *f,int m){//O(n)
    *f=1; for(int i=1;i<=x;++i)f[i]=mmul(f[i-1],i,m);}

void mfiv(int x,int *f,int fx,int m){//O(n)
    f[x] = mdiv(1,fx,m); 
    for(int i=x;i>0;--i)f[i-1]=mmul(f[i],i,m);}

int mncr(int n,int r,int m ,int* fac,int* fiv){//O(1)
    return mmul(fac[n],mmul(fiv[r],fiv[n-r],m),m);}


int main(){

    ll ans=0;
    ll n,m,k;
    cin >>n>>m>>k;

    mkf(n*m,MOD);
    mkfiv(n*m,MOD);


    for(int i=1;i<=n;i++){
        int mul= mmul(mmul((n-i),(m*m)%MOD,MOD),mncr(n*m-2,k-2,MOD,fact,finv),MOD);
        int x = mmul(i,mul,MOD);
        ans = (ans + x)%MOD;
    }

    for(int i=1;i<=m;i++){
        int mul= mmul(mmul((m-i),(n*n)%MOD,MOD),mncr((n*m)-2,k-2,MOD,fact,finv),MOD);
        int y = mmul(i,mul,MOD);
        ans = (ans + y)%MOD;
    }

    cout << ans <<endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<ll> Size;
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1);
        for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0, Size[i] = 1;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        Size[x] += Size[y];
        return true;
    }

    ll size(int x){
        return Size[root(x)];
    }
};

ll connected[100050];
ll A[100050];
ll B[100050];
int main() {
    //cout.precision(10);
    UnionFind uni(100050);
    ll N, M;
    cin >> N >> M;
    for(int i = 1; i <= M; i++) {
        cin >> A[i] >> B[i];
    }
    connected[M+1] = 0;
    for(int i = M; i >= 1; i--) {
        if(uni.issame(A[i], B[i])) {
            connected[i] = connected[i + 1];
            continue;
        }
        ll before = uni.size(A[i]);
        ll before2 = uni.size(B[i]);
        connected[i] = connected[i+1] - (before*(before-1))/2 - (before2*(before2-1))/2;
        ll after = before + before2;
        connected[i] += after*(after-1)/2;
        uni.merge(A[i], B[i]);
    }
    for(int i = 1; i <= M; i++) {
        cout << -connected[i+1] +connected[1] << endl;
        //cout << connected[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 5248
# D
from math import sqrt
def sieve(n:int)->list:
    """エラトステネスの篩"""
    if n<2:  return [False]*(n+1)
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(sqrt(n))+1):
        if is_prime[i]:
            for j in range(i*2, n+1, i):
                is_prime[j] = False
    
    return is_prime


N = int(1e5)
is_prime = sieve(N)
# like-2017
cnt = [0]*(N+1)
for i in range(1, N+1):
    cnt[i] += cnt[i-1]
    if is_prime[i] and is_prime[(i+1)//2]:
        cnt[i] += 1
    
import sys
Q = sys.stdin.readline()
for l,r in (map(int, line.split()) for line in sys.stdin.readlines()):
    print(cnt[r] - cnt[l-1])

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

namespace Atc_0028
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();

            int A = int.Parse(str.Split(' ')[0]);

            int B = int.Parse(str.Split(' ')[1]);

            if ((A + B) % 2 == 0)
            {
                Console.WriteLine((A + B) / 2);
            }
            else
            {
                Console.WriteLine("IMPOSSIBLE");
            }

        }
    }
}


Measured memory_bytes: 27432
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val a = List.fill(n)(sc.nextInt())

  def shiftCount(n: Int, res: Int = 0): Int = {
    if (n % 2 == 0) {
      shiftCount(n / 2, res + 1)
    } else {
      res
    }
  }

  println(a.map(shiftCount(_)).min)
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define DIM (long long)100007
#define INF (long long)100000000007

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pairll;

ll n,m,i,j,k,res,sum;
ll v[DIM];
ll w[DIM];
ll dp[107][DIM];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m;
    for(i=1; i<=n; i++) {

        cin >> w[i] >> v[i];
        sum+=v[i];
    }

    for(i=1; i<=n; i++){
        for(j=0; j<=sum; j++){
                dp[i][j]=INF;
        }
    }
    sum=0;
    for(i=1; i<=n; i++){

            for(j=0; j<=sum; j++){
                dp[i][j]=dp[i-1][j];
        }
        for(j=0; j<=sum; j++){
                if(dp[i-1][j]+w[i]<=m && dp[i-1][j]+w[i]<dp[i][j+v[i]]){
                    dp[i][j+v[i]]=dp[i-1][j]+w[i];
                }
        }
        sum+=v[i];
    }




    for(j=sum; j>=0; j--){
        for(i=1; i<=n; i++){
                if(dp[i][j]!=0 && dp[i][j]!=INF) {
                    res=max(j,res);
                    //cout << dp[i][j] << " ";
                }
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 81408
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
#include<math.h>
#include<list>
#include<map>
using namespace std;
typedef long long ll;
#define PI 3.14159265358979323846  



int main() {
	int n;
	string s,s2;
	bool ans=true;
	cin >>n>> s;
	if (s.length() % 2 == 0) {
		s2 = s.substr(s.length() / 2);
		for (int i = 0; i < s.length()/2; i++) {
			if (s2[i] != s[i]) {
				ans = false;
			}
		}
		
	}
	else {
		ans = false;
	}
	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
/*

Author : AllKilled
Date   : 201910277

Contest: AtCoder Beginner Contest 144.
Problem: Task E.
Result :

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

typedef long long LL;

const LL MAXN = 1e6+7;

///--------------------------------------------///

struct Node {
    LL p, a, f;
    friend bool operator < (const Node& x, const Node& y){
        return x.p<y.p || (x.p==y.p && x.f>y.f);
    }
};
priority_queue<Node> pq;
LL N, K, A[MAXN], F[MAXN];

int main()
{
    cin >> N >> K;
    LL sum = 0;
    for(int i = 1; i <= N; ++i){
        cin >> A[i];
        sum += A[i];
    }
    if(K >= sum) {
        cout << "0" << endl;
        return 0;
    }
    for(int i = 1; i <= N; ++i) cin >> F[i];
    sort(A+1, A+1+N);
    sort(F+1, F+1+N, greater<LL>());
    //for(int i = 1, j = N; i <= N; ++i, --j) cout<<A[i]<<" "<<F[i]<<endl;
    LL l = 1, r = 1e14;
    while(l < r){
        LL mid = l + r >> 1;
        LL sum = 0;
        for(int i = 1; i <= N; ++i){
            sum += max(0ll, A[i]-mid/F[i]);
        }
        if(sum <= K) r = mid;
        else l = mid + 1;
    }
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 5888
#include <iostream>
#include <math.h>
#include<iomanip>
using namespace std;
int main(){
  int max = 0;
  int min = 0;
  long long sum = 0;

  int i;
  int num;

  cin >> i;

  while(i > 0){
    cin >> num;

    if(min == 0 && max == 0 && sum == 0){
      min = num;
      max = num;
    }
    if(num > max){
      max = num;
    }
    if(num < min){
      min = num;
    }

    sum += num;
    i--;
  }



  cout << min << " " << max << " " << sum << endl;
}



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

bool solve() {
    ll N;
    cin >> N;
    vector<ll> A(N), B(N);
    for ( int i = 0; i < N; i++ ) cin >> A[i];
    for ( int i = 0; i < N; i++ ) cin >> B[i];
    vector<pii> ba;
    for ( int i = 0; i < N; i++ ) {
        ba.push_back(pii(B[i],A[i]));
    }
    sort(ba.begin(), ba.end());
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    for ( int i = 0; i < N; i++ ) {
        if ( A[i] > B[i] ) return false;
    }
    for ( int i = 0; i < N-1; i++ ) {
        if ( B[i] >= A[i+1] ) return true;
    }
    vector<ll> ia(N);
    for ( int i = 0; i < N; i++ ) {
        ia[i] = lower_bound(A.begin(), A.end(), ba[i].second) - A.begin();
    }
    ll k = 0;
    for ( int i = 0; i < N-1; i++ ) {
        k = ia[k];
        if ( k == 0 ) return true;
    }
    return false;
}

int main() {
    string ans = solve() ? "Yes" : "No";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4080
import sys
input=sys.stdin.readline

def main():
    inf=float('inf')
    n,m=map(int,input().split())
    Cost=[0]*m
    Key=[0]*m
    for i in range(m):
        a,b=map(int,input().split())
        C=tuple(map(int,input().split()))
        Cost[i]=a
        for c in C:
            Key[i]+=1<<(c-1)
    DP=[inf]*(1<<n)
    DP[0]=0
    for c,k in zip(Cost,Key):
        for i in range(1<<n):
            DP[i|k]=min(DP[i|k],DP[i]+c)
    print(-1 if DP[-1]==inf else DP[-1])

if __name__=='__main__':
    main()

Measured memory_bytes: 43628
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

#define mod 1000000007

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;

int sm[200002];
int tt[200002];

int main() {
	int N, C;
	cin >> N >> C;
	vector<int> s(N), t(N), c(N);
	rep(i, N) {
		cin >> s[i] >> t[i] >> c[i];
	}
	REP(i, 1, C + 1) {
		rep(j, 200002) tt[j] = 0;
		rep(j, N) {
			if (c[j] == i) {
				tt[s[j] * 2 - 1]++;
				tt[t[j] * 2]--;
			}
		}
		REP(j, 1, 200002) tt[j] += tt[j - 1];
		rep(j, 200002) if (tt[j] > 0) sm[j]++;
	}
	int mx = 0;
	rep(j, 200002) mx = max(mx, sm[j]);
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define mn(a, b) (a < b ? a : b)
#define mx(a, b) (a > b ? a : b)
#define f first
#define s second
#define all(v) (v).begin(), (v).end()
#define base 331

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int const MAXn = 1e5 + 2, MOD = 1e9 + 7;

int dp[MAXn][2];
vector < int > adya[MAXn];

void DFS(int nod, int p){
    bool hoja = true;
    ll mult1 = 1;
    ll mult2 = 1;
    for(auto to: adya[nod]){
        if(to == p) continue;
        hoja = false;
        DFS(to, nod);
        mult1 = mult1 * dp[to][0] % MOD;
        mult2 = mult2 * ((dp[to][0] + dp[to][1]) % MOD) % MOD;
    }
    if(hoja){
        dp[nod][0] = dp[nod][1] = 1;
        return;
    }
    dp[nod][1] = mult1;
    dp[nod][0] = mult2;
}

int main(){

    //freopen(".in","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for(int i = 1; i < n; i++){
        int n1, n2;
        cin>>n1>>n2;
        adya[n1].push_back(n2);
        adya[n2].push_back(n1);
    }
    DFS(1, -1);
    cout<<(dp[1][0] + dp[1][1]) % MOD;
    return 0;
}


Measured memory_bytes: 13440
#include <iostream>
#include <unordered_set>
#include <cstdint>
#include <vector>
#include <string>
#include <climits>
#include <set>
#include <algorithm>
using namespace std;

int main()
{
	int n;
	cin >> n;
	if (n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9)
		cout << "hon";
	else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8)
		cout << "pon";
	else cout << "bon";
}

Measured memory_bytes: 3572