akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e18
#define ret return

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int main(){
	string s;
	cin >> s;
	ll ans = 0;
	ll cnt = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i]=='B'){
			cnt++;
		}
		else{
			ans+=cnt;
		}
	}
	cout<<ans<<'\n';
}


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

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する
ll n,a,b;
vector<ll> h;
bool check(ll k){
    ll cnt = 0;
    rep(i,0,n){
        if(h[i] - b * k > 0){
            cnt += (h[i] - b * k)/(a-b);
            if((h[i] - b * k)%(a-b))cnt++;
        }
    }
    return cnt <= k;
}

int main() {
    cin >> n >> a >> b;
    rep(i,0,n){
        ll hi;
        cin >> hi;
        h.push_back(hi);
    }

    ll ok = (1 << 31 - 1),ng = 0;

    while(ok - ng > 1){
        ll mid = (ok + ng)/2;
        if(check(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    cout << ok << endl;

    return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	int n;
	string s;
	cin >> n >> s;
	vector<char> t(n);
	for(int i = 0; i < n; ++i)
	{
		t[i] = s[i];
	}
	t.erase(unique(t.begin(), t.end()), t.end());
	cout << t.size();
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
    int x,y,box;
    for(;;){
        scanf("%d%d",&x,&y);
        if(x==0&&y==0){
            break;
        }
        else if(x>y){
            box=x;
            x=y;
            y=box;
        }
        printf("%d %d\n",x,y);
    }
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
using namespace std;


int main(){
    int n;
	cin>>n;
	string s;
	cin>>s;
	int times=(n/2)+1;
	string a="",b="";
	vi v;
	int count=1;
	char t=s[0];
	for(int i=1;i<n;i++){
	    
	    if(s[i]==t){
	        count++;
	    }
	    else {
	        v.pb(count);
	        t=s[i];
	        count=1;
	    }
	}
	v.pb(count);
	int siz=v.size();
	ll sum=0;
	pan(i,siz){
	    sum+=v[i];
	    //cout<<v[i]<<" ";
	}
	/*if(siz!=0 && sum!=siz) cout<<sum-siz;
	else if(sum==siz && sum!=0 && siz!=0) cout<<sum;
	else cout<<1;*/
	if(siz!=0) cout<<siz;
	else cout<<1;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	cout<<(a<9&&b<9?"Yay!":":(")<<endl;
}


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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int i = n - 2;
    while(true){
        if (i == 0){
            cout << 0 << endl;
            return 0;
        }

        if (s.substr(0,i/2) == s.substr(i/2,i/2)){
            cout << i << endl;
            return 0;
        }
        i -= 2;  
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int n, m, lmax = 0, rmin = 100001;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r;
    if (lmax < l) {
      lmax = l;
    }
    if (r < rmin) {
      rmin = r;
    }
  }
  if (lmax > rmin) {
    cout << 0 << endl;
  }
  else {
    cout << rmin - lmax + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int x = n / 2;
        x += n % 2 == 0 ? 0 : 1;

        Double result = (double)x / n;

        System.out.println(result);
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    int n;
    scanf("%d",&n);
    ll ans=0;
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=n;j++) {
            for(int k=1;k<=n;k++) {
                ans+=__gcd(__gcd(i,j),k);
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}

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

int n,m;
double sa,p,ans;

int main(){
    scanf("%d%lf%lf",&n,&sa,&p); sa-=p;
    int t=2*n,l=n;
    for(int i=1;i<=n;i++){
        ans+=(sa*t+p*t*(t+1)/2.0)/t;
        sa=sa+sa/l+3*p/(2*l);
        p=p+2*p/l;
        l--;
        t-=2;
    }
    printf("%.6lf\n",ans);
}


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

using namespace std;

int main() {

    int N;
    cin >> N;

    if ((N%10==7||(N%100-N%10)/10==7)||(N-N%100)/100==7)  cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

using namespace std;
#define pb push_back
#define ALL(a) (a).begin() , a.end()
typedef long long ll;
int mod = 1e9 + 7;
int add(int a, int b){
  if(a + b >= mod)return a+ b - mod;
  return a + b;
}
int mul(int a, int b){
  return 1LL * a * b  % mod;
}
int power(int a, int b){
  int re = 1;
  while(b){
    if(b&1)re= mul(re, a);
    a = mul(a, a);
    b>>=1;
  }
  return re;
}
int const N = 100 *1001;
/********************i**********************************/
vector<int> edge[N], visited(N), child(N);
vector<pair<ll, int>> cont(N);
int co = 0;
void dfs1(int a, int p){
  co++;
  visited[a] = 1;
  for(int x : edge[a]){
    if(x == p)continue;
    dfs1(x, a);
  }

}
void dfs(int a, int p){
  auto &f = cont[a].first; 
  cont[a].second = a;
  child[a] = 1;
  for(int x : edge[a]){
    if(x == p)continue;
    dfs(x, a);
    f += 1LL * child[a] * child[x];
    child[a] += child[x];
  }
  f += 1LL * (co - child[a] ) * child[a]; 
}
void solve(){
  int a, b;
  cin >> b >> a;
  ll c = 0;
  for(int x = 1; x<=a; x++){
    int j;cin >> j;
    c += j;
  }
  if(c >= b)cout << "Yes\n";
  else cout << "No\n";
}
  
/******************************************************/
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(nullptr);
  int t;
  t = 1;
  // cin >> t;
  while(t--){
    solve();
  }
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <numeric>
#include <iomanip>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#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 rrep(i, n) for (int i=(int)(n)-1;i>=0;--i)
#define rrep1(i, n) for (int i=(int)(n);i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=(int)(r)-1;i>=l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

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

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

int n, m, a;
int to[1005][105];

signed main()
{
	while (1) {
		cin >> n >> m >> a;
		if (n == 0 and m == 0 and a == 0) break;

		memset(to, -1, sizeof to);

		rep(i, m) {
			int h, p, q; cin >> h >> p >> q;
			to[h][p] = q;
			to[h][q] = p;
		}

		int cur = a;

		for (int h = 1000; h >= 0; --h) {
			if (to[h][cur] != -1) {
				cur = to[h][cur];
			}
		}

		cout << cur << endl;
	}
}





Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef vector <ll> vi;
typedef pair <ll, ll> ii;
typedef vector <ii> vii;
#define mod 1000000007
#define pb push_back
ll max3(ll a,ll b,ll c)
{
    return max(max(a,b),max(a,c));
}
int main()
{
    ll n;
    cin>>n;
    vi a(n+1),b(n+1),c(n+1);
    for(ll i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    if(n==1)
    {
        cout<<max3(a[1],b[1],c[1])<<endl;
        return 0;
    }
    ll dp[n+1][3];
    dp[1][0]=a[1];
    dp[1][1]=b[1];
    dp[1][2]=c[1];
    for(ll i=2;i<=n;i++)
    {
        dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b[i]+max(dp[i-1][2],dp[i-1][0]);
        dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max3(dp[n][0],dp[n][1],dp[n][2])<<endl;
}


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

#define int long long

using namespace std;

const int N = 2e6 + 5, md = 1e9 + 7;
int fac[N], ifac[N];

int power(int x, int p) {
  int res = 1;
  while (p > 0) {
    if (p & 1) {
      (res *= x) %= md;
    }
    (x *= x) %= md;
    p >>= 1;
  }
  return res;
}

void precalc() {
  fac[0] = 1;
  for (int i = 1; i < N; i++) {
    fac[i] = fac[i - 1] * i % md;
  }
  ifac[N - 1] = power(fac[N - 1], md - 2);
  for (int i = N - 2; ~i; i--) {
    ifac[i] = ifac[i + 1] * (i + 1) % md;
  }
}

int C(int n, int k) {
  return fac[n] * ifac[k] % md * ifac[n - k] % md;
}

signed main() {
  int k;
  string s;
  cin >> k >> s;
  precalc();
  int n = s.size();
  int res = power(26, n + k);
  for (int i = 0; i < n; i++) {
    res += md - C(n + k, i) * power(25, n + k - i) % md;
    res %= md;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 35580
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll mod = 1000000007;
ll INF = 1000000009;




void solve(){
  int a[3][3];
  cin>>a[0][0]>>a[0][1]>>a[0][2];
  cin>>a[1][0]>>a[1][1]>>a[1][2];
  cin>>a[2][0]>>a[2][1]>>a[2][2];
  
  string ans="Yes";
  rep(j,3){
  int tmp=a[j][0]-a[0][0];
  rep(i,2){
    if(tmp!=a[j][i+1]-a[0][i+1]) ans="No";
  }
  }
  
  rep(j,3){
  int tmp=a[0][j]-a[0][0];
  rep(i,2){
    if(tmp!=a[i+1][j]-a[i+1][0]) ans="No";
  }
  }
  
  cout << ans << endl;
}

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


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

namespace AtCoder_20190707_1
{    class Program
    {
        static void Main(string[] args)
        {
            string[] ABN = Console.ReadLine().Split(' ');
            decimal A = decimal.Parse(ABN[0]);
            decimal B = decimal.Parse(ABN[1]);
            decimal N = decimal.Parse(ABN[2]);

            decimal x = Math.Min(B - 1,N);

            decimal answer = Math.Floor(A * x / B) - A * Math.Floor(x / B);

            Console.WriteLine(answer);
        }
    }
}

Measured memory_bytes: 27596
s = str(input())

# BC = Dとする
AD_s = ""
index = 0
while index < len(s):
    if s[index:index+2] == "BC":
        AD_s += "D"
        index += 1
    else:
        AD_s += s[index]
    index += 1
# 部分文字列を抽出(BとCで区切られる)
index = 0
l = []
s_part = ""
while index < len(AD_s):
    if AD_s[index] == "B" or AD_s[index] == "C" or index == len(AD_s) - 1:
        if index == len(AD_s) - 1:
            s_part += AD_s[index]
        if s_part != "":
            l.append(s_part)
            s_part = ""
    else:
        s_part += AD_s[index]
    index += 1

ans = 0

for part in l:
    # ADADとか
    d_count = 0
    for i, c in enumerate(list(part)):
        if c == "D":
            ans += i - d_count
            d_count += 1

print(ans)


Measured memory_bytes: 5224
from collections import Counter
n = int(input())
la = list(map(int, input().split()))
s = sum(la)
d = dict(Counter(la))

q = int(input())
for _ in range(q):
    b,c = map(int, input().split())
    if b in d:
        nb = d.pop(b)
    else:
        nb = 0
    delta = (c-b)*nb
    s += delta
    print(s)
    if nb > 0:
        if c in d:
            d[c] += nb
        else:
            d[c] = nb

Measured memory_bytes: 21304
A=[[[0 for k in range(1001)] for j in range(101)] for i in range(10)]
for j in range(101):
    A[1][j][j]=1
for i in range(2,10):
    for j in range(101):
        for k in range(j,i*j):
            for m in range((k-j)/(i-1),j):
                A[i][j][k]+=A[i-1][m][k-j]
while(1):
    [n,s]=[int(x) for x in raw_input().split()]
    if n==0:    break
    ans=0
    for j in range(101):
        ans+=A[n][j][s]
    print ans

Measured memory_bytes: 18252
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>

using namespace std;

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *nil;

void Insert(int k) {
    Node *y=nil;
    Node *x=root;
    Node *z;

    z=(Node*)malloc(sizeof(Node));
    z->key = k;
    z->left = nil;
    z->right = nil;

    while(x!=nil){
        y=x;
        if(z->key < x->key) {
            x = x->left;
        }else{
            x=x->right;
        }
    }
    z->parent = y;
    if(y==nil){
        root=z;
    }else{
        if((z->key)<(y->key)){
            y->left = z;
        }else{
            y->right = z;
        }
    }
}

void Inorder(Node *u) {
    if(u==nil) return;
    Inorder(u->left);
    cout<<" "<<(u->key);
    Inorder(u->right);
}

void Preorder(Node *u) {
    if(u==nil) return;
    cout<<" "<<(u->key);
    Preorder(u->left);
    Preorder(u->right);
}

int main() {

    int n,x;
    cin>>n;

    string command;
    for(int i=0;i<n;i++){
        cin >> command;
        if(command=="insert"){
            cin>>x;
            Insert(x);
            }else if(command=="print"){
            Inorder(root);
            cout<<endl;
            Preorder(root);
            cout<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 26464
#include <stdio.h>
#define N 102
#define BLACK 2
#define GLAY 1
#define WHITE 0

int g[N][N],d[N],color[N],k[N],q[N];
int time,n,head =0,tail =0;

void enqueue(int q[],int s){
  q[tail]=s;
  tail++;
}

int dequeue(int q[]){
  head++;
  return q[head-1];
}

void BFS(int s){
  int i,u;
  for(i=1;i<=n;i++){
    color[i] = WHITE;
    d[i] = -1;
  }
  color[s] = GLAY;
  d[s] = 0;
  enqueue(q,s);

  while(head!=tail){
    u = dequeue(q);
    for(i=1;i<=n;i++){
      if(g[u][i]==1){
	if(color[i]==WHITE){
	  color[i] = GLAY;
	  d[i] = d[u]+1;
	  enqueue(q,i);
	}
      }
    }
    color[u] = BLACK;
  }
}


int main(){
  int i,j,l,u,v;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&l);
    for(j=0;j<l;j++){
      scanf("%d",&v);
      g[u][v] = 1;
    }
  }

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

Measured memory_bytes: 636
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

queries = []
for i in range(m):
    b, c = map(int, input().split())
    queries.append((c,b))

queries.sort(reverse=True)
p = 0
for c, b in queries:
    while p < len(a) and b > 0:
        if a[p] < c:
            a[p] = c
            b -= 1
        p += 1

print(sum(a))
        

Measured memory_bytes: 20940
#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>;
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() {
string n;
int k;cin>>k>>n;
if(n.size()<=k){
    cout<<n<<endl;
}else{
    string ans="";
    for (int i = 0; i < k; i++) {
        ans+=n.at(i);
    }
    cout<<ans<<"..."<<endl;
}


}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <utility>
#include <map>
#include <inttypes.h>
int c[1001][1001] = {0};
/*int LCS(std::string s, std::string t){
    int n, m, c[1001][1001] = {0};
    n = s.size();
    m = t.size();
    int maxlen = 0;
    for(int i = 1; i <= n; i++){
        c[i][0] = 0;
    }
    for(int i = 1; i <= m; i++){
        c[0][i] = 0;
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(s[i - 1] == t[j - 1]){
                c[i][j] = c[i - 1][j - 1] + 1;
            }
            else{
                c[i][j] = std::max(c[i - 1][j], c[i][j - 1]);
            }
            maxlen = std::max(maxlen, c[i][j]);
        }
    }
    return maxlen;
}*/
int main(){
    int N;

    std::cin >> N;
    std::string s1, s2;
    for(int i = 0; i<N; i++){
        std::cin >> s1 >> s2;
        int n, m;
        n = s1.size();
        m = s2.size();
        int maxlen = 0;
        for(int i = 1; i <= n; i++){
            c[i][0] = 0;
        }
        for(int i = 1; i <= m; i++){
            c[0][i] = 0;
        }
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= m; j++){
                if(s1[i - 1] == s2[j - 1]){
                    c[i][j] = c[i - 1][j - 1] + 1;
                }
                else{
                    c[i][j] = std::max(c[i - 1][j], c[i][j - 1]);
                }
                maxlen = std::max(maxlen, c[i][j]);
            }
        }
        std::cout << maxlen << std::endl;
    }
    return 0;
}


Measured memory_bytes: 7028
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;

public class Main {
	public static void main(String args[]){
		    Scanner sc = new Scanner(System.in);	
			
			int n = sc.nextInt();
			int[] ar = new int[n];
			int sum = 0;
			for (int i = 0; i < n; i++) {
				ar[i] = sc.nextInt();
			}
			Arrays.sort(ar);
			ar[n-1] /= 2;
			for (int i = 0; i < n; i++) {
				sum += ar[i];
			}
			System.out.println(sum);

	}
}

Measured memory_bytes: 21588
def extecd(b, n):
    x0, x1, y0, y1 = 1, 0, 0, 1
    while n != 0:
        q, b, n = b // n, n, b % n
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    print(x0, y0)

def main():
    a, b = input().split()
    a = int(a)
    b = int(b)
    extecd(a, b)

main()



Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define ll long long
#define NMAX 100
using namespace std;
char s[256];
map<string,int>m;
int main()
{
    ll n;
    cin>>n;
    cin.get();
    for(int i=1; i<=n; i++)
    {
        cin.getline(s,256);
        m[s]++;
    }
    cout<<m.size();
    return 0;
}


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

int main(){
  int64_t a,b,c,k;
  cin>>a>>b>>c>>k;
  
  int s=k-a,t=k-a-b;
  if(s<=0){
    s=0;
  }
  if(t<=0){
    t=0;
  }
  
  if(a>=k){
    a=k;
  }
  
  cout<<a-t<<endl;
}

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

int main() {
  int x,y;
  x = 0;
  y = 0;
  for(int i = 0;i < 500000;i++){
    char a;
    a = '2';
    cin >> a;
    if(a == '0'){
      x++;
    }else if(a == '1'){
      y++;
    }else{
      break;
    }
  }
  
  int ans = min(x,y);
  cout << ans*2 <<endl;


}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    int a;
    int b;
    int c;
    
    public void solve(){
        Scanner sc = new Scanner(System.in);
        a=sc.nextInt();
        b=sc.nextInt();
        c=sc.nextInt();
        if((a<b) && (b<c)){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
    
    public static void main(String[] args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17296
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    // Rust version 1.15.1, which is used by AtCoder,
    // does not support std::str::FromStr for char
    ($iter:expr, char) => {
        $iter.next().unwrap().chars().next().expect("Parse error")
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
fn main() {
    use std::cmp::max;
    use std::cmp::min;
    use std::collections::HashMap;

    input!{
        a: chars,
        b: chars,
    }

    let ans = if a[0] == b[2] && a[1] == b[1] && a[2] == b[0] {
        "YES"
    } else {
        "NO"
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>

using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    int ans = 0;
    if(s == "SUN") ans = 7;
    else if(s == "SAT") ans = 1;
    else if(s == "FRI") ans = 2;
    else if(s == "THU") ans = 3;
    else if(s == "WED") ans = 4;
    else if(s == "TUE") ans = 5;
    else if(s == "MON") ans = 6;

    cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define mod 1000000007;
using namespace std;
bool sieve[10000000];
vector<ll>primes;
void pri(ll n)
{
    for(int i=2;i<=n;i++)
    {
        if(sieve[i]==1)
        continue;
        primes.push_back(i);
        for(int j=i+i;j<=n;j=j+i)
        {
            sieve[j]=1;
        }
    }
}
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll temp;
    temp=sqrt(n);
    ll tem2=n;
    pri(temp);
    ll count=0;
    ll num=1;
    for(ll i=0;i<primes.size();i++)
    {
        if(n<primes[i])
        break;
        if(n%primes[i]==0)
        {
            num=primes[i];
            while(n%num==0 && n!=0)
            {
                count++;
                n=n/num;
                num=num*primes[i];
            }
        }
    }
    if(n>temp && tem2!=1)
    {
        cout<<count+1;
    }
    else
    cout<<count;
    

    return 0;
}

Measured memory_bytes: 5264
N = int(input())
S = []
for _ in range(N):
    S.append(input())
print("AC x " + str(S.count("AC")))
print("WA x " + str(S.count("WA")))
print("TLE x " + str(S.count("TLE")))
print("RE x " + str(S.count("RE")))

Measured memory_bytes: 16116
import scala.io.StdIn

object Main{
  def main(args: Array[String]){
    StdIn.readLine()
    val line = StdIn.readLine().split(" ").toList.map(_.toInt)
    println(insertSort(List(line.head), line.tail).mkString(" "))
  }

  def insertSort(list1: List[Int], list2: List[Int]): List[Int] ={
    if(list2.length == 0) return list1
    else{
      println((list1 ::: list2).mkString(" "))
      insertSort((list2.head :: list1).sorted, list2.tail)
    }
  }
}

Measured memory_bytes: 46360
a_s = input()
b_s = input()

if len(a_s) > len(b_s):
    print("GREATER")
    exit()
elif len(a_s) < len(b_s):
    print("LESS")
    exit()

for a, b in zip(a_s, b_s):
    if a > b:
        print("GREATER")
        exit()
    elif b > a:
        print("LESS")
        exit()

print("EQUAL")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int   //used int to avoid mle
#define ulli unsigned long long int 
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define spl set<pll>
#define msl multiset <lli>
#define msp multiset <pll>
#define pll pair<lli, lli>
#define mll map<lli, lli>              //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x)
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define fbo find_by_order //returns iterator
#define fok order_of_key //return index
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
lli mod=998244353;
//string s=bitset<32>(n).to_string();
typedef tree<lli,null_type,less<lli>,rb_tree_tag, // change both to lli if set is req insted of multiset
tree_order_statistics_node_update> indexed_set;
int main()
{
	lli n;cin>>n;
	string s;
	cin>>s;
	lli r=0,g=0,b=0;
	for(lli i=0;i<n;i++){
		if(s[i]=='R')r++;
		else if(s[i]=='G')g++;
		else b++;
	}
	lli temp=r*g*b;
	//lli temp2=0;
	for(lli i=0;i<n;i++){
		for(lli j=i+1;j<n;j++){
			if(s[i]==s[j])continue;
			lli k=j+(j-i);
			if(k>=n)continue;
			if(s[k]==s[i] || s[k]==s[j])continue;
			temp--;
		}
	}
	cout<<temp;
	
    return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    int n; cin >> n;
    map<int, int> m;
    int l = 0;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        if(a <= 399) m[1]++;
        else if(a <= 799) m[2]++;
        else if(a <= 1199) m[3]++;
        else if(a <= 1599) m[4]++;
        else if(a <= 1999) m[5]++;
        else if(a <= 2399) m[6]++;
        else if(a <= 2799) m[7]++;
        else if(a <= 3199) m[8]++;
        else l++;
    }
    int min = m.size();
    int max = m.size();
    if(min == 0 && l) min = 1;
    if(l) max += l;
    cout << min << " " << max << endl;
}



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

int main() {
  int m, n, c, r = 0;
  cin >> n >> m >> c;
  vector<int> b(m);
  for(int i = 0; i < m; i++)
    cin >> b.at(i);
  for(int i = 0; i < n; i++){
    int s = c;
    for(int j = 0; j < m; j++){
      int a;
      cin >> a;
      s += (a * b.at(j));
    }
    if(s > 0)
      r++;
  }
  cout << r << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>


using namespace std;
using vi=vector<int>;


int is_prime(int x)
{
	if(x<2) return 0;
	if(x%2==0) return x==2;
	for(int i=3;i*i<=x;i+=2)
	{
		if(x%i==0) return 0;
	}
	return 1;
}


int main(void)
{
	int q;
	vi table(100000+1);

	for(unsigned int i=2;i<table.size();i++)
	{
		table[i]=table[i-1];
		if(is_prime(i) && is_prime((i+1)/2)) table[i]++;
	}

	while(scanf("%d", &q)==1)
	{
		vi l(q), r(q);

		for(int i=0;i<q;i++)
		{
			scanf("%d%d", &l[i], &r[i]);
		}
		for(int i=0;i<q;i++)
		{
			printf("%d\n", table[r[i]]-table[l[i]-1]);
		}
	}
	return 0;
}


Measured memory_bytes: 1792
#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 endl '\n'
#define MAX

typedef long long ll;
typedef pair<int,int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

bool ok(ll x){
	vector<bool> f(15, false);
	while(x > 0){
		f[x % 10] = true;
		x /= 10;
	}
	return f[3] && f[5] && f[7];
}

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	ll n;
	cin >> n;
	
	set<ll> S;
	
	queue<ll> Q;
	Q.push(3);
	Q.push(5);
	Q.push(7);
	
	S.insert(3);
	S.insert(5);
	S.insert(7);
	
	while(!Q.empty()){
		ll x = Q.front();Q.pop();
		if(x > n)
			continue;
		ll x1 = x * 10 + 3;
		ll x2 = x * 10 + 5;
		ll x3 = x * 10 + 7;
		if(S.find(x1) == S.end() && x1 <= n){
			S.insert(x1);
			Q.push(x1);
		}
		if(S.find(x2) == S.end() && x2 <= n){
			S.insert(x2);
			Q.push(x2);
		}
		if(S.find(x3) == S.end() && x3 <= n){
			S.insert(x3);
			Q.push(x3);
		}
	}
	
	ll ans = 0;
	for(auto &x : S)
		if(ok(x)){
			ans++;
			//cout << x << " ok" << endl;
		}
			
	
	cout << ans << endl;
	

	return 0;
}



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

using namespace std;
typedef long long int ll;


int main() {
   int n, k;
   cin>>n>>k;
   int ans =0;
   int y;
   while(n--){
       cin>>y;
       if(y >= k){
           ans++;
       }
   }
   cout<<ans;
}




Measured memory_bytes: 256
//
// Created by rajshah9914 on 09/04/20.
//

#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll,ll> pp;
ll prime[2000000];
ll M=1000000007;
void boost() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

void sieve(ll ending)
{
    for(ll i=2;i<ending;i++)
        prime[i]=1;
    for(int i=2;i*i<=ending;i++)
    {
        if(prime[i]==1)
        {
            for(int j=2*i;j<=ending;j=j+i)
            {
                prime[j]=0;
            }
        }
    }
    prime[1]=0;
}

ll ncrmodp(ll num,ll r)
{
    ll C[r+1];
    ll i,j;
    memset(C,0,sizeof(C));
    C[0]=1;
    for(i=1;i<=num;i++)
    {
        for(j=min(i,r);j>0;j--)
        {
            C[j]=((C[j])%M+(C[j-1])%M)%M;
        }
    }
    return C[r];
}

ll power(ll x,ll y)
{
    ll res = 1;
    x = x % M;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % M;

        y = y>>1; // y = y/2
        x = (x*x) % M;
    }
    return res;
}

void solve()
{
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='?')
        s[i]='D';
    }
    cout<<s<<endl;
}

int main()
{
    boost();
    solve();
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
#define ll long long
#define eps 1e-9
#define PI 2 * acos (0.0)
using namespace std;

int cnt[100005];

int main()
{
   

    int a, b, c, d, e, x, y, z;

    scanf("%d", &z);

    y = 0;

    for(int i = 0; i < z; i++)
    {
    	scanf("%d", &x);
    	cnt[x]++;
    }
    x = 0;

    for(int i = 1; i <= 100000; i++)
    {
    	if(cnt[i] > 1)
    	{
    		y = y + cnt[i] - 1;
    	}
    	if(cnt[i])
    	{
    		x++;
    	}
    }
    //cout<<y<<" "<<x<<endl;

    if((y & 1))
    {
    	x--;
    }

    cout<<x<<endl;

    
    return 0;
}


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

#define rep(i,n) for (int i = (n); i > 0; --i)
typedef long long ll;

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


void solve(long long A, long long B, long long K){
    ll a=min(A,B);
    ll k=0;
    rep(i,a){
        (A%i==0 and B%i==0)?k++:1;                
        if(k==K){
        cout<<i<<endl;

            return;
        }
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long K;
    scanf("%lld",&K);
    solve(A, B, K);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int N, D;
    cin >> N >> D;
    cout << (N + 2 * D) / (2 * D + 1) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}



use std::cmp;
use std::iter::Iterator;

fn main() {
    input! {
        n:usize,
        x:usize,
        l:[usize; n]
    }

    let mut d = 0;
    let mut cnt = 1;

    for i in 1..n+1 {
        d = d + l[i-1];

        if d > x{
            break;
        }

        cnt += 1;
        
    }

    println!("{}", cnt);

}



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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define x first
#define y second

#ifdef LOCAL
#include "/Users/swad/Desktop/CP/debug.h"
#endif

const int N = int(2e5) + 10;

int L, n;
int x[N];
vector<ll> psumL, psumR;

ll solve(vector<ll> &psumL, vector<ll> &psumR, int ls, int rs, int len) {
	return 2 * (psumL[ls + len - 1] - psumL[ls - 1]) + 2 * (psumR[rs + len - 1] - psumR[rs - 1]) - (psumR[rs + len - 1] - psumR[rs + len - 2]);
}

int main() {
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif

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

	psumL.resize(n + 2, 0);
	psumR.resize(n + 2, 0);
	for (int i = 1; i <= n; i++) psumL[i] = psumL[i - 1] + x[i];
	for (int i = n; i >= 1; i--) psumR[n + 1 - i] = psumR[n - i] + (L - x[i]);

	ll ans = 0LL;
	for (int target = 1; target <= n; target++) {
		int left = target - 1;
		int right = n - target;
		if (left == 0) {ans = max(ans, (ll)(L - x[2]) + max(x[2] - x[1], L - (x[2] - x[1]))); continue;}
		if (right == 0) {ans = max(ans, (ll)x[n - 1] + max(x[n] - x[n - 1], L - (x[n] - x[n - 1]))); continue;}

		int rem = abs(left - right);
		if (left <= right) {
			ans = max(ans,
				2 * (L - x[n + 1 - rem]) +
				solve(psumL, psumR, 1, rem + 1, target - 1) +
				max(x[target + 1] - x[target], L - (x[target + 1] - x[target])));
			ans = max(ans,
				solve(psumR, psumL, rem + 1, 1, target - 1) +
				max(x[target] - x[target - 1], L - (x[target] - x[target - 1])));
		}
		else {
			ans = max(ans,
				2 * x[rem] +
				solve(psumR, psumL, 1, rem + 1, target - 1 - rem) +
				max(x[target] - x[target - 1], L - (x[target] - x[target - 1])));
			ans = max(ans,
				solve(psumL, psumR, rem + 1, 1, target - 1 - rem) +
				max(x[target + 1] - x[target], L - (x[target + 1] - x[target])));
		}
	}

	printf("%lld\n", ans);

	return 0;
}

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

#define pi 3.141592653589793

int main(){
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    long double radm, radh, rad, c;

    radm = m * 6;
    radh = h * 30 + m / 2.0;

    rad = min(abs(360 - radh), radh) + min(abs(360 - radm), radm);
    rad = min(rad, min(abs(radm - radh), abs(radh - radm)));
    
    rad = pi / 180.0 * rad;

    c = sqrt(b * b + a * a - 2 * a * b * cosl(rad));

    printf("%.12Lf\n",c);
}

Measured memory_bytes: 3992
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, z, w;
int a[2010];

int dpx[2010], dpy[2010];
int calcX(int k);
int calcY(int k);

int calcY(int k) {
    if (dpy[k] < 0) {
        int res = abs(a[k] - a[n]);
        for (int i = k+1; i < n; i++) {
            res = min(res, calcX(i));
        }
        dpx[k] = res;
    }
    return dpx[k];
}


int calcX(int k) {
    if (dpx[k] < 0) {
        int res;
        res = (k == 0 ? abs(w - a[n]): abs(a[k] - a[n]));
        for (int i = k+1; i < n; i++) {
            res = max(res, calcY(i));
        }
        dpx[k] = res;
    }
    return dpx[k];
}

int solve() {
    memset(dpx, -1, sizeof(dpx));
    memset(dpy, -1, sizeof(dpy));
    return calcX(0);
}

void input() {
    cin >> n >> z >> w;
    for (int i = 1; i <= n; i++) cin >> a[i];
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 384
n,y = map(int,input().split())

satu = [1000,5000,10000]

sen = [1000 * i for i in range(n+1)]
gsen = [5000 * i for i in range(n+1)]
man = [10000 * i for i in range(n+1)]

#print(sen,gsen,man)
for i in range(n+1):
    for j in range(n+1-i):
        if man[i]+ gsen[j] + sen[n-i-j] == y:
            print(i,j,n-i-j)
            exit()

print("-1 -1 -1")






Measured memory_bytes: 9208
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#define F first
#define S second
using namespace std;

struct edge{
  int to,cost;
  edge(int to,int cost):to(to),cost(cost){}
};

typedef pair<double,pair<int,int> > P;

int n;
int m,p,a,b;
double t[11];
vector<edge> v[33];
double d[1<<9][33];

int main(void){
  while(1){
    cin >> n >> m >> p >> a >> b; if(!n) break;
    a--;b--;
    for(int i = 0; i < n; i++) cin >> t[i];
    for(int i = 0; i < 33; i++) v[i].clear();
    for(int i = 0; i < p; i++){
      int x,y,z;
      cin >> x >> y >> z;
      x--;y--;
      v[x].push_back(edge(y,z));
      v[y].push_back(edge(x,z));
    }

    priority_queue<P,vector<P>,greater<P> > que;
    for(int i = 0; i < 1<<9; i++) fill(d[i],d[i] + 33,1 << 28);
    d[0][a] = 0;
    que.push(P(0,make_pair(0,a)));
    while(!que.empty()){
      P p = que.top();que.pop();
      if(d[p.S.F][p.S.S] < p.F) continue;
      for(int i = 0; i < (int)v[p.S.S].size(); i++){
	for(int j = 0; j < n; j++){
	  if(p.S.F & 1 << j)continue;
	  if(d[p.S.F | 1 << j][v[p.S.S][i].to] > p.F + v[p.S.S][i].cost / t[j]){
	    d[p.S.F | 1 << j][v[p.S.S][i].to] = p.F + v[p.S.S][i].cost / t[j];
	    que.push(P(d[p.S.F | 1 << j][v[p.S.S][i].to],make_pair(p.S.F | 1 << j,v[p.S.S][i].to)));
	  }
	}
      }
    }
    double ret = (double)(1 << 28);
    for(int i = 0; i < 1 << 9; i++){
      ret = min(ret,d[i][b]);
    }
    if(ret == 1 << 28) puts("Impossible");
    else cout << ret << endl;
  }
}

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

const int N = 1100;

int adj[N][N], vis[N];
int dlt[N], wrk[2][N + N], *dp[2];

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n, m; cin >> n >> m;
	for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) if (i != j) adj[i][j] = 1;
	while (m--) {
		int u, v; cin >> u >> v;
		adj[u][v] = adj[v][u] = 0;
	}
	
	int cnt[2] = {0, 0};
	function<bool(int, int)> dfs = [&](int u, int id) {
		vis[u] = id, cnt[id]++;
		for (int v = 1; v <= n; v++) if (adj[u][v]) {
			if (vis[v] != -1 && vis[v] == id) return false;
			if (vis[v] == -1 && !dfs(v, !id)) return false;
		}
		return true;
	};
	
	int dltn = 0;
	for (int i = 1; i <= n; i++) vis[i] = -1;
	for (int i = 1; i <= n; i++) if (vis[i] == -1) {
		cnt[0] = cnt[1] = 0;
		if (!dfs(i, 0)) {
			cout << "-1\n";
			return 0;
		} else dlt[dltn++] = abs(cnt[0] - cnt[1]);
	}
	
	dp[0] = wrk[0] + N, dp[1] = wrk[1] + N;
	dp[0][0] = 1;
	for (int i = 0; i < dltn; i++) {
		for (int j = -n; j <= n; j++) if (dp[0][j]) dp[1][j + dlt[i]] = dp[1][j - dlt[i]] = 1;
		for (int j = -n; j <= n; j++) dp[0][j] = dp[1][j], dp[1][j] = 0;
	}
	
	int Min = n;
	for (int i = -n; i <= n; i++) if (dp[0][i]) Min = min(Min, abs(i));
	int a = (n - Min) / 2, b = (n + Min) / 2;
	cout << (long long)a * (a - 1) / 2 + (long long)b * (b - 1) / 2 << "\n";
	
	return 0;
}


Measured memory_bytes: 4352
#include <iostream>

int main(void){
    int N, ans=40;
    std::cin >> N;

    for (int i=0; i<N; ++i){
        int a, cnt=0;
        std::cin >> a;
        while (a % 2 == 0){
            a /= 2;
            ++cnt;
        }
        if (cnt < ans) ans = cnt;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3528
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int k, a, b;
  cin >> k >> a >> b;
  int ans = b/k*k;
  if(ans >= a) cout << "OK" << endl;
  else cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>

int main()
{
	int A,B;
	scanf("%d%d",&A,&B);
	if((A==2&&B==3)||(A==3&&B==2))
	{
		printf("1");
	}
	if((A==1&&B==2||A==2&&B==1))
	{
		printf("3");
	}
	if((A==3&&B==1||A==1&&B==3))
	{
		printf("2");
	}
	return 0;
}

Measured memory_bytes: 1616
#include <set>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

int main(){
  while(true){
    const int h = getInt();
    const int w = getInt();
    const int s = h * h + w * w;

    if(s == 0) break;

    pair<int, pair<int, int> > base = make_pair(s, make_pair(h, w));
    pair<int, pair<int, int> > ans = make_pair(300 * 300 + 300 * 300, make_pair(300, 300));

    for(int hh = 1; hh * hh <= s; hh++){
      for(int ww = hh + 1; ; ww++){
        const int ss = hh * hh + ww * ww;
        pair<int, pair<int, int> > tmp = make_pair(ss, make_pair(hh, ww));
        if(tmp > base){ ans = min(ans, tmp); break; }
      }
    }

    printf("%d %d\n", ans.second.first, ans.second.second);
  }

  return 0;
}

Measured memory_bytes: 1028
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        int N = sc.nextInt();
        int[] A = new int[N];
        long[] B = new long[N+1];
        for(int i=0;i<N;i++){
            A[i]=sc.nextInt();
        }
        B[0]=A[0];
        for(int i=1;i<N;i++){
            B[i]=(B[i-1]+A[i])%MOD;
        }
        for(int i=0;i<N;i++){
            long tmp = A[i]*( (B[N-1]-B[i])<0?(B[N-1]-B[i])+MOD:(B[N-1]-B[i]) );
            tmp%=MOD;
            ans+=tmp;
            ans%=MOD;
        }
        System.out.println(ans);
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 61584
import math
N = int(input())
cnt = 0
for a in range(1,N):
  for b in range(a,math.ceil(N/a)):
    c = N - a * b
    if c <= 0:
      break
    else:
      if a == b:
        cnt += 1
      else :
        cnt += 2
print(cnt)

Measured memory_bytes: 9064