akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	public static long MOD = 1000000007l;

	public static void main(String[] arg) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] a = new String[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.next();
		}
		sc.close();
		char first = a[0].charAt(a[0].length() - 1);
		boolean ans = true;
		for (int i = 1; i < n; i++) {
			if (!(first == a[i].charAt(0))) {
				ans = false;
				break;
			} else {
				// System.out.println(first);
				first = a[i].charAt(a[i].length() - 1);
				// System.out.println(first);
			}
		}
		if (ans) {
			Arrays.sort(a);
			String prev = a[0];
			for (int i = 1; i < n; i++) {
				if (prev.equals(a[i])) {
					ans = false;
					break;
				} else {
					prev = a[i];
				}
			}
		}
		System.out.println(ans ? "Yes" : "No");
	}
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n;
ll m;
int a[100005];
int s[200008];
ll sum[100005];
void solve() {
    cin >> n >> m;
    rep(i, n) cin >> a[i];
    sort(a, a + n);

    ll l = 0, r = 20000000005;
    while (r - l > 1) {
        auto mid = (l + r) / 2;
        ll res = 0;
        rep(i, n) {
            int pos = distance(a, lower_bound(a, a + n, mid - a[i]));
            res += n - pos;
        }
        if (res >= m) l = mid;
        else r = mid;
    }

    repd(i, n) sum[i] = sum[i + 1] + a[i];
    ll ans = 0;
    rep(i, n) {
        int pos = distance(a, lower_bound(a, a + n, l - a[i]));
        ans += sum[pos] + ((ll)a[i]) * (n - pos);
        m -= n - pos;
    }
    ans += ((ll)l) * m;

    cout << ans << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


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


int main() {

    ll x;
    cin >> x;
    if (1<= x && x <100) {
        cout << '0' << endl;
        return 0;
    }
    int res = x / 100;
    int t = x % 100;
    if (t / res < 5 || (t/res==5 && t%res == 0)) {
        cout << '1' << endl;
    } else cout << '0' << endl;
    return 0;
}

Measured memory_bytes: 256
#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<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
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 gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

   int k,s;
   cin>>k>>s;

   int sum=0;

   rep(i,k){
       rep(j,k){
           int z=s-i-j;
           if(z>=0 && z<=k)sum++;
       }
   }
   cout<<sum<<endl;


  
}



Measured memory_bytes: 3576
#include <bits/stdc++.h>
//\\//\\//\\//\\//\\//\\//\\//
#define fio ios::sync_with_stdio(false); cin.tie(nullptr)
#define all(x) (x).begin(),(x).end()
#define dlog(x) cerr<<#x<<'='<<x<<'\n'
#define endl '\n'
#define eb emplace_back
#define f first
#define s second
//\\//\\//\\//\\//\\//\\//\\//
using namespace::std;
using ll=long long;
using pii=pair<int,int>;
const int inf=INT_MAX,mod=1e9+7;
//\\//\\//\\//\\//\\//\\//\\//


signed main(){
      fio;
      int a,b; cin>>a>>b;
      int sum=0;
      while (b--) {
            int a; cin>>a; sum+=a;
      }

      cout<<(sum>=a?"Yes":"No");
      return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
using usize = ::std::size_t;
using u64 = ::std::int_least64_t;
//using u64 = int;
static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;
 
 
int main(int argc, char *argv[])
{
    // input from txt （提出時にこの箇所は削除すること）
    //std::ifstream in("in.txt");
    //std::cin.rdbuf(in.rdbuf());
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int D, T, S;
    cin >> D >> T >> S;
    if ((double)D/S <= (double) T) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
    
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=2001,INF=1<<30;

ll rui(ll a,ll b){
    if(b==1) return a%mod;
    if(b==0) return 1;
    if(b%2==0) return (rui(a,b/2)*rui(a,b/2))%mod;
    return (rui(a,b-1)*a)%mod;
}

ll comb(ll a,ll b){
    ll ans=1;
    for(ll i=a;i>a-b;i--){
        ans=ans*i%mod;
    }
    for(ll i=1;i<=b;i++){
        ans=(ans*rui(i,mod-2))%mod;
    }
    return ans;
}
 
int main(){
    
    ll m,n;cin>>m>>n;
    cout<<rui(m,n)<<endl;
}



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

const int maxn = 1000006;
multiset<int>MS;
int A[maxn];

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm

    int N, L;
    cin >> N >> L;
    for( int i = 1; i <= N; i++ )
        cin >> A[i];

    for( int i = 1; i <= L; i++ )
        MS.insert(A[i]);

    cout << *(MS.begin());
    for( int i = L+1; i <= N; i++ ){
        cout << " ";
        MS.erase( MS.find( A[i-L] ) );
        MS.insert( A[i] );
        cout << *(MS.begin());
    }
    cout << '\n';

    return 0;
}



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


using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

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

    ll ans=1e15;
    for(int c=0; c<(1<<N); c++){
        int cnt=0,pre_high=0;
        ll cost=0;
        
        for(int i=0; i<N; i++){
            if(1 & (c>>i)){
                cnt++;
                pre_high=max(pre_high+1,A[i]);
                cost+=pre_high-A[i];
            }else pre_high=max(A[i],pre_high);
        }
        if(cnt>=K) ans=min(ans,cost);
    }

    cout << ans << endl;


    return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define foreach(it, v) for(typeof(v.begin()) it=v.begin(); it!=v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;

int  N, K;

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

  cin >> N >> K;
  if (K==1) {
    cout << "0\n";
  } else {
    cout << N-K << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
ll x,ans;
int main(){
	cin >> x;
	ans=100;
	for(ll i=0;;i++){
		if(ans>=x)return printf("%lld",i),0;
		ans+=ans/100;
	}
	return 0;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	int k;
	for(int i=1;i<=m;i++)
	{
		cin>>k;
		n-=k;
	}
	cout<<max(-1,n);
	return 0;
}

Measured memory_bytes: 3644
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define MX 10000000000
#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}

ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}

void solve()
{
	int n, ans;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		double x = 1.08 * (double)i;
		if ((int)x == n)
		{
			cout << i;
			return;
		}
	}
	cout << ":(";
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}


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

using namespace std;

typedef long long ll;

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

	int n;
	cin >> n;

	vector<int> p(n);
	rep(i, n) cin >> p[i];

	int ans = 0;
	for(int i = 0; i < n-2; i++){
		vector<int> w(3);
		w[0] = p[i];
		w[1] = p[i+1];
		w[2] = p[i+2];

		sort(w.begin(), w.end());
		if(w[1] == p[i+1]) ans++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
def bfs(b):
    mem=[[False for i in range(n)]for j in range(2)]
    st=[0,0]
    for i in range(2):
        if b[i][0]!=1:continue
        while st[i]<n-1 and b[i][st[i]+1]==1:
            st[i]+=1
        if st[i]==n-1:return 0
    mem[0][st[0]]=True
    mem[1][st[1]]=True
    que=[[0,st[0],0],[1,st[1],0]]
    while len(que)!=0:
        d=que.pop(0)
        des=(d[0]+1)%2
        cst=d[2]+1
        for i in range(3):
            fl=d[1]+i
            if fl>=n:break
            state=b[des][fl]
            if state!=2 and fl==n-1:
                return cst
            if state==0:
                if mem[des][fl]==False:
                    que.append([des,fl,cst])
                    mem[des][fl]=True
            elif state==1:
                k=1
                while True:
                    if fl+k>=n:return cst
                    if b[des][fl+k]!=1:
                        if mem[des][fl+k-1]==False:
                            que.append([des,fl+k-1,cst])
                            mem[des][fl+k-1]=True
                        break
                    else: k+=1

            elif state==2:
                k=1
                while True:
                    if b[des][fl-k]!=2:
                        if mem[des][fl-k]==False:
                            que.append([des,fl-k,cst])
                            mem[des][fl-k]=True
                        break
                    else:k+=1  
    return -1
while True:
    n=int(input())
    if n==0:break
    b=[[int(p)for p in input().split(" ")],[int(p)for p in input().split(" ")]]
    count=bfs(b)
    print(str(count)if count>=0 else "NA")

Measured memory_bytes: 7828
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,n,...) for (int i = 1 , ##__VA_ARGS__ ; i <= n ; i++)
#define REP(i,n,...) for (int i = 0 , ##__VA_ARGS__ ; i < n ; i++)
#define ll long long
#define LL long long
#define mp make_pair
#define x first
#define y second

const int MAXN = 100005;

int n , a[MAXN*3];

int main (void) {
  cin >> n;
  FOR(i,n) scanf("%d",a+i*3);
  FOR(i,n) a[i*3-1] = a[i*3] - 1;
  FOR(i,n) a[i*3-2] = a[i*3] - 2;
  sort(a+1,a+1+n*3);
  int ans = 0 , cnt = 0;
  FOR(i,n*3) {
    if (i > 1 && a[i] == a[i-1]) cnt++;
    else cnt = 1;
    ans = max(ans,cnt);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}


int main() {
	int n;
	cin >> n;
	vector<string> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (auto c : v) {
		if (count(v.begin(), v.end(), c) > 1) {
			cout << "No" << endl;
			return 0;
		}
	}
	for (int i = 0; i < n-1; i++) {
		if (v[i][v[i].size() - 1] != v[i + 1][0]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


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

using namespace std;

int main()
{
  int a[3];
  int K;
  cin >> a[0] >> a[1] >> a[2] >> K;

  sort(a,a+3);

  cout << a[0] + a[1] + a[2]*pow(2,K) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int solve(int X, int A){
  if(X < A){
    return 0;
  }
  else
  {
    return 10;
  }  
}

int main() {
  int X, A;
  cin >> X >> A;
  cout << solve(X, A) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c,d,e;
    int ans = 1;
    //char s[101];
    // 整数の入力
    scanf("%d %d %d %d %d", &a, &b, &c, &d, &e);
    while(ans <= 5)
    {
        if (a != ans)
        {
            break;
        }
        ans++;
        if (b != ans)
        {
            break;
        }
        ans++;
        if (c != ans)
        {
            break;
        }
        ans++;
        if (d != ans)
        {
            break;
        }
        ans++;
        if (e != ans)
        {
            break;
        }
    }
    // スペース区切りの整数の入力
    //scanf("%d %d",&b,&c);
    // 文字列の入力
    //scanf("%s",s);
    // 出力
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 2136
#include<stdio.h>

int main(void)
{
	int a,b,c,sat;

	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
		sat=b;
		b=a;
		a=sat;
	}
	if(a>c){
		sat=c;
		c=a;
		a=sat;
	}
	if(b>c){
		sat=c;
		c=b;
		b=sat;
	}
	printf("%d %d %d\n",a,b,c);

	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define double long double
using namespace std;

const double INF = 1e9;
const double EPS = 1e-11;

// ????¬????
struct P3{
  double x,y,z;
  double vx,vy,vz;
  double r,vr;
  P3(double x=0, double y=0, double z=0):x(x),y(y),z(z){}
  P3 operator + (const P3 &a) const{ return P3(x+a.x, y+a.y, z+a.z); }
  P3 operator - (const P3 &a) const{ return P3(x-a.x, y-a.y, z-a.z); }
  P3 operator * (const double &c) const{ return P3(x*c, y*c, z*c); }
  void input(){cin>>x>>y>>z>>vx>>vy>>vz>>r>>vr;}
  P3 v ()const{return P3(vx,vy,vz);}
};
P3 operator * (double c, const P3 &a){ return P3(c * a.x, c * a.y, c * a.z); }


double norm(P3 a){ return a.x*a.x + a.y*a.y + a.z*a.z; }
double abs(P3 a){ return sqrt(norm(a)); }

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

double calc(P3 A,P3 B,double t){
  if((A.r-t*A.vr)<0|| (B.r-t*B.vr)<0) return -1;
  return abs((A+t*A.v())-(B+t*B.v())) - ((A.r-t*A.vr) + (B.r-t*B.vr));
}

double calc(P3 A,P3 B){
  double L=0,R=INF,cnt = 100;
  while(cnt--){
    double M = (L+R)/2;
    double y1 = calc(A,B,M);
    double y2 = calc(A,B,M+EPS);
    if(y1<0||y1-y2<0) R = M;
    else L = M+EPS;
  }
  return L;
}

int main(){
  int n;
  while(cin>>n,n){
    vector<P3>A(n);
    for(int i=0;i<n;i++) A[i].input();

    priority_queue<PP,vector<PP>,greater<PP> >Q;
    for(int i=0;i<n;i++)
      for(int j=i+1;j<n;j++){
	double t = calc(A[i],A[j]);
	if(abs(calc(A[i],A[j],t))<2e-8)Q.push(PP(t,P(i,j)));
      }

    vector<double> ans(n,-1);
    while(!Q.empty()){
      PP t = Q.top();Q.pop();
      double c = t.first;
      int a = t.second.first;
      int b = t.second.second;
      if(ans[a]>=0||ans[b]>=0)continue;
      ans[a] = ans[b] = c;
    }

    for(int i=0;i<n;i++){
      if(ans[i]<0) ans[i] = A[i].r / A[i].vr;
      ans[i] = min(ans[i],A[i].r / A[i].vr);
      printf("%.10Lf\n",ans[i]);
    }    
    
  }
  return 0;    
}

Measured memory_bytes: 3260
#include <stdio.h>
#include <stack>
#include <math.h>

using namespace std;


int main(){

	int n,m,table[100][100],checkTable[100],fixed[100],count,num,tmp_min,min_index,a,b,dist;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		for(int i = 0; i < n; i++){
			checkTable[i] = 0;
			for(int k = 0; k < n; k++)table[i][k] = 0;
		}

		scanf("%d",&m);

		for(int i = 0; i < m; i++){
			scanf("%d,%d,%d",&a,&b,&dist);
			table[a][b] = dist;
			table[b][a] = dist;
		}

		checkTable[0] = 1;	//0?????????????°???¨?????¨??°??????????????????
		fixed[0] = 0;
		count = 1,num = 0;

		//????°???¨?????¨??¢?????´?????????
		while(count < n){
			tmp_min = 2147483647;

			//????°???¨?????¨??¨?????°?????????????????????????????????????±???????
			for(int i = 0; i < count; i++){
				for(int k = 0; k < n; k++){
					if(table[fixed[i]][k] > 0 && checkTable[k] == 0 && table[fixed[i]][k] < tmp_min){
						tmp_min = table[fixed[i]][k];
						min_index = k;
					}
				}
			}

			num += (tmp_min/100)-1;
			checkTable[min_index] = 1;
			fixed[count] = min_index;
			count++;
		}

		printf("%d\n",num);

	}

    return 0;
}

Measured memory_bytes: 2732
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  string output = "NO";
  for(int i=0;i<b;i++){
    if(a*i%b==c){
      output = "YES";
      break;
    }
  }
  cout << output << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl d(n);
  rep(i, n) cin >> d[i];
  sort(all(d));
  cout << d[n / 2] - d[n / 2 - 1] << endl;
}

Measured memory_bytes: 3992
#include <iostream>
#include<string>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<set>
#include <limits>
#include <numeric>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define fi first
#define se second
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
#define MAX_B 1001001
#define NIL -1
#define MOD 1000000007
#define INF 1 << 29
#define INFTY 1000000000000000000LL
int dp[3010][3010];
//dp[i][j]:=(sのi文字目まで,tのj文字目まででできる最長の部分文字列の文字数)
int main(){
  string s,t;cin>>s>>t;
  rep(i,3010)rep(j,3010)dp[i][j]=0;
  int n=s.length(),m=t.length();
  rep(i,n+1)rep(j,m+1){
    if(s[i]==t[j]){
      dp[i+1][j+1]=max(dp[i][j]+1,dp[i+1][j+1]);
    }
    else dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
  }
  //ここからdpの復元
  string res="";
  int i=s.size(),j=t.size();
  while(i>0 && j>0){
    if(dp[i][j]==dp[i-1][j]){//(i-1,j)->(i,j)と更新されていた場合
      --i;
    }
    else if(dp[i][j]==dp[i][j-1]){
      --j;
    }
    else{
      res=s[i-1]+res;
      --i;--j;
    }
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 35712
// template.cpp {{{
#include <bits/stdc++.h>
using namespace std;

using lint = long long;
#define reps(i, a, n) for (lint i = (a); i < (lint)(n); ++i)
#define rep(i, n) reps(i, 0, n)
struct pre_{pre_(){cin.tie(0);ios::sync_with_stdio(0);}} pre__;
// }}}

signed main() {
  int n, m;
  int sum = 0;
  int t[100];
  cin >> n;
  rep(i, n) {
    cin >> t[i];
    sum += t[i];
  }
  cin >> m;
  rep(i, m) {
    int p, x;
    cin >> p >> x;
    cout << sum - t[p - 1] + x << endl;
  }
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i,n,v,j,t;
	scanf("%d",&n);
	if(n>100)
	{
		return 0;
	}
	int A[n];
	for(i=0;i<=n-1;i++)
	{
		scanf("%d",&A[i]);
	}
	for (i=0;i<n;i++)
	{
		v=A[i];
		j=i-1;
		while(j>=0&&A[j]>v)
		{
			A[j+1]=A[j];
			j--;
		}
			A[j+1]=v;
		
		for(t=0;t<=n-1;t++)
		{
			printf("%d",A[t]);
			
			if(t<n-1)
			{
				printf(" ");
			}
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2100
#include <stdio.h>
#include <string.h>

int main(void) {
    int n = 0;
    char c[100];
    scanf("%d", &n);
    scanf("%s", c);
    if (n >= strlen(c)) {
      puts(c);
    } else {
      for(int i = 0; i < n; i++) {
          printf("%c", c[i]);
      }
      puts("...");
    }
    return 0;
}

Measured memory_bytes: 2076
#include<cstdio>
#include<algorithm>
long long x[100000], v[100000], s[2][100000], t[2][100000];
int main() {
	long long n, c, i, ans;
	scanf("%lld%lld", &n, &c);
	for (i = 0; i < n; i++) scanf("%lld%lld", &x[i], &v[i]);
	s[0][0] = v[0];
	for (i = 1; i < n; i++)s[0][i] = s[0][i - 1] + v[i];
	s[1][n - 1] = v[n - 1];
	for (i = n - 2; i >= 0; i--)s[1][i] = s[1][i + 1] + v[i];
	for (i = 0; i < n; i++) {
		s[0][i] -= x[i];
		s[1][i] -= c - x[i];
		t[0][i] = s[0][i] - x[i];
		t[1][i] = s[1][i] - (c - x[i]);
	}
	t[0][0] = std::max(t[0][0], (long long)0);
	for (i = 1; i < n; i++) t[0][i] = std::max(t[0][i - 1], t[0][i]);
	t[1][n - 1] = std::max(t[1][n - 1], (long long)0);
	for (i = n - 2; i >= 0; i--)t[1][i] = std::max(t[1][i + 1], t[1][i]);
	for (i = 0; i < n - 1; i++) s[0][i] += t[1][i + 1];
	for (i = 1; i < n; i++)s[1][i] += t[0][i - 1];
	std::sort(s[0], s[0] + n);
	std::sort(s[1], s[1] + n);
	if (s[0][n - 1] < 0)s[0][n - 1] = 0;
	printf("%lld", std::max(s[0][n - 1], s[1][n - 1]));
	return 0;
}


Measured memory_bytes: 4864
n = int(input())
p = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
c = [0 for i in range(0, len(p))]

for i in range(0, len(p)):
    m = 1
    pi = p[i]
    while pi <= n:
        c[i] += n // pi
        m += 1
        pi = p[i]**m
        
c74 = 0
c24 = 0
c14 = 0
c4 = 0
c2 = 0

for i in range(0, len(p)):
    if c[i] >= 2:
        c2 += 1
    if c[i] >= 4:
        c4 += 1
    if c[i] >= 14:
        c14 += 1
    if c[i] >= 24:
        c24 += 1
    if c[i] >= 74:
        c74 += 1

print(c74 + (c4 - c14) * c14 + c14 * (c14 - 1) + (c2 - c24) * c24 + c24 * (c24 - 1) + (c2 - c4) * c4 * (c4 - 1) // 2 + c4 * (c4 - 1) * (c4 - 2) // 2)

Measured memory_bytes: 3064
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College

'''
from os import path
import sys
from heapq import heappush,heappop
from functools import cmp_to_key as ctk
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
mod=1000000007
# mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]

def bo(i):
    return ord(i)-ord('a')

file=0





def solve():


    # for _ in range(ii()):
    
        

    l,r,d=mi()
    ans=0
    for i in range(l,r+1):
        if i%d==0:
            ans+=1
    print(ans)








        
if __name__ =="__main__":

    if(file):

        if path.exists('input1.txt'):
            sys.stdin=open('input1.txt', 'r')
            sys.stdout=open('output1.txt','w')
        else:
            input=sys.stdin.readline
    solve()


Measured memory_bytes: 68200
import sys
  
r = []
for l in sys.stdin:
    s,w_str,h_str = l.split(',')
    w = float(w_str)
    h = float(h_str)
    bmi = w/(h**2)
    if bmi >= 25:
        r.append(s)

print(*r, sep='\n')



Measured memory_bytes: 5596
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

int main(){
	int n;
	cin >> n;
	for(int i=0; i<n; i++){
		int t, x, y;
		cin >> t >> x >> y;
		if(x+y>t || (x+y)%2 != t%2){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001



int main(){
    int N; cin >> N;
    vector<int> L(N);
    int s = 0;
    for(int i=0; i<N; i++){
        cin >> L[i];
        s+=L[i];
    }
    sort(L.begin(), L.end());
    s -= L[N-1];
    if(L[N-1]<s) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

using namespace std;
typedef long long Int;
Int dp[108000][2];
int n;
Int a[108000];
int main(){
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> a[i];
  }
  dp[0][0] = 0;
  dp[0][1] = 0;
  for(int i = 1;i <= n;i++){
    dp[i][0] = max(dp[i][0], dp[i-1][0] + a[i-1] / 2);
    if(a[i-1] >= 1)dp[i][0] = max(dp[i][0], dp[i-1][1] + (a[i-1] - 1) / 2 );
    if(a[i] > 0 && a[i-1] > 0)dp[i][1] = max(dp[i][1], dp[i-1][0] + (a[i-1] - 1) / 2 + 1);
    if(a[i] > 0 && a[i-1] > 1)dp[i][1] = max(dp[i][1], dp[i-1][1] + (a[i-1] - 2) / 2 + 1);
  }
  cout << dp[n][0] << endl;
  return 0;
}


Measured memory_bytes: 3192
use std::io;
use std::str::FromStr;
use std::cmp::min;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn dfs(left: i64, a_vec: &Vec<u64>, b_vec: &Vec<u64>, memo: &mut Vec<u64>) -> u64 {
    if left <= 0 {
        return 0;
    }
    if memo[left as usize] != std::u64::MAX {
        return memo[left as usize];
    }
    let mut min_val = std::u64::MAX;
    for i in 0..a_vec.len() {
        let tmp = dfs(left - a_vec[i] as i64, a_vec, b_vec, memo) + b_vec[i];
        min_val = min(min_val, tmp);
    }
    memo[left as usize] = min_val;
    min_val
}

fn main() {
    let (h, n) = input_tuple();
    let mut a_vec: Vec<u64> = Vec::new();
    let mut b_vec: Vec<u64> = Vec::new();
    for _ in 0..n {
        let (a, b) = input_tuple();
        a_vec.push(a);
        b_vec.push(b);
    }
    let mut memo: Vec<u64> = vec![std::u64::MAX; (h + 1) as usize];
    println!("{}", dfs(h as i64, &a_vec, &b_vec, &mut memo));
}


Measured memory_bytes: 4988
#include "bits/stdc++.h"
using namespace std;

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

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

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

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

template<typename T>
ostream& operator << (ostream& os, const set<T>& s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	ll a, b, x;
	cin >> a >> b >> x;

	cout << (b + x) / x - (a + x - 1) / x << endl;
	
	return 0;
}

Measured memory_bytes: 256
# Transit Tree Path

N = int(input())
p =[]
for i in range(N-1):
    p.append(list(map(int, input().split())))
Q,K = list(map(int, input().split()))
r = []
for i in range(Q):
    r.append(list(map(int, input().split())))

#隣接行列
adj = [[] for i in range(N+1)]
for pi in p:
    adj[pi[0]].append((pi[1],pi[2]))
    adj[pi[1]].append((pi[0],pi[2]))
adj


from collections import deque #decue使う
dist = [-1]*(N+1) #距離リスト
dist[K] = 0 #頂点Kからの距離は0
d = deque() #探索済みのリスト
d.append(K)
while len(d):
    pp = d.popleft() #探索中の頂点
    for q,c in adj[pp]:
        if dist[q] != -1:
            continue
        dist[q] = dist[pp]+c
        d.append(q)
for i in range(Q):
    x, y = r[i]
    print(dist[x]+dist[y])

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

using namespace std;

int main(void){
  int N;
  cin >> N;
  if(N & (N - 1)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
    return 0;
  }
  cout << 1 << " " << 2 << endl;
  cout << 2 << " " << 3 << endl;
  cout << 3 << " " << N + 1 << endl;
  cout << N + 1 << " " << N + 2 << endl;
  cout << N + 2 << " " << N + 3 << endl;
  for(int i = 4; i < N; i += 2){
    cout << i << " " << i + 1 << endl;
    cout << i + 1 << " " << N + 1 << endl;
    cout << i + N << " " << N + 1 << endl;
    cout << i + 1 + N << " " << i + N << endl;
  }
  if(N % 2 == 0){
    int b = 1;
    int NN = N;
    while(NN > 1){
        NN >>= 1;
        b <<= 1;
    }
    cout << N << " " << b + N << endl;
    cout << 2 * N << " " << (b ^ N ^ 1) << endl;
  }
  return 0;
}


Measured memory_bytes: 2816
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int A,B,n;
#define Maxn 4005
bool honest[Maxn];
int stack[Maxn],top;
char str[10];

inline char ask(int x,int y){
    printf("? %d %d\n",x,y);
    fflush(stdout);
    scanf("%s",str);
    return str[0];
}

int main(){
    scanf("%d%d",&A,&B);
    n=A+B;
    if(A<=B){
        puts("Impossible");
        return 0;
    }
    stack[++top]=0;
    for(register int i=1;i<n;++i){
        if(!top)stack[++top]=i;
        else{
        if(ask(stack[top],i)=='N')top--;
        else stack[++top]=i;
    }
    }
    int res=stack[top];
    honest[res]=true;
    for(register int i=0;i<n;++i)
        if(i!=res){
            if(ask(res,i)=='Y')honest[i]=true;
            else honest[i]=false;
        }
    printf("! ");
    for(register int i=0;i<n;++i)
        if(honest[i])printf("1");
        else printf("0");
    puts("");
    return 0;
}

Measured memory_bytes: 724
char buf[20000];sz;
int rd()
{
	int ret=0;
	for(;;)
	{
		char k=buf[sz++];
		if(k<'0')break;
		ret=ret*10+k-'0';
	}
	return ret;
}
int d[3001];
const int mod=998244353;
main()
{
	read(0,buf,20000);
	int N=rd();
	int S=rd();
	int ans=0;
	for(int i=0;i<N;i++)
	{
		++d[S];
		for(int j=rd(),k=0;j<=S;j++,k++)
		{
			d[k]+=d[j];
			if(d[k]>=mod)d[k]-=mod;
		}
		ans+=d[0];
		if(ans>=mod)ans-=mod;
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){

int a[1000];
int n;


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


int j;
for(j=n-1;j>-1;j=j-1){
    cout<<a[j];
        if(j>0){cout<<" ";}
        if(j==0){cout<<endl;}
        }
}


Measured memory_bytes: 3084
n = int(input())
R =[0 for i in range(n)]
for i in range(n):
	R[i] = int(input())
minv = R[0]
maxv = R[1]-R[0]
for i in range(1,n):
	maxv = max(maxv,R[i]-minv)
	minv = min(minv,R[i])
print(maxv)


Measured memory_bytes: 13604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, num, f;
  cin >> N;
  int sum = 0;
  num = N;
  while(num){
    f = num % 10;
    sum += f;
    num = num / 10;
  }
  if(N % sum == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main(){
	int a, b, x;
	bool end=false;
	char op;
	while(1){
		cin>>a>>op>>b;
		switch(op){
			case '+':
				x=a+b;
				break;
			case '-':
				x=a-b;
				break;
			case '*':
				x=a*b;
				break;
			case '/':
				x=a/b;
				break;
			case '?':
				end=true;
				break;
		}
		if(end) break;
		cout<<x<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

template <typename T>
struct WUF {
  int n, c;
  vector<int> p;
  vector<T> dw;
  WUF() {}
  WUF(int n) : n(n), c(n), p(n, -1), dw(n) {}
  int find(int x) {
    if (p[x] < 0) return x;
    int r = find(p[x]);
    dw[x] += dw[p[x]];
    return p[x] = r;
  }
  int unite(int x, int y, T w) {
    w += weight(x); w -= weight(y);
    x = find(x); y = find(y);
    if (x == y) return w == 0;
    if (p[x] > p[y]) swap(x,y), w = -w;
    p[x] += p[y];
    p[y] = x;
    dw[y] = w;
    c--;
    return 1;
  }
  T weight(int x) {
    find(x);
    return dw[x];
  }
  T diff(int x, int y) {
    assert(same(x, y));
    return weight(y) - weight(x);
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  int size(int x) {
    return -p[find(x)];
  }
  int count() {
    return c;
  }
};

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n,q;
  cin >> n >> q;
  WUF<int> wuf(n);
  REP(i,q) {
    int c;
    cin >> c;
    if (c == 0) {
      int x,y,z;
      cin >> x >> y >> z;
      wuf.unite(x,y,z);
    } else {
      int x,y;
      cin >> x >> y;
      if (wuf.same(x,y)) cout << wuf.diff(x,y) << endl;
      else cout << "?" << endl;
    }
  }

  return 0;
}


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

using ll = long long;

const ll MOD = 1e9 + 7;

ll fpow(ll a, ll b) {
    if (b == 1) return a;
    ll ret = fpow(a, b / 2);
    ret = (ret * ret) % MOD;
    if (b & 1)  ret = (ret * a) % MOD;
    return ret;
}

ll inv(ll x) {
    return fpow(x, MOD - 2);
}

vector<ll> primes;
bitset<1000005> isp;
long long lpf[1000005];
unordered_map<ll, ll> mx;

void sieve() {
    isp.set();
    isp[0] = isp[1] = false;
    for (ll i = 2; i <= 1000000; i++) {
        if (isp[i]) {
            primes.push_back(i);
            lpf[i] = i;
            for (ll nx = i * i; nx <= 1000000; nx += i) {
                isp[nx] = false;
                lpf[nx] = i;
            }
        }
    }    
}

#define fi first
#define se second

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    ll a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }    
    sieve();
    for (int i = 0; i < n; i++) {
        unordered_map<ll, ll> tm;

        ll titit = a[i];
        while(titit != 1){
            tm[lpf[titit]]++;
            titit /= lpf[titit];
        }
        for (auto it: tm) {
            mx[it.fi] = max(mx[it.fi], it.se);
        }
    }

    ll lc = 1;
    for (auto it: mx) {
        lc = (lc * fpow(it.fi, it.se)) % MOD;
    }
    ll b[n];
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        b[i] = (lc * inv(a[i])) % MOD;
        ans = (ans + b[i]) % MOD;
    }
    cout << ans << '\n';
    return 0;
}

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

int     main() {
        int K, T;
        cin >>K >>T;
        int a=0;
        for (int i=0; i<T; i++) {
                int a0;
                cin >>a0;
                a=max(a, a0);
        }
        K -=a;
        a -=K;
        a--;
        a=max(0, a);
        cout <<a <<endl;
        return 0;
};

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


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

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a, b, c, d, e;
    int k;

    int flag;

    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &d);
    scanf("%d", &e);
    scanf("%d", &k);

    flag = 0;

    if(b-a > k){
        flag = 1;
    }
    if(c-a > k){
        flag = 1;
    }
    if(d-a > k){
        flag = 1;
    }
    if(e-a > k){
        flag = 1;
    }

    if(c-b > k){
        flag = 1;
    }
    if(d-b > k){
        flag = 1;
    }
    if(e-b > k){
        flag = 1;
    }

    if(d-c > k){
        flag = 1;
    }
    if(e-c > k){
        flag = 1;
    }

    if(e-d > k){
        flag = 1;
    }

    if(flag == 0){
        printf("Yay!");
    }else{
        printf(":(");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

const int N = 1000;

int id[N], p[N], q[N], r[N], n, P, Q, R, C;

main(){
  while(cin >> n && n){
    for(int i=0;i<n;i++) cin >> id[i] >> p[i] >> q[i] >> r[i];
    cin >> P >> Q >> R >> C;
    int cnt = 0;
    for(int i=0;i<n;i++){
      if(p[i] > P || q[i] > Q || r[i] > R || 4 * p[i] + 9 * q[i] + 4 * r[i] > C) continue;
      ++cnt, cout << id[i] << endl;
    }
    if(!cnt) cout << "NA" << endl;
  }
}

Measured memory_bytes: 884
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        if (scanner.hasNextLine()) {
            String[] array = scanner.nextLine().split(" ");
            int A = Integer.parseInt(array[0]);
            int B = Integer.parseInt(array[1]);
            int K = Integer.parseInt(array[2]);

            if (A + K >= B - K + 1) {
                for (int i = A; i <= B; i++) {
                    System.out.println(i);
                }
            } else {
                for (int i = A; i < A + K; i++) {
                    System.out.println(i);
                }
                for (int i = B - K + 1; i <= B; i++) {
                    System.out.println(i);
                }
            }
        }
    }
}

Measured memory_bytes: 22608
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  string s;
  long K;
  cin >> s >> K;

  rep (i, s.size()) {
    if (s[i] == 'a') continue;
    long diff = 'z' + 1 - s[i];
    if (diff > K) continue;
    K -= diff;
    s[i] = 'a';
  }

  K %= 26;
  s[s.size() - 1] = 'a' + (s[s.size() - 1] - 'a' + K) % 26;

  cout << s << endl;
}

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


Measured memory_bytes: 592
k = gets.chomp.to_i
queue = [*1..9]
ans = -1
k.times do
    ans = queue.shift
    tmp = ans % 10
    queue << ans * 10 + tmp - 1 if tmp != 0
    queue << ans * 10 + tmp
    queue << ans * 10 + tmp + 1 if tmp != 9
end
puts ans

Measured memory_bytes: 3964
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.LinkedList;

public class Main {

	private static int calcCombineNum(int sum, int lack, int[] list) {
		// 計算
		int combiNum=(int)Math.pow(list.length, lack);
		int[] sums=new int[combiNum];
		Arrays.fill(sums, 0);
		for(int i=0; i<sums.length; i++) {
			int t=1;
			for(int j=0; j<lack; j++) {
				int index=(i/t)%list.length;
				sums[i]+=list[index];
				t*=list.length;
			}
		}
		// 判定
		int count=0;
		for(int i=0; i<sums.length; i++)
			if(sum==sums[i]%10)
				count++;
		return count;
	}

	private static int bai(int val) {
		return val>=5?(val-4)*2-1:2*val;
	}

	private static boolean isEven(int i, int length) {
		return (length-i)%2==0;
	}

	public static void main(String[] args) throws NumberFormatException, IOException {

		/** IDの桁数 */
		int n;
		/** 入力されたID */
		int lackOdd=0, lackEven=0, sum=0;
		/** 数字の候補の数 */
		int m;

		// データ読み込み
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		n=Integer.parseInt(br.readLine());
		char[] charArray=br.readLine().toCharArray();
		for(int i=0; i<charArray.length; i++) {
			if(charArray[i]=='*')
				if(isEven(i, charArray.length))
					lackEven++;
				else
					lackOdd++;
			else
				if(isEven(i, charArray.length))
					sum+=bai(Integer.parseInt(charArray[i]+""));
				else
					sum+=Integer.parseInt(charArray[i]+"");
		}
		m=Integer.parseInt(br.readLine());
		String line=br.readLine();
		String[] strArray=line.split(" ");
		LinkedList<Integer> tempCandidate=new LinkedList<Integer>();
		for(int i=0; i<m; i++) {
			int tempNum=Integer.parseInt(strArray[i]);
			tempCandidate.add(tempNum);
		}
		br.close();

		// 求める
		int num=10-sum%10;
		num%=10;
//		System.out.println("num: "+num);
		int[] evenList=new int[tempCandidate.size()];
		int count=0;
		for(int val: tempCandidate)
			evenList[count++]=bai(val);
		int[] oddList=new int[tempCandidate.size()];
		count=0;
		for(int val: tempCandidate)
			oddList[count++]=val;

		count=0;
		for(int i=0; i<10; i++) {
			// (i+j)%10=numとなるjを作る
			int j=i<=num?(num-i):(num-i+10);
			// 偶数でiをつくり，奇数でjを作る
			int c1=calcCombineNum(i, lackEven, evenList);
			int c2=calcCombineNum(j, lackOdd, oddList);
			count+=c1*c2;
//			System.out.println("(i, j) = ("+i+", "+j+")\tc1="+c1+"\tc2="+c2);
		}

		// 出力
		System.out.println(count);

	}
}

Measured memory_bytes: 53604
#include <bits/stdc++.h>
#define lowbit(x) ((x)&(-x))
#define mem(i, a) memset(i, a, sizeof(i))
#define sqr(x) ((x)*(x))
#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)
typedef long long ll;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const int maxn = 2e6 + 7;
using namespace std;
ll arr[maxn];
int main(void){
#ifdef ljxtt
freopen("data.in", "r", stdin);
#endif
    int i; cin >> i;
    for(int i = 1; i < maxn; i++){
        if(i % 3 && i % 5) arr[i] = i;
        else arr[i] = 0;
    }
    for(int i = 1; i < maxn; i++){
        arr[i] += arr[i - 1];
    }
    cout << arr[i] << endl;
    return 0;
}

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

int main()
{
  char c;
  set<char> st;
  for (int i = 0; i < 3; i++) {
    cin >> c;
    st.insert(c);
  }
  if (st.size() == 3) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

ll ten[11];

void query(ll n){
    cout<<"? "<<n<<endl;
}

bool answer(){
    char c;
    cin>>c;
    if(c=='Y') return true;
    else return false;
}

int main(){
  ten[0]=1;
  for(int i=1;i<=10;i++) ten[i]=ten[i-1]*10;

  query(ten[10]);
  if(answer()){
      int it=0;
      for(int i=9;i>=1;i--){
          query(ten[i]-1);
          if(answer()==false){
              it=i;
              break;
          }
      }
      cout<<"! "<<ten[it]<<endl;
      return 0;
  }

  int digit=1;
  for(int i=1;i<=9;i++){
      query(ten[i]);
      if(answer()) digit++;
      else break;
  }

  ll ans=0;
  for(int d=1;d<=digit;d++){
      if(d==digit){
        int ok=9,ng=-1;
        while(abs(ok-ng)>1){
            int mid=(ok+ng)/2;
            ll res=ans*10+mid;
            res*=1e9;
            query(res);
            if(answer()) ok=mid;
            else ng=mid;
        }
        ans=ans*10+ok;
      }else{
        int ok=0,ng=10;
        if(d==1) ok=1;
        while(abs(ok-ng)>1){
            int mid=(ok+ng)/2;
            ll res=ans*10+mid;
            query(res);
            if(answer()) ok=mid;
            else ng=mid;
        }
        ans=ans*10+ok;
      }
  }
  cout<<"! "<<ans<<endl;

  return 0;
}


Measured memory_bytes: 648