akhauriyash/Code-Regression huggingface dataset:
//It is made by Awson on 2018.2.2
#include <bits/stdc++.h>
#define LL long long
#define dob complex<double>
#define Abs(a) ((a) < 0 ? (-(a)) : (a))
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
#define Swap(a, b) ((a) ^= (b), (b) ^= (a), (a) ^= (b))
#define writeln(x) (write(x), putchar('\n'))
#define lowbit(x) ((x)&(-(x)))
using namespace std;
const int N = 100000;
const int yzd = 1e9+7;
void read(int &x) {
    char ch; bool flag = 0;
    for (ch = getchar(); !isdigit(ch) && ((flag |= (ch == '-')) || 1); ch = getchar());
    for (x = 0; isdigit(ch); x = (x<<1)+(x<<3)+ch-48, ch = getchar());
    x *= 1-2*flag;
}
void print(int x) {if (x > 9) print(x/10); putchar(x%10+48); }
void write(int x) {if (x < 0) putchar('-'); print(Abs(x)); }

int n, m, s, t, u, v, c;
struct tt {int to, next, cost; }edge[(N<<2)+5];
int path[N+5], top;
int ans1[N+5], ans2[N+5], vis[N+5], in[N+5];
LL dist1[N+5], dist2[N+5];
queue<int>Q;
vector<int>to[N+5];

void add(int u, int v, int c) {
    edge[++top].to = v, edge[top].cost = c, edge[top].next = path[u], path[u] = top;
}
void SPFA(int s, LL *dist) {
    dist[s] = 0; Q.push(s); vis[s] = 1;
    while (!Q.empty()) {
	int u = Q.front(); Q.pop(); vis[u] = 0;
	for (int i = path[u]; i; i = edge[i].next)
	    if (dist[edge[i].to] > dist[u]+edge[i].cost) {
		dist[edge[i].to] = dist[u]+edge[i].cost;
		if (!vis[edge[i].to]) {
		    vis[edge[i].to] = 1; Q.push(edge[i].to);
		}
	    }
    }
}
void topsort(int s, LL *dist, int *ans) {
    for (int u = 1; u <= n; u++) {
	to[u].clear();
	for (int i = path[u]; i; i = edge[i].next)
	    if (dist[edge[i].to] == dist[u]+edge[i].cost) to[u].push_back(edge[i].to), ++in[edge[i].to];
    }
    ans[s] = 1; Q.push(s);
    while (!Q.empty()) {
	int u = Q.front(), size = to[u].size(); Q.pop();
	for (int i = 0; i < size; i++) {
	    if (--in[to[u][i]] == 0) Q.push(to[u][i]); (ans[to[u][i]] += ans[u]) %= yzd;
	}
    }
}
void work() {
    read(n), read(m), read(s), read(t);
    for (int i = 1; i <= m; i++) {
	read(u), read(v), read(c); add(u, v, c); add(v, u, c);
    }
    memset(dist1, 127/3, sizeof(dist1));
    SPFA(s, dist1); topsort(s, dist1, ans1);
    memset(dist2, 127/3, sizeof(dist2));
    SPFA(t, dist2); topsort(t, dist2, ans2);
    int ans = 1ll*ans1[t]*ans1[t]%yzd;
    for (int u = 1; u <= n; u++) {
	if (dist1[u] == dist2[u] && dist2[u]*2 == dist1[t]) (ans -= 1ll*ans1[u]*ans1[u]%yzd*ans2[u]%yzd*ans2[u]%yzd) %= yzd;
	for (int i = path[u]; i; i = edge[i].next)
	    if (dist1[u]+edge[i].cost+dist2[edge[i].to] == dist1[t] && dist1[u]*2 < dist1[t] && dist2[edge[i].to]*2 < dist1[t])
		(ans -= 1ll*ans1[u]*ans1[u]%yzd*ans2[edge[i].to]%yzd*ans2[edge[i].to]%yzd) %= yzd;
    }
    writeln((ans+yzd)%yzd);
}
int main() {
    work();
    return 0;
}

Measured memory_bytes: 14208
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

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

    cout << n * n * n << endl;

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Mon May 13 18:58:31 2019

@author: avina
"""

A,B,K = map(int, input().strip().split())
i = min(A,B)
while K > 0:
  if A%i == 0 and B%i == 0:
    K-=1
  i-=1
print(i+1)

Measured memory_bytes: 2940
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
input = sys.stdin.readline
 
# bisect_left(lists, 3)
# bisect_right(lists, 3)

# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

def main():
	N, M = map(int, input().split(" "))
	#N = int(input())
	#S = input()

	A = input().split(" ")
	A = list(A)
	#A = A[:-1]
	A = [(int(s) * (-1), 1) for s in A]
	heapq.heapify(A)

	for i in range(M):
		b, c = map(int, input().split(" "))
		heapq.heappush(A, (c * (-1), b))
	
	ans = []
	for i in range(N):
		t, con = heapq.heappop(A)
		for _ in range(con):
			if len(ans) == N:
				print(sum(ans))
				sys.exit()
			ans.append(t * (-1))
	print(sum(ans))


if __name__ == "__main__":
	main()

Measured memory_bytes: 31276
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}

int main(){
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  if(k%2==0){
    cout<<a-b<<endl;
    return 0;
  }
  cout<<b-a<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
#include <typeinfo>
#include <cstdlib>

using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()

int main() {
    char date[15]; scanf("%s",date);
    string Date(date);
    ll a,b,c,d,e,f,g,h;
    a = ll(Date[0])-ll('0'); 
    b = ll(Date[1])-ll('0');
    c = ll(Date[2])-ll('0');
    d = ll(Date[3])-ll('0');
    e = ll(Date[5])-ll('0');
    f = ll(Date[6])-ll('0');
    g = ll(Date[8])-ll('0');
    h = ll(Date[9])-ll('0');
    ll year = a*1000+b*100+c*10+d;
    ll month = e*10+f;
    ll day = g*10+h;
    if (year < 2019) cout << "Heisei" << endl;
    else if(year > 2019) cout << "TBD" << endl;
    else {
        if (month < 4) cout << "Heisei" << endl;
        else if (month > 4) cout << "TBD" << endl;
        else {
            if (day <= 30) cout << "Heisei" << endl;
            else cout << "TBD" << endl;
            
        }
    }
    return 0;
}


Measured memory_bytes: 256
# 0405の分もやる

# ABC153-C
if False:
    N,K=map(int,input().split())
    H=[int(i) for i in input().split()]
    H.sort(reverse=True)
    print(sum(H[K:]))

# ABC153-D
if False:
    H=int(input())
    cnt=1
    ans=0
    while H>1:
        ans+=cnt
        H//=2
        cnt*=2
    print(ans+cnt)

# ABC153-A
if False:
    # ceil関数
    def ceil(a,b): #ceil(a/b)
        return (a+b-1)//b

    H,A=map(int,input().split())
    print(ceil(H,A))

# ABC153-B
H,N=map(int,input().split())
A=[int(i) for i in input().split()]
if sum(A)>=H:
    print('Yes')
else:
    print('No')

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


 
class ModInt{
private:
  long long val;
  static const int default_mod = 1e9 + 7;
  static int mod;
  static vector<ModInt> facts;
public:
  ModInt(long long val)
  {
    if(mod == 0){
      mod = default_mod;
    }
    this->val = ((val % mod) + mod) % mod;
  }
  ModInt()
    : ModInt(0)
  {
  }
  static void setMod(int mod){
    if(ModInt::mod != 0){
      throw "The modulo is already set.";
    }
    ModInt::mod = mod;
  }

  const ModInt operator* (const ModInt& another) const{
    return ModInt(val * another.val);
  }
  ModInt operator+ (const ModInt& another){
    return ModInt(val + another.val);
  }
  ModInt operator- (const ModInt & another){
    return ModInt(val - another.val + mod);
  }
  ModInt operator/(const ModInt& rhs){
    return (*this) * rhs.inv();
  }
  ModInt& operator*=(const ModInt& rhs){
    (*this) = (*this) * rhs;
    return *this;
  }
  ModInt& operator+=(const ModInt& rhs){
    (*this) = (*this) + rhs;
    return *this;
  }
  ModInt& operator-=(const ModInt& rhs){
    (*this) = (*this) - rhs;
    return *this;
  }
  ModInt& operator/=(const ModInt& rhs){
    (*this) = (*this) / rhs;
    return *this;
  }
  ModInt pow(long long exponent) const{
    exponent %= mod;
    if(exponent == 0){
      return ModInt(1);
    }else{
      if(exponent % 2){
        return ((*this) * (*this)).pow(exponent / 2) * (*this);
      }else{
        return ((*this) * (*this)).pow(exponent / 2);
      }
    }
  }
  ModInt inv() const{
    return this->pow(mod - 2);
  }
  static ModInt fact(long long n){
    if(n >= mod){
      return 0;
    }
    if(facts.size() < static_cast<size_t>(n + 1)){
      if(facts.size() == 0){
        facts.push_back(1);
      }
      for(int i = facts.size(); i <= n; i++){
        facts.push_back(facts[i - 1] * i);
      }
    }
    return facts[n];
  }
  static ModInt comb(long long n, long long r){
    if(r > n){
      return 0;
    }
    return ModInt::fact(n) * ModInt::fact(r).inv() * ModInt::fact(n - r).inv();
  }
 
  friend ostream& operator<< (ostream& os, const ModInt& modint){
    os << modint.val;
    return os;
  }
  friend istream& operator>>(istream& is, ModInt& modint){
    long long val;
    is >> val;
    modint.val = val % modint.mod;
    return is;
  }
  friend ModInt operator*(const long long lhs, const ModInt& rhs){
    return ModInt(lhs) * rhs;
  }
};
int ModInt::mod = 0;
vector<ModInt> ModInt::facts;

// 2^n - 1 - nCa - nCb

int main(){
  long long n, a, b;
  cin >> n >> a >> b;

  ModInt n2 = ModInt(2).pow(n);

  ModInt nca = 0, ncb = 0;
  if(n < 1e9 + 7){
    // nCa = n * ... * (n - a + 1) / a!
    vector<ModInt> facts_up(b + 1), facts_dn(b + 1);
    facts_dn[0] = ModInt(1);
    facts_up[0] = ModInt(n);
    for(int i = 1; i <= b; i++){
      facts_dn[i] = facts_dn[i - 1] * i;
      facts_up[i] = facts_up[i - 1] * (n - i);
    }

    nca = facts_up[a - 1] * facts_dn[a].inv();
    ncb = facts_up[b - 1] * facts_dn[b].inv();
  }

  //cout << n2 << ' ' << nca << ' ' << ncb << endl;
  ModInt ans = n2 - 1 - nca - ncb;
  cout << ans << endl;
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int a,b,ans = 0;
    cin >> a >> b;
    nfor(i, a, b + 1){
        if ((i % 10) == i / 10000 && (i % 100) / 10 == (i % 10000) / 1000) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    ll x, y;
    cin >> x >> y;
    x--;  y--;
    
    vector<vector<P>> G(n);
    rep(i, n-1) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(make_pair(b, 1));
        G[b].pb(make_pair(a, 1));
    }
    
    vl dist1(n, -1);  // dist1[v] : 頂点vの頂点xからの距離
    queue<ll> Q1;
    dist1[x] = 0;
    Q1.push(x);
    while(!Q1.empty()) {
        ll v = Q1.front();
        Q1.pop();
        for(auto p : G[v]) {
            ll u = p.first;
            ll cost = p.second; 
            if(dist1[u] != -1) {
                continue;
            }
            dist1[u] = dist1[v] + cost;
            Q1.push(u);
        }
    }
    
    vl dist2(n, -1);  // dist2[v] : 頂点vの頂点yからの距離
    queue<ll> Q2;
    dist2[y] = 0;
    Q2.push(y);
    while(!Q2.empty()) {
        ll v = Q2.front();
        Q2.pop();
        for(auto p : G[v]) {
            ll u = p.first;
            ll cost = p.second; 
            if(dist2[u] != -1) {
                continue;
            }
            dist2[u] = dist2[v] + cost;
            Q2.push(u);
        }
    }
    
    ll ans = 0;
    rep(v, n) {
        if(dist1[v] < dist2[v]) {
            chmax(ans, dist2[v]);
        }
    }
    ans--;
    
    out(ans);
    re0;
}

Measured memory_bytes: 9472
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

int N, M, K, Q, W, H, L, R, C, A, B;
string S;

int main() {
    cin >> N >> A >> B;
    if (N + 1 < A + B) {
        cout << -1 << endl;
        return 0;
    }
    vector<int> ans;
    if (A >= B) {
        if (B >= ((N + A - 1) / A)) {
            int b = 0;
            int now = 1;
            while ((b + (N - b + A - 1) / A) < B) {
                ans.push_back(now);
                b++;
                now++;
            }
            int low = now - 1;
            int up = low + A;
            while (low <= N) {
                now = up;
                while (now > low) {
                    if (now > N) {
                        now--;
                        continue;
                    }
                    ans.push_back(now);
                    now--;
                }
                low = up;
                up = up + A;
            }
            reverse(ALL(ans));
        } else {
            cout << -1 << endl;
            return 0;
        }
    } else {
        if (A >= ((N + B - 1) / B)) {
            int a = 0;
            int now = N;
            while ((a + (N - a + B - 1) / B) < A) {
                ans.push_back(now);
                a++;
                now--;
            }
            int up = now + 1;
            int low = up - B;
            while (up > 0) {
                now = low;
                while (now < up) {
                    if (now <= 0) {
                        now++;
                        continue;
                    }
                    ans.push_back(now);
                    now++;
                }
                up = low;
                low = low - B;
            }
            reverse(ALL(ans));
        } else {
            cout << -1 << endl;
            return 0;
        }
    }

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

    return 0;
}


Measured memory_bytes: 3440
#include <iostream>
#include <algorithm>
#include <complex>

using namespace std;

int main() {
	int a,b,c,d;
	
	cin >> a >> b >> c >> d;

  if (abs(a-c) <= d || (abs(a-b) <=  d && abs(b-c) <= d)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int b[100050];
    int len,i;
    char a[100050];
    scanf("%s",a);   len=strlen(a);
    for(i=0;i<len;i++)
    {
        if(a[i]=='0')
            b[i]=0;
        else
            b[i]=1;
    }


    int ci=0,ct=0;
    for(i=0;i<len;i++)
    {
        if(i%2==0)
        {
            if(b[i]!=0)
                ci++;
        }
        else
        {
            if(b[i]!=1)
                ci++;
        }

        if(i%2==0)
        {
            if(b[i]!=1)
                ct++;
        }
        else
        {
            if(b[i]!=0)
                ct++;
        }
    }

    printf("%d\n",min(ci,ct));
    return 0;
}

Measured memory_bytes: 768
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let n: usize = read();
    let mut a: Vec<u64> = read_col(n);
    let mut ans: u64 = 0;
    for i in 0..n {
        if a[i] == 0 {
            continue;
        }
        let p = (a[i] - 1) / 2;
        ans += p;
        a[i] -= 2 * p;
    }
    for i in 0..n - 1 {
        if a[i] == 2 {
            a[i] = 0;
            ans += 1;
        } else if a[i] == 1 {
            if a[i + 1] > 0 {
                a[i] -= 1;
                a[i + 1] -= 1;
                ans += 1;
            }
        }
    }
    if a[n - 1] == 2 {
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
typedef long long ll;
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
typedef struct{
    int p;
    int q;
}data;

//昇順
int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}
int asc(const void *a, const void *b) {
  long *A = (long *)a;
  long *B = (long *)b;
  if (*A > *B) return 1;
  if (*A < *B) return -1;
  return 0;
}

int kai(int n){
    if(n==0){
        return 1;
    }
    int sum=1;
    for(int i=1;i<=n;i++){
        sum*=i;
    }
    return sum;
}
//構造体の.pを降順
int comp( const void *c1, const void *c2 )
{ data test1 = *(data *)c1;
  data test2 = *(data *)c2;
  int tmp1 = test1.p;   /* b を基準とする */
  int tmp2 = test2.p;
    return tmp2 - tmp1;}




int main(){
    int bl,rd;
    scanf("%d",&rd);
    char rc[rd][12];
    rep(i,rd){
        scanf("%s",rc[i]);
    }
    scanf("%d",&bl);
    char bc[bl][12];
    rep(i,bl){
        scanf("%s",bc[i]);
    }
    int max=0;
    for(int i=0;i<rd;i++){
        int cnt=0;
        for(int j=i;j<rd;j++){
            if(strcmp(rc[i],rc[j])==0){
                cnt++;
            }else{
                ;
            }
        }
        for(int k=0;k<bl;k++){
            if(strcmp(rc[i],bc[k])==0){
                cnt--;
            }else{
                ;
            }
        }
        if(max<cnt){
            max=cnt;
        }
    }
    if(max<=0){
        printf("0");
        return 0;
    }else{
        printf("%d",max);
        return 0;
    }
}


Measured memory_bytes: 1708
import java.util.Scanner

fun main(args: Array<String>){
  val cin = Scanner(System.`in`)
  val a = cin.nextInt()
  val b = cin.nextInt()
  val c = cin.nextInt()
  if (b - a == c - b){
    println("YES")
  }
  else {
    println("NO")
  }
  
  cin.close()
}

Measured memory_bytes: 23340
#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "vector"
#include "map"
#include "set"
#include "queue"
using namespace std;
#define MAXN 1000006
//#define int long long
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define all(x) (x).begin() , (x).end()
#define mem( a ) memset( a , 0 , sizeof a )
typedef long long ll;
#define P 1000000007
int n , x;
int A[MAXN] , B[MAXN]; map<int,int> ok;
void solve() {
    int x , y;
    cin >> x >> y;
    if( ( y & 1 ) || y < 2 * x || 4 * x < y ) puts("No");
    else puts("Yes");
}

signed main() {
//    int T;cin >> T;while( T-- ) solve();
    solve();
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <stack>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右下左上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, -1 };
constexpr int dy[] = { 0, 1, 0, -1, 1, 1 };

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

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; ++i) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t szi, szj;
        inp(std::size_t _szi = 1, std::size_t _szj = 1) : szi(_szi), szj(_szj) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(szi); for (std::size_t i = 0; i < szi; ++i) std::cin >> a[i]; return a; }
        template <typename T> operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i) for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j]; return a;
        }
    };
    inp inp1;
}

int main() {

    int n = inp1;
    vector<int> a = inp(n);

    sort(allof(a));

    const int kMax = a[n - 1] + 1;
    vector<bool> table(kMax, true);
    vector<int> num(kMax, 0);

    for (auto v : a) {
        ++num[v];
    }

    int ans = 0;
    for (auto v : a) {
        if (!table[v]) continue;

        if (num[v] == 1) ++ans;

        for (int i = v; i < kMax; i += v) {
            table[i] = false;
        }
    }

    Cout(ans);

    return 0;
}


Measured memory_bytes: 7932
#include<bits/stdc++.h>
#define maxn 200005
#define ll long long
using namespace std;
int read(){
	int x=0,c;while(!isdigit(c=getchar()));
	while(x=x*10+c-'0',isdigit(c=getchar()));
	return x;
}
int mi[maxn],n,a[maxn],cnt[maxn];
void insert(int x){
	for(int i=0;i<=20;i++)
		if(x&mi[i])cnt[i]++;
}
bool check(int x){
	for(int i=0;i<=20;i++)
		if((x&mi[i])&&(cnt[i]))return 0;
	return 1;
}
void del(int x){
	for(int i=0;i<=20;i++)
		if(x&mi[i])cnt[i]--;
}
int main(){
	n=read();mi[0]=1;for(int i=1;i<=20;i++)mi[i]=mi[i-1]*2;ll ans=0;
	for(int i=1;i<=n;i++)a[i]=read();
	for(int i=1,r=0;i<=n;i++){
		if(r<i)insert(a[i]),r=i;
		while(r<n&&check(a[r+1]))r++,insert(a[r]);
		ans+=(r-i+1);
		del(a[i]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
//    ? WHY YOU OPEN THIS ?    //
 
#include<bits/stdc++.h>
using namespace std;
#define int long long
 
#define PAIR    pair<int,int>
#define Vector  vector<int>
#define MAP     map<int,int>
#define pb      push_back
#define mk      make_pair
#define sz(x)   (int)(x).size()
#define MOD     1e9+7 
#define all(a)  begin(a),end(a)
#define F       first
#define S       second
 
#define FOR(i,a,b)     for(int i=a;i<b;i++)
#define ROF(i,a,b)     for(int i=a;i>=b;i--)
#define check(c)       cout<<#c<<" : "<<c<<endl;
#define check2(a,b)    cout<<#a<<" : "<<a<<" | "<<#b<<" : "<<b<<endl;
#define check3(a,b,c)  cout<<#a<<" : "<<a<<" | "<<#b<<" : "<<b<<" | "<<#c<<" : "<<c<<endl;
#define SWIFT          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

// int gcd(int a, int b) 
// { 
//     if (b == 0) 
//         return a; 
//     return gcd(b, a % b);  
// } 

void testCase(){
    double n, x, t;
    cin >> n >> x >> t;
    int ans = ceil(n / x) * t;
    cout << ans << endl;
}
    
     
signed main(){
    SWIFT;
    
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    int t = 1;
    // int t; cin >> t;
    FOR(i, 0, t){
        testCase();
    }
    return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。
ll GCD(ll x , ll y){
    ll N = min(x , y);
    ll gcd = 1;
    for(ll i = 2; i <= N; i++){
        if(x % i == 0 && y % i == 0){
            gcd = i;
        }
        else{
            continue;
        }
    }
    return gcd;
}
int main () {
    ll A , B;
    cin >> A >> B;
    ll V = GCD(A , B);
    cout << A / V * B / V * V << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int K, X;
    cin >> K >> X;

    if (500 * K >= X) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {
	int n;cin>>n;
	vector<int> w(n);
	for(auto& x:w){
		cin>>x;
	}
	int ans=10000;
	for(int i=0;i<n-1;i++){
		int sum1=0;
		int sum2=0;
		for(int j=0;j<=i;j++){
			sum1+=w[j];
		}
		for(int j=i+1;j<n;j++){
			sum2+=w[j];
		}
//		cout<<sum1<<sum2<<endl;
		int dif=sum1-sum2;
		if(dif<0)dif*=-1;
		ans=min(ans,dif);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
A, B, C, D, E, F = map(int, input().split())


def concentration(water, suger):
    if water * E/100 < suger or water + suger == 0:
        return 0
    return (100 * suger/(water + suger))

lst_w = []
limit_w = (F+A*100-1)//(A*100)
for i in range(limit_w):
    for j in range(limit_w):
        if 100 * (A * i + B * j) <= F:
            lst_w += [100 * (A * i + B * j)]

lst_s = []
limit_s = (F+C-1)//C
for i in range(limit_s):
    for j in range(limit_s):
        if C* i + D * j <= F:
            lst_s += [C * i + D * j]

# print (lst_w)
# print (lst_s)
set_w = set(lst_w)
set_s = set(lst_s)

# print (set_w)
# print (set_s)

ans = 0
ans_total = 0
ans_suger = 0
for water in set_w:
    for suger in set_s:
        if water + suger <= F:
            a = concentration(water, suger)
            if ans < a:
                ans = a
                ans_total = water + suger
                ans_suger = suger
            if ans == 50:
                print (ans_total, ans_suger)
                sys.exit()

if ans == 0:
    print (A * 100, 0)
else:
    print (ans_total, ans_suger)

# print (ans)


Measured memory_bytes: 12456
#include <bits/stdc++.h>
#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables **************/
int n;
vector<int> a, b;
/**********************************************/

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

    cin >> n;
    a.resize(n);
    b.resize(n);
    REP(i, n) cin >> a[i];
    REP(i, n) cin >> b[i];
    int ans = 0;
    REP(i, 29){
        vector<int> amod(n, 0), bmod(n, 0);
        REP(j, n) amod[j] = a[j] % (2 << i), bmod[j] = b[j] % (2 << i);
        sort(all(bmod));
        
        int cnt = 0;
        REP(j, n){
            if(amod[j] & (1 << i)){
                cnt += lower_bound(all(bmod), (2 << i) - amod[j]) - bmod.begin();
                cnt += bmod.end() - lower_bound(all(bmod), (3 << i) - amod[j]);
            }else{
                cnt += lower_bound(all(bmod), (2 << i) - amod[j]) - lower_bound(all(bmod), (1 << i) - amod[j]);
            }
        }
        if(cnt % 2 == 1) ans ^= (1 << i);
    }
    cout << ans << endl;
}


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

#define ll long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (ll)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 200005

vector<int> g[mxn];
int main() {
sp;
int n,m;
cin>>n>>m;
int in[n+1],dp[n+1];
memset(in,0,sizeof in);
memset(dp,0,sizeof dp);
int x,y;
queue<int> q;
while(m--){
    cin>>x>>y;
    g[x].pb(y);
    ++in[y];
}
for(int i=1; i<=n; ++i)
if(in[i]==0)q.push(i);
int ans=1;
while(!q.empty()){
    x=q.front();
    q.pop();
    for(auto &it:g[x]){
        --in[it];
        if(in[it]==0)q.push(it);
        dp[it]=max(dp[it],dp[x]+1);
        ans=max(ans,dp[it]);
    }
}
cout<<ans;
return 0;
}


Measured memory_bytes: 8832
fun main(arr:Array<String>) {
    println(if(canBackHome(readLine()!!)) "Yes" else "No")
}

fun canBackHome(log:String):Boolean {
    val list1 = "SENW"
    val list2 = "NWSE"
    for(i in list1.indices) {
        if(log.contains(list1[i])) {
            if(!log.contains(list2[i])) {
                return false
            }
        }
    }
    return true
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()

int n;
int score[110][5];

void solve() {
	vector< int > all_score;
	
	for_(i,0,n) {
		int sum = 0;
		for_(j,0,5) sum += score[i][j];
		all_score.push_back(sum);
	}
	
	sort(allof(all_score));
	
	cout << all_score[n - 1] << " " << all_score[0] << endl;
}

int main() {
	while (cin >> n, n) {
		for_(i,0,n) for_(j,0,5) cin >> score[i][j];
		solve();
	}
	return 0;
}

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

using namespace std;
long long n,i,j,sol,cnt[27];
char s[200005];

int main()
{
    cin>>s;
    n=strlen(s);
    for(i=0;i<n;i++) cnt[s[i]-'a']++;
    sol=1+((n*(n+1))/2);
    for(i=0;i<26;i++) sol-=(cnt[i]*(cnt[i]+1))/2;
    cout<<sol<<'\n';
    return 0;
}


Measured memory_bytes: 384
<?php /*atcoder.php*/

$at = new Atcoder();
$at->main();
unset($at);

class Atcoder{
	private function lineIn(){
		$buf = fgets(STDIN);
		return $this->killNewLine($buf);
	}
	private function killNewLine($buf = null){
		$buf = str_replace("\r\n", "", $buf);
		$buf = str_replace("\n", "", $buf);
		$buf = str_replace("\r", "", $buf);
		return $buf;
	}

	public function main(){
		$s = $this->lineIn();
	
		if(1 == $s){
			echo "Hello World\n";
		}else{
			$ans  = $this->lineIn();
			$ans += $this->lineIn();
			echo $ans . "\n";
		}
	}
}
?>

Measured memory_bytes: 4728
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 10**6
for i in range(M):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x-1] + b[y-1] - c)
print(min(ans, min(a) + min(b)))


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

const int mod = 1e9 + 7;
const int MN = 2010;

int N, K;

int cc[MN][MN][2];
int dp(int n, int mn, int t) {
    if(n == N) return 1;
    int &ret = cc[n][mn][t];
    if(ret != -1) return ret;
    if(n == K - 1) return ret = mn == 1? 0 : dp(n + 1, 1, 1);

    ret = 0;
    if(t) {
        int cnt = N - mn - n + 1;
        if(cnt > 0) {
            ret += dp(n + 1, mn, 1);
            ret %= mod;
            if(mn == 1 && cnt > 1) {
                ret += dp(n + 1, mn, 1);
                ret %= mod;
            }
        }
        if(mn > 1) {
            ret += dp(n, mn - 1, 0);
            ret %= mod;
        }
    }
    else {
        ret += dp(n + 1, mn, 1);
        ret %= mod;
        if(mn > 1) {
            ret += dp(n, mn - 1, 0);
            ret %= mod;
        }
    }

    //cout << n << ' ' << mn << ' ' << ret << endl;

    return ret;
}

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

    memset(cc, -1, sizeof(cc));
    cout << dp(0, N + 1, 1);
}


Measured memory_bytes: 32128
#include <stdio.h>

int main(void){
    char c;
    char flag=0;
    int len;
    int i;
    
    while(scanf("%c",&c)==1){
        if(c=='\n'){
            printf("\n");
        }else if(c=='@'){
            flag=1;
        }else if(flag==1){
            len=c-'0';
            flag=2;
        }else if(flag==2){
            for(i=0;i<len;i++)printf("%c",c);
            flag=0;
        }else{
            printf("%c",c);
        }
    }
    
    return 0;
}



Measured memory_bytes: 2036
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
t = [int(input()) for _ in range(d)]

last = [0] * 26
ans = 0
for di in range(d):
    ans += s[di][t[di] - 1]
    last[t[di] - 1] = di + 1
    ans -= sum(c[i] * (di + 1 - last[i]) for i in range(26))
    print(ans)


Measured memory_bytes: 68988
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int mapgem[21][21];
VI wque;
vector<char> que;
VI gemx;
VI gemy;
string search(){
	//N y+ S y-
	//E x+ W x-
	int rx = 10;
	int ry = 10;
	int dx = 0;
	int dy = 0;
	int qsize = wque.size();
	mapgem[rx][ry]=0;
	REP(i,qsize){
		dx = 0;
		dy = 0;
		if(que[i] == 'N'){dy++;}
		else if(que[i] == 'S'){dy--;}
		else if(que[i] == 'E'){dx++;}
		else if(que[i] == 'W'){dx--;}
		REP(j,wque[i]){
			rx += dx;
			ry += dy;
			mapgem[rx][ry] = 0;
		}
	}
	REP(i,gemx.size()){
		if(mapgem[gemx[i]][gemy[i]]==1){return "No";}
	}
	return "Yes";
}
int main(){
	int endlchk =8101919;
	int	N;
	int M;
	char d;
	int l;
	int mx,my;
	while(true){
		if(endlchk != 8101919){cout << endl;}
		endlchk = 0;
		cin >> N;
		if(N==0){break;}
		REP(i,20){
			REP(j,20){
				mapgem[i][j]=0;
			}
		}
		REP(i,N){
			cin >> mx >> my;
			mapgem[mx][my] = 1;
			gemx.push_back(mx);
			gemy.push_back(my);
		}
		cin >> M;
		REP(i,M){
			cin >> d >> l;
			que.push_back(d);
			wque.push_back(l);
		}
		
		cout << search();
		que.clear();
		wque.clear();
		gemx.clear();
		gemy.clear();
	}
	return 0;
}

Measured memory_bytes: 3056
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <time.h>
#include <chrono>
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(ll i=a;i>b;i--)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,l,r) for(int i=(1);i<(r);i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = (1LL << 31) - 1;
const ll mod = 1e9 + 7;


ll N,ans;

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


	cin >> N;
	
	multiset<ll> st;

	st.insert(1e9+1);

	FOR(i, 0, N) {
		ll A;
		cin >> A;

		


		if (*st.begin()>=A) {//すべてAより大きかったら
			ans++;
		}
		else {//Aより小さいものが存在したら

			auto ite = st.lower_bound(A);
			
			ite--;
			st.erase(ite);
		}
		
		
		st.insert(A);

	}
	cout << ans << endl;


}


Measured memory_bytes: 8240
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

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

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

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

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


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int A, B, Q;
        cin >> A >> B >> Q;

        vector<ll> s(A), t(B);
        rep(i, 0, A) cin >> s[i];
        rep(i, 0, B) cin >> t[i];

        rep(i, 0, Q) {
            ll x;
            cin >> x;

            ll ans = INFl;
            //まっすぐ
            if (s.back() > x && t.back() > x) {
                ll tmp = max(*lower_bound(all(s), x) - x, *lower_bound(all(t), x) - x);
                chmin(ans, tmp);
            }

            if (s.front() < x && t.front() < x) {
                ll tmp = x - min(*(lower_bound(all(s), x) - 1), *(lower_bound(all(t), x) - 1));
                chmin(ans, tmp);
            }

            //左のs, 右のt
            if (s.front() < x && t.back() > x) {
                ll L = x - *(lower_bound(all(s), x) - 1);
                ll R = *(lower_bound(all(t), x)) - x;

                ll tmp = 2 * min(L, R) + max(L, R);
                chmin(ans, tmp);
            }

            if (s.back() > x && t.front() < x) {
                ll L = x - *(lower_bound(all(t), x) - 1);
                ll R = *(lower_bound(all(s), x)) - x;

                ll tmp = 2 * min(L, R) + max(L, R);
                chmin(ans, tmp);
            }

            cout << ans << endl;

        }

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N, A, B;
	cin >> N >> A >> B;
	cout << min(A, B) << " " << max(0, A + B - N) << endl;
}

Measured memory_bytes: 256
n,m,x = map(int,input().split())
c = [list(map(int,input().split())) for _ in range(n)]
ans = []
#n冊の本において買うか買わないかの2通りなので2**n
for i in range(2**n):
    #リストの中身は値段1と理解度m個
    a = [0]*m
    price = 0
    for j in range(n):
        #n冊あるうちj冊目を買うか買わないかを判定
        if ((i >> j) & 1):
            for k in range(m):
                a[k] += c[j][k+1]
            #j冊めを買うので、合計金額を増やす
            price += c[j][0]
    if all(j >= x for j in a):
        ans.append(price)

if len(ans) == 0:
    print("-1")
else:
    print(min(ans))

Measured memory_bytes: 9056
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll n, m;
vl visited;

void dfs(const vvl &G, ll v) {
    visited[v] = 1;
    rep(u, n) {
        if(visited[u]) {
            continue;
        }
        if(G[v][u]) {
            dfs(G, u);
        }
    }
}

int main() {
    
    cin >> n >> m;    

    vvl G(n, vl(n));
    vl a(m), b(m);
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--;  b[i]--;
        G[a[i]][b[i]] = G[b[i]][a[i]] = 1;
    }

    ll bridge = 0;
    rep(i, m) {
        G[a[i]][b[i]] = G[b[i]][a[i]] = 0;
        visited.assign(n, 0);
        dfs(G, 0);
        rep(j, n) {
            if(!visited[j]) {
                bridge++;
                break;
            }
        }
        G[a[i]][b[i]] = G[b[i]][a[i]] = 1;
    }

    out(bridge);
    re0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

const ll MAXN = static_cast<ll>(1e6) + 1LL;
bool P[MAXN];

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

    vector<ll> A(N);
    rep (i, N) { cin >> A[i]; }

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

    ll ans = 0;

    for (ll i=0;i<N;++i)
    {
        if (P[A[i]]) { continue; }

        for (ll j=1;j*A[i]<MAXN;++j)
        {
            P[j*A[i]] = true;
        }

        if (i+1<N && A[i] == A[i+1]) { continue; }

        ++ans;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5832
#include<iostream>
#include<string>
using namespace std;

int main()
{
	// #ifndef IO
	// freopen("input2.txt","r",stdin);
	// #endif

   string o,e;
  cin>>o>>e;
  int l=o.length()+e.length();
  string ans(l,'a');
  for(int i=1;i<=l;i++)
  {
  	if(i&1)
  	{
  		ans[i-1]=o[i/2];
  	}
  	else
  	{
  		ans[i-1]=e[(i/2)-1];
  	}
  }
  cout<<ans;

	return 0;
}

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

#define ll long long

const int mxN=2e5, M=1e9+7;
int n, h[mxN], a[mxN];
ll ft[mxN+1], dp, ans;

void upd(int i, ll x) {
	for(; i<=n; i+=i&-i)
		ft[i]=max(ft[i], x);
}

ll qry(int i) {
	ll r=0;
	for(; i; i-=i&-i)
		r=max(ft[i], r);
	return r;
}

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

	cin >> n;
	for(int i=0; i<n; ++i)
		cin >> h[i];
	for(int i=0; i<n; ++i)
		cin >> a[i];
	for(int i=0; i<n; ++i) {
		dp=qry(h[i])+a[i];
		ans=max(dp, ans);
		upd(h[i], dp);
	}
	cout << ans;
}


Measured memory_bytes: 3328
//
// Created by kuribohkute on 20/04/2019.
//
#include <iostream>
#include <queue>
using namespace std;
#define mp make_pair
#define X first
#define Y second
int h, w;
const int N = 1003;
char a[N][N];
bool inRange(int x, int y) {
    return x && x <= h && y && y <= w;
}
typedef pair <int, int> pii;
queue <pii> qu;
void solve(int &ans) {
    int dx[4] = {0, 0, -1, 1},
        dy[4] = {-1, 1, 0, 0};

    while (qu.size()) {
        queue <pii> qu2;
        bool ok = false;
        while (qu.size()) {
            pii fr = qu.front();
            qu.pop();
            for (int i = 0; i < 4; i++) {
                int x = fr.X + dx[i];
                int y = fr.Y + dy[i];
                if (inRange(x, y) && a[x][y] == '.') {
                    a[x][y] = '#';
                    qu2.push(mp(x, y));
                    ok = true;
                }
            }
        }
        ans += ok;
        while (qu2.size()) {
            qu.push(qu2.front());
            qu2.pop();
        }
    }
}
int main () {
    cin >> h >> w;
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            cin >> a[i][j];
            if (a[i][j] == '#') {
                qu.push(mp(i, j));
            }
        }
    }
    int ans = 0;
    solve (ans);
    cout << ans;
    return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    string s;cin >> s;
    int n = s.size();
    int l, r;
    inc(i, 0, n){
        if(s[i] == 'A'){
            l = i;
            break;
        }
    }
    dec(i, 0, n){
        if(s[i] == 'Z'){
            r = i;
            break;
        }
    }
    cout << r-l+1 << endl;
    return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
int main(int argc, char* argv[])
{
	int N,K,i,j;
	cin>>N>>K;
	vector<double> q(N);
	int p;
	for (i=0;i<N;i++){
		cin>>p;
		for (j=1;j<=p;j++){
			q[i]+=j;
		}
		q[i]/=p;
	}
	double ans=0;
	double w=0;
	for (i=0;i<K;i++){
		ans+=q[i];
	}
	w=ans;
	for (i=K;i<N;i++){
		w=w+q[i]-q[i-K];
		if (ans<w){
			ans=w;
		}
	}
	printf("%.6f\n",ans);

	return 0;
}

Measured memory_bytes: 1792