akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,M;
    cin >>N>>M;
    vector<string>A(N),B(M);

    rep(i,N){
        cin>>A[i];
    }
    rep(i,M){
        cin>>B[i];
    }
    rep(i,N-M+1){
        rep(j,N-M+1){
            ll flag=0;
            rep(k,M){
                rep(m,M){
                    if(A[i+k][j+m]!=B[k][m]){
                        flag=1;
                        break;
                    }

                }
                if(flag==1){
                    break;
                }
                if(k==M-1){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    
    cout <<"No" << endl;


    return 0;
    

}

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

using namespace std;


    


int main() {
    int N;
    cin >> N;
    
    string str;
    str=to_string(N);
    
    if(str[0]=='9' | str[1]=='9'){
        cout << "Yes" <<endl;
    }
    else{
        cout << "No" <<endl;
    }
}
    



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

#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define setbits(x) __builtin_popcount(x)
#define zerobits(x) __builtin_ctz(x)
#define setbitsll(x) __builtin_popcountll(x)
#define zerobitsll(x) __builtin_ctzll(x)
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x

typedef vector<int> vi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef map<int,int> mii;

const int MOD = 1e9+7;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,r;
	cin >> n >> r;
	if (n >= 10) {
		cout << r << '\n';
	} else {
		cout << r+100*(10-n) << '\n';
	}
	return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define pi          3.14159265358979323


void solve()
{
       ll n;
       cin>>n;
       ll ab=0,ba=0,ax=0,xa=0,bx=0,xb=0,aa=0,bb=0;
       ll ans=0;
       rep(i,0,n)
       {
              string s;
              cin>>s;
              ll k = sz(s);
              for(ll j=0; j< k-1; j++) if(s[j]=='A' && s[j+1]=='B') ans++;
              if(s[0]=='A' && s[k-1]=='B') ab++;
              else if(s[0]=='B' && s[k-1]=='A') ba++;
              else if(s[k-1]=='A') xa++;
              else if(s[0]=='B') bx++;
       }
       //cout<<ans<<" "<<ab<<" "<<xa<<" "<<ba<<" "<<bx<<endl;
       if(ab) ans+=ab-1;
       if(ba)
       {
              ans+=ba-1;
              if(bx) { ans++; bx--;}
              if(xa) { ans++; xa--;}
       }
       ans += min(bx, xa);
       cout<<ans;
}

int main()
{
       speed_up;
       ll T=1;
       //cin>>T;
       while(T--) solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
const ll INF = 1e16;

void solver(int N, string const &s, string const &t, int &ans){

    int cnt{};
    auto iter_t = t.begin();
    auto iter_s = s.begin();

    while(iter_s != s.end()){
        
        if((*iter_s) == (*iter_t)){
            ++cnt;
            ++iter_t;
        }
        else{
            cnt = 0;
            iter_t = t.begin();

            if((*iter_s) == (*iter_t)){
                ++cnt;
                ++iter_t;
            }
        }
        ++iter_s;
    }

    ans = 2*N - cnt;

    return;
}

int main(){

    int N;
    string s, t;
    cin >> N >> s >> t;

    int ans{};
    solver(N, s, t, ans);

    cout << ans << endl;

    return 0;
}



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

using namespace std;

typedef long long ll;

bool cmp(const vector<ll> &a, const vector<ll> &b){
    return a[0] < b[0];
}

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

    vector<vector<ll>> m(n, vector<ll>(2));
    for (int i = 0; i < n; i++){
        cin >> m[i][0] >> m[i][1];
    }
    sort(m.begin(), m.end(), cmp);

    int idx = 0;
    ll k, h;
    ll ans = 0;
    vector<ll> v(n + 1, 0);
    for (int i = 0; i < n; i++){
        v[i + 1] += v[i];
        h = m[i][1] - v[i + 1];
        if (h <= 0) continue;
        k = (h + a - 1) / a;
        ans += k;
        vector<ll> x{m[i][0] + 2 * d, 0};
        idx = upper_bound(m.begin() + i, m.end(), x, cmp) - m.begin();
        v[i + 1] += k * a;
        v[idx + 1] -= k * a;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12800
import java.util.Scanner;

class ABC {
	public static boolean upper(char ch) {
		return 'A' <= ch && ch <= 'Z';
	}
	public static boolean lower(char ch) {
		return 'a' <= ch && ch <= 'z';
	}
	public static boolean alphabet(char ch) {
		return ABC.upper(ch) || ABC.lower(ch);
	}
	public static char toLower(char upper) {
		return (char)(upper - ('A' - 'a'));
	}
	public static int getIndex(char lower) {
		return lower - 'a';
	}
	public static char getAlpha(int index) {
		return (char)((int)'a' + index);
	}
}

public class Main {
	public static void main(String[] args) {
		int alsize = 26;
		int count[] = new int[alsize];
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			String token = (String)sc.next();
			for (int i = 0; i < token.length(); ++i) {
				char ch = token.charAt(i);
				if (!(ABC.alphabet(ch)))
					continue;
				if (ABC.upper(ch))
					ch = ABC.toLower(ch);
				count[ABC.getIndex(ch)] += 1;
			}
		}
		for (int i = 0; i < alsize; ++i)
			System.out.println(ABC.getAlpha(i) + " : " + count[i]);
	}
}


Measured memory_bytes: 26204
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr double EPS = 1e-9;

vi ans(101010,-1);
// 各座標に格納したい情報を構造体にする
// 今回はX座標,Y座標,深さ(距離)を記述している

queue<int> q;
void bfs(vector<vector<int>> v, int n) {
    while(!q.empty()) {
        int now = q.front();q.pop();
        // cout<<"now: "<<now<<endl;
        for(int i = 0; i < v[now].size(); i++) {
            int next = v[now][i];
        // cout<<"next: "<<next<<endl;

            // 次に探索する場所が既に探索済みの場合
            if(ans[next]>=0) continue;
            // cout<<"ch"<<endl;
            ans[next] = now;
            q.push(next);
        }
    }
}

int main(){

    int n,m;
    cin>>n>>m;
    vvi v(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        v[a].pb(b);
        v[b].pb(a);
    }
    q.push(0);
    ans[0]=0;
    bfs(v,n);
    fin("Yes");
    for(int i=1;i<n;i++){
        fin(ans[i]+1);
    }
}



Measured memory_bytes: 16160
#include <bits/stdc++.h>
using namespace std;
using Int = long long;

const int MAX = 1000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
}

vector<int> S;
int memo[100001][201];
Int recur(int X, int N, int E)
{
    Int ans = 0;
    if (memo[X][N] != -1) {
        ans = memo[X][N];
    } else {
        if (N == 0) ans = X;
        for (int i = 0; i < N; i++) {
            int Y = X % S[i];
            auto it = upper_bound(begin(S), begin(S)+N-1, Y);
            ans += recur(Y, it - begin(S), begin(S)+N-1 - it);
            ans %= MOD;
        }
        memo[X][N] = ans;
    }
    (ans *= COM(E + N, E)) %= MOD;
    (ans *= fac[E]) %= MOD;
    return ans;
}
int main()
{
    COMinit();
    for (int i = 0; i < 100001; i++) for (int j = 0; j < 201; j++) memo[i][j] = -1;
    int N, X; cin >> N >> X;
    S.resize(N); for (auto& s : S) cin >> s;
    sort(begin(S), end(S));
    auto it = upper_bound(begin(S), end(S), X);
    cout << recur(X, it - begin(S), end(S) - it) << endl;
    return 0;
}

Measured memory_bytes: 78848
from math import *

Q = int(input())
r = []
for x in range(Q):
  A = [int(i) for i in input().split(' ')]
  x = A[0] * A[1]
  s = floor(sqrt(x))
  if s*s == x:
    if (A[0] != s): r.append(2*s - 3)
    else: r.append(2*s-2)
  elif (s*(s+1) < x):
    r.append(2*s - 1)
  else: 
    r.append(2*s - 2)

for i in r:print(i)

Measured memory_bytes: 3064
import math
from collections import Counter

n, m =map(int, input().split())
mod = 10**9+7

prime_count = Counter()
for i in range(2, math.ceil(math.sqrt(m))+1):
    while m % i == 0:
        m /= i
        prime_count[i] += 1
if m > 1:
    prime_count[int(m)] += 1    

def ncr(n, r, p):
    num = den = 1
    for i in range(r):
        num = (num * (n - i)) % p
        den = (den * (i + 1)) % p
    return (num * pow(den, p - 2, p)) % p

ans = 1
for p, q in prime_count.items():
    ans *= ncr(q+n-1, n-1, mod)
    ans %= mod
print(ans)

Measured memory_bytes: 3316
#include<iostream>
#include<string>

int main(){
    
    std::string o, e;
    std::cin >> o >> e;

    for(size_t i = 0, j = 0, k = 0; i < o.size() + e.size(); i++){
        if(i % 2 == 0){
            std::cout << o[j];
            j++;
        }else{
            std::cout << e[k];
            k++;
        }
    }std::cout << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;

template <class T> using V = vector<T>;

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

const long long INF = 1LL << 60;

using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;



#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define pb(a) push_back(a);




ll Sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}



const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}


#define comuse Comuse()

ll combi(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;
}

ll perm(int n,int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] % MOD) % MOD;
}


ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


vll div(ll n){
  vll ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  SORT(ret);
  return (ret);
}


ll modpow(ll a,ll n,ll mod){
  ll ans=1;
  while(n>0){
    if(n&1){
      ans=ans*a%mod;
    }

    a=a*a%mod;
    
    n>>=1;
  }

  return ans;
}

void Solve();


const int MAX_N = 131072;
//segment tree 
int NN;
int seg[MAX_N*2-1];
void seguse(){
  for(int i=0;i<2*NN-1;i++){
    seg[i]=INT_MAX;
  }
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}



/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
//segtreeの葉の先頭の添え字はn-1
void Solve(){
  ll h,a;
  	cin>>h>>a;
  cout<<h/a+!!(h%a)<<"\n";
}

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

int main(){
	int list[1000] = {2,3},listno = 2;
	int N, no[10000];
	cin >> N;
	for(int i = 0; i < N; i++)
		cin >> no[i];
	int count = 0;

	for(int i = 0; i < N; i++){
		bool flag = false;
		if(no[i] >= 4){
			if(no[i] % 2 != 0){
				flag = true;
				for(int j = 3; j * j <= no[i]; j += 2){
					if(no[i] % j == 0)
						flag = false;
				}
			}
			if(flag == true)
				count++;
		}else count++;
	}

	cout << count << endl;
}

Measured memory_bytes: 1196
import itertools

n = int(input())
M=0
A=0
R=0
C=0
H=0
cnt=0
for _ in range(n):
    newstr = str(input())
    if newstr[0] == "M":
        M+=1
    elif  newstr[0] == "A":
        A+=1
    elif  newstr[0] == "R":
        R+=1
    elif  newstr[0] == "C":
        C+=1
    elif  newstr[0] == "H":
        H+=1
lis = [M,A,R,C,H]
#print(lis)
lis2 = [_ for _ in lis if _ != 0]
#print(lis2)
if len(lis2) < 3:
    print(0)
    exit()
else:
    for i in itertools.combinations(lis2, r=3):
        cnt += i[0] * i[1] * i[2]
print(cnt)

Measured memory_bytes: 3064
#define de puts("#")
#define bug(x) cout<<#x<<" : "<<x<<endl
#define cha1 printf("L : %d,R : %d,x : %d,l : %d,r : %d,rt : %d\n",L,R,x,l,r,rt)
#define cha2 printf("L : %d,R : %d,l : %d,r : %d,rt : %d\n",L,R,l,r,rt)
#define cha3 printf("pos : %d,x : %d,l : %d,r : %d,rt : %d\n",pos,x,l,r,rt)
#define lcha1 printf("L : %lld,R : %lld,x : %lld,l : %lld,r : %lld,rt : %lld\n",L,R,x,l,r,rt)
#define lcha2 printf("L : %lld,R : %lld,l : %lld,r : %lld,rt : %lld\n",L,R,l,r,rt)
#define lcha3 printf("pos : %lld,x : %lld,l : %lld,r : %lld,rt : %lld\n",pos,x,l,r,rt)
#define huge(n,m,a) for(int i=1; i<=n; i++) {for(int j=1; j<=m; j++)printf("%d ",a[i][j]);puts("");}puts("")
#define lhuge(n,m,a) for(int i=1; i<=n; i++) {for(int j=1; j<=m; j++)printf("%lld ",a[i][j]);puts("");}puts("")
#define lowbit(x) (x&(-x))
#define IN freopen("in.txt","r",stdin)
#define OUT1 freopen("out1.txt","w",stdout)
#define OUT2 freopen("out2.txt","w",stdout)
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	int tot=m*2+1;
	int ans;
	if(n%tot==0)ans=n/tot;
	else ans=n/tot+1;
	printf("%d\n",ans);
	return 0;
}

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

int main(void) {
  ll N;
  cin >> N;
  vector<pll> A(N);
  REP(i, 0, N) {
    cin >> A[i].first;
    A[i].second = i;
  }

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

  vector<ll> ans(N);
  REP(i, 0, N) {
    if(i < N / 2) ans[A[i].second] = A[N / 2].first;
    else ans[A[i].second] = A[N / 2 - 1].first;
  }
  REP(i, 0, N) cout << ans[i] << endl;
}


Measured memory_bytes: 6912
#include <iostream>
#include <vector>
#include <chrono>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <random>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

int main()
{
    fastInp;

    ll n;
    cin >> n;

    if (n % 1000 == 0) {
        cout << "0";
        return 0;
    }
    cout << 1000 - n % 1000;

    return 0;
}

Measured memory_bytes: 3648
#define dbg(...) fprintf(stderr,__VA_ARGS__)
#define dpr(x) cerr<<#x<<": "<<x<<endl;
#define dprc(c) do{cerr<<#c<<":";for(auto&_i:(c)){cerr<<" "<<_i;}cerr<<endl;}while(0)
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
int INF = 1e9+7;
#define all(c) begin(c), end(c)
#define tr(i,c) for(auto i=begin(c);i!=end(c);i++)
#define rtr(i,c) for(auto i=(c).rbegin();i!=(c).rend();i++)
#define rep(i,b) for(auto i=0;i<(b);i++)
#define pb push_back
#define sz(c) int((c).size())

bool primep(int n) {
  if (n == 1) return false;
  if (n == 2) return true;
  if ((n & 1) == 0) return false;
  int rt = sqrt(n)+1;
  for (int i = 3; i < rt; i += 2) {
    if ((n % i) == 0) return false;
  }
  return true;
}

int main(int argc, char **argv)
{
  int n, res = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (primep(x)) res++;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3096
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;
const long long INF = 1e18;

int main()
{
	int n, W;
	cin >> n >> W;
	vector<long long> v(n), w(n);
	for (int i = 0; i < n; i++)
	{
		cin >> w[i] >> v[i];
	}
	vector<long long> dp(100001, INF);
	dp[0] = 0;

	for (int i = 0; i < n; i++) {
		for (int j = 100000; j >= 0; j--) {
			if (j - v[i] >= 0) {
				dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
			}
		}
	}
	for (int i = 100000; i >= 0; i--) {
		if (dp[i] <= W) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
import fileinput


def num_turns(total, n_1, n_2, n_3):
    _n_1 = n_1 + n_2 + n_3 + 1
    _n_2 = n_2 + n_3 + 1
    _n_3 = n_3 + 1

    _arr = [0.0] * (_n_1 * _n_2 * _n_3)

    for i_3 in range(n_3 + 1):
        for i_2 in range(n_2 + 1 + n_3 - i_3):
            for i_1 in range(n_1 + 1 + n_2 + n_3 - i_3 - i_2):
                with_sushi = i_1 + i_2 + i_3
                if with_sushi == 0:
                    continue
                expectation = total / with_sushi
                if i_1 > 0:
                    p = i_1 / with_sushi
                    expectation += p * _arr[(i_1 - 1) + i_2 * _n_1 + i_3 * _n_1 * _n_2]

                if i_2 > 0:
                    p = i_2 / with_sushi
                    expectation += p * _arr[i_1 + 1 + (i_2 - 1) * _n_1 + i_3 * _n_1 * _n_2]

                if i_3 > 0:
                    p = i_3 / with_sushi
                    expectation += p * _arr[i_1 + (i_2 + 1) * _n_1 + (i_3 - 1) * _n_1 * _n_2]
                _arr[i_1 + i_2 * _n_1 + i_3 * _n_1 * _n_2] = expectation

    return _arr[n_1 + n_2 * _n_1 + n_3 * _n_1 * _n_2]


inp = fileinput.FileInput()
total = int(inp.readline())

n_1 = 0
n_2 = 0
n_3 = 0

for v in inp.readline().split(" "):
    v = int(v)
    if v == 1:
        n_1 += 1
    if v == 2:
        n_2 += 1
    if v == 3:
        n_3 += 1

print(num_turns(total, n_1, n_2, n_3))

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

namespace ABC087A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n,a,b,c;
          
            c = int.Parse(Console.ReadLine());
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());
            n = (c - a) % b;
            Console.WriteLine(n);
            Console.ReadKey();
    } }
}

Measured memory_bytes: 11092
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
ab = [inpl() for _ in range(n)]
now = 0
ab.sort(key = lambda x:x[1])
# ab.sort()
# print(ab)
for i in range(n):
    a,b = ab[i]
    now += a
    if now > b:
        print('No')
        # print(i)
        break
else:
    print('Yes')


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

int main(){
  int N; cin>>N;
  set<int> st;
  for(int i=0;i<N;i++){
    int a; cin>>a;
    if(st.find(a) == st.end())
      st.insert(a);
    else st.erase(a);
  }
  cout<<st.size()<<endl;
  return 0;
}


Measured memory_bytes: 4864
import itertools
N, M, Q = map(int,input().split())
s = [tuple(map(int, input().split())) for i  in range(Q)]
l = list(range(1,M+1))
ans = []
for v in itertools.combinations_with_replacement(l, N):
    count = 0
    for i in range(Q):
        a, b, c, d = s[i]
        if v[b-1] - v[a-1] == c:
            count += d
    ans.append(count)
print(max(ans))


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

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

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define frr(i,x,y) for(ll i=x-1;i>=y;i--)
#define inf 10000000000000000
const ll mod=998244353;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

void solve()
{
    ll a,b,n;
    cin>>a>>b>>n;
    ll ans;
    if(n<b)
    {
        ans=a*n/b;
    }
    else
    {
        ans=a*(b-1)/b;
    }
    cout<<ans<<endl;
    return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N;
    cin >> N;
    ll nt = 0,nx = 0,ny = 0;
    bool flg = true;
    for (int i = 0; i < N; i++) {
        ll t,x,y;
        cin >> t >> x >> y;
        ll cost = abs(nx - x) + abs(ny - y);
        if(cost > t-nt){
            flg = false;
        } else {
            ll d = (t - nt) - cost;
            if(d % 2 != 0){
                flg = false;
            }
        }
        nt = t; nx = x; ny = y;
    }
    Yes(flg);
}

Measured memory_bytes: 3616
MOD = 10**9 + 7
N, M = map(int, input().split())
S = [int(i) for i in input().split()]
T = [int(i) for i in input().split()]

dp = [[0 for j in range(2010)] for i in range(2010)]
dp[0][0] = 1
for s in range(N+1):
    for t in range(M+1):
        if 0 < s and 0 < t and S[s-1] == T[t-1]:
            dp[s][t] += dp[s-1][t-1]
        if 0 < s:
            dp[s][t] += dp[s-1][t]
        if 0 < t:
            dp[s][t] += dp[s][t-1]
        if 0 < s and 0 < t:
            dp[s][t] -= dp[s-1][t-1]
        dp[s][t] %= MOD
print(dp[N][M])


Measured memory_bytes: 101156
s = input()
p, g = 0, 0
ans = 0
for e in s:
    if e == "g":
        if p < g:
            p += 1
            ans += 1
        else:
            g += 1
    else:
        if p < g:
            p += 1
        else:
            g += 1
            ans -= 1
print(ans)


Measured memory_bytes: 39664
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> as(N);
  F0R(i, N) {
    cin >> as[i];
  }
  sort(rrng(as));

  i64 result = 0;
  F0R(i, N) {
    result += as[i / 2];
  }
  result -= as[0];
  cout << result;
}
#endif


Measured memory_bytes: 3992
N, M = map(int, input().split())

l = []
for i in range(1, int(M**0.5)+1):
    if M%i==0:
        l.append(M//i)
        if M//i != i:
            l.append(i)
l.sort(reverse=True)

for i in l:
    a = M//i
    if a >= N:
        print(i)
        break

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long


int main(){
    IOS;

    long int n,k;
    cin>>n>>k;

    vector<long int> v(n);
    for(long int i = 0; i < n; i++)
        cin>>v[i];
    
    vector<long int> dp(n,LONG_MAX);
    dp[0] = 0;

    for(long int i = 1; i < n; i++){
        for(long int j = 1; j <= k; j++){
            if(i >= j)
                dp[i] = min(dp[i],dp[i-j] + abs(v[i]-v[i-j]));
        }
    }

    cout<<dp.back();
    return 0;
}

Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func main() {
	var N int
	fmt.Scan(&N)
	d := atoi(nextSlice())

	sort.Ints(d)
	N /= 2
	fmt.Println(d[N] - d[N-1])
}

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func nextSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func scanSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func scanFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

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

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

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

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

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

func yesOrNo(b bool) {
	if b {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

func yesorNO(b bool) {
	if b {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}

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

using namespace std;

int main(void)
{
    string x;
    cin>>x;
    int cnt=0;
    for(int i=0;i<x.length();++i)
    {
        if(x[i]=='+')
        {
            cnt++;
        }
        else
        {
            cnt--;
        }
    }
    cout <<cnt <<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
int main(){
    CST(10);
    ll n,a,b;cin >> n >>a >>b;
    vl v(n);rep(i,n)cin >> v[i];
    pair<ll,ll> dp[n+1][n+1];
    rep(i,n+1)rep(j,n+1)dp[i][j]={0,0};
    dp[0][0].se=1;
    rep(i,n){
        rep(j,n+1){
            if(i<j)continue;
            if(dp[i+1][j].fi<dp[i][j].fi){
                dp[i+1][j].fi=dp[i][j].fi;
                dp[i+1][j].se=dp[i][j].se;
            }
            else if(dp[i+1][j].fi==dp[i][j].fi){
                dp[i+1][j].se+=dp[i][j].se;
            }
            if(dp[i+1][j+1].fi<dp[i][j].fi+v[i]){
                dp[i+1][j+1].fi=dp[i][j].fi+v[i];
                dp[i+1][j+1].se=dp[i][j].se;
            }   
            else if(dp[i+1][j+1].fi==dp[i][j].fi+v[i]){
                dp[i+1][j+1].se+=dp[i][j].se;
            }        
        }
    }
    /*rep(i,n+1){
        rep(j,n+1){
            cout << dp[i][j].fi <<" ";
        }
        cout <<endl;
    }
    rep(i,n+1){
        rep(j,n+1){
            cout << dp[i][j].se <<" ";
        }
        cout <<endl;
    }*/
    pair<ll,double> max={0,0};
    ll ans=0;
    rep(i,n+1){
        if(a<=i&&i<=b){
            ll inte=dp[n][i].fi/i;
            ll tmp=dp[n][i].fi%i;
            double deci=(double)tmp/i;
            if(inte>max.fi){
                max={inte,deci};
                ans=dp[n][i].se;
                continue;
            }
            if(inte==max.fi){
                if(deci>max.se){
                    max={inte,deci};
                    ans=dp[n][i].se;
                    continue;
                }
                if(deci==max.se){
                    ans+=dp[n][i].se;
                }
            }
        }
    }
    cout << max.se+max.fi <<endl;
    cout << ans <<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    string N;

    cin >> N;

    int ans = 0;
    for (int i = 0; i < N.size(); i++) {
        ans += N[i] - '0';
    }
    if (ans % 9 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3752
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    ans = 0
    for i in range(1, n):
        if A[i] < A[i - 1]:
            ans += A[i - 1] - A[i]
            A[i] = A[i - 1]
    print(ans)
resolve()

Measured memory_bytes: 94072
# import sys
 
# N:県, M:市
N, M = list(map(int, input().split()))

A = {}
# {ken: [(city_no, city_year)],...}

res = [None] * M

for i in range(M):
  k, y = list(map(int, input().split()))
  if k in A.keys():
    A[k].append((i, y))
  else:
    A[k] = [(i, y)]

# print(A)
# A: {県番号: {市1の年:市1のindex, 市2の年:市2のindex}}

for k, v in A.items():
  # sort by year
  c_list = sorted(v, key=lambda x: x[1])
  counter = 1
  for c in c_list:
    res[c[0]] = (k, counter)
    counter += 1

for x in res:
  print("{:0>6}{:0>6}".format(x[0], x[1]))


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

using namespace std;

#define int long long
int const maxn = 1005;
vector < pair < int, int > > g[maxn];
int answer[maxn];
int ok[maxn], used[maxn], check[maxn];
int inf = 1e18;

void dfs(int v, int i) {
    used[v] = i;
    for (auto u : g[v]) {
        if (used[u.first] != i) dfs(u.first, i);
    }
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m, a, b, c;
    cin >> n >> m;
    for (int i = 1; i <= m; ++i) {
        cin >> a >> b >> c;
        g[a].push_back({b, c});
    }
    for (int i = 2; i <= n; ++i) answer[i] = -inf;
    for (int i = 1; i <= n; ++i) {
        dfs(i, i);
        ok[i] = (used[n] == i);
    }
    for (int i = 1; i < n; ++i) {
        for (int j = 1; j <= n; ++j) {
            for (auto u : g[j]) {
                answer[u.first] = max(answer[u.first], answer[j] + u.second);
            }
        }
    }
    for (int j = 1; j <= n; ++j) {
        for (auto u : g[j]) {
            if (answer[u.first] < answer[j] + u.second) check[u.first] = 1;
        }
    }
    for (int i = 1; i <= n; ++i) {
        if (check[i] && ok[i]) {
            cout << "inf";
            exit(0);
        }
    }
    cout << answer[n];
    return 0;
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll INF=1LL<<60;
const ll MOD=1e9+7;

int main(){
    int N, K; cin >> N >> K;
    vi p(N);
    for(auto &x : p) cin >> x;
    sort(all(p));
    ll sum=0;
    for(int i=0; i<K; i++){
        sum+=p[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>

#define K 10001
#define L 2000001

void CountingSort(int *,int *,int);

int main(){
  int i,n;
  int A[L],B[L],C[K];

  scanf("%d",&n);
  for(i=1;i<=n;i++) scanf("%d",&A[i]);

  CountingSort(A,B,n);

  for(i=1;i<n;i++) printf("%d ",B[i]);
  printf("%d\n",B[i]);
  
  return 0;

}

void CountingSort(int *A,int *B,int n){
  int i,j;
  int C[K];
  
  for(i=0;i<K;i++) C[i]=0;

  /*C[i]にiの出現回数を記録*/
  for(j=1;j<=n;j++) C[A[j]]++;

  /*C[i]にi以下の出現回数を記録*/
  for(i=1;i<K;i++) C[i]=C[i]+C[i-1];

  for(j=n;0<j;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

}




Measured memory_bytes: 17392
s = gets.chomp
if s.length % 2 == 0
  s = s.slice(0, s.length - 2)
else
  s = s.slice(0, s.length - 1)
end
s.length.downto(0) do |i|
  s1 = s.slice(0, s.length / 2)
  s2 = s.slice(s.length / 2, s.length)
  break if s1 == s2
  s = s.slice(0, s.length - 2)
end
puts s.length


Measured memory_bytes: 1788
function Main(input) {
  input.trim();
  input = input.split("\n");
  var N = input[0];
  input.shift();
  var arr = arr1dto2d(input);
  var sum = 0;
  for(var p=0;p<N;p++){
    var mem = arr[p];
    var ato = mem[0];
    arr[p][0] -= mem[1];
    arr[p][1] += ato;
  }
  arr.sort(function(a,b){return(a[1] - b[1]);});
  var P = -900000000000;
  for(var i=0;i<N;i++){
    if(P<=arr[i][0]){
      sum++;
      P = arr[i][1];
    }
  }
  console.log(sum);
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
function arr1dto2d (arr){
	for(var i=0;i<arr.length;i++){
    arr[i]=arr[i].split(" ").map(Number);
    }
  return arr;
}

Measured memory_bytes: 49136
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <iostream>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N), maxAry(0);
    REP(i, N) { cin >> A.at(i); }
    for (int n : A) {
        if (!maxAry.size()) {
            maxAry.push_back(n);
        } else {
            int left = 0, right = maxAry.size();
            while (left < right) {
                int mid = (left + right) / 2;
                if (maxAry[mid] >= n) {
                    left = mid + 1;
                } else {
                    right = mid - 1;
                }
            }

            if (left == maxAry.size())
                maxAry.push_back(n);
            else if (n > maxAry[left])
                maxAry[left] = n;
            else
                maxAry[left + 1] = n;
        }
    }
    cout << maxAry.size() << "\n";
}

Measured memory_bytes: 1276
n=int(input())
#a,b=map(int,input().split())
l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

import bisect

l.sort()
ans=0
for i in range(n):
    for j in range(i+1,n):
        a=l[i]
        b=l[j]
        index=bisect.bisect_left(l,a+b)
        ans+=max(index-(j+1),0)
print(ans)


Measured memory_bytes: 45448
N = int(input())
money = 1000
line = list(map(int, input().split()))
prices = []
increaseFlag = False
decreaseFlag = False
upFlag = False
for cnt, val in enumerate(line):
    if cnt == 0:
        prices.append(val)
    elif prices[-1] == val:
        continue
    elif prices[-1] > val:
        increaseFlag = False
        if len(prices) == 1:
            prices[-1] = val
        else:
            if decreaseFlag:
                prices[-1] = val
            else:
                prices.append(val)
                decreaseFlag = True
    elif prices[-1] < val:
        decreaseFlag = False
        upFlag = True
        if increaseFlag:
            prices[-1] = val
        else:
            prices.append(val)
            increaseFlag = True
if len(prices) == 1:
    print(1000)
elif not upFlag:
    print(1000)
else:
    kabuNum = 0
    leng = len(prices) - (len(prices) % 2)
    for i in range(leng):
        if i % 2 == 0:
            kabuNum = money // prices[i]
            money -= kabuNum * prices[i]
        else:
            money += kabuNum * prices[i]
    print(money)


Measured memory_bytes: 9260
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)

for _ in range(m):
    max_a = heapq.heappop(a) * (-1)
    heapq.heappush(a, (max_a//2)*(-1))
print(sum(a)*(-1))


Measured memory_bytes: 72216
use strict;
my $N = <>;
my @A = split(/\s+/, <>);
my %cnt; # 同じ棒の長さの本数と値のhash
foreach my $key (@A){
    if ($cnt{$key}) {
        $cnt{$key} = $cnt{$key} + 1;
    } else {
        $cnt{$key} = 1;
    }
}

my $edge1 = 0;
my $edge2 = 0;
foreach (sort {$b <=> $a} keys %cnt) {
    if ($cnt{$_} >= 2) {
        if ($cnt{$_} >= 4) {
            $edge1 = $_ if $edge1 == 0;
            $edge2 = $_ if $edge2 == 0;
            last;
        } else {
            if ($edge2 == 0) {
                $edge2 = $_;
            } elsif ($edge1 == 0) {
                $edge1 = $_;
            }
        }
    }
}
if ($edge1 && $edge2) { # どちらか0だと長方形を作れない
    print $edge1 * $edge2;
} else {
    print 0;
}


Measured memory_bytes: 31724
#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>;

bool dp[110000];

int main() {
    int n, k;
    cin >> n >> k;
    int a[n];
    rep(i,n) cin >> a[i];

    for (int i = 0; i <= k; i++) {
        dp[i] = false;
        for (int j = 0; j < n; j++) {
            if (i - a[j] >= 0) dp[i] = dp[i] || !dp[i-a[j]];
        }
    }
    string ans = "Second";
    if (dp[k]) ans = "First";
    cout << ans << endl;
}

Measured memory_bytes: 384
N = int(input())
s = input()

for bit in range(4):
    animal = [-1] * N
    animal[0] = bit % 2
    animal[1] = bit // 2
    for i in range(1, N-1):
        if (animal[i] == 0) ^ (s[i] == 'o'):
            animal[i+1] = 1 - animal[i-1]
        else:
            animal[i+1] = animal[i-1]
    ok = True
    if animal[-1] == 0:
        if (s[-1] == 'o') ^ (animal[-2] == animal[0]):
            ok = False
    if animal[-1] == 1:
        if (s[-1] == 'o') ^ (animal[-2] != animal[0]):
            ok = False
    if animal[0] == 0:
        if (s[0] == 'o') ^ (animal[-1] == animal[1]):
            ok = False
    if animal[0] == 1:
        if (s[0] == 'o') ^ (animal[-1] != animal[1]):
            ok = False
    if ok:
        ans = ''
        for i in range(N):
            ans += 'S' if animal[i] == 0 else 'W'
        print(ans)
        exit()
print(-1)


Measured memory_bytes: 4852
/*Flamenco Sketches*/
#include<bits/stdc++.h>
using namespace std;
 
#define NL '\n'
#define xx first
#define yy second
#define ll long long
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define sz(x) x.size()
#define all(x) (x).begin(), (x).end()
#define mem(a, b) memset(a, b, sizeof(a))
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;++i)
#define async() ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
 
//#define FayeValentine 
void dbg(){cerr<<NL;}template<typename H,typename... T> void dbg(H h,T... t){cerr<<' '<<h;dbg(t... );}
#ifdef  FayeValentine
#define debug(...) cerr<<"("<<#__VA_ARGS__<<"):",dbg(__VA_ARGS__)
#else
#define debug(...) 
#endif


void absinthe() {
	int x, a, b; cin >> x >> a >> b; 
	if(abs(x-a) < abs(x-b)) cout << 'A' << NL;
	else cout << 'B' << NL; 
}
 
 
int main(){
  //freopen("input.txt", "r", stdin);
  async();
  int __t = 1; //cin >> __t;
  for(int __c = 1; __c <=__t; __c++) {
    //cout << "Case #" << __c << ": "; 
    absinthe();
  }
}  

Measured memory_bytes: 256
n=int(input())
a=[int(j) for j in input().split()]
q=int(input())
m=[int(j) for j in input().split()]
ans=[False]*q
c=[[] for i in range(2001)]
for i in range(q):
    c[m[i]].append(i)


for i in range(1<<n):
    b=bin(i)[2:].rjust(n,"0")
    tmp=0
    for j in range(n):
        if int(b[j]):
            tmp+=a[j]
    for j in c[tmp]:
        ans[j]=True

for i in ans:
    if i:
        print("yes")
    else:
        print("no")



Measured memory_bytes: 5720
import java.util.Scanner;
//import java.io.*;
//import java.util.Arrays;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		//InputStreamReader is = new InputStreamReader(System.in);
		//BufferedReader br = new BufferedReader(is);
		//String text = scan.next();
		int n = scan.nextInt();
		int tama[] = new int[10];
		int hantei;
		String kekka[] = new String[n];
		for(int i = 0 ; i < n ; i++){
			hantei = 0;
			int b = 0;
			int c = 0;
			for(int j = 0 ; j < 10 ; j++){
				tama[j] = scan.nextInt();
			}
			for(int j = 0 ; j < 10 ; j++){
				if(b < tama[j]){
					b = tama[j];
				}else if(c < tama[j]){
					c = tama[j];
				}else{
					kekka[i] = "NO";
					hantei++;
					break;
				}
			}
			if(hantei == 0){
				kekka[i]="YES";
			}
		}
		for(int i = 0 ; i < n ; i++){
			System.out.println(kekka[i]);
		}
	}
}

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

int main(){
  int V,E,r;
  cin >> V >> E >> r;
  vector< vector< pair<int,int> > > v(V);
  int s,t,d;
  for(int i = 0; i < E; ++i){
    cin >> s >> t >> d;
    v[t].push_back(make_pair(s,d));
  }
  vector<int> M(V,20000010);
  M[r] = 0;
  int i;
  for(i = 0; i < V; ++i){
    int check = 0;
    for(int j = 0; j < V; ++j){
      int minimum = 20000010;
      for(size_t k = 0; k < v[j].size(); ++k){
	int another;
	if(M[v[j][k].first] == 20000010) another = 20000010;
	else another = M[v[j][k].first] + v[j][k].second;
	minimum = min(minimum, another);
      }
      minimum = min(minimum, M[j]);
      if(M[j] == minimum) check += 1;
      M[j] = minimum;
    }
    if(check == V) break;
  }
  if(i == V) cout << "NEGATIVE CYCLE" << endl;
  else{
    for(int j = 0; j < V; ++j){
      if(M[j] == 20000010) cout << "INF" <<endl;
      else cout << M[j] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3160