akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
 
using namespace std;
 
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-10;

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

int main(){
	string s, t, u;
	int x, y;
	int k, l;
	cin>>s;
	int ans = 0;
	if(atoi(s.c_str())%2==0) ans++;
	for(int i = 1; i < s.size(); i++){
		t = s.substr(0, i);
		u = s.substr(i);
		if(t[0]=='0' || u[0]=='0') continue;
		k = atoi(t.c_str());
		l = atoi(u.c_str());
		if(l >= k && (l-k)%2==0) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1200
def rekkyo(n, s):
  if len(s) == n:
    rek.append(int(s))
    return
  
  for i in range(1, n+1):
    if not str(i) in s:
      rekkyo(n, s + str(i))
     
  return

n = int(input())
p = int(input().replace(' ', ''))
q = int(input().replace(' ', ''))

rek = []
rekkyo(n, '')

rek.sort()
p_pos = rek.index(p)
q_pos = rek.index(q)

if p_pos < q_pos:
  ans = q_pos - p_pos
else:
  ans = p_pos - q_pos

print(ans)

Measured memory_bytes: 46940
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    vector<string> s(3);
    cin >> s[0] >> s[1] >> s[2];
    cout << s[0][0] << s[1][1] << s[2][2] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

typedef pair<int, int> P;

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

    int K, A, B;
    cin >> K >> A >> B;

    if (B - A < 2LL) {
        cout << K + 1LL << endl;
        return 0;
    }

    int ans = 0;

    // 最初の1枚
    {
        int need = A - 1LL;
        need++; // 1円
        need++; // B枚に返る
        if (need > K) {
            cout << K + 1LL << endl;
            return 0;
        }

        if (B > need + 1LL) {
            ans = B;
        } else {
            ans = need + 1LL;
        }
        K -= need;
    }

    int num = K / 2LL;
    ans += (B-A) * num;
    K -= num * 2;
    ans += K;
    cout << ans << endl;


    return 0;
}


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

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

int main() {
int n, k, q;
cin >> n >> k >> q;
int a[100050];
map<int, int> sc;
for(int i = 1; i <= q; i++){
cin >> a[i];
sc[a[i]]++;
}
for(int i = 1; i <= n; i++){
if(k-q+sc[i] > 0) cout << "Yes" << endl;
else cout << "No" << endl;
}
}

Measured memory_bytes: 5760
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define int long long
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
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;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>istream&operator>>(istream&is,vector<T>&vec){rep(i,vec.size())is>>vec[i];return is;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

bool kirai[10];

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

    rep(i, K) {
        int a;
        cin >> a;
        kirai[a] = true;
    }

    rep1(i, 100000) {
        string a = to_string(i);

        rep(j, a.size()) if (kirai[a[j] - '0']) goto nxt;

        if (N <= i) {
            cout << i << endl;
            return 0;
        }
nxt:;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
using namespace std;
 
int st[100];
int si=0;
 
int pop(){
  return st[--si];
}
 
void push(int val){
  st[si++]=val;
}
 
int main(){
  char t[10];
  int a,b;
  while (cin >>t){
    if ('0'<=t[0]&&t[0]<='9')push(atoi(t));
    else{
    b=pop();
    a=pop();
      if (t[0]=='+')push(a+b);
      else if (t[0]=='-')push(a-b);
      else if (t[0]=='*')push(a*b);
    }
  }
  cout << pop() << endl;
  return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

    int ans = -1;
    rep2(i, 50000) {
        double p = i*(double)1.08;
        if (p >= n && p < n+1) {
            ans = i;
            break;
        }
    }
    if (ans == -1) {
        puts(":(");
        return 0;
    }
    cout << ans << endl;
    return 0;
}

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

int factorial(int k){
    if(k==0) return 1;

    int now=factorial(k-1);
    return k*now;
}

int main() {
    int N; cin >> N;
    vector<int> x(N); vector<int> y(N);
    for(int i=0; i<N; i++){
        cin >> x.at(i) >> y.at(i);
    }
    vector<int> order(N);
    for(int i=0; i<N; i++){
        order.at(i)=i;
    }
    double sum=0;
    do{
        for(int i=0; i<N-1; i++){
            int xnow=x.at(order.at(i+1))-x.at(order.at(i));
            int ynow=y.at(order.at(i+1))-y.at(order.at(i));
            sum=sum+sqrt(xnow*xnow+ynow*ynow);
        }
    }while(next_permutation(order.begin(),order.end()));



    cout << setprecision(7) << sum/factorial(N) << endl;
}

    

Measured memory_bytes: 3796
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

vector<ll> enum_divisors(ll N) {
    vector<ll> res;
    for (ll i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N / i != i) res.push_back(N / i);
        }
    }
    // 小さい順に並び替える
    sort(all(res));
    return res;
}

int main() {
    ll a, b,ans=0;
    cin >> a >> b;
    vector<ll>divi = enum_divisors(b);
    for (auto c : divi) {
        if (c <= b / a)ans = max(ans, c);
    }
    cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

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

  int res = 1900*m + 100*(n-m);
  rep(i, m){
    res *= 2;
  }

  cout << res << endl;

  return 0;
}


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

struct SuffixArray{
    vector<int> array, rank, lcp;
    int k, N;
    vector<int> S;

    SuffixArray(vector<int>& S){ initialize(S); }
    SuffixArray(string S=""){ initialize(S); }

    bool cmp(int i, int j){
        if(rank[i] != rank[j]) return (rank[i] < rank[j]);
        int ri = (i+k < N ? rank[i+k] : -1);
        int rj = (j+k < N ? rank[j+k] : -1);
        return ri < rj;
    }
    
    void initialize(vector<int>& Sin){
        S = Sin;
        N = S.size();
        array.resize(N);
        for(int i=0; i<N; i++) array[i] = i;
        rank = S;
        vector<int> tmp(N);

        for(k=1; k<N; k*=2){
            sort(array.begin(), array.end(), [&](int i, int j){ return cmp(i, j); });

            tmp[array[0]] = 0;
            for(int i=1; i<N; i++){
                tmp[array[i]] = tmp[array[i-1]] + cmp(array[i-1], array[i]);
            }
            for(int i=0; i<N; i++) rank[i] = tmp[i];
        }
    }

    void initialize(string& S){
        vector<int> s;
        for(int i=0; i<int(S.size()); i++) s.push_back(S[i]);
        initialize(s);
    }

    void calc_lcp(){
        lcp.resize(N-1);
        int h = 0;
        for(int i=0; i<N; i++){
            if(h > 0) h--;
            if(rank[i] == 0) continue;
            int j = array[rank[i]-1];
            for(; j+h<N && i+h<N; h++){
                if(S[j+h] != S[i+h]) break;
            }
            lcp[rank[i]-1] = h;
        }
    }
};

int main(){
    string S;
    cin >> S;
    int64_t N = S.size();
    int64_t ans = N*(N+1)/2;

    SuffixArray sa(S);
    sa.calc_lcp();
    for(int a : sa.lcp) ans -= a;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 14276
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits.h>
#define vi vector<int>
using namespace std;
vi heights, solutions;
vector<bool> sol_ready;
int minimum_cost_to(int position, int max_step)
{
	if (sol_ready[position])
		return solutions[position];
	int min_cost = INT_MAX;
	int current_height = heights[position];
	for (int new_position = position-1; new_position >= 0 && new_position >= position-max_step; new_position--)
	{
		int new_height = heights[new_position];
		int new_cost = minimum_cost_to(new_position, max_step) + abs(current_height - new_height);
		min_cost = min(min_cost, new_cost);
	}
	solutions[position] = min_cost;
	sol_ready[position] = true;
	return min_cost;
}
int main()
{
	ios::sync_with_stdio(false);
	int n, max_step; cin >> n >> max_step;
	solutions = vi(n); heights = vi(n);
	sol_ready = vector<bool>(n);
	for (size_t i = 0; i < n; i++)
		cin >> heights[i];
	sol_ready[0] = true;
	cout << minimum_cost_to(n - 1, max_step);
	return 0;
}

Measured memory_bytes: 10368
N, K = list(map(int, input().split()))
ans = 0
koe = False
for i in range(N):
    a = i + 1
    if a > K-1:
        koe = True
        break
    flag = True
    count = 0
    while flag:
        a = a * 2 # N
        count = count + 1
        if (a >= K):
            flag = False
    ans += 1/N * (1/2)**count
if koe:
    ans += (N-(K-1))/N
print(ans)

Measured memory_bytes: 3064
import sys
import bisect
N, M = map(int, input().split())
A = sorted(map(int, input().split()))
CB = [None] * M
for i in range(M):
    b, c = map(int, sys.stdin.readline().split())
    CB[i] = (c, b)
CB.sort(reverse=True)

i = 0
ans = 0
for c, b in CB:
    x = bisect.bisect_left(A, c, i)
    count = min(x - i, b)
    ans += c * count
    i += count
for j in range(i, N):
    ans += A[j]
print(ans)

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

int ps[100005];
char s[100005];

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

    int l=strlen(s);

    for(int i=1;i<l;i++)
	{
        if (s[i-1]=='A' && s[i]=='C') 
		  ps[i]++;
        ps[i]+=ps[i - 1];
    }

    while(q--)
	{
        int x,y;
        
        scanf("%d%d",&x,&y);
        
        x--;
		y--;
		
        printf("%d\n", ps[y] - ps[x]);
    }
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;

    int a;
    a = N / 100;
    if (a == 7)
    {
        cout << "Yes" << endl;
        return 0;
    }
    N %= 100;

    a = N / 10;
    if (a == 7)
    {
        cout << "Yes" << endl;
        return 0;
    }
    N %= 10;

    a = N / 1;
    if (a == 7)
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3632
#!/usr/bin/env python3

def main():
    n = int(input())
    s1 = input()
    s2 = input()
    i = 0
    res = 1
    while i < n:
        if i == 0:
            if s1[i] == s2[i]:
                res *= 3
                i += 1
                pretwo = False
            else:
                res *= 6
                i += 2
                pretwo = True
        else:
            if s1[i] == s2[i]:
                res *= (1 if pretwo else 2)
                i += 1
                pretwo = False
            else:
                res *= (3 if pretwo else 2)
                i += 2
                pretwo = True
    print(res % (10 ** 9 + 7))

if __name__ == "__main__":
    main()


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

using namespace std;

string s;
int ans;

int main(void)
{
	ios::sync_with_stdio(false);
	cin >> s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='2')
		{
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int n;
  string s;
  cin >> n;
  rep(i, n){
    cin >> s;
    if (s == "Y") {
      cout << "Four";
      return 0;
    }
  }
  cout << "Three";
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
 
 
int main() {
 
  // input number
  int n;
  cin>>n;
 
  // input card
  vector<vector<int>> card(4, vector<int>(13,0));
  for(int i=0;i<n;i++){
    char pic;
    int num;
    cin>>pic>>num;
   // スペードが'S'、ハートが'H'、クラブが'C'、ダイヤが'D' = 0,1,2,3
    if(pic=='S')
      card.at(0).at(num-1)=1;
    else if(pic=='H')
      card.at(1).at(num-1)=1;      
    else if(pic=='C')
      card.at(2).at(num-1)=1;
    else
      card.at(3).at(num-1)=1;
  }
   
   // output card
   for(int i=0;i<4;i++){
     for(int j=0;j<13;j++){
       if(card.at(i).at(j)==0)
         if(i==0)
           cout<<'S'<<' '<<j+1<<endl;
         else if(i==1)
           cout<<'H'<<' '<<j+1<<endl;
         else if(i==2)
           cout<<'C'<<' '<<j+1<<endl;
         else
           cout<<'D'<<' '<<j+1<<endl;
           
     }
  }
  
  return 0;
}


Measured memory_bytes: 3144
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c = LI()
    ans = 10 ** 5
    ans = min(ans, abs(a - b) + abs(b - c))
    ans = min(ans, abs(a - c) + abs(b - c))
    ans = min(ans, abs(a - c) + abs(a - b))
    print(ans)
    return

#B
def B():
    s, t = S(), S()
    f = 0
    for i in range(len(s)):
        f = f or s[i:] + s[:i] == t
    print(["No","Yes"][f])
    return

#C
def C():
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    B()


Measured memory_bytes: 38640
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;



//void f() {
//    int n;
//    string a, b;
//    cin >> n >> a >> b;
//    vector<pair<int, int>> ans;
//    int valid = 0;
//    map<string, vector<int>> d;
//    for (int i = 0; i < n; i++) {
//        string s = string(1, a[i]) + b[i];
//        if (a[i] == b[i]) valid++;
//        else d[s].pb(i);
//
//    }
//
//    int op = 0;
//    for (auto &e : d) {
//        if (e.second.size() % 2) {
//            cout << "No\n";
//            return;
//        }
//
//        op += e.second.size() / 2;
//    }
//
//    cout << "Yes\n" << op << '\n';
//    for (auto e : d) {
//        for (int i = 0; i < e.second.size(); i += 2) {
//            cout << e.second[i] + 1 << ' ' << e.second[i + 1] + 1 << '\n';
//        }
//    }
//
//
//
//}




bool prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }

    return true;
}


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


    int n, x;
    cin >> n >> x;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];

    ll dp[n + 1][2501];
    memset(dp, 0, sizeof dp);
    dp[0][0] = 1;

    for (int i = 0; i < n; i++) {
        for (int j = n; j; j--) {
            for (int s = 2500; s; s--) {
//                if (j == 2 && s == 16 && i == 2) cout << dp[2][8];
                if (s >= a[i]) dp[j][s] += dp[j - 1][s - a[i]];
            }
        }


//        cout << dp[2][16] << ' ';
    }

//    for (int i = 1; i < n + 1; i++) {
//        for (int s = 1; s < 34; s++) cout << dp[i][s] << ' ';
//        cout << '\n';
//    }


    ll ans = 0;
    for (int s = x; s < min(n * x + 1, 2501); s += x) ans += dp[s / x][s];
    cout << ans;


}

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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	vector<pair<int,int>> s;
	int n;
	int sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		s.push_back(make_pair(b, a));
	}
	sort(s.begin(), s.end());
	for (int i = 0; i < n; i++) {
		pair<int, int> key;
		key = s[i];
		sum = sum + key.second;
		if (sum > key.first) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";

}

Measured memory_bytes: 2420
s = input()
t = input()
l = len(t)
ans = 0
a = 0
list1 = [0]
for i in range(len(s) - l + 1):
  ss = list(s[i:i+l])
  for j in range(l):
    if ss[j] ==t[j]:
      ans += 1
      list1.append(ans)
    else:
      pass
  ans = 0
m =  max(list1)
print(l-m)

Measured memory_bytes: 14404
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)


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

using namespace std;

typedef short sho;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str; 
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<ld,ld> pld;
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;

#define LOCAL
#define MP make_pair 
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define begin(x) (x).begin() 
#define end(x) (x).end()
#define rbegin(x) (x).rbegin()
#define rend(x) (x).rend()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define PF push_front 
#define PB push_back
#define PP push
#define lb lower_bound 
#define ub upper_bound
#define lowbit(x) x&(-x)
#define testbit(x,i) x&(1<<i)

inline void checkmin(int &x,int y){x=min(x,y);}
inline void checkmax(int &x,int y){x=max(x,y);}

int x,y,z;

int main() 
{
	#ifndef LOCAL
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /* start code */
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;
    /* end code */
	return 0;
}

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

 
int main() {
   string s;
   cin>>s;
   if(s=="Sunny")cout<<"Cloudy"<<endl;
   if(s=="Cloudy")cout<<"Rainy"<<endl;
   if(s=="Rainy")cout<<"Sunny"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define ll long long
#define pb push_back
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

void solve() {
    int n;
    cin >> n;
    int times[10001] = {};
    for(int i = 1; i<=100; i++) {
        for(int j = 1; j<=100; j++) {
            for(int k = 1; k<=100; k++) {
                int curr = (i*i + j*j+k*k+ i*j + i*k + j*k);
                if(curr <= 10000) {
                    times[curr] ++;
                }
            }
        }
    }
    for(int i = 1; i<=n; i++) {
        cout << times[i] << '\n';
    }
}

int main() {_
    int t = 1;
    //cin >> t;
    //Plese remember to uncomment for taking test cases.
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3684
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4") 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
typedef vector<pl> vpl;
#define F0R(i, a) for (int i=0; i<(a); i++)
#define f first
#define s second
#define ub upper_bound
#define all(x) x.begin(), x.end()
const ll identity=0;
const ll SZ = 131072*2;

ll sum[2*SZ], lazy[2*SZ];

ll combine(ll A,ll B){
    return A+B;
}
ll combineUpd(ll A,ll B){
    return A+B;
}
void push(int index,ll L,ll R){
    sum[index]=combineUpd(sum[index],lazy[index]);
    if (L!=R)lazy[2*index]=combineUpd(lazy[2*index],lazy[index]),lazy[2*index+1]=combineUpd(lazy[2*index+1],lazy[index]);
    lazy[index]=identity;
}
void pull(int index){
    sum[index]=combine(sum[2*index],sum[2*index+1]);
}
ll query(int lo,int hi,int index=1,ll L=0,ll R=SZ-1){
    push(index,L,R);
    if (lo>R || L>hi) return 0;
    if (lo<=L && R<=hi) return sum[index];
    int M=(L+R)/2;
    return combine(query(lo,hi,2*index,L,M),query(lo,hi,2*index+1,M+1,R));
}
void update(int lo,int hi,ll increase,int index=1,ll L=0,ll R=SZ-1){
    push(index,L,R);
    if (hi<L || R<lo) return;
    if (lo<=L && R<=hi) {
        lazy[index]=increase;
        push(index,L,R);
        return;
    }
    int M=(L+R) / 2;
    update(lo,hi,increase,2*index,L,M);update(lo,hi,increase,2*index+1,M+1,R);
    pull(index);
}
int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);    
    int N;cin>>N;
    ll D;cin>>D;
    ll A;cin>>A;
    vpl data(N);
    F0R(i,N){
        ll A,B;cin>>A>>B;data[i]={A,B};
    }
    F0R(i,2*SZ){
        sum[i]=0;lazy[i]=0;
    }
    sort(all(data));
    map<ll, ll>coords;F0R(i, N)coords.insert({data[i].f, i});
    F0R(i,N){
        update(i,i,data[i].s);
    }
    ll ans=0;
    F0R(i,N){
        if (query(i,i)<=0) continue;
        ll cur=(query(i,i)+A-1)/A;
        ans+=cur;
        ll maxBound=(--coords.ub(data[i].f+2*D))->s;
        update(i,maxBound,-1*cur*A);
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 24064
local mfl = math.floor
local mce, msq = math.ceil, math.sqrt
local function getprimes(x)
  local primes = {}
  local allnums = {}
  for i = 1, x do allnums[i] = true end
  for i = 2, x do
    if allnums[i] then
      table.insert(primes, i)
      local lim = mfl(x / i)
      for j = 2, lim do
        allnums[j * i] = false
      end
    end
  end
  return primes
end

local function getdivisorparts(x, primes)
  local prime_num = #primes
  local tmp = {}
  local lim = mce(msq(x))
  local primepos = 1
  local dv = primes[primepos]
  while primepos <= prime_num and dv <= lim do
    if x % dv == 0 then
      local asdf = {}
      asdf.p = dv
      asdf.cnt = 1
      x = x / dv
      while x % dv == 0 do
        x = x / dv
        asdf.cnt = asdf.cnt + 1
      end
      table.insert(tmp, asdf)
      lim = mce(msq(x))
    end
    if primepos == prime_num then break end
    primepos = primepos + 1
    dv = primes[primepos]
  end
  if x ~= 1 then
    local asdf = {}
    asdf.p, asdf.cnt = x, 1
    table.insert(tmp, asdf)
  end
  return tmp
end

local function getdivisor(divisorparts)
  local t = {}
  local pat = 1
  local len = #divisorparts
  local allpat = 1
  for i = 1, len do
    allpat = allpat * (1 + divisorparts[i].cnt)
  end
  for t_i_pat = 0, allpat - 1 do
    local div = allpat
    local i_pat = t_i_pat
    local ret = 1
    for i = 1, len do
      div = mfl(div / (divisorparts[i].cnt + 1))
      local mul = mfl(i_pat / div)
      i_pat = i_pat % div
      for j = 1, mul do
        ret = ret * divisorparts[i].p
      end
    end
    table.insert(t, ret)
  end
  table.sort(t)
  return t
end


local n, s = io.read("*n", "*n")
local lim = 316228

local function solve(x)
  local tn = n
  local c = 0
  while 0 < tn do
    c = c + tn % x
    tn = mfl(tn / x)
  end
  return c == s
end

local found = false
for x = 2, lim - 1 do
  if solve(x) then
    found = true
    print(x)
    break
  end
end
if not found then
  if n == s then
    print(n + 1)
    found = true
  elseif s < n then
    local mul = n - s
    local primes = getprimes(lim)
    local divp = getdivisorparts(mul, primes)
    local divs = getdivisor(divp)
    for i = 1, #divs do
      local cand = divs[i]
      local a1 = mfl(mul / cand)
      if a1 <= cand then
        local a0 = s - a1
        if 0 <= a0 and a0 <= cand then
          found = true
          print(cand + 1)
          break
        end
      end
    end
  end
  if not found then
    print(-1)
  end
end


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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
static const int N = 300;

int n,R;
vector< vector< pair<int, int> > > adj(N, vector< pair<int, int> >());
vll hyou(8, vl(8, 0));
vl d(N, INF);
vi r(8);

void dijkstra(int i) {
	priority_queue< pair<int, int>, vector< pair<int, int> >, greater< pair<int, int> > > pq;
	vi color(n + 1, WHITE);

	d[r[i]-1] = 0;
	pq.push(make_pair(0, r[i]-1));
	color[r[i]-1] = GRAY;

	while (!pq.empty()) {
		pair<int, int> f = pq.top();
		pq.pop();
		int u = f.second;
		color[u] = BLACK;
		if (d[u] < f.first) {
			continue;
		}
		for (int j = 0; j < adj[u].size(); j++) {
			int v = adj[u][j].second;
			if (color[v] == BLACK) {
				continue;
			}
			if (d[v] > d[u] + adj[u][j].first) {
				d[v] = d[u] + adj[u][j].first;
				pq.push(make_pair(d[v], v));
				color[v] = GRAY;
			}
		}
	}
	for (int j = 0; j < R; j++) {
		hyou[i][j] = d[r[j]-1];
	}

}


int main() {
	srand((unsigned)time(NULL));
	int m, i, j;
	cin >> n >> m >> R;
	for (i = 0; i < R; i++) {
		cin >> r[i];
	}
	int a, b, c;
	for (i = 0; i < m; i++) {
		cin >> a >> b >> c;
		adj[a-1].push_back(make_pair(c, b-1));
		adj[b-1].push_back(make_pair(c, a-1));
	}
	for (i = 0; i < R; i++) {
		for (j = 0; j < d.size(); j++) {
			d[j] = INF;
		}
		dijkstra(i);
	}
	ll mini = INF;
	for (i = 0; i < 50000; i++) {
		vi a(R, -1);
		for (j = 0; j < R; j++) {
			int u = rand() % R;
			if (a[u] == -1) {
				a[u] = j;
			}
			else {
				j--;
			}
		}
		ll sum = 0;
		for (j = 1; j < R; j++) {
			sum += hyou[a[j-1]][a[j]];
		}
		mini = min(sum, mini);
	}
	cout << mini << endl;
}


Measured memory_bytes: 768
#include<iostream>
using namespace std;
int main(void)
{
	int n,sum,i,b[300];
	cin>>n;
	for(i=0;i<n-1;i++) cin>>b[i];
	sum=b[0];
	for(i=1;i<n;i++){
		if(b[i]==b[i-1]) sum=sum+b[i];
		else if(b[i]>b[i-1] && b[i+1]>=b[i] && i!=n-1){
			sum=sum+b[i-1];
			sum=sum+b[i];
			i++;
		}
		else if(b[i]>b[i-1] && b[i]>b[i+1] && i!=n-1) sum=sum+b[i-1];
		else if(b[i]<b[i-1] && b[i]>b[i+1] && i!=n-1) sum=sum+b[i];
		else if(b[i]<b[i-1] && b[i]<=b[i+1] && i!=n-1){
			sum=sum+b[i]*2;
			i++; 
		}
		else if(i==n-1) sum=sum+b[i-1];
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <queue>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = (a); i < (n); i++)
#define MP make_pair
#define all(s) (s).begin(), (s).end()
#define rev(s) (s).rbegin(), (s).rend()
#define X first
#define Y second

using namespace std;

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

bool check(vector<int> &v){
	rep(i, v.size()){
		if(v[i] != i+1) return false;
	}
	return true;
}

bool istri[1000010];

void settri(){
	fill(istri, istri+1000010, false);
	int tri = 0;
	for(int i = 0; tri <= 1000000; i++){
		tri += i;
		istri[tri] = true;
	}
}

int main(){
	settri();
	int n;
	while(cin >> n, n){
		vector<int> v(n);
		int sum = 0;
		rep(i, n){
			cin >> v[i];
			sum += v[i];
		}

		if(!istri[sum]){
			cout << -1 << endl;
			continue;
		}

		int cnt = 0;
		while(1){
			if(check(v)){
				cout << cnt << endl;
				break;
			}
			if(cnt == 10000){
				cout << -1 << endl;
				break;
			}

			vector<int> next;
			rep(i, v.size()){
				if(v[i]-1 == 0) continue;
				next.push_back(v[i]-1);
			}
			next.push_back(v.size());
			v = next;
			cnt++;
		}
	}


	return 0;
}

Measured memory_bytes: 2224
#define PROB Treestrat

#include <bits/stdc++.h>

using namespace std;
typedef long long LL;
#define rep(i, l, r) for (int i = l; i<r;i++)
#define all(b) b.begin() , b.end()
#define mp(a, b) make_pair(a,b)
#define pb(a) push_back(a)
#define vi vector<int>
#define vd vector<double>
#define vs vector<string>
#define vii vector<pair<int,int>>
#define vvi vector<vector<int>>
#define ii pair<int,int>
#define turnOff(k, i) (k&(~(1<<(i-1))))
#define isOn(k, i) (k&&(1<<i-1)?true:false)
#define pll pair<long long int , long long int>
#define ull unsigned long long int
#define ll  long long int
#ifdef  DEBUG
#define MAXN 20
#else
#define MAXN 200050
#endif
#define MAXLG 20
#define endl '\n'
#define PI 3.14159265i3589793238
#define MOD (1000000007l)
#define INF (1000000007)
#define EPS (0.00000001)
#define treap treapNode*

vi adj[MAXN];


int dfs (int curr,int par = -1) {
    int nim = 0;
    for (int nxt : adj[curr]) {
        if (nxt!=par) {
            nim = nim ^(dfs(nxt,curr)+1);
        }
    }
    return nim;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
#ifdef DEBUG
    freopen("input", "r", stdin);
#endif
    int n;
    cin>>n;
    rep (i,0,n-1) {
        int x,y;
        cin>>x>>y;
        adj[--x].push_back(--y);
        adj[y].push_back(x);
    }
    if(dfs(0)!=0) cout<<"Alice";
    else cout<<"Bob";
    return 0;
}















































Measured memory_bytes: 12800
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define ORDER_MAX 500000
#define KEY_MAX 2000000000
#define KEY_MIN -2000000000
#define NIL KEY_MIN-1


typedef struct node{
  int key;
  struct node *l;
  struct node *r;
  struct node *p;
}Node;

void inorder(Node *);
void preorder(Node *);
void insert(int);

Node *root;

int main(){
  int i,m;
  char *str_print = "print";
  char *str_insert = "insert";
  char str[7];
  int k;

  scanf("%d",&m);
  root = NULL;
        
  for(i = 0; i < m; i++){//入力
    scanf("%s",str);
    //printf("test str %s",str);
    if(strcmp(str,str_print) == 0){//print
     inorder(root);
     printf("\n");
     preorder(root);
     printf("\n");
    }
    else if(strcmp(str,str_insert) == 0){//insert
      scanf("%d",&k);
      insert(k);
    }
    //printf("test for\n");
  }

  return 0;
}

void inorder(Node *x){
  if(x != NULL){
    inorder(x->l);
    printf(" %d",x->key);
    inorder(x->r);
  }
}

void preorder(Node *x){
  if(x == NULL)return;
  printf(" %d",x->key);
  preorder(x->l);
  preorder(x->r);
}

void insert(int k){
  Node *x,*y,*z;

  y = NULL;
  x = root;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->l = z->r = z->p = NULL;
  
  while(x != NULL){
    //printf("test");
    y = x;
    if(z->key < x->key){
      x = x->l;
    }
    else x = x->r;
  }
  z->p = y;

  if(y == NULL)root = z;
  else if(z->key < y->key)y->l = z;
  else y->r = z;
  
}


Measured memory_bytes: 25208
import math
x=int(input())
flag=True
if x==2:
    print(x)
else:
    while flag:
        i=2
        f=True
        while i<x and f:
            if x%i==0:
                f=False
            i+=1
        if f==True:
            print(x)
            flag=False
        else:
            x+=1











Measured memory_bytes: 2940
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let a: i32 = input();
    let b: i32 = input();
    let c: i32 = input();
    let d: i32 = input();
    println!("{}", std::cmp::max(a * b, c * d));
}


Measured memory_bytes: 4352
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <unordered_map>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;
typedef long long LL;

int main() {
	LL n, x;
	cin >> n >> x;
	LL a[100001];
	LL ans = 0;
	for (LL i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (LL i = 1; i < n; i++) {
		if (a[i-1] + a[i] > x) {
			int temp = (a[i - 1] + a[i]) - x;
			ans += temp;
			if (a[i] > temp) {
				a[i] -= temp;
			}
			else {
				a[i] = 0;
			}
		}
	}
	cout << ans << endl;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-9;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int64 N;
vector<int64> G[212345];
vector<int64> d;
vector<int64> vs[2];

void dfs(int64 v, int64 p, int64 dep=0) {
  d[v] = dep;
  vs[d[v]%2].push_back(v);
  for (auto &u : G[v]) {
    if (u == p) continue;
    dfs(u, v, dep+1);
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long double a, b, c;
  cin >> a >> b >> c;

  if (2*sqrt(a*b) < c-a-b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 5248
n = int(input())
a = list(map(int, input().split()))
cnt = [0] * (10 ** 5 + 1)

sum = 0
for i in a:
    cnt[i] += 1
    sum += i

q = int(input())
ans = [0] * q
for _ in range(q):
    b, c = map(int, input().split())
    sum += (c - b) * cnt[b]
    cnt[c] += cnt[b]
    cnt[b] = 0
    ans[_] = sum

print(*ans, sep="\n")

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

using ll = long long;
#define REP(i, n) for(int (i)=0; (i)< (n); ++i)
#define REPR(i, n) for(int (i)=(n); (i)>=0; --i)
#define FOR(i, n, m) for(int (i)=(n); (i)<(m); ++i)
constexpr int INF = 1e9;
//constexpr ll INF = 1LL << 62;
constexpr int mod = 1e9+7;

vector<vector<int>> g;
vector<int> in, out, dist;
vector<bool> homon;
bool ans = true;
void bfs(int V){
  queue<int> que;
  REP(i, V){
    if(in[i] == 0){
       que.push(i);
       homon[i]=true;
    }
  }
  if(que.empty()) ans = false;
  while(!que.empty()){
    int v = que.front(); que.pop();
    for(auto nv : g[v]){
      dist[nv] = max(dist[nv], dist[v]+1);
      in[nv]--;
      if(in[nv] == 0){
         que.push(nv);
         homon[nv] = true;
      }
    }
  }
  REP(i, V){
    if(!homon[i]) ans = false;
  }
}
int main(){
  int N;
  cin >> N;
  int V = 0;
  vector<vector<int>> id(N, vector<int>(N));
  REP(i, N){
    FOR(j, i+1, N){
      id[i][j] = V;
      V++;
    }
  }
  g.resize(V);
  vector<vector<int>> A(N, vector<int>(N-1));
  REP(i, N){
    REP(j, N-1){
      cin >> A[i][j];
      A[i][j]--;
    }
  }
  in.resize(V, 0), out.resize(V, 0);
  dist.resize(V, 0), homon.resize(V, false);
  REP(i, N){
    REP(j, N-2){
      int a = A[i][j], b = A[i][j+1];
      int s = i, t = i;
      if(a > s) swap(a, s);
      if(b > t) swap(b, t);
      s = id[a][s];
      t = id[b][t];
      g[s].push_back(t);
      in[t]++, out[s]++;
    }
  }
  bfs(V);
  int cnt = 0;
  REP(i, V){
    cnt = max(cnt, dist[i]);
  }
  if(ans){
    cout << cnt+1 << endl;
  }
  else{
    cout << -1 << endl;
  }
  return 0;
}


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

int bubbleSort(int A[],int N){
    int sw=0;
    bool flag =1;
    for(int i=0;flag;i++){
        flag=0;
        for(int j=N-1;j>=i+1;j--){
            if(A[j]<A[j-1]){
                swap(A[j],A[j-1]);
                flag=1;
                sw++;
            }
        }
    }
    return sw;
}
int main(){
    int A[100],N,sw;
    cin>>N;
    for(int i=0;i<N;i++) cin>>A[i];
    
    sw=bubbleSort(A,N);
    
    for (int i=0;i<N;i++){
        if(i)cout<<" ";
        cout<<A[i];
    }
    cout<<endl;
    cout<<sw<<endl;
    
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

const int N=1e5+44;
double T[N];

int main(){
    //freopen("INPUT.INP","r",stdin);
    //freopen("OUTPUT.OUT","w",stdout);
    int n,c;
    double k;
    cin >> n >> c >> k;
    for(int i=1;i<=n;i++) cin >> T[i];
    sort(T+1,T+n+1);
    T[n+1]=T[n]+k+1;
    double depart_time=T[1]+k;
    int passenger=1,bus=0;
    for(int i=2;i<=n+1;i++){
        if(passenger<c && T[i]<=depart_time) passenger++; else{
            bus++;
            passenger=1;
            depart_time=T[i]+k;
        }
    }
    cout << bus << "\n";
    return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

string s, t = "CODEFESTIVAL2016";

int main() {
	cin >> s;
	
	int ans = 0;
	inc(i, t.size()) {
		if(s[i] != t[i]) { ans++; }
	}
	
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))

ans = 0
x = dict()
#O(N)
for i in range(N):
    if a[i] in x:
        x[a[i]] += 1
    else:
        x[a[i]] = 1
    if (a[i]-1) in x:
        x[a[i]-1] += 1
    else:
        x[a[i]-1] = 1
    if (a[i]+1) in x:
        x[a[i]+1] += 1
    else:
        x[a[i]+1] = 1
for idx in x:
    ans = max(ans,x[idx])

print(ans)

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

using namespace std;

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

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

using ll = long long;
using P = pair<ll, ll>;
ll N, A, B;
bool ok(vector<ll> h, ll t) {
    rep(i, N) { h[i] -= t * B; }

    ll cnt = 0;
    ll D = A - B;
    rep(i, N) {
        if (h[i] > 0) {
            cnt += (h[i] + D - 1) / D;
        }
    }
    return cnt <= t;
}
const ll INF = 1e9;
int main() {
    cin >> N >> A >> B;
    vector<ll> h(N);
    rep(i, N) { cin >> h[i]; }
    ll lb = 0, ub = INF;
    while (ub - lb > 1) {
        ll mid = (lb + ub) / 2;
        if (ok(h, mid))
            ub = mid;
        else
            lb = mid;
    }

    cout << ub << endl;

    return 0;
}


Measured memory_bytes: 1792
import math

N = int(input())
N_log = math.floor(math.log(N, 10))
N_top = N // pow(10, N_log)
N_bottom = N % 10
N_rest = N % pow(10, N_log)


def n_b(b0, b1):
    if b0 == 0:
        return 0
    ret = 0
    for keta in range(N_log + 1):
        ret += n_b_keta(b0, b1, keta)
    return ret


def n_b_keta(b0, b1, keta):
    if keta == 0:
        return b0==b1
    elif keta != N_log:
        return pow(10, keta - 1)
    else:
        if b0 > N_top:
            return 0
        elif b0 < N_top:
            return pow(10, keta - 1)
        else:
            return 1 + (N_rest//10) - (b1>N_bottom)

ans = 0
pre = 0
for i in range(1, N + 1):
    ans += n_b(int(str(i)[-1]), int(str(i)[0]))
    # print(i, ans-pre)
    pre = ans
print(ans)


Measured memory_bytes: 74212