akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace contest19
{
    class Program
    {
        static void Main(string[] args)
        {
            var read_line_origin = Console.ReadLine();
//            string[] read_line = read_line_origin.Split();
            int n = int.Parse(read_line_origin);

            long ans = 1;

            for (int i = n; i > 0; i--)
            {
                ans *= i;
            }

            
            Console.WriteLine("{0}", ans.ToString());
            //            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 5632
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

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

    int min_cost = 1009;
    rep(i,n)
    {
        int ci,ti;
        cin >> ci >> ti;
        if(ti > t) continue;
        if(ci < min_cost)
            min_cost = ci;
    }

    if(min_cost == 1009)
        cout << "TLE" << endl;
    else
        cout << min_cost << endl;
    return 0;
}

Measured memory_bytes: 256
N = [int(i) for i in input().split()]

max = N[0]
max_index = 0

for i in range(len(N)):
    if N[i] > max:
        max = N[i]
        max_index = i

ans = N[max_index] * 10 + N[max_index - 1] + N[max_index - 2]

print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define mo1 1019260817
#define mo2 1009260817
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int pow(int x,int y,int mo){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mo;
		x=1ll*x*x%mo;y>>=1;
	}
	return ret;
}
char S[250010];
int bs1=19260817,ibs1=966804715,bs2=19491001,ibs2=251190511;
std::unordered_map<ll,int>M;
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi();scanf("%s",S+1);
	int p1=1,p2=1,x1=0,x2=0;
	for(int i=1;i<=n;++i){
		if(S[i]=='+'||S[i]=='-'){
			if(S[i]=='+')x1=(x1+p1)%mo1,x2=(x2+p2)%mo2;
			else x1=(x1+mo1-p1)%mo1,x2=(x2+mo2-p2)%mo2;
		}else{
			if(S[i]=='<')p1=1ll*p1*bs1%mo1,p2=1ll*p2*bs2%mo2;
			else p1=1ll*p1*ibs1%mo1,p2=1ll*p2*ibs2%mo2;
		}
	}
	int X1=x1,X2=x2;x1=x2=0;ll ans=0;
	for(int i=1;i<=n;++i){
		int y1=(x1+1ll*X1*p1)%mo1,y2=(x2+1ll*X2*p2)%mo2;
		++M[(1ll*y1<<32)|y2];
		if(S[i]=='+'||S[i]=='-'){
			if(S[i]=='+')x1=(x1+p1)%mo1,x2=(x2+p2)%mo2;
			else x1=(x1+mo1-p1)%mo1,x2=(x2+mo2-p2)%mo2;
		}else{
			if(S[i]=='<')p1=1ll*p1*bs1%mo1,p2=1ll*p2*bs2%mo2;
			else p1=1ll*p1*ibs1%mo1,p2=1ll*p2*ibs2%mo2;
		}
		ans+=M[(1ll*x1<<32)|x2];
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 20212
N,K=map(int,input().split())
A=sorted(map(int,input().split()))
x=0
r=10**18+1
l=-(10**18)
while l+1<r:
    x=(l+r)//2
    k=0
    for a in A:
        if a<0:
            ll,rr=-1,N
            while ll+1<rr:
                c=(rr+ll)//2
                if x>a*A[c]:
                    rr=c
                else:
                    ll=c
            k+=N-rr
        else:
            ll,rr=-1,N
            while ll+1<rr:
                c=(rr+ll)//2
                if x>a*A[c]:
                    ll=c
                else:
                    rr=c
            k+=rr
        if x>a**2:
            k-=1
    k//=2
    if k<K:
        l=x
    else:
        r=x
print(l)

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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;


int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    set<int> s;
    rp(i, 0, 3000) {
        rp(j, 0, 3000) {
            if(i*c + j*d > f) break;
            s.insert(i*c + j*d);
        }
    }
    vector<int> sugar_list(s.begin(), s.end());
    int mass = 100*a;
    int res = 0;
    rp(i, 0, 30) {
        rp(j, 0, 30) {
            int water = i*a*100 + j*b*100;
            int limit = min(f - water, (water/100) * e);
            int ok = -1; int ng = sugar_list.size();
            while(abs(ok - ng) > 1) {
                int x = (ok + ng) / 2;
                if(sugar_list[x] <= limit) ok = x;
                else ng = x;
            }
            int sugar = 0;
            if(ok >= 0) sugar = sugar_list[ok];
            if(mass*sugar > (water + sugar) * res){
                mass = water + sugar;
                res = sugar;
            }
        }
    }
    printf("%d %d\n", mass, res);
    return 0;
}

Measured memory_bytes: 3888
#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;

const int MAX_N=50000;
const int MAX_M=20;

int d[MAX_M];
int dp[MAX_M+1][MAX_N+1];
int n,m;

void solve(){
	for(int i=0;i<=m;i++){
		for(int j=0;j<=n;j++){
                      if(j==0){
                            dp[i][j]=0;
                              }
                       else if(i!=0){
                             if(j<d[i-1]){
				dp[i][j]=dp[i-1][j];
			}
			else{
				dp[i][j]=min(dp[i-1][j],dp[i][j-d[i-1]]+1);
			}
                       }
		}

	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d",&d[i]);
	}
        memset (dp,10000,sizeof(dp));

	solve();

	printf("%d\n",dp[m][n]);
	return 0;
}

Measured memory_bytes: 5136
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void chOut(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;

int cnt = 0;
void add(int i, int j, int k){
    cout << "+ " << i << " " << j << " " << k << endl;
    cnt++;
}

void comp(int i, int j, int k){
    cout << "< " << i << " " << j << " " << k << endl;
    cnt++;
}

signed main(){

    Out(32986);
    comp(3, 0, 10);
    REP(i, 30){
        add(100 + i, 10, 100 + i);
        REP(_, i) add(100 + i, 100 + i, 100 + i);
    }

    REP(t, 2){
        IREP(i, 30){
            add(2000 + i + 10000 * t, 3000 + 10000 * t, 2000 + i + 10000 * t);
            REP(j, i) add(2000 + i + 10000 * t, 100 + j, 2000 + i + 10000 * t);
            comp(2000 + i + 10000 * t, t, 1000 + i + 10000 * t);
            REP(_, i) add(1000 + i + 10000 * t, 1000 + i + 10000 * t, 1000 + i + 10000 * t);
            add(3000 + 10000 * t, 1000 + i + 10000 * t, 3000 + 10000 * t);
        }
    }

    REP(i, 30) REP(j, 30){
        comp(3, 1000 + i, 20000);
        comp(3, 11000 + j, 20001);
        comp(20001, 10, 20002);
        comp(20002, 20000, 20003);
        REP(_, i + j) add(20003, 20003, 20003);
        add(2, 20003, 2);
    }
    //Out(cnt);

    return 0;
}


Measured memory_bytes: 3652
X, Y, Z, K=map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
C=list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

import heapq
nums=[[-(A[0]+B[0]+C[0]), 0, 0, 0]]
heapq.heapify(nums)

sumi=set()
sumi.add((0, 0, 0))

for _ in range(K):
  out, a, b, c=heapq.heappop(nums)
  print(-out)
  if a<X-1 and not((a+1, b, c) in sumi):
    heapq.heappush(nums, [-(A[a+1]+B[b]+C[c]), a+1, b, c])
    sumi.add((a+1, b, c))
  if b<Y-1 and not((a, b+1, c) in sumi):
    heapq.heappush(nums, [-(A[a]+B[b+1]+C[c]), a, b+1, c])
    sumi.add((a, b+1, c))
  if c<Z-1 and not((a, b, c+1) in sumi):
    heapq.heappush(nums, [-(A[a]+B[b]+C[c+1]), a, b, c+1])
    sumi.add((a, b, c+1))


Measured memory_bytes: 4976
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#include <time.h> //for clock
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;
using ll = long long;

int main(){
    int n, q;
    string s;
    cin >> n >> q >> s;

    int imos[100001];
    int i;

    imos[0] = 0;

    for(i = 1; i < s.size(); i++){
        if(s[i-1] == 'A' && s[i] == 'C'){
            imos[i] = imos[i-1] + 1;
        }else{
            imos[i] = imos[i-1];
        }
    }
    imos[s.size()] = imos[s.size()-1];

    int l, r;
    for(i = 0; i < q; i++){
        cin >> l >> r;
        if(r == s.size()){
            cout << imos[r] - imos[l-1] << endl;
        }else{
            if(s[r-1] == 'A' && s[r] == 'C'){
                cout << imos[r] - imos[l-1] - 1 << endl;
            }else{
                cout << imos[r] - imos[l-1] << endl; 
            }
        }
    }

    /*
    for(i = 0; i <= s.size(); i++){
        cout << imos[i] << endl;
    }
    */
 }


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
      mint a = pow(t>>1);
      a *= a;
    if (t&1) a *= *this;
      return a;
  }
   mint inv() const { return pow(MOD-2);}
   mint& operator/=(const mint a) { return *this *= a.inv();}
   mint operator/(const mint a) const { return mint(*this) /= a;}
};
typedef vector<mint> vm;
typedef vector<vm> vvm;
  
int main() {
  string s;
  cin >> s;
  int d;
  cin >> d;
  vvm dp(2,vm(d,0));
  dp[1][0]=1;
  int len = sz(s);
  rep(i,len) {
    vvm dp2(2,vm(d,0));
    int x = s[i]-'0';
    rep(j,10) {
      rep(k,2) {
        int nk=k;
        if(k) {
          if(j<x) {
            nk--;
          } else if(j>x) {
            continue;
          }
        }
        rep(l,d) {
          dp2[nk][(l+j)%d]+=dp[k][l];
        }
      }
    }
    dp = dp2;
  }
  mint ans = dp[0][0]+dp[1][0];
  ans-=1;
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 256
N, A = map(int, input().split())
x = [int(i) for i in input().split()]

x.sort()
x = [i - A for i in x]
D = {0 : 1}
for i in x :
    for j, k in list(D.items()) :
        D[i+j] = D.get(i+j, 0) + k

print(D[0] - 1)


Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> x(n);
    for(int i = 0; i < n; i++){
        scanf("%d", &x[i]);
    }
    vector<int> y(x);
    sort(y.begin(), y.end());
    for(int i = 0; i < n; i++){
        if(x[i] <= y[(n-2)/2]) printf("%d\n", y[n/2]);
        else                   printf("%d\n", y[(n-2)/2]);
    }
    return 0;
}

Measured memory_bytes: 3712
a, b, c = map(int, input().split())
ab = a+b
bc = b+c
ca = c+a
flg = False
if ab == c:
    flg = True
if bc == a:
    flg = True
if ca == b:
    flg = True

if flg == True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
#include <cstring>
#include <cstdio>

using namespace std;

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

double dp[110][110];
bool lose[110], back[110];
int N,T,L,B;
int next(int j, int spot){
    j+=spot;
    if(j>N){
        j = N-(j-N);
    }
    return j;
}

int main(){
    while(~scanf("%d %d %d %d", &N,&T,&L,&B) && N){
        memset(dp,0,sizeof(dp));
        memset(lose,0,sizeof(lose));
        memset(back,0,sizeof(back));
        dp[0][0] = 1;
        rep(i,L){ int x; scanf("%d",&x); lose[x]=true; }
        rep(i,B){ int x; scanf("%d",&x); back[x]=true; }
        rep(i,T){
            rep(j,N+1){
                if(j==N){
                    dp[i+1][N]+=dp[i][N];
                    continue;
                }
                loop(k,1,7){
                    int x=next(j,k);
                    if(back[x]){
                        dp[i+1][0] += dp[i][j]/6;
                    }else if(lose[x]){
                        dp[i+2][x] += dp[i][j]/6;
                    }else{
                        dp[i+1][x] += dp[i][j]/6;
                    }
                }
            }
        }
        printf("%.10lf\n", dp[T][N]);
    }
}

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

int main() {
  long long int a,b,c,d,x,y;
  d =  0;
  cin >> a >> b;
  for (int i=0; i<a; i++) {
    cin >> x >> y;
    c = b*b;
    x = x*x;
    y = y*y;
    if ((x+y) <= c) {
      d++;
    } 
  }
  cout << d;
} 


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

#pragma GCC optimize(2)

#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define per(i, r, l) for (int i = (r); i >= (l); --i)
using namespace std;

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

int gi() {
	int f = 1, x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9') {
		if (ch == '-') f = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9') {
		x = (x << 1) + (x << 3) + ch - '0';
		ch = getchar();
	}
	return f * x;
}

int cnt[15][15];

int f(int x) {
	if (x < 10) return x;
	else return f(x / 10); 
}
int main() {
	int n = gi();
	rep (i, 1, n) {
		if (i % 10 != 0) ++cnt[f(i)][i % 10];
	}
	ll ans = 0;
	for (int a = 1; a <= n; a++) {
		if (a % 10 == 0) continue;
		int aa = f(a), bb = a % 10;
		ans += cnt[bb][aa];
	}
	cout << ans << endl; 
  return 0;
}


Measured memory_bytes: 256
def larger(x, y):
	if x > y: return x
	return y

N = int(input())
dpa = [0]
dpb = [0]
dpc = [0]
for i in range(0, N):
	a, b, c = map(int, input().split())
	if i == 0:
		dpa.append(a)
		dpb.append(b)
		dpc.append(c)
	else:
		newa = larger(dpb[-1], dpc[-1])+a
		newb = larger(dpa[-1], dpc[-1])+b
		newc = larger(dpa[-1], dpb[-1])+c
		dpa.append(newa)
		dpb.append(newb)
		dpc.append(newc)
print(larger(larger(dpa[-1], dpb[-1]), dpc[-1]))

Measured memory_bytes: 69448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll n,p,ans=1;
  cin>>n>>p;
  for(int i=2;(ll)i*i<=p;i++)
  {
    
    if(p%i==0)
    {
      int count=0;
      while(p%i==0)
      {
        p/=i;
        count++;
      }
      count/=n;
      while(count--)ans*=i;
    }
  }
  if(p>1 && n==1)ans*=p;
  cout<<ans<<endl;
  return 0;
}

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

int main(void)
{
    ios :: sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    int n, m;
    cin >> n >> m;
    
    cout << (1 << m) * (m * 1900 + (n - m) * 100);
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
string s;
int n,a,b,c,d;
bool can(int start, int end) {
	for (int i = start; i < end; i++)
	{
		if (s[i] == '#' && s[i+1] == '#') return false;
	}
	return true;
} 

int main() {
	cin >>n>>a>>b>>c>>d;
	cin >> s;
	s = '#' + s + '#';
	
	if (!can(a,c) || !can(b,d)) {
		cout << "No" << endl;
		return 0;
	}

	if (c > d) {
		bool passing = false;
		for (int i = b; i <= d; i++)
		{
			if (s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.') passing = true;
		}
		if (!passing) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3872
def solve():
	n = int(input())
	tasks = []
	for i in range(n):
		a, b = map(int,input().split())
		tasks.append((b,a))

	tasks.sort()

	t = 0
	for task in tasks:
		t += task[1]
		if t > task[0]:
			return False
	return True

print("Yes" if solve() else "No")

Measured memory_bytes: 94464
using System.Linq;
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var ary = Enumerable.Repeat("-", 10).ToArray();
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            for (int i = 0; i < n; i++)
            {
                var ice = int.Parse(Console.ReadLine().Trim());
                if (ary[ice] == "-") ary[ice] = "*";
                else ary[ice] += "*";
            }
            foreach (var x in ary) Console.WriteLine(x);
        }
    }
}

Measured memory_bytes: 9996
#include <iostream>

using namespace std;

int main(){
    long long a;
    long long b;
    long long k;
    cin >> a >> b >> k;
    if(k <= a){
        cout << a - k << " " << b << endl;
    }
    else if(k <= a + b){
        cout << 0 << " " << b - (k - a) << endl;
    }
    else{
        cout << 0 << " " << 0 << endl;
    }
}

Measured memory_bytes: 256
ABVW = [map(int, input().split()) for _ in range(2)]
AB, VW = [list(i) for i in zip(*ABVW)]
T = int(input())
 
x = abs(AB[0] - AB[1])
y = (VW[0] - VW[1])*T
if abs(AB[0] - AB[1]) - (VW[0] - VW[1])*T <= 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long n,a[1000],b[1000],c[1000],ans=0,i;
	cin>>n;
	for(i=0;i<n-1;i++) {
		cin>>a[i];
	}
	ans=a[n-2];
	for(i=n-3;i>=0;i--) {
		ans+=min(a[i],a[i+1]);
	}
	ans+=a[0];
	
	cout<<ans;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 9e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class ACanYouGetAC {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    string s;
	    in >> s;

	    bool res = false;
	    for(int i=0; i<s.length()-1; i++){
	        string t = s.substr(i, 2);
	        if(t == "AC"){
	            res = true;
	            break;
	        }
	    }

	    ans(res, out);
	}
};


int main() {
	ACanYouGetAC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
int main(void)
{
	int n,a[100];
	int i;
	scanf("%d",&n);
	
	for(i = 0;i < n;i++)
		scanf("%d",&a[i]);
	for(i = n-1;i >= 1;i--)
		printf("%d ",a[i]);
	printf("%d",a[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline void myassert(bool a,string s){ if(!a)cerr<<s<<endl,exit(0);}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=120;
const int mod=1e9+7;

inline int power(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=(ll)ans*a%mod;
		b>>=1;
		a=(ll)a*a%mod;
	}
	return ans;
}

int n,h[maxn];
int sx[maxn],tx;

inline void init()
{
	n=read();
	REP(i,1,n)h[i]=read(),sx[i]=h[i]; tx=n;
	sort(sx+1,sx+tx+1); tx=unique(sx+1,sx+tx+1)-sx-1;
}

int g[maxn][2];

inline void doing()
{
	DREP(i,tx,1)
	{
		int f[2]={0},empty=1;
		int mult=power(2,sx[i]-sx[i-1]-1);
		REP(j,1,n)if(h[j]>=sx[i])
		{
			if(h[j]>sx[i])while(j<n && h[j+1]>sx[i])++j;
			else g[j][0]=0,g[j][1]=1;
			if(empty)f[0]=g[j][0],f[1]=g[j][1]*2%mod;
			else {
				int tmp[2]; ;
				tmp[0]=((ll)f[0]*g[j][0]+(ll)f[1]*g[j][0]+(ll)f[0]*g[j][1]*2+(ll)f[1]*g[j][1])%mod;
				tmp[1]=((ll)f[1]*g[j][1])%mod;
				f[0]=tmp[0]; f[1]=tmp[1];
			}
			empty=0;
			if(j==n || h[j+1]<sx[i])
			{
				g[j][0]=f[0],g[j][1]=(ll)f[1]*mult%mod;
			}
		}else f[0]=f[1]=0,empty=1;
	}
	int ans=(g[n][0]+g[n][1])%mod;
	printf("%d\n",ans);
}

int main()
{
	init();
	doing();
	return 0;
}


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

int main(){
    vector<int> A(3);
    for(int i = 0; i < 3; i++)
        cin >> A[i];

    sort(A.begin(), A.end());
    int ans = A[2] - A[1];
    A[0] += ans;
    A[1] += ans;
    if((A[1]-A[0]) % 2 == 0)
        ans += (A[1] - A[0]) / 2;
    else{
        ans += (A[1] - A[0] + 1) / 2;
        ans++;
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define ll long long

signed main(){
    int n,a;
    cin >> n >> a;
    vector<int> x(n);
    for (int i = 0;i < n;++i){
        cin >> x[i];
        x[i] -= a;
    }

    /*
        dp[i][j] : i番目までで合計j-2500を実現する方法
     */
    ll dp[n + 1][5001];
    // 初期化
    for (int i = 0;i <= n;++i)
        for (int j = 0;j < 5001;++j)
            dp[i][j] = 0;
    dp[0][2500] = 1;
    // 遷移
    for (int i = 1;i <= n;++i){
        int xi = x[i - 1];
        for (int j = 0;j < 5001;++j){
            dp[i][j] = dp[i - 1][j];
            if (j >= xi)
                dp[i][j] += dp[i - 1][j - xi];
        }
    }

    cout << dp[n][2500] - 1 << endl;

    return 0;
}

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

int main () {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  
  bool A = b - a <= k;
  bool B = c - a <= k;
  bool C = d - a <= k;
  bool D = e - a <= k;
  bool E = c - b <= k;
  bool F = d - b <= k;
  bool G = e - b <= k;
  bool H = d - c <= k;
  bool I = e - c <= k;
  bool J = e - d <= k;
  
  if (A && B && C && D && F && G && H && I && J) {
    cout << "Yay!" << endl;
  }
  else {
    cout << ":(" << endl;
  }
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N, M;
    cin >> N >> M;
    PR((100*(N+18*M))<<M);

    return 0;
}

/*



*/

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  int k; cin>>k;
  string s; cin>>s;
  if(s.size()<=k) cout << s;
  else {
    rep(i, k) cout << s.at(i);
    cout << "...";
  }
}

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

using namespace std;

#define ll long long 
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ff first
#define ss second
#define endl "\n"
#define MOD 1000000007
#define MOD1 998244353

ll GCD(ll x,ll y){if(y==0)return x;return GCD(y,x%y);}
ll LCM(ll x,ll y){return (x*y)/(GCD(x,y));}
ll LOGK(ll x,ll k){if(x>=k)return 1+LOGK(x/k,k);return 0;}
ll MPOW( ll a, ll b, ll m) { if(b==0) return 1; ll x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
ll MINV(ll a,ll m) {return MPOW(a,m-2,m);}

class pnc{
  ll FACT_MAX,MODU;
  vector<ll> fact;
public:
  pnc( ll n, ll m) { FACT_MAX = n; fact.resize(FACT_MAX); MODU = m; MFACT_INIT(MODU);}
  void MFACT_INIT( ll m) { fact[0]=1; for(ll i=1;i<FACT_MAX;++i) fact[i]=(i*fact[i-1])%MODU;}
  ll MFACT( ll n) { return fact[n];}
  ll PERM( ll n, ll r) { return (fact[n]*::MINV(fact[n-r],MODU))%MODU;}
  ll COMB( ll n , ll r) { return (PERM(n,r)*::MINV(fact[r],MODU))%MODU;}
};

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

    ll test=1;
    //cin>>test;
    while(test--)
    {
        ll r;
        cin>>r;

        cout<<setprecision(8);

        ld ans=(2*22*r)/7.0;

        cout<<ans;
    }
}

Measured memory_bytes: 3800
import bisect
import sys
input = sys.stdin.readline
n = int(input())
L = list(map(int, input().split()))

L.sort()
# print(L)
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        A = L[i] + L[j] - 1
        sa = abs(L[i] - L[j]) + 1
        big = bisect.bisect_right(L, A)
        sml = bisect.bisect_left(L, sa)
        num = big - sml
        if sa <= L[i] <= A:
            num -= 1
        if sa <= L[j] <= A:
            num -= 1
        # print(L[i], L[j])
        # print(sml, big, num)
        # print(num)
        if num > 0:
            ans += num
        # print(sa, A, L)
        # print(sml, big)
        # print(dab)
print(ans//3)


# print(ans)


Measured memory_bytes: 48984
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL res = 1;
    LL sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

double exp(double a, LL b){
    double res = 1;
    double sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

signed  main(){
    int N, L;
    cin >> N >> L;
    int sum = (L*2+N-1)*N/2;
    int ans = INF;
    REP(i, N){
        if(abs(ans) > abs(L+i))ans=L+i;
    }
    cout << sum - ans << endl;
    return 0;
}



Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()


def main():
    N, M = map(int, input().split())
    cakes = [(0, 0, 0)]
    for _ in range(N):
        x, y, z = map(int, input().split())
        cakes.append((x, y, z))

    """
    これはdpするべきではなかった。O(NlogN)で解ける。
    単純にx+y+zやx-y-z等のそれぞれに対してcakesをソートして大きい値から取れば良い。
    """

    ans = 0
    for i in range(8):
        sorted_cakes = []
        for j in range(1, N + 1):
            S = 0
            for k in range(3): # iの立っているビットでx, y, zの符号を管理している！！
                if i & (1 << k):
                    S += cakes[j][k]
                else:
                    S -= cakes[j][k]
            sorted_cakes.append(S)
        sorted_cakes.sort()
        ans = max(ans, sum(sorted_cakes[N - M:]))
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 71272
from bisect import bisect_left
n,m = map(int, input().split())

l = [[] for _ in range(n)]
city = []
for i in range(m):
  p,y = map(int, input().split())
  city.append([p,y])
  l[p-1].append(y)

for i in l: i.sort()
for i in city:
  ans = ""
  ans += "0"*(6-len(str(i[0])))+str(i[0])
  t = str(bisect_left(l[i[0]-1], i[1]) + 1)
  ans += "0"*(6-len(t))+t
  print(ans)

Measured memory_bytes: 34240
import java.util.*
import kotlin.comparisons.*

fun main(args : Array<String>) {
  val n = readLine()!!.toInt()
  val w = readLine()!!.split(' ').map(String::toInt)
  val s = IntArray(n)
  s[0] = w[0]
  for (i in 1 until n) {
    s[i] = s[i - 1] + w[i]
  }
  var ans = Int.MAX_VALUE
  for (i in 0..n - 2) {
    val s1 = s[i]
    val s2 = s[n - 1] - s[i]
    ans = Math.min(ans, Math.abs(s1 - s2))
  }
  println(ans)
}


Measured memory_bytes: 38304
#include <stdio.h>
#include <math.h>
  
 
int main(void)
{
 
    double  x1, y1, x2, y2,X,Y,D;
    double distance;
     
    scanf("%lf %lf %lf %lf",&x1, &y1, &x2, &y2);
     
    X = pow(x2-x1,2);
    Y = pow(y2-y1,2);
 
    D = X + Y;
 
    distance = sqrt(D);
     
    printf("%f\n",distance);
 
    return 0;
 
}

Measured memory_bytes: 652
#include<bits/stdc++.h>
using namespace std;
//arvid
int N;
bool ada = false;

int main () {
    cin >> N;
    for (int i=1; i<=9; i++) {
        for(int j=1; j<=9; j++) {
            if (i*j == N) {
                ada = true;
            }
        }
    }
if(ada){
    cout << "Yes" << endl;
}else{
    cout << "No" << endl;
    }
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include<cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include<bitset>

#define REP(i, b, n) for(int i=b;i<(int)n;i++)
#define rep(i, n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define FOR(it, o)  for(__typeof((o).begin()) it=(o).begin(); it!=(o).end(); ++it)
#define dbg(x) cout << __LINE__ << ' ' << #x << " = " << (x) << endl


typedef long long ll;

using namespace std;

//ハマったらチェックリスト見ろ!!

class DisJointSet{
public:
    vector<int> v;//親の添字を入れる
    DisJointSet(int n){//初期化
        v = vector<int>(n);
        rep(i, n)v[i] = i;
    }
    int find(int x){//親を返す
        if(v[x] == x)return x;
        else return v[x] = find(v[x]);
    }
    void unite(int x, int y){//xとyをくっつける
        x = find(x);
        y = find(y);
        if(x == y)return;
        v[x] = y;
    }
    bool same(int x, int y){//xとyが同じ集合かどうか
        return find(x) == find(y);
    }
};

vector<vector<int> > V;

vector<int> countSize(int now, map<int, int> &visited, int c){
    if(visited.count(now)){
        if(visited[now] != c){
            vector<int> tmp(2);
            tmp[0] = -1;
            return tmp;
        }
        else return vector<int>(2);
    }
    visited[now] = c;
    c = (c+1)%2;

    vector<int> ret(2);
    ret[0] = ret[1] = 0;
    ret[c] = 1;
    rep(i, V.size()){
        if(V[now][i] == 0)continue;
        vector<int> tmp = countSize(i, visited, c);
        if(min(tmp[0], tmp[1]) == -1)return tmp;
        ret[0] += tmp[0];
        ret[1] += tmp[1];
    }
    return ret;
}



int main() {
    int N;
    cin >> N;
    rep(i, N)V.push_back(vector<int>(N));
    rep(i, N)rep(j, N)V[i][j] = 1;
    int M ;
    cin >> M;
    DisJointSet ds(N), ds2(N);
    rep(i, M){
        int a, b;
        cin >> a >> b;
        a--;b--;
        V[a][b] = V[b][a] = 0;
        ds2.unite(a,b);
    }
    rep(i, N)V[i][i] = 0;


    rep(i, N)rep(j, N)if(V[i][j]){
                ds.unite(i, j);
            }
    set<int> used;
    vector< vector<int> > ANS;

    rep(i, N){
        if(used.count(ds.find(i)) != 0)continue;
        map<int, int> visited;
        vector<int> tmp = countSize(i, visited, 0);
        if(min(tmp[0], tmp[1]) == -1){
            cout << -1 <<endl;
            return 0;
        }
        ANS.push_back(tmp);
        used.insert(ds.find(i));
    }


    set<int> SUM;
    SUM.insert(0);

    FOR(it1, ANS){
        set<int> next;
        FOR(it2, SUM){
            next.insert(*it2 + (*it1)[0]);
            next.insert(*it2 + (*it1)[1]);
        }
        SUM = next;
    }

    int ans = 1e9;
    FOR(it, SUM){
        int a = *it;
        int b = N - a;
        ans = min(ans, a*(a-1)/2 + b*(b-1)/2);
    }
    cout << ans <<endl;

    return 0;
}

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

int main() {
    int N, K;
    cin >> N >>K;
    double ans=0, then=0;
    vector<double> a(N);
    
    for(int i=0; i<N; i++){
	cin >> a[i];
	a[i]++;
    }
    
    for(int i=0; i<K; i++){
	then += a[i]/2;
    }
    ans=then;

    for(int i=K; i<N; i++){
	then -= a[i-K]/2;
	then += a[i]/2;
	ans = max(ans, then);	
    }
    printf("%.10f\n", ans);
    
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(b%a==0){
    cout << a+b << endl;
  }else{
    cout << b-a << endl;
  }
  return 0;
}

Measured memory_bytes: 256
S = input()
S2 = S
ans = 'WA'
if S[0] == 'A' and S[2:-1].count('C') == 1 and S[0].replace('A', 'a') + S[1] + S[2:-1].replace('C', 'c') + S[-1] == S2.lower():
    ans = 'AC'
print(ans)   

Measured memory_bytes: 3060
use std::io::BufRead;
fn main() {
    let f = read_field();
    println!("{}", if solve(&f) { "Yes" } else { "No" })
}

fn solve(f: &Field) -> bool {
    for y in 0..f.h {
        for x in 0..f.w {
            if f.at(x, y).unwrap_or(false) {
                // we need to paint here
                if !&[
                    (x.checked_sub(1), Some(y)),
                    (Some(x + 1), Some(y)),
                    (Some(x), y.checked_sub(1)),
                    (Some(x), Some(y + 1)),
                ]
                .iter()
                .any(|&(nx, ny)| f.at_opt(nx, ny).unwrap_or(false))
                {
                    return false;
                }
            }
        }
    }
    true
}

fn read_field() -> Field {
    let stdin = std::io::stdin();
    let mut input = stdin.lock();
    let mut l = String::new();
    let _ = input.read_line(&mut l);
    let hw: Vec<u32> = l
        .split_whitespace()
        .map(|n| n.parse().expect("readnumerror!"))
        .collect();
    let h = hw[0];
    let w = hw[1];
    let mut f: Vec<Cell> = Vec::with_capacity((h * w) as usize);
    for line in input.lines() {
        for c in line.expect("read line error").trim().chars() {
            match c {
                '.' => f.push(false),
                '#' => f.push(true),
                _ => panic!(format!("unexpected char {}", c)),
            }
        }
    }
    Field {
        h: h,
        w: w,
        field: f,
    }
}

struct Field {
    h: u32,
    w: u32,
    field: Vec<Cell>,
}

impl Field {
    fn at_opt(&self, x: Option<u32>, y: Option<u32>) -> Option<Cell> {
        if x.is_none() || y.is_none() {
            return None;
        }
        let x = x.unwrap();
        let y = y.unwrap();
        if x < self.w && y < self.h {
            self.field
                .get(x as usize + y as usize * (self.w as usize))
                .map(|&b| b)
        } else {
            None
        }
    }
    // fn at_opt(&self, x: Option<u32>, y: Option<u32>) -> Option<Cell> {
    //     if x? < self.w && y? < self.h {
    //         self.field
    //             .get(x? as usize + y? as usize * (self.w as usize))
    //             .copied()
    //     } else {
    //         None
    //     }
    // }
    fn at(&self, x: u32, y: u32) -> Option<Cell> {
        if x < self.w && y < self.h {
            self.field
                .get(x as usize + y as usize * (self.w as usize))
                .map(|&b| b)
        } else {
            None
        }
    }
}

type Cell = bool;


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n, m, l;
    cin >> n >> m >> l;
    vector<vector<ll>> dist(n, vector<ll>(n, LINF));
    vector<vector<int>> dist2(n, vector<int>(n, INF));
    rep(i, n) dist[i][i] = dist2[i][i] = 0;
    rep(i, m) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        a--; b--;
        dist[a][b] = c;
        dist[b][a] = c;
    }
    rep(k, n) rep(i, n) rep(j, n) {
        chmin(dist[i][j], dist[i][k] + dist[k][j]);
    }
    rep(i, n) rep(j, n) {
        if (dist[i][j] > l) continue;
        dist2[i][j] = dist2[j][i] = 1;
    }
    rep(k, n) rep(i, n) rep(j, n) {
        chmin(dist2[i][j], dist2[i][k] + dist2[k][j]);
    }
    int q;
    cin >> q;
    while(q--) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        cout << (dist2[s][t] == INF ? -1 : dist2[s][t] - 1) << endl;
    }
}

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


Measured memory_bytes: 4280
#!/usr/bin/perl

$line = 0;
while (<>) {
    chomp;
    if ($line == 0) {
        $n = $_;
    } else {
        push @a, $_;
    }
    $line++;
}

$i = 1;
$r{$i}++;
while ($i != 2) {
    $i = $a[$i - 1];
    $cnt++;
    if ($r{$i}) {
        print "-1\n";
        exit;
    }
    if ($cnt > $n) {
        print "-1\n";
        exit;
    }
}
print "$cnt\n";


Measured memory_bytes: 8448
import java.lang.reflect.Array;
import java.util.*;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        if (s.charAt(0) == s.charAt(1) && s.charAt(1) == s.charAt(2)) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }

}


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

int main(){
    string ss;
    cin >> ss;
    for(int i=0;i<5;i++){cout << ss[i];}
    cout << " ";
    for(int i=6;i<13;i++){cout << ss[i];}
    cout << " ";
    for(int i=14;i<19;i++){cout << ss[i];}
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
class Program {
    static void Main (string[] args) {
        var inp = Console.ReadLine().Split(' ');
        float a = float.Parse(inp[0]);
        float b = float.Parse(inp[1]);
        int r = (int)(a / b) + 1;
        if(!(a % b == 0)) {
            Console.WriteLine(r);
        } else {
            Console.WriteLine(r - 1);
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>

using namespace std;

long long MOD = 1000000007;

long long dp[50001][5001];

int BIT_SIZE = 64;
long long power(long long m, long long n){
    long long ans = 1;
    long long tmp = m;
    for(int i = 0; i < BIT_SIZE; i++){
        //cout << ans << endl;
        if(((n >> i) & 1) == 1){
            ans = ans * tmp % MOD;
        }
        tmp = (tmp * tmp) % MOD;
    }
    return ans;
}

long long inv(long long a){
    return power(a, MOD - 2);
}

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

    dp[0][0] = 1;
    for(int i = 1; i <= N; i++){
        for(int j = 0; j <= N; j++){
            if(j == 0){
                dp[i][j]  = (dp[i - 1][j] + dp[i - 1][j + 1]) % MOD;
            } else if (j==N){
                dp[i][j] = (dp[i - 1][j - 1] * 2) % MOD;
            } else {
                dp[i][j] = ((dp[i - 1][j - 1] * 2) % MOD + (dp[i - 1][j + 1]) % MOD) % MOD; 
            }
        }
    }

    long long ans = dp[N][s.size()];
    long long inv2 = inv(2);
    for(int i = 0; i < s.size(); i++){
        ans = (ans * inv2) % MOD;
    }    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 196864
def points(me, you, R, S, P):
    hand_map = {
        'r':'p',
        's':'r',
        'p':'s'
    }
    if hand_map[you] == me:
        if me == 'r':
            return R
        elif me =='p':
            return P
        elif me =='s':
            return S
    else:
        return 0
    
def main():
    N, K = list(map(int, input().split()))
    R, S, P = list(map(int, input().split()))
    T = input()
    Ts = list(T)

    hand_map = {
        'r':'p',
        's':'r',
        'p':'s'
    }

    memo = []
    cum = 0
    for i, t in enumerate(Ts):
        hand = hand_map[t]
        
        if i >= K:
            if hand == memo[i - K]:
                hand = 'na'
            

        memo.append(hand)
        cum += points(hand, t, R, S, P)
        # print(cum, i, t, memo)


    print(cum)

if __name__ == "__main__":
    main()


Measured memory_bytes: 4980
n=int(input())
c=list(map(int, input().split()))
d = c[1:]
k = 1000

for i in range(n-1):
    if c[i] >= d[i]:
        pass
    if c[i] < d[i]:
        l = k//c[i]
        k -= c[i]*l
        k += l*d[i]

print(k)

Measured memory_bytes: 9004
//abc133
#include <iostream>
#include <math.h>

int main(){
    int n,d;
    std::cin >> n >> d;
    int x[n][d];
    for(int i=0;i<n;++i){
        for(int j=0;j<d;++j){
            std::cin >> x[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<n-1;++i){
        for(int j=i+1;j<n;++j){
            double temp=0;
            for(int l=0;l<d;++l){
                temp+=(x[i][l]-x[j][l])*(x[i][l]-x[j][l]);
            }
            temp=sqrt(temp);
            temp=fmod(temp,1);
            if(temp==0){
                ans++;
            }
        }
    }
    
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 384
n=int(input())
for i in range(1,3501):
    for j in range(1,3501):
        if 4*i*j-n*(i+j)<=0:
            continue
        else:
            if (n*i*j)%(4*i*j-n*(i+j))==0:
                h=i
                N=j
                w=n*i*j//(4*i*j-n*(i+j))
                break
print(h,N,w)


Measured memory_bytes: 43320
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"

vector<string>sts;
vector<int>indnums;
int a = 0;
struct yaml {
	bool is_dir;
	map<string, yaml>mp;
	string prop;
	void operator =(const yaml yaml_) {
		is_dir = yaml_.is_dir;
		mp = yaml_.mp;
		prop = yaml_.prop;
	}
};
yaml getmap(const int ind);
pair<string,yaml> getmapitem(const int ind) {
	yaml ayaml;
	
	const int n = sts[a].find(':');
	string key = sts[a].substr(indnums[a], n-indnums[a]);
	if (n == sts[a].size()-1) {
		ayaml.is_dir = true;
		a++;
		ayaml = getmap(indnums[a]);
	}
	else {
		ayaml.is_dir = false;
		string name = sts[a].substr(n + 2);
		ayaml.prop = name;
		a++;
	}
	return make_pair(key,ayaml);
}
yaml getmap(const int ind) {
	yaml ayaml;
	ayaml.is_dir = true;
	ayaml.mp.emplace(getmapitem(ind));
	while (1) {
		if (a >= sts.size() || indnums[a] != ind)break;
		ayaml.mp.emplace(getmapitem(ind));
	}
	return ayaml;
}

int main() {
	string st; cin >> st;
	int now = 1;
	vector<string>keys;
	while (1) {
		int n = st.find('.',now);
		if (n == string::npos) {
			break;
		}
		else {
			keys.emplace_back(st.substr(now, n-now));
		}
		now = n+1;
	}
	keys.emplace_back(st.substr(now));
	string ast;
	getline(cin, ast);
	while (getline(cin,ast)) {
		int n = ast.find_first_not_of(' ');
		sts.push_back(ast);
		indnums.emplace_back(n);
	}
	yaml y=getmap(0);
	int anstype=0;
	string ans;
	yaml nyaml = y;
	
	for (int i = 0; i < keys.size(); ++i) {
		auto it = nyaml.mp.find(keys[i]);
		if (it == nyaml.mp.end()) {
			anstype = -1;
			break;
		}
		else {
			nyaml = it->second;
		}
	}
	if (anstype == -1) {
		cout << "no such property" << endl;
	}
	else {
		if (nyaml.is_dir) {
			cout << "object" << endl;
		}
		else {
			cout << "string \"" << nyaml.prop << "\"" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3516
S = input()
ans = 0
l = ["A", "T", "C", "G"]
length = len(S)
for i in range(length):
    if S[i] in l:
        temp = 1
        for j in range(i + 1, length):
            if S[j] in l:
                temp += 1
            else:
                break
        ans = max(temp, ans)
print(ans)

Measured memory_bytes: 61832