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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define rep(i, a) for (int i=0; i<(a); i++) 
#define ub        upper_bound            // first element >  val(itr)
#define lb        lower_bound            // first element >= val(itr)

#define mp make_pair
#define pb push_back
#define pi 3.141592653589793
//#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define bitcount(a) __builtin_popcount(a) // count set bits
#define all(x) (x).begin(),(x).end()

const ll MOD = 1e9 + 7;
const int inf = 1e9+9;
const long long INF = 1e18+3;

//to debug 
#define dbg(x) cout << "Line " << __LINE__ << " | " #x ": " << (x) << endl

template<typename T> T gcd(T a,T b){ if(b>a) return gcd(b,a);return b==0?a:gcd(b,a%b); }
template<typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template<typename T> T fast_power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

inline ll mod(ll x,ll n) {if (x < n) return x; if (x >= n) return x - n;}
string IntToString(ll a){ ostringstream temp; temp << a; return temp.str();}
ll findMMI_fermat(ll n,ll M) {ll ans= fast_power(n,M-2,M);return ans;}//i.e In (a/b)%M..it calculates MMI of b wrt M,only if M is prime
ll add(ll a,ll b,ll M)  { return ( mod(a,M ) + mod(b,M ))%M;     }
ll sub(ll a, ll b,ll M) { return (mod(a,M ) + M - mod(b,M ))%M;   }
ll mult(ll a,ll b,ll M) { return  ( mod(a,M)*mod(b,M) ) %M ; }
bool isprime(ll a){ if(a==2) {return 1;}if(!(a&1) ) {return 0;}for(ll i=3;i*i<=a;i+=2){if(a%i==0) {return 0;} } return 1;} 

  
               /* -------------------------------Main Code------------------------------- */



int main() {
	FAST
	int n;cin>>n;
	double a[n];
	double den = 0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		den += (1/a[i]);
	}
	double ans = 1/den;
	cout.precision(6);
	cout<<ans<<endl;
 	return 0;
	
}

	

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

vector<int> g[100010];
vector<int> color(100010, 0);
vector< vector<bool> > dp;

void search(int d, int v, int c) {
    if(dp[v][d]) return;
    dp[v][d] = true;
    if(color[v]==0) color[v] = c;
    if(d==0) {
        //color[v] = c; 
        return;
    }
    search(d-1, v, c);
    for(int i=0;i<g[v].size();i++) {
        search(d-1, g[v][i], c);
    }

}

int main() {
    dp = vector< vector<bool> >(100010, vector<bool>(12, false));
    ll n, m;
    cin >> n >> m;
    for(int i=0;i<m;i++) {
        int ai, bi;
        cin >> ai >> bi;
        ai--; bi--;
        g[ai].push_back(bi);
        g[bi].push_back(ai);
    }
    int Q;
    cin >> Q;
    vector<int> v(Q), dv(Q), cv(Q);
    for(int i=0;i<Q;i++) {
        cin >> v[i] >> dv[i] >> cv[i];
        v[i]--;
    }

    for(int i=Q-1;i>=0;i--) {
        search(dv[i], v[i], cv[i]);
    }

    for(int i=0;i<n;i++) {
        cout << color[i] << endl;
    }

}


Measured memory_bytes: 16760
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<assert.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
int N,x,y,pos,tri0,tri1,tri2,pw3[13]={1},A[531441],salsa[531441],sw[200001];
char T[200001];
void OUT(int x){if(x<0)putchar('-'),x=-x;if(x>=10)OUT(x/10);putchar(x%10+48);}
char* replace(char* s,const char* before,const char* after)
{
  assert(s!=(char*)NULL);assert(before!=(char*)NULL);assert(after!=(char*)NULL);
  const size_t szb=strlen(before),sza=strlen(after);
  char* pt=s;
  if(szb==0)return s;
  for(;;)
  {
    pt=strstr(pt,before);if(pt==(char*)NULL)break;const char* remain=pt+szb;
    memmove(pt+sza,remain,strlen(remain)+1);
    memcpy(pt,after,sza);
    pt+=sza;
  }
  return s;
}
signed main(void)
{
  x=scanf("%d %s",&N,T+1);
  replace(T+1,"SS","");if(T[0]=='\n')return 0;
  rep(i,N)pw3[i+1]=3*pw3[i];
  tri0=pw3[N],tri1=pw3[N/2],tri2=pw3[N-N/2];
  rep(i,tri0)salsa[i]=salsa[i/3]*3+(3-i%3)%3;
  rep(i,tri1)
  {
    x=i,pos=0;
    rep(j,strlen(T+1))
    {
      if(T[j+1]=='S'){x=salsa[x];if(sw[pos]>0)pos--;else sw[++pos]=1;}
      if(T[j+1]=='R'){x++;if(x==tri1)sw[++pos]=-1,x=0;}
    }
    rep(j,tri2)
    {
      y=j;
      rep(k,pos){if(sw[k+1]>0)y=salsa[y];else if(sw[k+1]<0){if((++y)==tri2)y=0;}}
      A[i+j*tri1]=y*tri1+x;
    }
  }
  rep(i,tri0)OUT(A[i]),putchar('\t');
}

Measured memory_bytes: 8204
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
typedef long long ll;

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007
#define MODB  998244353 

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

int main() {
	ll ans = 0;
	ll tmp;
	int n; cin >> n;
	int q; cin >> q;
	int t, p, x, l, r;
	fenwick_tree<ll> fw(n);
	REP(i, n){
		cin >> tmp;
		fw.add(i, tmp);
	}
	REP(i, q){
		cin >> t;
		if(t==0){
			cin >> p >> x;
			fw.add(p, x);
		}
		else{
			cin >> l >> r;
			cout << fw.sum(l, r) << endl;
		}
	}
	//cout << ans << endl;
}

Measured memory_bytes: 8220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1001001001;

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	ll d = 50;
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vector<vector<ll>> dp(d + 1, vector<ll>(2, -1));
	dp[0][1] = 0;

	for (int i = 1; i <= d; i++) {
		ll mask = 1LL << d - i;
		ll num = 0;
		for (int j = 0; j < n; j++) if (a[j] & mask) num++;
		ll count1 = mask * num;
		ll count0 = mask * (n - num);

		if (dp[i - 1][1] != -1) {
			if (k & mask) {
			dp[i][0] = dp[i - 1][1] + count1;
			dp[i][1] = dp[i - 1][1] + count0;
			}
			else dp[i][1] = dp[i - 1][1] + count1;
		}

		if (dp[i - 1][0] != -1) {
			dp[i][0] = max(dp[i][0], dp[i - 1][0] + max(count0, count1));
		}
	}
	cout << max(dp[d][0], dp[d][1]) << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main() {
    int n;
    scanf("%d", &n);
    int t, count = 0;
    for (int i = 0; i < n; i++) {
        if (count > 0) {
            break;
        }
        scanf("%d", &t);
        if (t % 2 == 0 ) {
            if (t % 3 == 0 || t % 5 == 0) {
                ;
            } else {
                count++;
            }
        }
    }
    if (count > 0) {
        printf("DENIED");
    } else {
        printf("APPROVED");
    }

    return 0;
}


Measured memory_bytes: 128
//
//  main.cpp
//  B - Frog 2
//
//  Created by Nishant Dhankhar on 15/01/19.
//  Copyright © 2019 Nishant Dhankhar. All rights reserved.
//

#include <bits/stdc++.h> //REMEMBER TO REMOVE '/'
#include <iostream>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
const int INF = 1e9;

signed main() {
    int n;
    cin>>n;
    int k;
    cin>>k;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int dp[n];
    dp[0]=0;
    
    for(int i=1;i<n;i++){
        dp[i]=INF;
        for(int j=1;j<=k;j++){
            if(i>=j)
            dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
        }
        
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
n,q=[int(_) for _ in input().split()]
ki=[[] for _ in range(n)]
ans=[0]*n
 
def dfs(numQ,parent):
    for child in ki[numQ]:
        if child==parent:
            continue
        ans[child]+=ans[numQ]
        dfs(child,numQ)
 
for i in range(n-1):
    a,b=[int(_) for _ in input().split()]
    ki[a-1].append(b-1)
    ki[b-1].append(a-1)
 
for i in range(q):
    p,x=[int(_) for _ in input().split()]
    ans[p-1]+=x
 
dfs(0,-1)
print(*ans)

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

struct Union_Find
{
	int n;
	vector<int> tree;

	Union_Find(int n) : n(n), tree(n, -1)
	{
	}

	int size(int x)
	{
		assert(0 <= x && x < n);
		return -tree[root(x)];
	}

	int root(int x)
	{
		assert(0 <= x && x < n);
		if (tree[x] < 0)
		{
			return x;
		}
		return tree[x] = root(tree[x]);
	}

	bool same(int x, int y)
	{
		assert(0 <= x && x < n && 0 <= y && y < n);
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		assert(0 <= x && x < n && 0 <= y && y < n);
		x = root(x);
		y = root(y);
		if (x == y)
		{
			return false;
		}
		if (tree[x] > tree[y])
		{
			swap(x, y);
		}
		tree[x] += tree[y];
		tree[y] = x;
		return true;
	}
};

int main()
{
	int64_t n, m;
	cin >> n >> m;
	vector<pair<int64_t, int64_t>> ps(m);
	for (auto &p : ps)
	{
		cin >> p.first >> p.second;
		p.first--;
		p.second--;
	}

	Union_Find uf(n);

	reverse(ps.begin(), ps.end());

	vector<int64_t> ans(m, n * (n - 1) / 2);

	for (int i = 0; i < m - 1; i++)
	{
		auto &p = ps[i];
		if (uf.same(p.first, p.second))
		{
			ans[i + 1] = ans[i];
		}
		else
		{
			int64_t a = uf.size(p.first), b = uf.size(p.second);
			ans[i + 1] = ans[i] - a * b;
			uf.merge(p.first, p.second);
		}
	}

	reverse(ans.begin(), ans.end());

	for (auto &x : ans)
	{
		cout << x << endl;
	}

	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string.h>

using namespace std;

#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define pb push_back
#define sz(s) (int)s.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)

const int N=(int)1e5+7;
const long long inf = (long long)1e16 + 7;

int main() {
    int n, a[1111], x = 0, mn = 1111, mx = 0;
    cin >> n;
    forn(i, n) cin >> a[i];
    sort(a, a + n);
    int y = 0, c = 0;
    forn(i, n) {

        if (a[i] >= 3200) {
            x++;
            continue;
        }

        if (a[i] < y) continue;
        else {
            while (a[i] >= y) y += 400;
            if (a[i] >= 3200) {
                x++;
                continue;
            }
            c++;
        }
    }
    if(!c) mn=1,mx=x;
    else mn=c,mx=c+x;
    cout << mn << " " << mx << endl;
    return 0;
}

Measured memory_bytes: 256
// <easy.cpp> - Mon Mar 27 20:17:23 2017
// This file is created by XuYike's black technology automatically.
// Copyright (C) 2015 ChangJun High School, Inc.
// I don't know what this program is.
 
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long lol;
#define next NEXT
template<typename T>
inline void gg(T &res){
    res=0;T fh=1;char ch=getchar();
    while((ch>'9'||ch<'0')&&ch!='-')ch=getchar();
    if(ch=='-')fh=-1,ch=getchar();
    while(ch>='0'&&ch<='9')res=res*10+ch-'0',ch=getchar();
    res*=fh;
}
inline int gi(){int x;gg(x);return x;}
inline lol gl(){lol x;gg(x);return x;}
const int MAXN=400010;
const int INF=1e9;
const int MOD=924844033;
int bt,b[MAXN],next[MAXN],to[MAXN];
inline void add(int x,int y){
    next[++bt]=b[x];b[x]=bt;to[bt]=y;
    next[++bt]=b[y];b[y]=bt;to[bt]=x;
}
int n,size[MAXN],A[MAXN<<1],B[MAXN<<1],L,R[MAXN<<1];
void dfs(int x,int f){
    A[n]++;size[x]=1;
    for(int i=b[x];i;i=next[i]){
        if(to[i]==f)continue;
        dfs(to[i],x);
        size[x]+=size[to[i]];
        if(--A[size[to[i]]]<0)A[size[to[i]]]+=MOD;
    }
    if(--A[n-size[x]]<0)A[n-size[x]]+=MOD;
}
int qpow(int x,int y){
    int res=1;
    while(y){
        if(y&1)res=1ll*res*x%MOD;
        x=1ll*x*x%MOD;
        y>>=1;
    }
    return res;
}
void ntt(int *a,int f){
    for(int i=0;i<n;i++)if(i<R[i])swap(a[i],a[R[i]]);
    for(int i=1;i<n;i<<=1){
        int gn=qpow(5,(MOD-1)/(i<<1));
        if(f < 0) gn = qpow(gn, MOD-2);
        for(int j=0;j<n;j+=i<<1){
            int g=1;
            for(int k=0;k<i;k++,g=1ll*g*gn%MOD){
                int x=a[j+k],y=1ll*g*a[j+k+i]%MOD;
                a[j+k]=(x+y)%MOD;
                a[j+k+i]=(x-y+MOD)%MOD;
            }
        }
    }
    if(f==-1){
     //   reverse(a+1,a+n);
        int ny=qpow(n,MOD-2);
        for(int i=0;i<n;i++)a[i]=1ll*a[i]*ny%MOD;
    }
}
int nj[MAXN];
int main(){
    n=gi();
    for(int i=1;i<n;i++)add(gi(),gi());
    dfs(1,0);
    int jc=1;
    for(int i=1;i<=n;i++)A[i]=1ll*A[i]*(jc=1ll*jc*i%MOD)%MOD;
    nj[n]=qpow(jc,MOD-2);for(int i=n;i;i--)nj[i-1]=1ll*nj[i]*i%MOD;
    for(int i=1;i<=n;i++)B[i]=nj[n-i];
    int m=n;
    for(n=1;n<=m<<1;n<<=1)L++;
    for(int i=0;i<n;i++)R[i]=R[i>>1]>>1|((i&1)<<(L-1));
    ntt(A,1);ntt(B,1);
    for(int i=0;i<n;i++)A[i]=1ll*A[i]*B[i]%MOD;
    ntt(A,-1);
    for(int i=1;i<=m;i++)printf("%d\n",1ll*A[m+i]*nj[i]%MOD);
    return 0;
}

Measured memory_bytes: 25728
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> a.at(i);
	}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	int Alice=0;
	int Bob=0;
	for (int i = 0; i < n; ++i)
	{
		if(i%2==0){
			Alice = Alice + a.at(i);
		}
		else{
			Bob = Bob + a.at(i);
		}
	}
	cout << Alice-Bob << endl;


}

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

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

	int n;
	cin >> n;
	int d[4] = {};
	for (int i = 0; i < 4; ++i) {
		d[i] = n % 10;
		n /= 10;
	}
	string answer = "No";
	if (d[1] == d[2]) {
		if (d[0] == d[1] || d[2] == d[3]) {
			answer = "Yes";
		}
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
int du[maxn];
int x,y;
int main()
{
    repd(i,1,3)
    {
    	cin>>x>>y;
    	du[x]++;
    	du[y]++;
    }
    repd(i,1,4)
    {
    	if(du[i]>=3)
    	{
    		printf("NO\n");
    		return 0;
    	}
    }
    printf("YES\n");
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



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

/*
int binSearch(vector<int> vec, int x)
{
  int l, r, i;
  
  for(l=0, r = vec.size(); r-l>1; i++)
    {
      i = (l+r)/2;

      if(vec[i]==x)
	return i;
      else if(k[i]<x)
	{
*/

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

  vector<int> A(N), B(N);  
  
  int i;
  for(i = 0; i < N; i++)
    cin >> A[i];

  //copy(A.begin(), A.end(), B.begin());

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

  int j, k;
  for(j = 0; j < N; j++)
      B[A[j]-1] = j+1;
  for(k=0;k<N;k++)
    {
      cout << B[k];
      if(k!=N-1)
	cout << " ";
      else
	cout << endl;
    }
  return 0;
}


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

int main() {
	const __uint128_t INF = 1e19;
	const __uint128_t MAX = 1e18;
	
	int n;
	cin >> n;

	__uint128_t val = 1;
	for (int i = 0; i < n; i++) {
		long long e;
		cin >> e;
		val *= e;
		val = min(val, INF);
	}
	
	if (val > MAX) cout << -1 << '\n';
	else cout << (long long)(val) << '\n';
	
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int n;cin>>n;
    vector<ll>V(n);
    for(int i=0;i<n;i++)cin>>V[i];
    sort(V.begin(),V.end());
    vector<ll>Ans;
    for(int i=0;i<n-1;i++){
        if(V[i]==V[i+1]){Ans.push_back(V[i]);i++;}
    }
    int s=Ans.size();
    if(s<2)cout<<0<<endl;
    else cout<<Ans[s-1]*Ans[s-2]<<endl;
}

Measured memory_bytes: 1660
def main():
    import sys
    import decimal
    input = sys.stdin.readline
    n, m, d = [int(x) for x in input().strip().split()]
    if d == 0:
        print((m-1)/n)
        return True
    print(((n-d)*2*(m-1) / pow(n, 2)))

if __name__ == '__main__':
    main()

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

namespace ABC061A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);
            if (a <= c && c <= b)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");

            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    string S;cin >> S;
    if(S == "SUN") cout << 7 << endl;
    if(S == "MON") cout << 6 << endl;
    if(S == "TUE") cout << 5 << endl;
    if(S == "WED") cout << 4 << endl;
    if(S == "THU") cout << 3 << endl;
    if(S == "FRI") cout << 2 << endl;
    if(S == "SAT") cout << 1 << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

n = ini()
a = inl()
ans = [0] * n
for i in a:
    ans[i-1] += 1
out(ans)

Measured memory_bytes: 32936
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            double a = in.nextDouble();
            double b = in.nextDouble();
            out.println(a / b);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
            this.bufPointer = 0;
            this.bufLength = 0;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isPrintableChar(int c) {
            return c >= 33 && c <= 126;
        }

        public String next() {
            StringBuilder sb = new StringBuilder();

            int b = readByte();
            while (!isPrintableChar(b))
                b = readByte();

            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }

            return sb.toString();
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }
}



Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main(){
	fast;
	ll s,w; cin>>s>>w;
	if(w>=s)cout<<"unsafe\n";
	else
		cout<<"safe\n";
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  vll a(n);
  REP(i, n) cin >> a[i];

  ll ans = a[0] / 2;
  ll carry = a[0] % 2;

  FOR(i, 1, n) {
    ans += (a[i] + carry) / 2;
    carry = (a[i] == 0) ? 0 : (a[i] + carry) % 2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cmath>
//#include<array>
#include<algorithm>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
//#include<map>
//#include<list>

using namespace std;
using LLI = long long int;

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//int gcd(int x, int y) {
//	int tmp, r;
//	if (x < y) {
//		tmp = x;
//		x = y;
//		y = tmp;
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

int main(void) {
	int A,B,C;
	cin >> A >> B >> C;
	int a = B / A;

	if (a >= C) {
		cout << C << endl;
	}
	else {
		cout << a << endl;
	}


}

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

int main()
{
	int N; cin >> N;
	int K; cin >> K;

	string S; cin >> S;

	int cnt1 = 0;
	int cnt2 = 0;
	int pre = -1;
	for (int i = 0; i < N; i++)
	{
		if (S[i] == pre)
		{
			cnt2++;
		}
		else
		{
			cnt1++;
		}
		pre = S[i];
	}

	cout<<cnt2 + min(2*K, cnt1-1)<<endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
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 (b<a) {a=b; return 1;} return 0;}


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, ll> mp;
    rep(i, n) {
        cin >> a[i];
        mp[a[i]]++;
    }
    ll ans = 0;
    for (auto p : mp) {
        ll j = p.second;
        ans += j*(j-1) / 2;
    }
    rep(i, n) {
        ll j = mp[a[i]];
        ll cur = ans - (j*(j-1) / 2) + ((j-1)*(j-2)/2);
        cout << cur << endl;
    }
}


Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1000000007;

int main(){
    long long n;
    cin>>n;
    long long a=pow(n,0.5);
    //aはnの平方根以下の整数
    //小さいほうがこれを超えることはないのでnで割れるか調べつつデクリメント
    while(a>0){
        if(n%a==0) break;
        a--;
    }
    long long b=n/a;
    rep(i,11){
        if(pow(10,i+1)>b){
            cout<<i+1<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import numpy as np
import itertools

N = int(input())
info = []
for i in range(N):
    A = int(input())
    for _ in range(A):
        x,y = map(int,input().split())
        info.append((i,x-1,y))
        
A = np.array(list(itertools.product([0,1],repeat=N)),np.bool)
for i,x,y in info:
    bl = (~A[:,i]) | (A[:,x] == bool(y))
    A = A[bl]
 
answer = A.sum(axis = 1).max()
print(answer)


Measured memory_bytes: 32824
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        sc.close();
        System.out.println((x - z) / (y + z));
    }
}

Measured memory_bytes: 35584
#include <stdio.h>

int main(void)
{
	int N;
	double v, t;
	
	while (scanf("%lf", &v) != EOF){
		t = v / 9.8;
		for (N = 1; 4.9 * t * t >= 5 * N - 5; N++){
		}
		printf("%d\n", N);
	}
	
	return (0);
}

Measured memory_bytes: 628
#include<bits/stdc++.h>
using namespace std;
long md = 1e9;
int main() {
  long n, k, s;
  cin>>n>>k>>s;
  
  if(s ==  md) {
  	for(long i = 1; i<=k; i++)
    	cout<<s<<" ";
    for(long i = k + 1; i<=n; i++)
      	cout<<1<<" ";  
  }
  else {
		for(long i = 1; i<=k; i++)
    		cout<<s<<" ";
    	for(long i = k + 1; i<=n; i++)
      		cout<<s+1<<" ";  
  }
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
#define SP << " " <<
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  998244353
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
template <class Mono = ll>
struct SegTree{
    using FuncMonoMono = function<Mono(Mono,Mono)>;
    FuncMonoMono operation; //区間クエリ
    FuncMonoMono setval; //点更新
    int N;
    vector<Mono> dat;
    Mono unitMono; //初期値であり単位元

    SegTree(int n, Mono unitm, FuncMonoMono _operation, FuncMonoMono _setval) : unitMono(unitm), operation(_operation), setval(_setval) {
        N = 1;
        while(N < n) N <<= 1;
        dat.resize(2*N-1, unitMono);
    }

    void update(int i, const Mono &val) { // 0-indexed
        i += (N - 1); //最下段に移動
        dat[i] = setval(dat[i],val);
        while(i > 0) { //上に向かって更新
            i = (i - 1) / 2;
            dat[i] = operation(dat[i*2+1], dat[i*2+2]);
        }
    }

    Mono _query(int a, int b, int k, int l, int r) {
        // [a,b)をみる。現在k,範囲[l,r)。0-indexed。
        if(r <= a or b <= l) return unitMono; //範囲外
        if(a <= l and r <= b) return dat[k]; //被覆
        Mono vl = _query(a, b, 2*k+1, l, (l+r)/2);
        Mono vr = _query(a, b, 2*k+2, (l+r)/2, r);
        return operation(vl, vr);
    }

    Mono query(int a, int b){ //[a,b)
        return _query(a,b,0,0,N);
    }

    inline Mono operator[](int i){
        return dat[i+N-1];
    }

};

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<P> XD;
    rep(i,N){
        ll xx,dd; cin>>xx>>dd;
        XD.emplace_back(xx,dd);
    }

    SORT(XD);

    vector<ll> X(N);
    rep(i,N) X[i]=XD[i].first;

    // sokokara ikerubasho
    ll ikeru[N];

    // max
    SegTree<> seg(N,-INF2,[](ll a, ll b){return max(a,b);}, [](ll a, ll b){return b;});

    rep(i,N){
        seg.update(i,i);
    }

    repr(i,N-1,0){
        ll basho=lower_bound(ALL(X), X[i]+XD[i].second)-X.begin();
        --basho;
        ll sai=seg.query(i,basho+1);
        ikeru[i]=sai;
        seg.update(i,sai);
    }

    //rep(i,N) de(ikeru[i]);

    ll dp[N+1]={};
    dp[0]=1;
    rep(i,N){
        dp[i+1]+=dp[i];
        dp[i+1]%=MOD;
        dp[ikeru[i]+1]+=dp[i];
        dp[ikeru[i]+1]%=MOD;
    }
    cout<< dp[N]<<"\n";

}

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


Measured memory_bytes: 13164
package main

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

var sc = bufio.NewScanner(os.Stdin)

func stringLineScan() string {
	sc.Scan()
	return sc.Text()
}

var searched []bool
var count int

func main() {
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(stringLineScan())
	s := stringLineScan()
	l := 0
	r := 0
	for i := 0; i < n; i++ {
		if string(s[i]) == "(" {
			r++
		} else {
			r--
		}
		if r == -1 {
			r++
			l++
		}
	}
	fmt.Println(strings.Repeat("(", l) + s + strings.Repeat(")", r))
}


Measured memory_bytes: 640
import sys

def solve():
    N, C, K = map(int, sys.stdin.readline().split())
    T = [int(sys.stdin.readline().rstrip()) for i in range(N)]
    T.sort()

    l = T[0]
    cnt = 1
    ans = 1

    for i in range(1, N):
        if T[i] - l <= K and cnt < C:
            cnt += 1
        else:
            l = T[i]
            cnt = 1
            ans += 1

    print(ans)


def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

if __name__ == '__main__':
    solve()

Measured memory_bytes: 7384
package main

import (
    "fmt"
    "os"
    "bufio"
    "strconv"
    // "sort"
)
var sc = bufio.NewScanner(os.Stdin)


func main() {
    sc.Split(bufio.ScanWords)
    // code goes here
    X, Y := nextInt(), nextInt()
    
    fmt.Println(X + Y/2);
}



func nextInt() int {
    sc.Scan()
    v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}
func nextInt64() int64 {
    sc.Scan()
    v, e := strconv.ParseInt(sc.Text(), 10, 64)
    if e != nil { panic(e) }
    return v
}
func nextString() string {
    sc.Scan()
    return sc.Text()
}
func nextFloat() float64 {
    sc.Scan()
    v, e := strconv.ParseFloat(sc.Text(), 64)
    if e != nil { panic(e) }
    return v
}
func Max(x, y int) int { if x > y { return x }; return y }
func Min(x, y int) int { if x < y { return x }; return y }
func Abs(x int) int { if x > 0 { return x }; return -x }



Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N, M, K := ReadInt(), ReadInt(), ReadInt()
	for i := 0; i <= M; i++ {
		for j := 0; j <= N; j++ {
			v := N*i + M*j - 2*i*j
			if v == K {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
from collections import defaultdict
N = int(input())
d = defaultdict(int)
for a in input().split():
    d[a] += 1
ls = [(k, d[k]) for k in d if d[k] >= 2]
if ls == []:
    print(0)
elif len(ls) == 1:
    print(0 if ls[0][1] < 4 else int(ls[0][0])**2)
else:
    ls.sort(key= lambda x: int(x[0]), reverse=True)
    m,n = ls[0],ls[1]
    print(int(m[0])*int(n[0]) if m[1] < 4 else int(m[0])**2)

Measured memory_bytes: 21416
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main() {
	int a;
	string s;
	cin >> a >> s;
	if (a>=3200){
		cout << s << endl;
	}
	else{
		cout << "red" << endl;
	}

	return 0;
}



Measured memory_bytes: 888
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Int n, a, b;
    cin >> n >> a >> b;

    Int ans = 0;
    for (Int i = 1; i <= n; i++) {
        Int tem = 0, I = i;
        while (I > 0) {
            tem += I % 10;
            I /= 10;
        }

        if (a <= tem && tem <= b) {
            ans += i;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

struct Point {double x, y;};

void koch(int n, Point a, Point b) {
  if (n == 0) return;

  Point s, t, u;
  double th = M_PI * 60.0 / 180.0;

  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n-1, a, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n-1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n-1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n-1, t, b);
}

int main() {
  Point a, b;
  int n;

  scanf("%d", &n);

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n", a.x, a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);

  return 0;
}



Measured memory_bytes: 2764
const lines: string[] = [];
const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});
reader.on("line", function (line: string) {
  lines.push(line);
});

reader.on("close", function () {
  const input = lines.shift();
  const res = input === "ABC" ? "ARC" : "ABC";
  console.log(res);
});


Measured memory_bytes: 30060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long int n,sum=0;cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    for(int i=0;i<n-1;i++){
        if(arr[i]>arr[i+1]){
            sum+=arr[i]-arr[i+1];
            arr[i+1]=arr[i];
        }
    }
    cout<<sum<<endl;
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  rep(i,s.size()) cout << 'x';
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//#include <vector>
//#include <climits>
std::vector<std::vector<long long>> warshall_floyd(long long n, long long m, std::vector<std::vector<long long>> &edge) {
	std::vector<std::vector<long long>> ret(n, std::vector<long long>(n, LLONG_MAX));
	for (long long i = 0; i < n; i++) ret[i][i] = 0;
	for (long long i = 0; i < m; i++) {
		ret[edge[i][0]][edge[i][1]] = std::min(ret[edge[i][0]][edge[i][1]], edge[i][2]);
	}
	for (long long k = 0; k < n; k++) {
		for (long long i = 0; i < n; i++) {
			for (long long j = 0; j < n; j++) {
				if (ret[i][k] < LLONG_MAX && ret[k][j] < LLONG_MAX) {
					ret[i][j] = std::min(ret[i][j], ret[i][k] + ret[k][j]);
				}
			}
		}
	}
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n, m, l;
	cin >> n >> m >> l;
	vector<vector<ll>> edge(0);
	for (ll i = 0; i < m; i++) {
		ll a, b, c;
		cin >> a >> b >> c;
		if (c > l) {
			i--;
			m--;
			continue;
		}
		a--; b--;
		edge.push_back({a, b, c});
		edge.push_back({b, a, c});
	}
	vector<vector<ll>> dist = warshall_floyd(n, 2 * m, edge);

	vector<vector<ll>> edge2(0);
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < n; j++) {
			if (dist[i][j] <= l) {
				edge2.push_back({i, j, 1});
			}
		}
	}
	vector<vector<ll>> cnt = warshall_floyd(n, edge2.size(), edge2);

	ll q;
	cin >> q;
	while (q--) {
		ll s, t;
		cin >> s >> t;
		s--; t--;
		if (cnt[s][t] == inf) cout << -1 << endl;
		else cout << cnt[s][t] - 1 << endl;
	}
}


Measured memory_bytes: 14540
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;
using ll = long long;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main()
{
	int f = 0, i, n;
	string s;

	cin >> s;
	n = s.length();

	for (i = 0; i < n - 1; i++) {
		if (s[i] == 'A' && s[i + 1] == 'C') {
			f = 1;
		}
	}

	if (f) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

int main() {
  int long long n;
  cin >> n;
  int ans =1;
  vector<int> a(n);
 for(int i=0;i<n;i++){
  cin >> a.at(i);
   }
  for(int i=0;i<n;i++){
    if (a.at(i) == ans){
       ans++;
    }
  }
  if(ans==1){
    cout << -1;
  }
    else{ 
      cout << n - ans+1 ;
    }

}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
#define endl "\n"
//#define int long long
#define ALL(x) begin(x),end(x)
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
//const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return ((fact(i - 1)) * i) % MOD;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
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;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}
/*signed*/int main(void) {
    int a, b;
    cin >> a >> b;
    cout << a * b << " " << a * 2 + b * 2 << endl;
}


Measured memory_bytes: 3076
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		long[] a=new long[n+1];
		long[] b =new long[n];
		for(int i=0; i<=n; i++){
			a[i] =sc.nextLong();
		}
		for(int i=0; i<n; i++){
			b[i]=sc.nextLong();
		}
		long ans=0;
		for(int i=0; i<n; i++){
			if(a[i]<b[i]){
				ans+=a[i];
				if(a[i+1]<b[i]-a[i]){
					ans+=a[i+1];
					a[i+1]=0;
				}else{
					ans+=b[i]-a[i];
					a[i+1]-=b[i]-a[i];
				}
			}else{
				ans+=b[i];
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 65224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main()
{
    ll N, K; cin >> N >> K;
    vector<int> A(N); cin >> A;

    vector<int> done(N+1, -1);
    vector<int> dest(N+1, 0); //i回目の行き先

    dest[0] = 1;
    done[1] = 0;
    int l = -1, r = -1;
    for (int i = 1; i < N; i++) {
        int a = A[dest[i-1]-1];
        if (done[a] != -1) {
            l = done[a];
            r = i - 1;
            break;
        } else {
            dest[i] = a;
            done[a] = i;
        }
    }

    int ans;
    if (K <= r) {
        ans = dest[K];
    } else {
        K-=l;
        ans = dest[l + K % (r-l+1)];
    }


    cout << ans << endl;
}


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

/**
 * Second Sum
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int[] P = new int[N];
            for (int i = 0; i < N; i++) {
                P[i] = sc.nextInt();
            }

            int[] Q = new int[N];
            for (int i = 0; i < N; i++) {
                Q[P[i] - 1] = i;
            }

            long sum = 0;

            List<Integer> index = new ArrayList<>();
            index.add(Q[N - 1]);

            for (int i = N - 2; i >= 0; i--) {
                int p = Q[i];

                int c = -(Collections.binarySearch(index, p) + 1);

                int a1 = c - 1 >= 0 ? index.get(c - 1) : -1;
                int a2 = c - 2 >= 0 ? index.get(c - 2) : -1;
                int b1 = c < index.size() ? index.get(c) : N;
                int b2 = c + 1 < index.size() ? index.get(c + 1) : N;

                if (a1 != -1) {
                    sum += (long) (i + 1) * (a1 - a2) * (b1 - p);
                }

                if (b1 != N) {
                    sum += (long) (i + 1) * (p - a1) * (b2 - b1);
                }

                index.add(c, p);
            }

            System.out.println(sum);
        }
    }

}


Measured memory_bytes: 51364