akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define sort(vec) sort(vec.begin(),vec.end())
#define int long long
long long ans;

int gcd(int x,int y){
	if(y==0) return x;
	else return gcd(y,x%y);
}

int lcm(int x,int y){
	return x*y/gcd(x,y);
}
 
signed main(){
	int n;
	cin>>n;
	vector<int>a(n),b(n),c(n),d(n),e(n+1);
	e[n]=0;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++)cin>>b[i];
	for(int i=0;i<n;i++)cin>>c[i];
	sort(a);
	sort(b);
	sort(c);
	for(int i=0;i<n;i++)d[i]=n-(upper_bound(c.begin(),c.end(),b[i])-c.begin());
	for(int i=n-1;i>=0;i--)e[i]=e[i+1]+d[i];
	for(int i=0;i<n;i++){
		int x=upper_bound(b.begin(),b.end(),a[i])-b.begin();
		if(a[i]>=b[n-1])x=n;
		ans+=e[x];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl '\n'
#define rep(i,n) for(int i=0;i<n;i++) 
#define all(v) v.begin(),v.end()
#define F first
#define S second 
const ll MOD=1e9+7;
template<typename ForwardIterator,typename T>
ForwardIterator first_less_than(ForwardIterator first,ForwardIterator last,T val)
{
	auto it=lower_bound(first,last,val);
	return (it==first?first:it);
}

void solve()
{
	long double d,s,t;
	cin>>d>>t>>s;
	long double val=d/s;
	//cout<<val<<endl;
	if(val<=t)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
}

int main()
{
	ios_base::sync_with_stdio(false); 
  	 cin.tie(NULL);  
	int tt;
	tt=1;
	while(tt--)
	{
		solve();
	}
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
#define mp make_pair
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define mst(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double eps = 1e-9;
const int maxn = 1e5+9;
const double pi=3.14159265358979323846264;
const int inf = 1e9;
const ll mod = 1e9+7;
char op[19],pq[19];
int main()
{
    ios::sync_with_stdio(false);
    cin>>op>>pq;
    int n=strlen(op);
    int m=strlen(pq);
    if(n!=m-1) cout<<"no";
    else{
        int fg=1;
        for(int i=0;i<n;++i){
            if(op[i]!=pq[i]){
                fg=0;
                break;
            }
        }
        if(fg) cout<<"Yes";
        else cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 3640
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,k;
int main()
{
	scanf("%d%d",&n,&k);
	if(k>(n+1)/2)
	{
		printf("-1\n");
		return 0;
	}
	int kk=(n+1)/2;
	int a=kk+n*2-1;
	int b=kk+n*3-1-(kk+n*2-1);
	for(int j=kk+n*3-1;j>=kk+n*2-1;j-=2,a--,b--)
	{
		int v=j-kk+k;
		if(j==kk+n*2-1)v++;
		printf("%d %d %d\n",b-kk+k,a-kk+k,v);
	}
	b=kk+n-1;
	for(int j=kk+n*3-2;a>=kk+n;a--,b--,j-=2)
	{
		printf("%d %d %d\n",b-kk+k,a-kk+k,j-kk+k);
	}
	return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar(); getchar();return 0;
using namespace std;
typedef pair<ll, ll>P;
string s[19191];
signed main() {
	ll n;
	cin >> n;
	rep(i, n)cin >> s[i];
	ll ans = 0;
	rep(i, n) {
		rep(j, s[i].size() - 1) {
			if (s[i][j] == 'A' && s[i][j + 1] == 'B')ans++;
		}
	}
	ll cnta = 0, cntb = 0, cntc = 0;
	rep(i, n) {
		if (s[i][0] == 'B' && s[i][s[i].size() - 1] == 'A')cnta++;
		else if (s[i][0] == 'B')cntb++;
		else if (s[i][s[i].size() - 1] == 'A')cntc++;
	}
	ll p = min(cntb, cntc);
	if (cntb == 0 && cntc == 0)cout << max((ll)0, cnta - 1) + ans << endl;
	else if (cntb == 0 || cntc == 0)cout << cnta + ans << endl;
	else cout << cnta + p + ans << endl;
	ggr
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <math.h>
#include <set>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;

long long int  euc(long long int a, long long int b, long long int &x, long long int &y) {
  long long int xx = y = 0; long long int yy = x = 1;
  while (b) {
    long long int q = a / b; long long int t = b; b = a % b;
    a = t; t = xx; xx = x - q * xx; x = t;
    t = yy; yy = y - q * yy; y = t;
  }
  return a;
}
 
long long int mod_inverse(long long int a, long long int n) {
  long long int x, y;
  if (euc(a,n,x,y) > 1) return -1;
  return ((x % n) + n) % n;
}
 
long long int ans, a = 2, n, l;
 
void upd(long long int x, long long int y) {
  if ((l = mod_inverse(a * x, y)) > 0)
    ans = min( ans, l * x * a - 1  );
	ans=min(ans, (y-l) * x * a);
}


int main() {
  cin >> n; ans = n + (n % 2 == 0);
  while (n % 2 == 0)
    a *= 2, n /= 2;
  for (long long int i = 1; i * i <= n; i++)
    if (n % i == 0)
      upd(i, n / i), upd(n / i, i);
  cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define fp(i,l,r) for(register int i=(l);i<=(r);++i)
#define fd(i,l,r) for(register int i=(l);i>=(r);--i)
using namespace std;
int main(){
	char ch[10000+20];
	int bz=0;
	gets(ch);
	fp(i,0,strlen(ch)-1){
		if(ch[i]=='C'){
			bz=1;
		}
		if(ch[i]=='F'&&bz==1){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

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

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

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

	map<string, long long> cnt;
	for (int i = 0; i < n; i++){
		string s;
		cin>>s;
		sort(all(s));
		cnt[s]++;
	}

	ll ans=0;
	for(auto i: cnt){
		ans+=i.second*(i.second-1)/2;
	}

	cout<<ans<<endl;

	return 0;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		
		System.out.println(Math.max(a*b,Math.max(a+b,a-b)));
	}
}

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

int main(void) {
    ll x;
    cin >> x;

    ll nx = x /500;
    ll nx2 = (x - nx*500) / 5 ;

    cout << nx * 1000 + 5 * nx2 << endl;
    return 0;
}

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

int main() {
	ll x;
	cin >> x;
	const ll d = 1000;
	vector<pair<ll, ll>> s;
	for(ll i = -d; i <= d; i++) {
		s.push_back({i*i*i*i*i, i});
	}
	sort(all(s));
	rep(i, s.size()-1) {
		for(int j = 0; j < s.size(); j++){
			ll now = s[j].first - s[i].first;
			if(now == x) {
				printf("%lld %lld\n", s[j].second, s[i].second);
				return 0;
			}
		}
	}
	return 0;
}

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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }

template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

template <typename T> inline T gcd(T a, T b) {
	//if (b == 0) return a;
	T r; while ((r = a % b) != 0) a = b, b = r;
	return b;
}

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

    int N;
    cin >> N;
    vector<int> A(N);
    cin >> A;
    vector<int> L(N);
    vector<int> R(N);
    
    L[0] = A[0];
    R[N-1] = A[N-1];
    rep1(i, N) {
        L[i] = gcd(L[i-1], A[i]);
        R[N-1-i] = gcd(R[N-i], A[N-1-i]);
    }
    // cout<<"A:";cout_h(A);
    // cout<<"L:";cout_h(L);
    // cout<<"R:";cout_h(R);
    int ans = -1;
    chmax(ans, R[1]);
    rep1(i, N - 1) {
        chmax(ans, gcd(L[i-1], R[i+1]));
    }
    chmax(ans, L[N-2]);

    cout << ans << endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

// priceをキーに降順でソート
//sort(fruits.begin(), fruits.end(),
//     [](const fruit& x, const fruit& y) { return x.price > y.price;});

/*
int main() {
    int A, B, C;
    int x;
    std::cin >> A >> B >> C;
    x=min(A, B+C);
    std::cout << B+C-x << std::endl;

    return 0;
}
 */

/*
int main(){
    int N;
    std::cin >> N;
    int count = 0;
    for(int i=1; i<=N; i++){
        if((0<i && i<10)||(100<=i && i<1000)||(10000<=i && i<100000)){
            count++;
        }
    }
    std::cout << count << std::endl;
    return 0;
}
 */

int main(){
    int N;
    std::cin >> N;
    int H[N];
    for(int i=0; i<N; i++){
        std::cin >> H[i];
    }
    H[0]=max(1, H[0]-1);
    for(int i=1; i<N; i++){
        if(H[i-1]<H[i]){
            H[i]--;
        }
        else if(H[i-1]>H[i]){
            std::cout << "No" << std::endl;
            return 0;
        }
    }
    std::cout << "Yes" << std::endl;
    return 0;
}



Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)


ll solve(pii a,pii b){
	if(a.first<=b.first&&b.second<=a.second){
		return b.second-b.first+1;
	}
	else if(b.first<=a.first&&a.second<=b.second){
		return a.second-a.first+1;
	}
	else if(a.first<=b.first&&b.first<=a.second){
		return a.second-b.first+1;
	}
	else if(b.first<=a.first&&a.first<=b.second){
		return b.second-a.first+1;
	}
	else return 0;
}

const ll MOD = (1e9)+7;
int main(){
	int n;
	cin>>n;
	vector<int> t(n);
	vector<int> a(n);
	rep(i,n)cin>>t[i];
	rep(i,n)cin>>a[i];
	
	vector<pii> tt(n),aa(n);
	
	tt[0] = pii(t[0],t[0]);
	for(int i=1;i<n;i++){
		if(t[i]>t[i-1]){
			tt[i] = pii(t[i],t[i]);
		}
		else{
			tt[i] = pii(1,t[i]);
		}
	}
	
	
	aa[n-1] = pii(a[n-1],a[n-1]);
	for(int i=n-2;i>=0;i--){
		if(a[i]>a[i+1]){
			aa[i] = pii(a[i],a[i]);
		}
		else{
			aa[i] = pii(1,a[i]);
		}
	}
	
	
	ll ans = 1;
	rep(i,n){
		if(tt[i].second<aa[i].first || aa[i].second<tt[i].first){
			cout<<0<<endl;
			return 0;
		}
		pii x=tt[i],y=aa[i];
		ll  tmp = solve(x,y)%MOD;
		ans = (ans*tmp)%MOD;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
long long n,x;
long long h[100005],f[100005];
int main(){
	cin>>n;
	h[0]=0;
	for(int i=1;i<=n;i++){
		cin>>h[i];
	}
	f[1]=0;
	f[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;i++){
		f[i]=min(f[i-1]+abs(h[i]-h[i-1]),f[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<f[n];
}


Measured memory_bytes: 1792
N,M,C=map(int,input().split())
lst=[[0,0,0] for _ in range(N)]
B=list(map(int,input().split()))
ans=0
for i in range(N):
  lst[i]=list(map(int,input().split()))
  v=0
  for j in range(M):
    v+=B[j]*lst[i][j]
  if v+C>0:
    ans+=1
print(ans)

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  for(int i=0; i<S.size(); i++){
    if( (char)(S.at(i) + N) <= 'Z') S.at(i) = (char)(S.at(i) + N);
    else S.at(i) = (char)(S.at(i) + N -26); 
  }
  cout << S << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	int Difference,i,Sum;
	while(scanf("%d", &Difference) == 1){
		Sum = 0;
		for(i = Difference; i < 600; i+= Difference){
			Sum += Difference*i*i;
		}
	
		printf("%d\n", Sum);
	}
	
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n, m; cin >> n >> m;
    using Elem = tuple<int, int>;
    vector<Elem> xy(m);
    rep(i, m){
        int x, y; cin >> x >> y;
        y--;
        xy[i] = Elem(x, y);
    }
    sort(_all(xy));

    vector<vi> rest(n, vi(2, 1));
    vi sum(n, 1);

    rep(i, m){
        int x, y; tie(x, y) = xy[i];
        int a = y, b = y + 1;

        sum[a] += rest[b][0];
        sum[b] += rest[a][1];

        rest[a][0] += rest[b][0];
        rest[b][1] += rest[a][1];

        rest[a][1] = 0;
        rest[b][0] = 0;
    }

    rep(i, n){
        cout << (i >= 1 ? " ":"") << sum[i];
    }
    cout << endl;

    return 0;
}

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

char s[10];

int main(){
    int cnt[4] = {};
    int n;
    scanf("%d", &n);
    while (n --){
        scanf("%s", s);
        cnt[0] += !strcmp(s, "AC");
        cnt[1] += !strcmp(s, "WA");
        cnt[2] += !strcmp(s, "TLE");
        cnt[3] += !strcmp(s, "RE");
    }
    printf("AC x %d\n", cnt[0]);
    printf("WA x %d\n", cnt[1]);
    printf("TLE x %d\n", cnt[2]);
    printf("RE x %d\n", cnt[3]);
    return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const double PI  =3.141592653589793238463;
long long mod = 1000000007;

int main()
{

   ios::sync_with_stdio(false);
	cin.tie(0);
	ll t;
	t=1;
	while(t--)
    {
int n;
string s;
cin>>n>>s;
if(s.length()<=n) cout<<s<<endl;
else
cout<<s.substr(0,n)+"..."<<endl;

    
    }
}









Measured memory_bytes: 3656
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;

const int MXN = 2e5, IINF = 1e9 + 10, INF = 1e18 + IINF + 10, MOD = 1000000007;
const ld PI = 4.0 * atanl(1.0), PREC = .000001;
const char nl = '\n';

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.end(), x.begin()
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)(x).size()
#define ins insert

int n, m, t, a[MXN];

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

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

int main() {
  fast();
  cin >> n;
  int s = 0;
  int mn = MXN, ok = 0;
  FOR(i, 0, n) {
    cin >> a[i];
    s += a[i];
    if (a[i] % 10 != 0) mn = min(mn, a[i]), ok = 1;
  }
  if (s % 10 == 0 and ok) {
    cout << s - mn;
    return 0;
  }
  if (ok) {
    cout << s;
    return 0;
  }
  cout << 0;
  return 0;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
 
using namespace std;
 
#define ull unsigned long long
#define ll long long
#define int long long
#define ld long double
 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
 
#define MX LLONG_MAX
#define MN LLONG_MIN

const int N=1e5+5;
const ll mod=1e9+7;
 
ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}          
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

int32_t main()                  
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll a[n];
    for(ll i=0;i<n;i++)
        cin>>a[i];
    multiset<pair<ll,ll> > s;
    for(ll i=0;i<m;i++)
    {
        ll b,c;
        cin>>b>>c;
        s.insert({c,b});
    }
    sort(a,a+n);
    ll ind=0;
    for(auto it=s.rbegin();it!=s.rend();it++)
    {
        ll val = it->fi;
        ll f = it->se;
        while(f-- && a[ind]<val)
        {
            a[ind] = val;
            ind++;
        }
    }
    ll ans=0;
    for(ll i=0;i<n;i++)
        ans += a[i];
    cout<<ans;
    return 0;
}  

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

int num_counts(const vector<int>& d_list, int thres) {
    int res = 0;
    for (const int d : d_list){
        if (d < thres) res += 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> d_list(N);
    range(i, 0, N) cin >> d_list.at(i);
    sort(d_list.begin(), d_list.end());
    int num_problems = N / 2;
    // lower_bound
    // (lo, hi]
    int lo = 0, hi = 1e5 + 1;
    while (hi - lo > 1) {
        int mid = (hi - lo) / 2 + lo;
        if (num_counts(d_list, mid) < num_problems) lo = mid;
        else hi = mid;
    }
    int lb = hi;
    // upper_bound
    // (lo, hi]
    lo = 0, hi = 1e5 + 1;
    while (hi - lo > 1) {
        int mid = (hi - lo) / 2 + lo;
        if (num_counts(d_list, mid) <= num_problems) lo = mid;
        else hi = mid;
    }
    int ub = hi;
    // cout << lb << " " << ub << "\n";
    cout << ub - lb << "\n";
    return 0;
}


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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    char s;
    cin >> s;

    if (isupper(s))
    {
        cout << "A" << endl;
    }
    else
    {
        cout << "a" << endl;
    }
}

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

using namespace std;
#define MAX_N (500010)
int A[MAX_N];
int L[(MAX_N >> 1) + 1];
int R[(MAX_N >> 1) + 1];
int cnt = 0;

void merge(int A[], int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	//vector<int> L(n1 + 1), R(n2 + 1);
	for (int i = 0; i < n1; i++) L[i] = A[left + i];
	for (int i = 0; i < n2; i++) R[i] = A[mid + i];
	L[n1] = R[n2] = 1000000001;
	int i = 0, j = 0;
	for (int k = left; k < right; k++){
		cnt++;
		if (L[i] <= R[j]) A[k] = L[i++];
		else A[k] = R[j++];
	}
	//return cnt;
	//vector<int>().swap(L);
	//vector<int>().swap(R);
}

void merge_sort(int A[], int left, int right){
	//int sum = 0;
	if (left + 1 < right){
		int mid = (left + right) / 2;
		//sum = merge_sort(A, left, mid) + merge_sort(A, mid, right);
		//sum += merge(A, left, mid, right);
		merge_sort(A, left, mid);
		merge_sort(A, mid, right);
		merge(A, left, mid, right);
	}
	//return sum;
}

void solve(){
	int n, sum;
	cin >> n;
	//vector<int> A(n);
	for (int i = 0; i < n; i++) cin >> A[i];
	merge_sort(A, 0, n);
	for (int i = 0; i < n; i++){
		if (i) cout << " ";
		cout << A[i];
	}
	//cout << endl << sum << endl;
	cout << endl << cnt << endl;
}

signed main(){
	solve();
}

Measured memory_bytes: 6868
#include <iostream>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  string S;
  cin >> S;

  int con = 0;
  int mx_con = 0;
  rep(i, S.size()) {
    if (i > 0 && S[i] != S[i-1]) con = 0;
    con++;
    if (mx_con < con) mx_con = con;
  }

  if (mx_con >= 3) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

using namespace std;

int main(){
    int i,j,N;
    ios::sync_with_stdio(false); cin.tie(0);


    cin>>N;
    vector <string> data1(N),data2(N);

    for(i=0;i<N;i++){
        cin>>data1[i];
        data2[i]=data1[i];
    }   
    //バブルソート
    for(i=0;i<N;i++){
        for(j=N-1;j>i;j--){
            if(data1[j][1]<data1[j-1][1])
                swap(data1[j],data1[j-1]);
        }   
    }   
    //選択ソート
    for(i=0;i<N;i++){
        int minj=i;
        for(j=i;j<N;j++)
            if(data2[j][1]<data2[minj][1])minj=j;
        swap(data2[i],data2[minj]);                            
    }   
    for(i=0;i<N;i++)cout<<(i!=0?" ":"")<<data1[i];
    cout<<"\n"<<"Stable"<<"\n";
    for(i=0;i<N;i++)cout<<(i!=0?" ":"")<<data2[i];
    cout<<"\n"<<((data1==data2)?"Stable":"Not stable")<<"\n";
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
int main()
{
    int N, K, C;
    cin >> N >> K >> C;
    string S;
    cin >> S;
    vector<int> pre(N);
    vector<int> prelast(N);
    vector<int> suf(N);
    int cnt = 0;
    int last = -1e8;
    REP(i, N) {
        if(i > last + C && S[i] == 'o') {
            cnt++;
            last = i;
        }
        pre[i] = cnt;
        prelast[i] = last;
    }
    cnt = 0;
    last = 1e8;
    IREP(i, N) {
        if(i < last - C && S[i] == 'o') {
            cnt++;
            last = i;
        }
        suf[i] = cnt;
    }
    vector<int> ans;
    REP(i, N) {
        if(S[i] == 'x') continue;
        int tmp = 0;
        int last = i+1;
        if(i > 0) {
            tmp += pre[i-1];
            if(prelast[i-1] != -1e8) last = max(last, prelast[i-1] + C);
        }
        if(last < N) tmp += suf[last];
        //cout << i << " " << tmp << endl;
        if(tmp < K) ans.push_back(i+1);
    }

    REP(i, ans.size()) cout << ans[i] << endl;
}

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

      if((a * n) < b) {
        System.out.println(a * n);
      } else {
        System.out.println(b);
      }
	}
}

Measured memory_bytes: 22868
import sys
input = sys.stdin.readline

n = int(input())
A = list(map(int,input().split()))

cnt = [0,n-1]

As = sorted(list(zip(A,range(n))), reverse = True)

dp = [[0]*(n+1) for _ in range(n+1)]

# 配る
for i in range(n):
    for j in range(i+1):
        a,p = As[i]
        dp[i+1][j] = max(dp[i+1][j],dp[i][j] + a * (n-1 - p -i+j))
        dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j] + a * (p - j))

print(max(dp[n]))


Measured memory_bytes: 100088
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
	int c,g,n;
	while(1)
	{
		cin>>n;
		if(n==0)
		{
			break;
		}
		g=1000-n;
		c=(g/500)+(g%500/100)+(g%500%100/50)+(g%500%100%50/10)+(g%500%100%50%10/5)+(g%500%100%50%10%5);
		cout<<c<<endl;
	}
	return 0;
}

	
	

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = 1e9 + 1;

int main() {
  int n,d[100];
  cin >> n;
  for(int i = 0; i < n; i++)
    cin >> d[i];
  
  int sum = 0;
  for(int i = 0; i < n; i++) {
    for(int j = i+1; j < n; j++)
      sum += d[i]*d[j];
  }

  cout << sum << endl;  
}

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

#define For(i,n) for(int i =0; i<n;i++)
#define whatis(x) cerr<<#x<<" is : "<<x<<endl;
using namespace std;


typedef long long ll;

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

    ll ans =0;
    int n;cin>>n;
    ll a[n];
    For(i,n)
       cin>>a[i];

    For(i,n-1){
        if(a[i]%2){
            ans+=a[i]/2;
            a[i]=1;
            if(a[i+1]){
                a[i+1]--;
                ans++;
            }
        }else{
        ans+=a[i]/2;
        }
    }
    ans+=a[n-1]/2;

    cout<<ans<<endl;
}



Measured memory_bytes: 1024
import math
N = int(input())

X = N / 1.08
x1 = math.floor(X)
x2 = math.ceil(X)

if math.floor(x1 * 1.08) == N:
    print(x1)
elif math.floor(x2 * 1.08) == N:
    print(x2)
else:
    print(":(")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <stdlib.h>
#include <cmath>
using namespace std;

int main(){
    int N,D[101][2];
    cin>>N;
    int flag=0,ans=0;

    for(int i=0;i<N;i++){
        cin>>D[i][0]>>D[i][1];
    }

    for(int i=0;i<N;i++){
        if(D[i][0] != D[i][1]){
            flag=0;
        }else{
            flag++;
        }
        if(flag>ans)    ans=flag;
    }

    if(ans>=3)  cout<<"Yes"<<endl;
    else    cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9 + 7;
const ld PI = 3.141592653589793;
main(){

	ios_base::sync_with_stdio(false);
	/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    
    int a,p;
    cin>>a>>p;
    int ans=a*3+p;
    cout<<ans/2;
    
    
    return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int x;
    int res;
    string s;
    while(cin >> s)
    {
        if (s[0] == '0') break;
        res = 0;
        int i;
        for (i = 0; i < s.length(); i++)
            res += s[i] -'0';
        cout << res << endl;
    }
    return 0;
}



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

#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
typedef pair<ll,ll> pll;

const int N = 2e5+2;
int n, mini, maxi;
int A[N], B[N];

int med(int ar[N])
{
    if (n % 2 == 0)
        return ar[n/2] + ar[n/2+1];
    return ar[n/2+1];
}

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] >> B[i];
    }
    sort(A+1,A+n+1);
    sort(B+1,B+n+1);
    mini = med(A);
    maxi = med(B);
    cout << maxi-mini+1 << '\n';
    return 0;
}

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

using namespace std;

using ll = long long;
constexpr int MAX_N = 301;
double dp[MAX_N][MAX_N][MAX_N];

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

    int n;
    cin >> n;

    array<int, 3> cnt = {0, 0, 0};
    for (int i = 0, a; i < n; ++i) {
        cin >> a;
        ++cnt[a - 1];
    }

    for (int i3 = 0; i3 <= cnt[2]; ++i3) {
        for (int i2 = 0; i2 <= cnt[1] + cnt[2]; ++i2) {
            for (int i1 = 0; i1 <= cnt[0] + cnt[1] + cnt[2]; ++i1) {
                int i0 = n - (i1 + i2 + i3);
                if (i0 < 0) break;
                if (i0 == n) continue;

                double res = 0.0;
                if (i1 != 0)
                    res += dp[i1 - 1][i2][i3] * i1;
                if (i2 != 0)
                    res += dp[i1 + 1][i2 - 1][i3] * i2;
                if (i3 != 0)
                    res += dp[i1][i2 + 1][i3 - 1] * i3;
                res = res / (double)n + 1.0;

                if (i0 != 0) res *= n / (double)(n - i0);
                dp[i1][i2][i3] = res;
            }
        }
    }

    cout << dp[cnt[0]][cnt[1]][cnt[2]] << endl;

    return 0;
}


Measured memory_bytes: 213248
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import Data.List

main = do
  n <- readLn :: IO Int
  a <- getIntListBC
  let s = sum a
  print $ minimum . init $ solve 0 s a

bsToInt :: BC.ByteString -> Int
bsToInt = fst . fromJust . BC.readInt

getIntListBC :: IO [Int]
getIntListBC = map bsToInt . BC.words <$> BC.getLine

solve :: Int -> Int -> [Int] -> [Int]
solve _ _ []     = []
solve i s (a:as) = let t = s - (a + i)
                   in (abs $ t - (a + i)) : solve (a+i) s as


Measured memory_bytes: 22908
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define srtarr(x, n) sort(x, x+n)
#define dsrtarr(x, n) sort(x, x+n, greater<>());
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007

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

using namespace std;
/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */

int d[100010];
int main() {
    int n;
    cin >>n ;
    rep(i, n){
        cin >> d[i];
    }
    srtarr(d, n);
    cout << d[n/2] - d[n/2-1] << endl;

}




Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
	int N, M;
	int a[51] = { 0 }, b[51] = { 0 };
	int i, j, cnt=0;

	scanf("%d %d", &N, &M);
	for (i = 1; i <= M; i++) scanf("%d %d", &a[i], &b[i]);

	for (i = 1; i <= N; i++) {
		for (j = 1; j <= M; j++) {
			if ((a[j] == i) || (b[j] == i)) cnt++;
		}
		printf("%d\n", cnt);
		cnt = 0;
	}

	return 0;
}

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

int main() {
    long long a, b, x;
    cin >> a >> b >> x;
    long long ans{0};
    if (a == 0) {
        a = 1;
        ans++;
    }
    ans += b / x;
    ans -= (a - 1) / x;
    cout << ans << endl;
    return 0;
}


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

int main() {
  int A, B, m;
  cin >> A >> B >> m;
  vector<int> a(A);
  rep(i,A) cin >> a.at(i);
  vector<int> b(B);
  rep(i,B) cin >> b.at(i);
  vector<int> x(m);
  vector<int> y(m);
  vector<int> c(m);
  rep(i,m) cin >> x.at(i) >> y.at(i) >> c.at(i);
  int ans = INT_MAX;
  rep(i,m) ans = min(ans, a.at(x.at(i)-1)+b.at(y.at(i)-1)-c.at(i));
  int mina = INT_MAX;
  int minb = INT_MAX;
  rep(i,A) mina = min(mina, a.at(i));
  rep(i,B) minb = min(minb, b.at(i));
  ans = min(ans, mina+minb);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2176
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		double m;
		double max = 0, min = 1000000;
		
		while(scan.hasNextDouble()){
			m = scan.nextDouble();
			
			if(m > max)max = m;
			if(m < min)min = m;
		}
		
		System.out.println(max - min);
	}
}

Measured memory_bytes: 27880
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;
const LL INF=1LL<<50,mod=1e9+7;
const int N=100005,M=200005*2;
struct edge{
	int x,y,z;
}e[M];
struct gragh{
	int cnt,x[M],y[M],z[M],nxt[M],fst[N],ways[N];
	void clear(){
		cnt=0;
		memset(fst,0,sizeof fst);
	}
	void add(int a,int b,int c){
		y[++cnt]=b,x[cnt]=a,z[cnt]=c,nxt[cnt]=fst[a],fst[a]=cnt;
	}
}G,DAG,DAF;
int n,m,S,T,vis[N];
int q[N],head,tail,qmod,in[N];
LL dis[2][N];
void SPFA(int t,int S){
	int x,y;
	head=tail=0,qmod=n+1;
	memset(vis,0,sizeof vis);
	for (int i=1;i<=n;i++)
		dis[t][i]=INF;
	dis[t][S]=0;
	q[tail=tail%qmod+1]=S;
	vis[S]=1;
	while (head!=tail){
		vis[x=q[head=head%qmod+1]]=0;
		for (int i=G.fst[x];i;i=G.nxt[i]){
			y=G.y[i];
			if (dis[t][x]+G.z[i]<dis[t][y]){
				dis[t][y]=dis[t][x]+G.z[i];
				if (!vis[y])
					vis[q[tail=tail%qmod+1]=y]=1;
			}
		}
	}
}
void build_DAG(){
	DAG.clear(),DAF.clear();
	for (int i=1;i<=m;i++){
		int &x=e[i].x,&y=e[i].y,z=e[i].z;
		if (dis[0][x]>dis[0][y])
			swap(x,y);
		if (dis[0][x]+z==dis[0][y]&&dis[1][y]+z==dis[1][x])
			DAG.add(x,y,z),DAF.add(y,x,z);
	}
}
void build_ways(){
	int x,y;
	head=tail=0;
	memset(in,0,sizeof in);
	memset(DAG.ways,0,sizeof DAG.ways);
	DAG.ways[S]=1;
	for (int i=1;i<=m;i++)
		in[DAG.y[i]]++;
	q[++tail]=S;
	while (head<tail){
		x=q[++head];
		for (int i=DAG.fst[x];i;i=DAG.nxt[i]){
			y=DAG.y[i];
			DAG.ways[y]=(DAG.ways[y]+DAG.ways[x])%mod;
			if (!--in[y])
				q[++tail]=y;
		}
	}
	head=tail=0;
	memset(in,0,sizeof in);
	memset(DAF.ways,0,sizeof DAF.ways);
	DAF.ways[T]=1;
	for (int i=1;i<=m;i++)
		in[DAF.y[i]]++;
	q[++tail]=T;
	while (head<tail){
		x=q[++head];
		for (int i=DAF.fst[x];i;i=DAF.nxt[i]){
			y=DAF.y[i];
			DAF.ways[y]=(DAF.ways[y]+DAF.ways[x])%mod;
			if (!--in[y])
				q[++tail]=y;
		}
	}
}
bool inway(int x){
	return dis[0][x]+dis[1][x]==dis[0][T];
}
LL sqr(LL x){
	return x%mod*(x%mod)%mod;
}
int main(){
	scanf("%d%d%d%d",&n,&m,&S,&T);
	G.clear();
	for (int i=1;i<=m;i++){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		G.add(x,y,z),G.add(y,x,z);
		e[i].x=x,e[i].y=y,e[i].z=z;
	}
	SPFA(0,S);
	SPFA(1,T);
	build_DAG();
	build_ways();
	LL ans=sqr(DAG.ways[T])%mod;
	for (int i=1;i<=n;i++)
		if (dis[0][i]*2==dis[0][T]&&dis[1][i]*2==dis[0][T])
			ans=(ans+mod-sqr(1LL*DAG.ways[i]*DAF.ways[i]))%mod;
	for (int i=1;i<=DAG.cnt;i++){
		int x=DAG.x[i],y=DAG.y[i];
		if (inway(x)&&inway(y)&&dis[0][x]*2<dis[0][T]&&dis[1][y]*2<dis[0][T])
			ans=(ans+mod-sqr(1LL*DAG.ways[x]*DAF.ways[y]))%mod;
	}
	printf("%d",(int)ans);
	return 0;
}

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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

ll N, L;
VL x, a;
vector<VL> dp;

int main() {
    cin >> N >> L;
    REP(i, N) x.emplace_back(IN());
    REP(i, N) a.emplace_back(IN());
    dp.resize(N, VL(L, 0));
    if(a[0] == 0)
        dp[0][x[0]] = 1;
    else {
        for(ll i = x[0]; i < L; i += a[0]) {
            dp[0][i] = 1;
        }
    }
    FOR(i, 1, N) {
        ll start = 0;
        REP(j, x[i])(start += dp[i - 1][j]) %= MOD;
        dp[i][x[i]] = start;
        if(a[i] == 0)
            continue;
        else {
            FOR(j, x[i], L) {
                if((j - x[i]) % a[i] == 0) {
                    dp[i][j] = start;
                }
                (start += dp[i - 1][j]) %= MOD;
            }
        }
    }
    ll ans = 0;
    REP(i, L)(ans += dp[N - 1][i]) %= MOD;
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 198512
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char *argv[])
{
    int a, b, c, k;

    std::cin >> a >> b >> c;
    std::cin >> k;

    while (a >= b) {
        b *= 2;
        k--;
    }
    while (b >= c) {
        c *= 2;
        k--;
    }

    if (k >= 0) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}



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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int ans;
  ans = 0;
  int count = 0;
  int ab = min(a, b);
  for (int i = ab; i > 0; i--){
    if (a % i == 0 && b % i == 0) count++;
    if (count == c){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}

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

int N, M;
int Ai[1000];
int Bj[1000];

int Acnt[1000];
int maxi;
int maxv;

signed main()
{
	cin >> N >> M;
	rep(i,N) cin >> Ai[i];
	rep(j,M) cin >> Bj[j];
	
	maxi = -1;
	maxv = -1;

	rep(j,M) rep(i,N) if (Ai[i] <= Bj[j]) {
		Acnt[i] += 1;
		if (Acnt[i] > maxv) {
			maxv = Acnt[i];
			maxi = i;
		}
		break;
	}

	cout << maxi + 1 << endl;
}

Measured memory_bytes: 1172
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()


int main() {
	
	string S, T;
	ll N;
	cin >> S >> T;
	N = S.size();

	map<ll, ll> S_dict, T_dict;
	vll newS(N), newT(N);

	rep(i, N) {
		if (S_dict.find(S[i] - 'a') != S_dict.end()) newS[i] = S_dict[S[i] - 'a'];
		else {
			S_dict[S[i] - 'a'] = S_dict.size();
			newS[i] = S_dict[S[i] - 'a'];
		}
		if (T_dict.find(T[i] - 'a') != T_dict.end()) newT[i] = T_dict[T[i] - 'a'];
		else {
			T_dict[T[i] - 'a'] = T_dict.size();
			newT[i] = T_dict[T[i] - 'a'];
		}
	}

	cout << (newS == newT ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3848
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define vstroku() to_string()
#define vchislo() to_ulong()
#define numberof1(x) __builtin_popcount(x)
#define povsemelementam(i,mnozh) for(auto i: mnozh)
#define podotrezok(i,j) substr(i-1,j) // like prefix sum, (i,j)=s[j]-s[i-1]
#define pb push_back
#define pf push_front
#define popf pop_front
#define popb pop_back 
#define pii pair <int, int>
#define F first
#define S second
#define mipletsplay ios_base::sync_with_stdio(0); cin.tie(0); 


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 3e5;
const ll INF = 1e9;
const ll kek = 998244353;

int main() {
	mipletsplay;
int n;
cin>>n;
vector <pair <ll,ll> > a(n);
for (int i=0;i<n;i++)
cin>>a[i].second>>a[i].first;
ll sum=0;
sort(a.begin(),a.end());
bool ok=true;
for (int i=0;i<n;i++)
{
if (sum+a[i].second<=a[i].first)
sum+=a[i].second;
else
ok=false;
}
if (ok)
cout<<"Yes";
else
cout<<"No"; }

Measured memory_bytes: 3328
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
#define MH 5000
using namespace std;
bool ck(int *f){
	rep(i,5)if(!f[i])return 0;
	return 1;
}
int main(){
	int n;
	while(cin>>n,n){
		int d,l,x,y,c=0;
		int field[MH][5]={0};
		rep(i,n){
			cin>>d>>l>>x,y=MH,x--,d--;
			for(;y>0;y--)rep(j,(d?1:l))if(field[y-1][x+j])goto END;
			END:
			rep(j,l)field[y+d*j][x+(1-d)*j]=1;
			rep(i,MH)while(ck(field[i])){
				rep(j,MH-i-1)rep(k,5)field[j+i][k]=field[j+i+1][k];
				rep(k,5)field[MH-1][k]=0;
			}
		}
		rep(i,MH)rep(j,5)c+=field[i][j];
		cout<<c<<endl;
	}
	return 0;
}

Measured memory_bytes: 964
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>

using namespace std;
typedef long long int ll;typedef pair<int, int> P;
const long long mod = 1e9 + 7;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define ALL(a) (a).begin(),(a).end()

int main(void) {
	int n, m; cin >> n >> m;
	vector<int> ok(n + 1, true);
	rep(i, m) {
		int a; cin >> a;
		ok[a] = false;
	}
	vector<ll> v(n + 1);
	v[0] = 1;
	for (int now = 0; now < n; ++now) {
		for (int next = now + 1; next <= min(n, now + 2); ++next) {
			if (ok[next]) {
				v[next] += v[now];
				v[next] %= mod;
			}
		}
	}
	cout << v[n] << endl;
	return 0;
}

Measured memory_bytes: 1408
//誤差注意。あと、2つの値段の和が、5%で105円だからって、0%で100円とは限らない！！
#include<iostream>
using namespace std;

int x,y,s;

int main(){
	int i,j,ans;
	
	while( 1 ){
		cin >> x >> y >> s;
		if( !x )break;
		
		ans = 0;
		for( i = 1; i < 2000; i++ ){
			for( j = 1; j < 2000; j++ ){
				//税抜きi円とj円の品物
				int tmp = i*(100+x)/100 + j*(100+x)/100;
				//cout << tmp << endl;
				if( tmp != s )
					continue;
				ans = max( ans, i*(100+y)/100 + j*(100+y)/100 ) ;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
order_time = [0, 0, 0, 0, 0]
order = len(order_time)
time = 0
last_order = 9
count_change = 0

for i in range(0, order):
    order_time[i] = int(input())
    if (order_time[i] % 10 != 0) and (order_time[i] % 10 <= last_order % 10):
        last_order = order_time[i]
        count_change += 1

for i in range(0, order):
    if order_time[i] % 10 != 0:
        time += order_time[i] // 10 * 10 + 10
    else:
        time += order_time[i]

if count_change == 0:
    last_order = 0
else:
    time -= last_order // 10 * 10 + 10
    time += last_order

print(time)


Measured memory_bytes: 3064
N,W = [int(i) for i in input().rstrip().split()]
F = [[int(i) for i in input().rstrip().split()] for _ in range(N)]

DP = []
for w,v in F:
    if DP == []:
        DP = [0]*w+[v]*(W-w+1)
    else:
        dp = DP[::]
        for w2 in range(w,W+1):
            dp[w2] = max(DP[w2-w] + v, DP[w2])
        DP = dp
    #print(DP)
print(DP[-1])


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

int main(){
	int a,b,ans=0;
	scanf("%d%d",&a,&b);
	if(a>b)swap(a,b);
	for(int i=a;i<=b;i++){
		int num[10],len=0,t=i;
		while(t)num[++len]=t%10,t/=10;
		bool flag=true;
		for(int j=1;j<=len-j+1;j++)if(num[len-j+1]!=num[j]){
			flag=false;
			break;
		}
		if(flag)ans++;
	}
	printf("%d\n",ans);
	return 0;
}

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

using ll = long long;
using pll = pair <ll, ll>;
const int MAX = 1e5+5;

ll n;

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

	cin >> n;
	cout << 1-n << endl;

    return 0;
}


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

int main() {
  int X, Y, Z;
  cin >> X >> Y >> Z;

  int temp;

  temp = Y;
  Y = X;
  X = temp;

  temp = Z;
  Z = X;
  X = temp;

  cout << X << ' ' << Y << ' ' << Z << endl;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let dn = read_vec::<i32>();
    let (d,n) = (dn[0],dn[1]);
    let div = if d == 0 {
        1
    } else {
        (1..d+1).fold(1,|x,y| x * 100)
    };
    let ans = if n == 100 {
        div * (n + 1)
    } else {
        div * (n)
    };
   
    println!("{}",ans );
}


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

#define ll long long
#define INF 1234567890
#define N (int)(1e5 + 5)
#define pi acos(-1)

ll dp[N];
bool viz[N];

void solve()
{
   int n, w;
   cin >> n >> w;
   for(int i = 1; i <= n; ++i)
   {
       ll w_i, v;
       cin >> w_i >> v;
       viz[0] = 1;
       for(int j = w - w_i; j >= 0; --j)
        if(viz[j])
        dp[j + w_i] = max(dp[j + w_i], dp[j] + v), viz[j + w_i] = 1;
   }
   ll maxim = -INF;
   for(int i = 1; i <= w; ++i)
    maxim = max(maxim, dp[i]);
    cout << maxim;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 1152