akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define sc(a) scanf("%c",&a)
#define ss(a) scanf("%s",a)
#define pi(a) printf("%d\n",a)
#define pl(a) printf("%lld\n",a)
#define pc(a) putchar(a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i, a, b) for(register int i=a;i<=b;++i)
#define repd(i, a, b) for(register int i=a;i>=b;--i)
#define reps(s) for(register int i=head[s];i;i=Next[i])
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pii pair<int,int>
#define mii unordered_map<int,int>
#define msi unordered_map<string,int>
#define lowbit(x) ((x)&(-(x)))
#define ce(i, r) i==r?'\n':' '
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;

inline int qr() {
    int f = 0, fu = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-')fu = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        f = (f << 3) + (f << 1) + c - 48;
        c = getchar();
    }
    return f * fu;
}

const int N = 2e5 + 10, MOD = 1e9 + 7;
int a[N], n;
ll b[N];

int main() {
    n = qr();
    repi(i, 1, n)a[i] = qr();
    repd(i, n, 1)b[i] = (b[i + 1] + a[i]) % MOD;
    ll ans = 0;
    repi(i, 1, n - 1)ans = (ans + a[i] * b[i + 1] % MOD) % MOD;
    pl(ans);
    return 0;
}


Measured memory_bytes: 6100
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include <numeric>

#define LL long long
#define MOD 1000000007

using namespace std;


/*
LL GCD(LL a, LL b) {
	if (a < b) GCD(b, a);
	LL r;
	while ((r = a%b)) {
		a = b;
		b = r;
	}
	return b;
}
*/


LL A[100000];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	if (S.length() == 2) {
		cout << S << endl;
	}
	else {
		cout << S[2] << S[1] << S[0] << endl;
	}

}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
  char a, b, c, d;
  scanf(" %c %c %c %c", &a, &b, &c, &d);
  int f = 0;
  if(a == b){
    if(a != c && c == d){
      f = 1;
    }
  }else if(a == c){
    if(a != b && b == d){
      f = 1;
    }
  }else if(a == d){
    if(a != b && b == c){
      f = 1;
    }
  }
  if(f){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


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

using namespace std;
using ll = long long;

int main() {
  ll n, x;
  cin >> n >> x;
  vector<ll> vec(n);
  for (auto &v : vec)
    cin >> v;
  sort(vec.begin(), vec.end());

  int cnt = 0;
  for (ll i = 0; i < n; ++i) {
    if (i != 0)
      vec[i] += vec[i-1];
    if (vec[i] == x || (vec[i] < x && i != n - 1))
      cnt += 1;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 3540
H,W,D = map(int,input().split())
A = [0]*(H*W+1)
for i in range(H):
    a = list(map(int,input().split()))
    for j in range(W):
        A[a[j]] = (i,j)
d = [0]*(H*W+1)
for i in range(D+1,H*W+1):
    d[i] = d[i-D]+abs(A[i][0]-A[i-D][0])+abs(A[i][1]-A[i-D][1])
Q = int(input())
for i in range(Q):
    L,R = map(int,input().split())
    print(d[R]-d[L])

Measured memory_bytes: 58916
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (int i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<long long, long long>;
const int INF = 1001001007;
const int MOD = 1000000007;
template <typename T>
void printvec(vector<T> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main(){
    int n, m; cin >> n >> m;
    vector<double> ar(n);
    rep(i,n) cin >> ar[i];
    priority_queue<double> q;
    rep(i,n) q.push(ar[i]);
    rep(i,m){
        double a = q.top(); q.pop();
        a /= 2;
        q.push(a);
    }
    ll ans = 0;
    while (!q.empty()){
        int b = q.top(); q.pop();
        ans += b;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2168
from time import time
from random import random

limit_secs = 2
start_time = time()

D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

def calc_score(t):
    score = 0
    S = 0
    last = [-1] * 26
    for d in range(len(t)):
        S += s[d][t[d]]
        last[t[d]] = d
        for i in range(26):
            S -= c[i] * (d - last[i])
        score += max(10 ** 6 + S, 0)
    return score

def solution1():
    return [i % 26 for i in range(D)]

def solution2():
    t = None
    score = -1
    for i in range(26):
        nt = [(i + j) % 26 for j in range(D)]
        if calc_score(nt) > score:
            t = nt
    return t

def solution3():
    t = []
    for _ in range(D):
        score = -1
        best = -1
        t.append(0)
        for i in range(26):
            t[-1] = i
            new_score = calc_score(t)
            if new_score > score:
                best = i
                score = new_score
        t[-1] = best
    return t

def optimize0(t):
    return t

def optimize1(t):
    score = calc_score(t)
    while time() - start_time + 0.15 < limit_secs:
        d = int(random() * D)
        q = int(random() * 26)
        old = t[d]
        t[d] = q
        new_score = calc_score(t)
        if new_score < score:
            t[d] = old
        else:
            score = new_score
    return t

t = solution3()
t = optimize0(t)
print('\n'.join(str(e + 1) for e in t))


Measured memory_bytes: 84100
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int N; cin >> N;
	bool flag = true;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		if (a[i] > i) flag = false;
		if (i > 0 && a[i - 1] + 1 < a[i]) flag = false;

	}
	if (!flag) cout << -1 << endl;
	else {
		ll ans = 0;
		for (int i = 1; i < N; i++) {
			if (a[i - 1] + 1 == a[i]) ans++;
			else ans += a[i];
		}
		cout << ans << endl;
	}
}

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

int main(){
    string s, t;
    cin >> s >> t;
    rep(i, s.size()){
        if(s[i] != t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3548
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <cmath>         // sqrt
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;
typedef tuple<ll, ll, string> Tlls;

ll N, M, X;
ll INF = 1000000000;
ll ANS = INF;
ll data[100][100];
vector<ll> ans(100);

ll dfs(ll p, vector<ll> ans, ll data[100][100])
{
  vector<ll> tmp(15);
  if (p > N)
  {
    rep2(i, 1, M + 1)
    {
      if (ans.at(i) < X)
      {
        return INF;
      }
    }
    ANS = min(ANS, ans.at(0));
    return ANS;
  }
  rep(i, M + 1)
  {
    tmp.at(i) = data[p][i] + ans.at(i);
  }
  dfs(p + 1, tmp, data);
  dfs(p + 1, ans, data);
  return ANS;
}

int main()
{
  cin >> N >> M >> X;
  ll inputdata[100][100];
  rep(i, N)
  {
    rep(j, M + 1)
    {
      cin >> inputdata[i][j];
    }
  }
  ll ans2 = dfs(0, ans, inputdata);
  if (ans2 == INF)
  {
    cout << "-1" << endl;
  }
  else
  {
    cout << ans2 << endl;
  }
  return 0;
}


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

//const int INF = 1001001001;
const ll INF = 1000000000000000000;

double dist(pair<int,int> a, pair<int,int> b){
	double dx, dy;
	dx = a.first - b.first;
	dy = a.second - b.second;
	return sqrt(dx*dx + dy*dy);
}

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n) {
		ll x;
		cin >> x;
		if (x == 0) {
			cout << 0 << endl;
			return 0;
		}
		a[i] = x;
	}

	ll ans = 1;
	rep(i,n) {
		if (ans <= INF/a[i]) {
			ans *= a[i];
		}
		else {
			ans = -1;
			break;
		}
	}
	cout << ans << endl;
	return 0;
} 


Measured memory_bytes: 4100
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b, c; cin >> a >> b >> c;
    if (a + b + c >= 22) puts("bust");
    else puts("win");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <cmath>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	int N, A, B; cin >> N >> A >> B;
	cout << min(N*A, B) << endl;


	return 0;
}

Measured memory_bytes: 256
n, T = map(int, input().split())
ct = [list(map(int, input().split())) for _ in range(n)]
li = []
for i in ct:
    if i[1] <= T:
        li.append(i[0])
if len(li) != 0:
    print(min(sorted(li)))
else:
    print('TLE')

Measured memory_bytes: 3060
import java.util.*;
 
public class Main{
  
  	public static void main(String[] args){
      	
      	Scanner sc = new Scanner(System.in);
      	int N = sc.nextInt();
      	if(N%2==0){
          System.out.println(N);
        }else{
          System.out.println(N*2);
        }
    }
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    long long int h[n];
    for (int i=0;i<n;i++) cin>>h[i];
    long long int dp[n];
    dp[0]=0;
    for (int i=1;i<n;i++){
        dp[i]=1e9;
        for (int j=max(i-k,0);j<i;j++){
            dp[i]=min(dp[i],dp[j]+abs(h[j]-h[i]));
        }
    }
    cout<<dp[n-1]<<"\n";
	return 0;
}

Measured memory_bytes: 1792
while True:

    a,op,b = input().split()
    a = int(a)
    b = int(b)

    if op == "?":
        break
    elif op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op ==  "*":
        print(a*b)
    elif op == "/":
        print(int(a/b))

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

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));
    for (int i = 0; i < N; i++) {
        cin >> C[i];
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }

    int ans = 1001001001;
    for (int bit = 0; bit < (1<<N); bit++) {
        int sum = 0;
        vector<int> v(M);
        for (int i = 0; i < N; i++) {
            if (bit & (1<<i)) {
                sum += C[i];
                for (int j = 0; j < M; j++) {
                    v[j] += A[i][j];
                }
            }
        }
        bool check = true;
        for (int j = 0; j < M; j++) {
            if (v[j] < X) check = false;
        }
        if (check) {
            ans = min(ans, sum);
        }
    }

    if (ans < 1001001001) cout << ans << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int n_step(int n);

int main()
{
	int n;
	cin >> n;
	cout << n_step(n) << endl;
}

int n_step(int n)
{
	int num = 0;
	for(int i=1; i<=n; i++) {
		num = num + i;
		if(num >= n) {
			return i;
			
		}
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int curTime = 0, curX = 0, curY = 0;
    rep(i,n){
        int t, x, y;
        cin >> t >> x >> y;
        if(abs(curX - x) + abs(curY - y) > t - curTime){
            cout << "No" << endl;
            return 0;
        }
        if((abs(curX - x) + abs(curY - y))%2 != (t - curTime)%2){
            cout << "No" << endl;
            return 0;
        }
        curTime = t;
        curX = x;
        curY = y;
    }
    cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=9;
vector<double>q;
struct two
{
    double x,y;
};
two a[N];
int dd[N],n;
double s,ans;
double cal(double a, double b,double c, double d)
{
    return (double) sqrt((a-c)*(a-c)+(b-d)*(b-d));
}
void vet(int j, int d)
{
    if (d==n+1){
        ans+=s;
        return ;
    }
    for (int i=1; i<=n; i++)
    if (!dd[i]){
        double k=cal(a[i].x,a[i].y,a[j].x,a[j].y);
        s+=k;
        dd[i]=1;
        if (d==1) s=0;
        //cout << j << ' ' << i << ' ' << d << ' ' << s << ' ' << k <<endl;
        vet(i,d+1);
        s-=k;
        dd[i]=0;
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i=1; i<=n; i++) cin >> a[i].x >> a[i].y;
    vet(1,1);
    double k=1;
    for (int i=1; i<=n; i++) k=(double)k*i;
    printf("%0.10f",ans/k);
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    ll n,m,v,p,cnt,sum=0,vd; cin>>n>>m>>v>>p;
    ll ans=p;
    vector<ll> a(n,0),s(n+1,0);
    rep(i,n) cin>>a[i];
    sort(al(a)); reverse(al(a));
    rep(i,n){
        sum+=a[i]; s[i+1]=sum;
    }
    for(ll i=p;i<n;i++){
        if(a[p-1]>a[i]+m) break;
        vd=v-(n-i)-(p-1);
        if((a[i]+m)*(i-(p-1))-(s[i]-s[p-1])>=vd*m){
            ans++;
        }
        else break;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
S = list(input())

if(0 < int(S[0] + S[1]) < 13):
    if(0 < int(S[2] + S[3]) < 13):
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif(0 < int(S[2] + S[3]) < 13):
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
void solve()
{
	int A,B,M;
	cin>>A>>B>>M;
	vector<int>a(A),b(B);
	map<int,int>oa,ob;
	vector<pair<pair<int,int>,int>>voucher(M);
	rep(i,A){
		cin>>a[i];
		oa[i]=a[i];
	}
	rep(i,B){
		cin>>b[i];
		ob[i]=b[i];
	}
	sort(all(b));
	sort(all(a));
	int ans=a[0]+b[0];
	rep(i,M){
		int x,y,c;
		cin>>x>>y>>c;
		x--;y--;
		int tp=oa[x]+ob[y]-c;
		ans=min(ans,tp);
	}
	cout<<ans<<endl;

}

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


Measured memory_bytes: 11648
#include <bits/stdc++.h>
using namespace std;
#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 rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = LLONG_MAX;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */


int main() {
    int a,b,c,d;cin >> a >> b >> c >> d;
    cout << max(0, min(b,d)-max(a,c)) << endl;
    return 0;
}

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

int main(){
int n;
cin >> n;
int a[15];
for (int i=0;i<n;i++){
cin >> a[i];
}
int price=0;
for (int i=0;i<n;i++){
price=max(price,a[i]);
}
int x=price/2;
int sum=0;
for (int i=0;i<n;i++){
sum+=a[i];
}
int ans=sum-price+x;
cout << ans << endl;
}

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

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

const ll INF = 1LL << 60;

int min_remainder(int L, int R) {
    if (R - L + 1 >= 2019) {
        return 0;
    }
    int ans = 2020;
    for (int i = L; i <= R; i++) {
        int rem1 = i % mod;
        for (int j = i + 1; j <= R; j++) {
            int rem2 = j % mod;
            chmin(ans, (rem1 * rem2) % mod);
        }
    }

    return ans;
}

int main() {
    int L, R;
    cin >> L >> R;

    int ans = min_remainder(L, R);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] d = new int[N+1];
		for( int i=1; i<=N; i++ ){
			d[i] = sc.nextInt();
		}
		Arrays.sort(d);
		System.out.println(d[N/2+1]-d[N/2]);
	}
}


Measured memory_bytes: 51016
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
    string divide[4]={"dream","dreamer","erase","eraser"};
    string S;
    cin>>S;
    reverse(begin(S),end(S));
    for(int i=0;i<4;i++)reverse(begin(divide[i]),end(divide[i]));
    bool can=true;
    for(int i=0;i<S.size();){
        bool can2=false;
        for(int j=0;j<4;j++){
            if(S.substr(i,divide[j].size())==divide[j]){
                can2=true;
                i+=divide[j].size();
            }
        }
        if(!can2){
            can=false;
            break;
        }
    }
    if(can)cout<<"YES"<<'\n';
    else cout<<"NO"<<'\n';
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n, v) rep(i, n) cin >> v[i]

using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1, 0, -1, 0}, y_pos[4] = {0, 1, 0, -1};
int ctoi(char c)
{
	if (c >= '0' && c <= '9')
	{
		return c - '0';
	}
	return 0;
}

char upper(char c)
{
	return c - 0x20;
}

char lower(char c)
{
	return c + 0x20;
}

void unique_vector(vector<int> &v)
{
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
	std::fill((T *)array, (T *)(array + N), val);
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y)
{
	if (y == 0)
		return x;
	return gcd(y, x % y);
}

//最小公倍数
ll lcm(ll x, ll y)
{
	ll g = gcd(x, y);
	return x / g * y;
}

ll myPow(ll x, ll n, ll m)
{
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

//k!
ll facctorialMethod(ll k)
{
	ll sum = 1;
	for (ll i = 1; i <= k; ++i)
	{
		sum *= i;
		sum %= MOD;
	}
	return sum;
}

//nCr
ll permutationMethod(ll n, ll r)
{
	ll n_sum, r_sum;
	ll i;
	r = n - r;
	n_sum = facctorialMethod(n);
	r_sum = facctorialMethod(r);
	return n_sum / r_sum;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int> r, g, b;
	ll ans = 0;
	rep(i, s.length())
	{
		if(s[i] == 'R')
		{
			r.push_back(i+1);
		}
		else if (s[i] == 'G')
		{
			g.push_back(i+1);
		}
		else
		{
			b.push_back(i+1);
		}
	}
	ans = r.size() * g.size() * b.size() ;
	rep(i, r.size())
	{
		rep(k,g.size()){
			int M = max(r[i], g[k]);
			int m = min(r[i], g[k]);
			int d = M - m;
			ans -= binary_search(b.begin(), b.end(), M + d) ? 1 : 0;
			ans -= binary_search(b.begin(), b.end(), m - d) ? 1 : 0;
			if(d%2!=0){
				continue;
			}
			ans -= binary_search(b.begin(), b.end(), m + d / 2) ? 1 : 0;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
int a,b,h,m;
int main(){
	scanf("%d%d%d%d",&a,&b,&h,&m);
	double d=abs((h*60.0+m)*0.5-m*6.0);
	if(d>=180.0)d=360.0-d;
	double rd=(double)d*acos(-1.0)/180.0;
	double ans=sqrt((double)a*a+(double)b*b-2.0*a*b*cos(rd));
	printf("%.15lf",ans);
}

Measured memory_bytes: 4220
#include <bits/stdc++.h>
#ifdef _DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif
#define REP(i, m, n) for(int (i) = (int)(m); (i) < (int)(n); ++(i))
#define rep(i, n) REP(i, 0, n)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9 + 7;
const ll LINF = 1LL << 60;
template<class T, class U> inline bool chmax(T &a, const U &b) { if(a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if(a > b) { a = b; return true; } return false; }

int dp[1<<15][15];
vector<vector<int>> g;
int V, E;

int dst(int s) {
  int res = INF;
  rep(S,1<<15) rep(i,15) dp[S][i] = INF;
  dp[1<<s][s] = 0;
  rep(S,1<<V) rep(i,V) {
    if(dp[S][i] == INF) continue;
    rep(j,V) {
      if(S>>j&1) continue;
      int nS = S | 1<<j;
      int nd = dp[S][i]+g[i][j];
      chmin(dp[nS][j], nd);
    }
  }
  rep(i,V) {
    if(dp[(1<<V)-1][i] == INF) continue;
    chmin(res, dp[(1<<V)-1][i]+g[i][s]);
  }
  return res;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  cin >> V >> E;
  g.assign(V, vector<int>(V, INF));
  rep(i,E) {
    int s, t, d;
    cin >> s >> t >> d;
    g[s][t] = d;
  }

  int ans = INF;
  rep(i,V) {
    chmin(ans, dst(i));
  }
  if(ans == INF) ans = -1;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 5140
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

vvi dp;
vi A;
i64 N;

i64 calc_dp(i64 l, i64 r){
  if(dp[l][r] != INF) return dp[l][r];
  return dp[l][r] = max(-1 * calc_dp(l+1,r) + A[l], -1 * calc_dp(l,r+1) + A[N-1-r]  );
}

void Main()
{
  cin >> N;
  A.resize(N);
  cin >> A;

  dp.resize(N+1, vi(N+1, INF));
  rep(i,N+1){
    dp[i][N-i] = 0;
  }

  cout << calc_dp(0,0) << "\n";

}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define pb push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr double eps = 1e-14; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/


int main(){
    int N,Ma,Mb;
    cin >> N >> Ma >> Mb;
    int a[64],b[64],c[64];
    for(int i=0;i<N;i++) cin >> a[i] >> b[i] >> c[i];
    array<array<int,512>,512> dp;
    for(int i=0;i<512;i++) dp[i].fill(INF);
    dp[0][0] = 0;
    for(int i=0;i<N;i++){
        for(int j=511;j>=0;j--){
            for(int k=511;k>=0;k--){
                if(dp[j][k]!=INF && j+a[i]<512 && k+b[i]<512){
                    dp[j+a[i]][k+b[i]] = min(dp[j+a[i]][k+b[i]],dp[j][k]+c[i]);
                }
            }
        }
    }

    int ans=INF;
    for(int i=1;i<=500;i++){
        int ta = Ma*i,tb=Mb*i;
        if(ta>511 or tb>511) break;
        ans = min(ans,dp[ta][tb]);
    }
    if(ans==INF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int n;
  cin >> n;
  int x = ceil((double)n/1.08);
  if (floor(x*1.08) == n) cout << x << endl;
  else cout << ":(" << endl;
  return 0;
}

Measured memory_bytes: 256
// Problem : F - Distance Sums
// Contest : AtCoder Regular Contest 103
// URL : https://atcoder.jp/contests/arc103/tasks/arc103_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define cerr if(1)cerr
#define size(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define temptts template <class T, class... Ts>

const int N = 1e6 + 1, mod = 1e9 + 7, inf = 2e9;

struct pp {
	ll v;
	int i;
	bool operator < (const pp &o) const {
		return v < o.v;
	}
} d[N];

map<ll, int> id;
int n, h[N], sz[N];
ll dp[N], D[N];
vector<int> adj[N];
vector<pair<int, int>> ans;

void add(int v, int u) {
	ans.push_back({u, v});
	adj[v].push_back(u);
	adj[u].push_back(v);
	sz[v] += sz[u];
}

void dfs_size(int v, int p = 0) {
	sz[v] = 1;
	dp[1] += h[v];
	for (auto u : adj[v]) {
		if (u == p) continue;
		h[u] = h[v] + 1;
		dfs_size(u, v);
		sz[v] += sz[u];
	}
}

void dfs(int v, int p = 0) {
	for (auto u : adj[v]) {
		if (u == p) continue;
		dp[u] = dp[v] + n - 2 * sz[u];
		dfs(u, v);
	}
	if (dp[v] != D[v]) {
		cout << -1;
		exit(0);
	}
}

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> D[i];
		d[i] = {D[i], i};
	}
	sort(d + 1, d + n + 1);
	for (int i = 1; i <= n; i++) {
		id[d[i].v] = i;
	}
	for (int i = n; i >= 2; i--) {
		sz[d[i].i]++;
		ll j = d[i].v - n + 2 * sz[d[i].i];
		if (!id[j] || id[j] == i) {
			return cout << -1, 0;
		}
		add(d[id[j]].i, d[i].i);
	}
	memset(sz, 0, sizeof sz);
	dfs_size(1);
	dfs(1);
	for (auto& x : ans) {
		cout << x.first << ' ' << x.second << '\n';
	}
}


Measured memory_bytes: 54516
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n;
map<int,int> cnt;

int main() {
	cin >> n;
	rep(i, n) {
		int num;
		cin >> num;
		cnt[num]++;
	}
	int ans = 0;
	for (auto it = cnt.begin(); it != cnt.end(); it++) {
		if (it->first <= it->second) {
			ans += it->second - it->first;
		}
		else ans += it->second;
	}
	cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> mp;
  rep(i, n) cin >> a[i];
  rep(i, n){
    mp[a[i]]++;
  }
  if(mp.size() % 2 == 0){
    cout << mp.size() - 1 << endl;
  }else {
    cout << mp.size() << endl;
  }
}

Measured memory_bytes: 5376
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

long long int LCM(long long int a, long long int b){
	long long int dummy1, dummy2, dummy;
	dummy1 = max(a, b);
	dummy2 = min(a, b);
	while(true){
		dummy = dummy1 % dummy2;
		dummy1 = dummy2;
		dummy2 = dummy;
		if(dummy == 0){
			break;
		}
	}
	return (a / dummy1) * (b / dummy1) * dummy1;
}

int main(){
	
	long long int a[3], m[3], span[3];
	
	for(int i = 0; i < 3; i++){
		cin >> a[i] >> m[i];
	}
	
	while(a[0] != 0){
		
		long long int dummy;
		
		for(int i = 0; i < 3; i++){
			span[i] = 1;
			dummy = a[i] % m[i];
			for(int loop = 1; loop < 1000000; loop++){
				if(dummy == 1){
					span[i] = loop;
					break;
				}
				dummy = (dummy * a[i]) % m[i];
			}
		}
		/*
		for(int i = 0; i < 3; i++){
			cout << span[i] << " ";
		}
		
		cout << endl;
		*/
		long long int ans;
		
		ans = LCM(LCM(span[0], span[1]), span[2]);
		
		cout << ans << endl;
		
		for(int i = 0; i < 3; i++){
			cin >> a[i] >> m[i];
		}
	}
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

int main() {

    ll N, K;
    vector<ll> h;
    cin >> N >> K;
    for (int i = 0; i < N; ++i) {
        ll hh;
        cin >> hh;
        h.push_back(hh);
    }

    sort(h.begin(),h.end());
    ll min = h[h.size()-1]  - h[0];

    for (int i = K-1; i < N; ++i) {
       ll m = h[i] - h[i - K +1];
        if(min > m){
            min = m;
        }
    }

    cout << min << endl;
    return 0;
}

Measured memory_bytes: 1400
abcd = input()
for i in range(2**3):
    eq = ''
    for j in range(3):
        eq += abcd[j]
        if(i >> j) & 1:
            eq += '+'
        else:
            eq += '-'
    eq += abcd[-1]
    if eval(eq) == 7:
        print(eq + '=7')
        break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define oo 0x3f3f3f3f
#define ooLL 0x3f3f3f3f3f3f3f3f
#define fastio() ios_base::sync_with_stdio(false); cin.tie(NULL)
const int mod = 1e9+7;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
 
int main(){
    int t = 1;
    for(int ti = 1; ti <= t ; ++ti){
        int d;
        scanf("%d", &d);
        int r = d%10;
        if(r == 2 || r == 4 || r == 5 || r == 7 || r == 9) printf("hon\n");
        else if(r == 0 || r == 1 || r == 6 || r == 8) printf("pon\n");
        else if(r == 3) printf("bon\n");
    }
    return 0;
}

Measured memory_bytes: 3688
#include<stdio.h>
#include<string.h>
#define LEN 100005

 typedef struct pp{
   char name[100];
   int t;
 }P;

P Q[LEN];

int head,tail,n;

void enqueue(P x);
P dequeue();
int min(int a,int b);

int main(){
  int elaps=0,c;
  int i,q;
  P u;

  scanf("%d %d",&n,&q);

  for(i=1;i<=n;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }

  head=1;
  tail=n+1;

  while(head!=tail){
    u=dequeue();
    c=min(q,u.t);
    u.t-=c;
    elaps+=c;
    if(u.t>0)enqueue(u);
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }

  return 0;
}

void enqueue(P x){
  Q[tail]=x;
  tail=(tail+1)%LEN;
}

P dequeue(){
  P x = Q[head];
  head=(head+1)%LEN;
  return x;
}

int min(int a,int b){
  return a<b?a:b;
}



Measured memory_bytes: 11844
#include<stdio.h>
int main()
{
	int n,h[10],s[10],k[10],i,j,temp,flg,cnt;
 	   while(1){
     	   flg=0;
      	  cnt=0;
       	 scanf("%d",&n);
       	 if(n==0000)break;
        while(1){
            if(n==6174)break;
            if(n<1000){
                h[0]=0;
            }
            else{
                h[0]=n/1000;
            }
            if(n<100){
                h[1]=0;
            }
            else{
                h[1]=(n%1000)/100;
            }
            if(n<10){
                h[2]=0;
            }
            else{
                h[2]=((n%1000)%100)/10;
            }
            h[3]=(((n%1000)%100)%10)/1;
            if(h[0]==h[1]&&h[0]==h[2]&&h[0]==h[3]){
            flg=1;
            printf("NA\n");
            break;
            }
            cnt++;
 //          printf("%d\n",cnt);
            for(i=0;i<4;i++){
                s[i]=h[i];
                k[i]=h[i];
            }
            for(i=0;i<3;i++){
                for(j=i+1;j<4;j++){
                    if(s[i]>s[j]){
                        temp=s[i];
                        s[i]=s[j];
                        s[j]=temp;
                    }
                }
            }
            for(i=0;i<3;i++){
                for(j=i+1;j<4;j++){
                    if(k[i]<k[j]){
                        temp=k[i];
                        k[i]=k[j];
                        k[j]=temp;
                    }
                }
            }
            n=(k[0]*1000+k[1]*100+k[2]*10+k[3])-(s[0]*1000+s[1]*100+s[2]*10+s[3]);
        }
        if(flg!=1){
            printf("%d\n",cnt);
        }
    }
    return 0;
}

Measured memory_bytes: 608
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
ans = 0
for i in range(N-1):
    if A[i+1] > A[i] * 2:
        ans = i + 1
    A[i+1] = A[i] + A[i+1]
print(N - ans)


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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

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

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

void permute(vi& a,const vi& is)
{
	int n=a.size();
	for(int i:is) a.push_back(a[i]);
	a.erase(begin(a),begin(a)+n);
}

int solve(vi& hs,vi& as,vi& ds,vi& ss)
{
	{
		vi is(1,0);
		repi(i,1,hs.size()){
			int a=max(as[0]-ds[i],0); // 与ダメージ
			int b=max(as[i]-ds[0],0); // 被ダメージ
			if(a==0)
				if(b==0); // 与・被ダメージが0である敵はいなかったことにする
				else return -1;
			else
				is.push_back(i);
		}
		permute(hs,is); permute(as,is); permute(ds,is); permute(ss,is);
	}
	
	int n=hs.size();
	vi ts(n); // 殺すために必要なターン数
	vi ps(n); // 被ダメージ
	repi(i,1,n){
		int dam=max(as[0]-ds[i],0);
		assert(dam>0);
		ts[i]=(hs[i]+dam-1)/dam;
		ps[i]=max(as[i]-ds[0],0);
	}
	
	ll dam=0; // 自分の最初のターン目までの被ダメージ
	repi(i,1,n) if(ss[i]>ss[0]) dam+=ps[i];
	
	{
		vi is(n); iota(all(is),0);
		sort(all(is),[&](int i,int j){return ss[i]>ss[j];});
		permute(ts,is); permute(ps,is);
		
		rep(i,n) if(is[i]==0){
			rotate(begin(ts),begin(ts)+i+1,end(ts)); ts.pop_back();
			rotate(begin(ps),begin(ps)+i+1,end(ps)); ps.pop_back();
			n--;
			break;
		}
	}
	
	ll h=hs[0];
	{
		vi is(n); iota(all(is),0);
		sort(all(is),[&](int i,int j){return ll(ts[i])*(ps[j])<ll(ts[j])*(ps[i]);});
		permute(ts,is); permute(ps,is);
	}
	
	vl sum(n+1);
	per(i,n) sum[i]=sum[i+1]+ps[i];
	
	bool ok=true;
	rep(i,n){
		if(h<=dam+1.*ts[i]*sum[i]-ps[i]){
			ok=false;
			break;
		}
		dam+=ll(ts[i])*sum[i]-ps[i];
	}
	
	return ok?dam:-1;
}

int main()
{
	for(int n;cin>>n && n;){
		vi hs(n+1),as(n+1),ds(n+1),ss(n+1);
		rep(i,n+1) cin>>hs[i]>>as[i]>>ds[i]>>ss[i];
		
		cout<<solve(hs,as,ds,ss)<<endl;
		
	}
}

Measured memory_bytes: 3392
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

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

  int x; cin >> x;
  if (x == 7 || x == 5 || x == 3) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;

int N;
int dp[100010][2];
vector<VI>G(100010);

void f(int to, int from) {
	dp[to][0] = dp[to][1] = 1;


	for (int t = 0; t < G[to].size();t++) {
		int a = G[to][t];
		if (G[to][t] != from) {
			f(G[to][t], to);
			dp[to][0] *= (dp[a][0] + dp[a][1]);
			dp[to][1] *= dp[a][0];
			dp[to][0] %= mod;
			dp[to][1] %= mod;
		}
	}
}




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

	cin >> N;
	

	REP(i, N - 1) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	f(0, -1);

	//REP(i, N)cout << dp[i][0] << " " << dp[i][1] << endl;

	cout << (dp[0][0]+dp[0][1])%mod << endl;

	return 0;
}



Measured memory_bytes: 14208
#include <stdio.h>

int main(int argc, const char * argv[]){
    int a,b;
    scanf("%d %d", &a, &b);
    if (a>b) {
        printf("a > b\n");
    }else if(a<b){
        printf("a < b\n");
    }else{
        printf("a == b\n");
    }
}


Measured memory_bytes: 2136
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

long long int n,a,b,ans1,ans2;

int main()
{
	scanf("%lld%lld%lld",&n,&a,&b);
	ans1=n*a;
	ans2=b;
	printf("%lld\n",min(ans1,ans2));
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 100000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

class segtree{
public:
	static const int N=1<<12;
	int dp[1<<13];
	segtree(){
		memset(dp,0,sizeof(dp));
	}
	void init(){
		memset(dp,0,sizeof(dp));
	}
	void update(int k,int v){
		k+=N-1;
		dp[k]+=v;
		while(k>0){
			k=(k-1)/2;
			dp[k]=dp[k*2+1]+dp[k*2+2];
		}
	}

	int query(int a,int b,int k=0,int l=0,int r=N){
		if(b<=l || r<=a)return 0;
		if(a<=l && r<=b)return dp[k];
		int mid=(l+r)/2;
		int vl=query(a,b,k*2+1,l,mid);
		int vr=query(a,b,k*2+2,mid,r);
		return vl+vr;
	}
};

segtree seg;
segtree seg2;

int n;
int t[5005],a[5005];
int dp[3001][3001];
int bx[3001];
int wx[3001];
vector<int> vec; 

int main(void){
	scanf("%d%*c",&n);
	for(int i=0;i<n*2;i++){
		char c;
		scanf("%c %d%*c",&c,&a[i]);
		if(c=='W'){
			t[i]=0;
			wx[a[i]-1]=i;
		}else{
			t[i]=1;
			bx[a[i]-1]=i;
		}

	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			dp[i][j]=INF;
		}
	}
	dp[0][0]=0;
	seg.init();
	for(int i=0;i<n;i++){
		seg.update(bx[i],1);
	}
	for(int i=0;i<=n;i++){
		seg2.init();
		for(int j=0;j<n;j++){
			seg2.update(wx[j],1);
		}
		for(int j=0;j<=n;j++){
			if(i==n && j==n)continue;
			if(i<n){
				int vc=seg2.query(0,bx[i]);
				dp[i+1][j]=min(dp[i+1][j],dp[i][j]+vc);
			}
			if(j<n){
				int vc=seg.query(0,wx[j]);
				dp[i][j+1]=min(dp[i][j+1],dp[i][j]+vc);
			}

			seg2.update(wx[j],-1);
		}
		seg.update(bx[i],-1);
	}
	int ans=0;
	seg.init();
	for(int i=0;i<2*n;i++){
		if(t[i]==0){
			vec.push_back(a[i]-1);
		}
	}
	for(int i=0;i<n;i++){
		ans+=i-seg.query(0,vec[i]);
		seg.update(vec[i],1);
	}
	seg.init();
	vec.clear();
	for(int i=0;i<2*n;i++){
		if(t[i]==1){
			vec.push_back(a[i]-1);
		}
	}
	for(int i=0;i<n;i++){
		ans+=i-seg.query(0,vec[i]);
		seg.update(vec[i],1);
	}
	printf("%d\n",dp[n][n]+ans);
	return 0;
}

Measured memory_bytes: 24960
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n;
    cin >> n;
    int d[n];
    for(int i = 0;i < n;i++)
    {
        cin >> d[i];
    }
    sort(d,d + n);
    int ans = 0;
    for(int i = 1;i < n;i++)
    {
        if(d[i] > d[i - 1])
        {
            ans++;
        }
    }
    cout << ans + 1 << "\n";
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a, b = map(int, input().split())
c = int(input())

topping = []
for _ in range(n):
    d = int(input())
    topping.append(d)

topping.sort(reverse=True)
ans = c // a
total = c

for i, t in enumerate(topping):
    total += t
    cal = total // (a + (i+1) * b)
    if ans <= cal:
        ans = cal
    else:
        break

print(ans)



Measured memory_bytes: 5600