akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  map<char,int> mp;
  rep(i,N) {
    mp[s[i]]++;
  }
  ll ans = 1;
  for(auto m : mp) {
    ans *= (ll)(m.second + 1);
    ans %= MOD;
  }
  cout << (ans + MOD - 1) % MOD << endl;
  return 0;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
N, T = map(int,input().split())
a = []
for i in range(N):
    a.append([int(i) for i in input().split()])

ans = []
x = 0
for i in range(N):
    if a[i][1] > T:
        x += 1
    if a[i][1] <= T:
        ans.append(a[i][0])

if x == N:
    print("TLE")
else:
    print(min(ans))


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>

using namespace std;
using ll = long long int;
using ld = long double;
using vec = vector<int>;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(a)   sort(a.begin(), a.end())
const int INF = 2147483647;
const ll  MOD = 1000000007;
const ld  EPS = 1.0E-14;

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

    ld ans = sqrt(a) + sqrt(b) + EPS;

    if(ans < sqrt(c)) cout << "Yes";
    else              cout << "No";
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<iomanip>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
double t(in x, double p){
  in tt=x/2;
  double tpt=1/p;
  return tt*tpt;
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in x;
  double p;
  cin>>x>>p;
  p/=100;
  cout<<setprecision(15);
  if(x%2!=0)
    cout<<1+p*t(x-1,p)+(1-p)*t(x+1,p)<<endl;
  else
    cout<<t(x,p)<<endl;
  return 0;
}


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

using namespace std;

int main(){

	long long int N,ret=0;
	long long int tmp;
	vector<long long int> A;
	cin>>N;


	for(int i=0;i<N;i++){
		cin>>tmp;
		A.push_back(tmp);
	}
	long long int sum=0;
	for(int i=0;i<N;i++){
		if(A[i]!=0){
			sum+=A[i];
		}else{
			ret+=sum/2;
			sum=0;
		}
	}
	ret+=sum/2;
	cout<<ret<<endl;

	return 0;
}



Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {
    static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
        String[] in = getLine().split(" ");
        int restCount = toInt(in[0]);
        long biscket = 1;
        long a = toLong(in[1]); // a枚で一円と交換
        long b = toLong(in[2]); // 1円でb枚と交換

        while(biscket != a && restCount != 0) {
            restCount--;
            biscket++;
        }

        if(restCount == 0) {
            print("" + biscket);
            return;
        }

        // 偶数回になるように調整
        if(restCount % 2 == 1) {
            biscket++;
            restCount--;
        }

        if(restCount == 0) {
            print("" + biscket);
            return;
        }

        // 交換が非効率の場合
        if(b - a <= 2) {
            biscket += restCount;
            print("" + biscket);
            return;
        } else {
            long changeBiscket = (b - a) * restCount / 2;
            biscket += changeBiscket;
//            print(String.format("%d %d %d %d", a, b, restCount, changeBiscket));
            print("" + biscket);
            return;
        }
    }

    public static int getInt() {
        return scan.nextInt();
    }

    public static String getLine() {
        return scan.nextLine();
    }

    public static int toInt(String str) {
        return Integer.parseInt(str);
    }

    public static long toLong(String str) {
        return Long.parseLong(str);
    }

    public static void print(String str) {
        System.out.println(str);
    }
}


Measured memory_bytes: 21972
n = int(input())
ans = 0

a, b = [], []
for i in range(n):
    ai, bi = map(int, input().split())

    a.append(ai)
    b.append(bi)

c = 0
for i in reversed(range(n)):
    a[i] += c
    x = a[i] % b[i]
    if x:
        if a[i] < b[i]:
            c += b[i] - a[i]
        elif a[i] > b[i]:
            c += b[i] - x

print(c)


Measured memory_bytes: 21592
// Date: 2020-04-04

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define IO freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout)
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define D(x) cout << #x << " = " << x << endl;
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int main() {
    LL n, k;
    cin >> n >> k;
    LL tp = n/k;
    n -= tp*k;
    LL ans = min(n, k-n);
    cout << ans;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();

        while (t != 0) {
            int n = scanner.nextInt();
            int i = 0;
            int y = t;
            for (int a = 0; a < n; a++) {
                int s = scanner.nextInt();
                int f = scanner.nextInt();
                int x = f - s;
                y = y - x;
            }
            if (y <= 0) {
                System.out.println("OK");
            } else {
                System.out.println(y);
            }
            t = scanner.nextInt();
        }
    }
}



Measured memory_bytes: 31860
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int k;
    std::cin >> k;

    auto f = [](const auto n) {
        auto m = n, s = 0ll;
        while (m) {
            s += m % 10;
            m /= 10;
        }
        return 1.0 * n / s;
    };

    std::vector<i64> ret { 1 };
    while (ret.size() < k) {
        auto lst = ret.back() + 1;
        double min = f(lst);
        i64 cand = lst;
        for (i64 c = 10, j = 0; j < 16; c *= 10, j++) {
            i64 x = (lst / c + 1) * c - 1;
            auto v = f(x);
            if (v < min) {
                cand = x;
                min = v;
            }
        }
        ret.push_back(cand);
    }

    for (auto e : ret) std::cout << e << std::endl;

    return 0;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 998244353;

struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 x) : x(x) {
    if (x > P || x < 0) { cerr << "Invalied FiniteField!" << endl; exit(1); }
  }
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

ostream& operator<<(ostream& s, const FiniteField& v) {
	s << v.Value(); return s;
}

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

  int n;
  cin >> n;
  vector<int> xs(n);
  int max_value = 0;
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
    max_value = max(xs[i], max_value);
  }

  vector<FiniteField> ws(max_value + 1);
  vector<vector<int>> v_to_ds(max_value + 1);
  for (int i = 1; i <= max_value; i++) {
    ws[i] = FiniteField(1) / i;
    v_to_ds[i].push_back(i);
  }
  for (int i = 1; i <= max_value; i++) {
    for (int k = 2; i * k <= max_value; k++) {
      ws[i * k] -= ws[i];
      v_to_ds[i * k].push_back(i);
    }
  }

  vector<FiniteField> ss(max_value + 1);
  for (int x : xs) {
    for (int d : v_to_ds[x]) {
      ss[d] += x;
    }
  }

  FiniteField t = 0;
  for (int i = 1; i <= max_value; i++) {
    if (DEBUG) cout << "i: " << i << endl;
    if (DEBUG) cout << "ss[i]: " << ss[i] << endl;
    FiniteField inc = ws[i] * ss[i] * ss[i];
    if (DEBUG) cout << "inc: " << inc << endl;
    if (DEBUG) cout << "dec:" << P - inc.Value() << endl;
    t += ws[i] * ss[i] * ss[i];
  }

  for (int x : xs) {
    t -= x;
  }
  t /= 2;

  cout << t.Value() << endl;
}

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

class UFS
{
private:
    int *fa;

public:
    inline UFS(int);
    inline int find(int);
    inline void merge(int, int);
};

inline UFS::UFS(int n)
{
    fa = new int[n + 1];
    for (int i = 1; i <= n; ++i)
    {
        fa[i] = i;
    }
}

inline int UFS::find(int x)
{
    while (x != fa[x])
    {
        x = fa[x] = fa[fa[x]];
    }
    return x;
}

inline void UFS::merge(int x, int y)
{
    int u = find(x), v = find(y);
    if (u != v)
    {
        fa[u] = v;
    }
}

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

    int x, y;
    UFS s(n);
    for (int i = 0; i < m; ++i)
    {
        std::cin >> x >> y;
        s.merge(x, y);
    }

    int *siz;
    siz = new int[n + 1]();
    for (int i = 1; i <= n; ++i)
    {
        siz[s.find(i)]++;
    }

    int max = 0;
    for (int i = 1; i <= n; ++i)
    {
        max = std::max(max, siz[i]);
    }
    std::cout << max << std::endl;
    return 0;
}

Measured memory_bytes: 5188
s = input()
LS = len(s)
rs = s[::-1]
lc = []
rc = []
lx = 0
rx = 0
for i in range(LS):
    if s[i] != 'x':
        lc.append(s[i])
    if rs[i] != 'x':
        rc.append(rs[i])
cnt = 0
if lc==rc or len(lc)+len(rc)==1:
    i = 0
    j = LS-1
    while j>i:
        if s[i]!=s[j]:
            if s[i]=='x':
                cnt+=1
                i +=1
            elif s[j]=='x':
                cnt+=1
                j -=1
        else:
            i +=1
            j -=1
    print(cnt)
else:
    print(-1)

Measured memory_bytes: 4920
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
 
LL l,r;

LL dp[100][2][2][2];

LL rec(int k,bool yr,bool xl,bool f){
    if(k==-1) return f;
    if(~dp[k][yr][xl][f]) return dp[k][yr][xl][f];
    LL ret=0;
    int y=yr?(r>>k&1):1;
    int x=xl?(l>>k&1):0;
    if(!f){
        ret = (ret + rec(k-1,yr,x&xl,true))%mod;
        if(x==0) ret = (ret + rec(k-1,false,xl,false))%mod;
    }
    else{
        for (int i = 0; i <= y; i++) {
            if(i==0){
                if(x==0){
                    ret = (ret + rec(k-1,(y==i)&yr,xl,f))%mod;
                }
            }
            else{
                if(x==1){
                    ret = (ret + rec(k-1,y&yr,xl,f))%mod;
                }
                else{
                    ret = (ret + rec(k-1,y&yr,xl,f))%mod;
                    ret = (ret + rec(k-1,y&yr,false,f))%mod;
                }
            }
        }
    }
    return dp[k][yr][xl][f] = ret;
}


int main(){
    cin >> l >> r;
    memset(dp,-1,sizeof(dp));
    LL t = r;
    int s=0;
    while(t){
        s++;
        t/=2;
    }
    cout << rec(s-1,true,true,false) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define de(x) cout<<#x<<"="<<x<<endl
long long x[55],y[55];
bool inrec(int a1,int a2,int b1,int b2,int dc){
	int mx=max(x[a1],x[a2]),mix=min(x[a1],x[a2]),mxy=max(y[b1],y[b2]),miny=min(y[b1],y[b2]);
	if(x[dc]>=mix&&x[dc]<=mx&&y[dc]>=miny&&y[dc]<=mxy)return true;
	else return false;
}
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		scanf("%lld %lld",&x[i],&y[i]);
	}long long ans=inf,tmp=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			for(int p=0;p<n;p++){
				for(int q=p+1;q<n;q++){
					tmp=0;
				for(int k=0;k<n;k++){
				if(inrec(i,j,p,q,k))tmp++;
				}//de(tmp);
				if(tmp>=k){
					long long xx=x[i]-x[j],yy=y[p]-y[q],tt=xx*yy;
					if(tt<0)tt=-tt;
					ans=min(ans, tt);
				}
				}
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
/*
гонфлад
*/
#pragma ARCENIY_KIRILLOV_UVIDEL_KROKODILOV
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
using namespace std;
typedef long long ll;

main(){
    int n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    int q = __gcd(n, m);
    int f = (n / q) * m;
    map <int, char> b;
    int re = f / n;
    int we = f / m;
    for (int i = 0; i < n; i++){
        b[i * re] = s[i];
    }
    for (int j = 0; j < m; j++){
        if (b[j * we] != t[j] && (j * we) % re == 0){
            cout << -1;
            return 0;
        }
    }
    cout << f;
}


Measured memory_bytes: 10880
n,t = gets.split.map(&:to_i)
list = (1..n).map{gets.split.map(&:to_i)}.sort
dp = [0]*(t)
ans = 0
list.each{|a,b|
  predp = dp.dup
  (0..t-1-a).each{|ti|
    if dp[tia=ti+a] < predpb=predp[ti]+b
      dp[tia] = predpb
    end
  }
  if ans < tmpans=predp[t-1]+b
    ans = tmpans
  end
}
p ans

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

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

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < N; X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair

using namespace std;

int main(){

    //2の倍数だが4の倍数ではない数(A),4の倍数の数(B),それ以外の数(C)がそれぞれ何個あるかを数える
    //2の倍数ではない数の隣にできるのは,4の倍数の数のみなので
    //C<=BならばYesか
    //そう単純ではなく
    //Aが0ならはC - 1<=Bならtrueだが、Aが1以上ならC<= B

    int n;
    cin >> n;
    int a = 0;
    int b = 0;
    int c = 0;

    rep(i,n){
        int tmp;
        cin >> tmp;

        int m = tmp % 4;

        if(m == 2){
            a++;
        }else if(m == 0){
            b++;
        }else{
            c++;
        }
    }

    bool ans = true;

    cerr << a << " " << b << " " << c << endl;

    if(a > 0){
        ans = c <= b;
    }else{
        ans = c - 1 <= b;
    }
    cerr << ans << endl;

    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;

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

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	COMinit();
	int n, k; cin >> n >> k;
	VE a(n); rep(i, n)cin >> a[i];
	sort(ALL(a));
	int ans = 0;
	rep(i, n) {
		int now = COM(i, k - 1);
		ans += (a[i] * now)%MOD;
		ans %= MOD;
	}
	reverse(ALL(a));
	rep(i, n) {
		int now = COM(i, k - 1);
		now = -now;
		ans += (a[i] * now) % MOD;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


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

    int n,k;
    cin >> n >> k;
    vl h(n);
    rep(i,n){
        cin >> h[i];
    }
    sort(all(h));
    ll s = INF;
    rep(i,n-k+1){
        s = min(s,h[i+k-1]-h[i]);
    }
    cout << s << endl;

    return 0;
}
    


Measured memory_bytes: 1024
def main():
    H, W = (int(i) for i in input().split())
    A = [input() for j in range(H)]
    from collections import deque
    st = deque()
    dist = [[-1]*W for i in range(H)]
    for h in range(H):
        for w in range(W):
            if A[h][w] == '#': 
                st.append((h,w))
                dist[h][w] = 0
    
    def bfs():
        ans = 0
        que = st
        d = ((1,0),(0,1),(-1,0),(0,-1))

        while que:
            uy,ux = que.popleft()
            for dy, dx in d:
                next_y = uy + dy
                next_x = ux + dx
                if not(0 <= next_y < H and 0 <= next_x < W): continue
                if dist[next_y][next_x] != -1: continue
                if A[next_y][next_x] == '#': continue
                dist[next_y][next_x] = dist[uy][ux] + 1
                ans = max(ans, dist[next_y][next_x])
                que.append((next_y, next_x))
        return ans
    
    print(bfs())

if __name__ == '__main__':
    main()

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


int main()
{
	
	long long n,k;
	cin >> n >> k;

	long long ans = 0;
	if(n % k == 0) ans = 0;
	else{
		ans = n % k;
		if(ans > k / 2) ans = k - ans; 
	}
	
	printf("%lld\n",ans);
	return 0;
 } 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    vector<int> v(3);
    for (int i = 0; i < 3; ++i) {
        std::cin >> v.at(i);
    }
    std::sort(v.begin(),v.end());
    vector<int> v_true = {5, 5, 7};
    bool is577;
    for (int i = 0; i < 3; ++i) {
        is577 = v.at(i) == v_true.at(i);
        if (!is577){
            break;
        }
    }
    std::cout << (is577 ? "YES" : "NO");
}

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

int main(){
  string s,t;
  int i=0;

  cin >> s >> t;

  string str = s;
  str += s;

  for(int i=0;i < s.size();++i){
    for(int j=i;j < i+s.size();++j){
      if(str[j] != t[j-i])
	{
	  break;
	}
      if(j == i+s.size()-1)
	{
	  cout << "Yes" << endl;
	  return 0;
	}
    }
  }
  cout << "No" << endl;
  return 0;
}    

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException{
		FastScanner f = new FastScanner(); //Replace "problem" with problem name
        
        long k = f.nextLong();
        
        if(k % 50 == 0){
        	System.out.println("50");
        	for(int i = 0; i < 50; i++){
            System.out.print((49+k/50) + " ");
          }
          System.out.println();
          return;
        }
        
        long[] list = new long[50];
        for(int i = 0; i < 50; i++){
        	list[i] = (k/50) + 50;
        	
        }
        for(int i = 0; i < 50 - k%50; i++){
        	long max = 0; int maxi = 0;
        	for(int j = 0; j < 50; j++){
        		if(list[j] > max){
        			max = list[j];
        			maxi = j;
        		}
        	}
        	list[maxi] -= 50;
        	for(int j = 0; j < 50; j++){
        		if(j == maxi){
        			continue;
        		}
        		list[j]++;
        	}
        }
        
        System.out.println(50);
        for(int i = 0; i < 50; i++){
        	System.out.print(list[i] + " ");
        }
        
        
	}


	public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}


Measured memory_bytes: 22740
n = int(input())
G = [[] for _ in range(n)]
u1 = 0
for _ in range(n):
    u, k, *v = [int(i) for i in input().split()]
    G[u - 1] = v
    if k != 0 and u1 == 0:
        u1 = u

time = 1
u = u1
D = []
out = [[i+1, 0, 0] for i in range(n)]
T = []
while True:
    if u not in D:
        out[u - 1][1] = time
        D.append(u)
        T.append(u)

    for d in D:
        if d in G[u - 1]:
            idx = G[u - 1].index(d)
            del G[u - 1][idx]

    if G[u - 1] == []:
        time += 1
        out[T.pop() - 1][2] = time
        if T == []:
            if len(D) == n:
                break
            else:
                for ni in range(n):
                    if ni + 1 not in D:
                        u = ni + 1
                        break
                time += 1
                continue
        else:
            u = T[-1]
    else:
        u = G[u - 1].pop(0)
        time += 1

for ni in range(n):
    print(*out[ni])



Measured memory_bytes: 5656
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
/**************************************************************************/
signed main()
{
    fast;
    string s,t;
    cin>>s>>t;
    int ans = 0;
    int n = s.size();
    for(int i=0;i<n;i++)
        if(s[i]==t[i])
            ans++;
    cout<<ans;
}

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

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

    vector<vector<int>> x(n, vector<int>(d));
    rep(i, n)
    {
        rep(j, d) cin >> x[i][j];
    }

    int ans = 0;
    rep(i, n) rep(j, i)
    {
        int sq = 0;
        rep(k, d)
        {
            int s = x[i][k] - x[j][k];
            sq += s * s;
        }
        int s = sqrt(sq) + 0.5;
        // intのキャストは切り捨てなので、四捨五入のために0.5加算する
        // 正解ならs*sとsqが一致する
        if (s * s == sq)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n,m,k=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=0
for i in range(1,n):
    if a[i]+a[i-1]<=k:
        a[i]+=a[i-1]
        c=i

    else:
        break
    


d=0 

for i in range(1,m):
    if b[i]+b[i-1]<=k:
        b[i]+=b[i-1]
        d=i

    else:
        break

#print(c,d)
if a[0]<=k:
    mx=c+1
else:
    mx=0
j=0
while c>=0 and j<=d:
    if a[c]+b[j]<=k:
        
        j+=1
        mx=max(mx,c+1+j)
        #print(c,j,mx)
    else:
        c-=1
if b[0]<=k:
    mx=max(mx,d+1)
print(mx)
    

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

typedef long long ll;

#define PB push_back
#define MP make_pair

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll h, w, k; cin >> h >> w >> k;
	char grid[h][w];
	for (ll i = 0; i < h; ++i) {
		string s; cin >> s;
		for (ll j = 0; j < w; ++j) 
			grid[i][j] = s[j];
	}
	ll ans = 0; 
	vector<set<int>> sh, sw;
	for (ll i = 0; i < (1<<h); ++i) {
		set<int> subset;
		for (int j = 0; j < h; ++j) {
			if (i & (1 << j)) subset.insert(j);
		}
		sh.PB(subset);
	}
	for (ll i = 0; i < (1<<w); ++i) {
		set<int> subset;
		for (int j = 0; j < w; ++j) {
			if (i & (1 << j)) subset.insert(j);
		}
		sw.PB(subset);
	}
	for (auto i : sh) {
		for (auto j : sw) {
			int tmp = 0;
			for (auto r : i) {
				for (auto c : j) {
					if (grid[r][c] == '#') tmp++;
				}
			}
			if (tmp == k) ans++;
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3676
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())

    res = 0
    for i in range(1, (n + 1) // 2):
        if i != n - i:
            res += 1

    print(res)


if __name__ == '__main__':
    resolve()


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

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)
typedef long long ll;

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);
int gcd(int a, int b);

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for(int i=0; i<m; i++) cin >> x[i];

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

    if(n > m) {
        cout << 0 << endl;
        return 0;
    }

    vector<int> diff(m-1);
    for(int i=0; i<diff.size(); i++) {
        diff[i] = x[i+1] - x[i]; 
    }

    sort(diff.begin(), diff.end());
    int sum = 0; 
    for(int i=0; i<diff.size() - n + 1; i++) {
        sum += diff[i];
    }
    cout << sum << endl;
    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

int sum_digits(int num) {
    int rtn = 0;
    while(num != 0) {
        int tmp = num % 10; 
        rtn += tmp;
        num /= 10; 
    }   
    return rtn;
}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}

// ユークリウッドの互除法
int gcd(int a, int b) {
    if(b==0) return a;
    else return gcd(b, a % b);
}



Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
template <class T>
bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T>
bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

template <typename T = ll>
struct TreeBFS {
    vector<T> dist;
    vector<vector<pair<int, T>>> edges;
    TreeBFS(int n) : dist(n, -1), edges(n) {}
    void addEdge(int f, int t, T w) {
        edges[f].emplace_back(t, w);
        edges[t].emplace_back(f, w);
    }
    void bfs(int start) {
        dist[start] = 0;
        deque<int> node;
        node.push_back(start);
        while (node.size() != 0) {
            int n = node.front();
            node.pop_front();
            for (auto e : edges[n]) {
                if (dist[e.first] == -1) {
                    dist[e.first] = dist[n] + e.second;
                    node.push_back(e.first);
                }
            }
        }
    }
};

int main() {
    int n;
    cin >> n;
    TreeBFS<ll> tr(n);
    for (int i = 0; i < n - 1; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        tr.addEdge(a - 1, b - 1, c);
    }
    int q, k;
    cin >> q >> k;
    tr.bfs(k - 1);
    vi x(q), y(q);
    for (int i = 0; i < q; ++i) {
        cin >> x[i] >> y[i];
        x[i]--;
        y[i]--;
    }
    for (int i = 0; i < q; ++i) {
        cout << tr.dist[x[i]] + tr.dist[y[i]] << endl;
    }
    return 0;
}

Measured memory_bytes: 10752
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n; cin >> n;
	if(n <= 26){
		cout << (char)(n-1+'a') << "\n";
		return 0;
	}
	string ans;
	ll now = 0;
	int num = 0;
	while(1){
		now = (now + 1) * 26;
		num++;
		if(now >= n) break;
	}
	ll t = 1;
	rep(i,num-2){
		n -= t;
		t *= 26;
	}
	n -= t;
	rep(i,num-1){
		int b = n % 26;
		ans.push_back((char)(b+'a'));
		n /= 26;
	}
	ans.push_back((char)((n-1)+'a'));
	reverse(all(ans));
	cout << ans << "\n";
}


Measured memory_bytes: 3624
#include<stdio.h>                                                               
#include<stdlib.h>

int main(void){
    int N;
    scanf("%d",&N);
    int R;
    scanf("%d",&R);
    int S=0;
    if(N >= 10){
        S=R;
    }else{
        S=R+(100*(10-N));
    }
    printf("%d\n",S);

    return 0;
}

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

int main() {
  int P,Q,R,A,B,C;
  cin >> P>>Q>>R;
  A=P+Q;
  B=Q+R;
  C=R+P;
  if (A < B) {
    if(A>C){
      cout<<C<<endl;
    }
    else if(A<=C){
      cout<<A<<endl;
    }
  }
  else if(A>=B){
    if(B>C){
      cout<<C<<endl;
    }
    else if(B<=C){
      cout<<B<<endl;
    }
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
#define MAX 120

int main(){
  int n,a[MAX];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  int ans=1;
  for(int i=1;i<n;i++){
    if(a[i]!=a[i-1]) ans++;
  }
  cout<<ans<<endl;
}


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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;
long long int a[4005], b[4005], g[4005];
int main(){
    int n; cin >> n;
    string s; cin >> s;
    a[n]=0; b[n]=0; g[n]=0;
    for(int i=n-1;i>=0;i--){
        if(s[i]=='R'){
            a[i] = a[i+1] + 1;
            g[i] = g[i+1];
            b[i] = b[i+1];
        }
        else if(s[i]=='G'){
            g[i] = g[i+1]+1;
            a[i] = a[i+1];
            b[i] = b[i+1];
        }
        else if(s[i]=='B'){
            b[i] = b[i+1]+1;
            g[i] = g[i+1];
            a[i] = a[i+1];
        }
    }

    long long int al = 0;
    long long int sa = 0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            if(s[i]!=s[j]){
                if(((s[i]=='R')&&(s[j]=='G')) || ((s[i]=='G')&&(s[j]=='R'))){
                    al += b[j+1];
                }
                if(((s[i]=='R')&&(s[j]=='B')) || ((s[i]=='B')&&(s[j]=='R'))){
                    al += g[j+1];
                }
                if(((s[i]=='B')&&(s[j]=='G')) || ((s[i]=='G')&&(s[j]=='B'))){
                    al += a[j+1];
                }
            }
        }
    }

    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            int k = j + (j-i);
            if(s[i]!=s[j] && k < n){
                if(s[i]!=s[k] && s[j]!=s[k]){
                    sa++;
                }
            }
        }
    }
    cout << al - sa << endl;
    return 0;
}

Measured memory_bytes: 3700
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;


public class AtCoder {
    static string S;
    static void Main() {
        S = Console.ReadLine();
        long ans=0;
       for(int i = 0; i < Math.Pow(2, S.Length - 1); i++) {
            string s = Convert.ToString(i, 2).PadLeft(S.Length-1);
            ans += l(s);
          //  Console.WriteLine(l(s));
        }
        Console.WriteLine(ans);
    }
    static long l(string s) {
        long ans = 0;
        string m = S[0].ToString();
        int a=0;
        for(int i = 0; i < S.Length - 1; i++) {
           // m += S[i+1];
            if (s[i] == '1') {
                ans += int.Parse(m);
                m = "";
                a = 1;
            }
            m += S[i+1];
        }
        if (a == 0) {
            ans = long.Parse(S);
        }
        else {
            if(m!="")
            ans += int.Parse(m);
        }
        return ans;
    }
}

Measured memory_bytes: 3288
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {
	
	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================
	
	int X;
	cin >> X;



	vint list = {100, 101, 102, 103, 104, 105};
	for (int i = 0; i < 2 << 5; i++) {
		int tempX = X;

		for (int j = 0; j < 5; j++) {
			if ((i >> j) & 1) {
				tempX -= list[j];
			}
		}

		for (int j = 0; tempX - j * 100 >= 0; j++) {
			if ((tempX - j * 100) % 105 == 0) {
				cout << 1 << endl;
				return 0;
			}
		}
	}


	cout << 0;





}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K,ans;
  cin >> N >> K;
  vector<int> h(N);
  for(int i=0;i<N;i++){
    cin >> h.at(i);
  }

  ans=0;
  for(int i=0;i<N;i++){ 
    if(K<=h.at(i)){
	  ans=ans+1;
    }else{
    }
  }
  
  cout << ans << endl;

}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	string s; cin >> s;
	cout << count(ALL(s), '1') << endl;
}

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

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

    for(int i=0;i<=N;++i){
        for(int k = 0; k <=N-i; k++)
        {   
            int z=N-i-k;
            if(i*10000+k*5000+z*1000==Y){
                cout<<i<<" "<<k<<" "<<z<<endl;
                return 0;
            }
        }
        
    }


    cout<<"-1 -1 -1"<<endl;
}

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

set<string> s;

signed main() {
	ios::sync_with_stdio(0);
	int N;
	cin >> N;
	for (register int i = 1;i <= N; i ++)
		{
			string st;
			cin >> st;
			s.insert(st) ;
		}
	cout << s.size() << endl;
}

Measured memory_bytes: 19240
import java.util.*;

public class Main {
    static int calu(int n, int m, int A[], int S[]) {
        int count=0;
        for(int i=0;i<m;i++){
            count+=bsearch(S[i],A,0,n);
        }
        return count;
    }
    static int bsearch(int si,int A[],int left,int right)
    {   
        while (left < right){
            int mid = (left + right) / 2;
            if (A[mid] == si) return 1;
            else if (si < A[mid]) right = mid;
            else left = mid + 1;
        }
        return 0;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] A,S;
        A = new int[n]; 
        for(int i = 0; i < n; i++) {
            A[i] = sc.nextInt();
        }
        int m = sc.nextInt();
        S = new int[m];
        for(int i = 0; i < m; i++) {
            S[i] = sc.nextInt();
        }
        System.out.println(calu(n,m,A,S));
        sc.close();
    }
}


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

int main() {
	// your code goes here
	int n;
	string s;
	cin>>n>>s;
	char cur = s[0];
	int cnt = 1;
	for(int i=0;i<n;++i){
	    if(s[i]==cur)continue;
	    else{
	        cnt++;
	        cur=s[i];
	    }
	}
	cout<<cnt;
}


Measured memory_bytes: 512
N = int(input())
a = [0]*N
b = [0]*N
c = [0]*N
for i in range(N):
  a[i],b[i],c[i] = map(int,input().split())
dp = [[0]*3 for _ in range(N)]
dp[0] = [a[0],b[0],c[0]]
for j in range(0,N-1):
  dp[j+1][0] = max(dp[j][1] + a[j+1],dp[j][2] + a[j+1])
  dp[j+1][1] = max(dp[j][0] + b[j+1],dp[j][2] + b[j+1])
  dp[j+1][2] = max(dp[j][0] + c[j+1],dp[j][1] + c[j+1])

print(max(dp[N-1][0],dp[N-1][1],dp[N-1][2]))


Measured memory_bytes: 61272
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int w, a, b;
  cin >> w >> a >> b;
  if (abs(a - b) <= w) {
    cout << 0 << endl;
    return 0;
  }
  cout << min(abs(a + w - b), abs(b + w - a)) << endl;
  return 0;
}

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

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int c = int.Parse(Console.ReadLine());
            int d = int.Parse(Console.ReadLine());
            int e = int.Parse(Console.ReadLine());
            int k = int.Parse(Console.ReadLine());

            if (e - a <= k)
            {
                Console.WriteLine("Yay!");

            }
            else {
                Console.WriteLine(":(");
            }
            Console.ReadKey();
        }
    }
}


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

using namespace std;

int main() {
  vector<int> x(5);
  for (int i = 0; i < 5; ++i) {
    cin >> x[i];
  }
  int k;
  cin >> k;
  for (int i = 0; i < 4; ++i) {
    for (int j = i + 1; j < 5; ++j) {
      if (abs(x[i] - x[j]) > k) {
	cout << ":(" << endl;
	return 0;
      }
    }
  }
  cout << "Yay!" << endl;
  return 0;
}



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

int main() {
    int h, n;
    cin >> h >> n;
    int a, sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a;
        sum += a;
    }
    if (sum >= h) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) x.begin(), x.end()
#define pb  push_back
#define mb  make_pair
#define fi  first
#define se  second

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
const ll mod = 1000000007;

void solve()
{
    ll n;
    cin >> n;
    if(n < 2){
        cout << 0;
        return;
    } else if(n < 4){
        cout<< 1;
        return;
    }
    int c = 0;
    ll limit = sqrt(n) + 1, res = 0;
    while(n % 2 == 0){
        c++;
        n /= 2;
    }
    if(c){
        res += (ll)((sqrt(8*c+1)-1.0)/2.0);
    }
    ll f = 3;
    while(f <= limit){
        c = 0;
        while(n % f == 0){
            c++;
            n /= f;
        }
        if(c){
            res += (ll)((sqrt(8*c+1)-1.0)/2.0);
        }
        f += 2;
    }
    if(n > 1){
        res++;
    }
    cout << res;

}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    //int t; cin >> t; while(t--)
    solve();
	return 0;
}


Measured memory_bytes: 3672