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

int main(){


  int a[5];

  int minn=10;
  int mini=5;
  int cnt=0;
  
  for(int i=0;i<5;i++){

	cin>>a[i];

	if(minn>(a[i]%10)&&a[i]%10!=0){
	  minn=a[i]%10;
	  mini=i;
	}
  }

  for(int i=0;i<5;i++){

	if(mini!=i){
	  if(a[i]%10==0){
		cnt+=a[i];
	  }else{
		cnt+=(a[i]+(10-a[i]%10));
	  }
	}

  }

  if(mini!=5){
	
	cout<<cnt+a[mini]<<endl;

  }else{
	cout<<cnt<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> p2;
ll res[100005];
void dfs(ll i,ll p,vector<vector<p2>> &v){
    for(ll j=0;j<v[i].size();j++)
    if(v[i][j].first!=p){
        if(v[i][j].second)
        res[v[i][j].first]=(res[i]==0?1:0);
        else
        res[v[i][j].first]=res[i];
        dfs(v[i][j].first,i,v);
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    vector<vector<p2>> v(n+1);
    for(ll i=0;i<n-1;i++){
        ll a,b,w;
        cin>>a>>b>>w;
        v[a].push_back({b,w%2});
        v[b].push_back({a,w%2});
    }
    res[1]=0;
    dfs(1,1,v);
    for(ll i=1;i<=n;i++)
    cout<<res[i]<<endl;
}

Measured memory_bytes: 9984
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int,int *> P;
typedef pair<long long,int>PP;
typedef long long ll;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b+1<c){
    c=a+b+1;
  }
  cout<<b+c<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

struct pos3
{
	double x;
	double y;
	double z;
	double r;
};
int main() {
	int n;
	while (cin >> n, n) {
		vector<pos3> ball(n);
		REP(i, n) {
			double a, b, c, d;
			cin >> a >> b >> c >> d;
			ball[i] = { a,b,c,d };
		}
		vector<pair<double, pii>> dis;
		REP(i, n)
			FOR(j, i + 1, n) {
			dis.push_back({
				sqrt((ball[i].x - ball[j].x)*(ball[i].x - ball[j].x) +
				(ball[i].y - ball[j].y)*(ball[i].y - ball[j].y) +
				(ball[i].z - ball[j].z)*(ball[i].z - ball[j].z)) -
				sqrt((ball[i].r + ball[j].r)*(ball[i].r + ball[j].r))
				,{i,j} });
		}
		SORT(dis);
		UnionFind uf(n);
		double ans = 0.0;
		REP(i, dis.size()) {
			if (uf.find(dis[i].second.first) != uf.find(dis[i].second.second)) {
				uf.unite(dis[i].second.first, dis[i].second.second);
				ans += max(0.0, dis[i].first);
				bool clear = true;
				FOR(i, 1, n)
					if (uf.find(0) != uf.find(i))
						clear = false;
				if (clear)
					break;
			}
		}
		printf("%.3lf\n", ans);
	}
}

Measured memory_bytes: 3284
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d; cin >> a >> b >> c >> d;
    cout << min({abs(a+d-b-c), abs(a+b-c-d), abs(a+c-b-d)}) << "\n";
    return 0;
}


Measured memory_bytes: 3216
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const ab = stdin.split('\n')[0].split(' ')

const ans = () => {
  const joinedAB = ab.join('')
  const numAB = Number(joinedAB)

  const sqrt = Math.sqrt(numAB)

  console.log(Number.isInteger(sqrt) ? 'Yes' : 'No')
}

ans()


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define print(x,y) (cout << (x) << (y))
#define inf INT_MAX
#define sz(x) (ll)x.size()
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair< int , pii> piii;
typedef pair<int,bool> pib;
typedef vector<pii> vii;
typedef vector<pib> vib;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<string,string> pss;
typedef vector<pss> vss;
const int MOD = 1e9 + 7; //998244353;


int main() {
    string s;
    cin >> s;
    if(s== "ABC")cout << "ARC"; else cout << "ABC";
}




Measured memory_bytes: 3592
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 998244353;
const ll MAX = 200001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

int main(){
  ll n,p; cin >> n >> p; ll cnt1 = 0; ll cnt0 = 0;
  ll cnt = 0;
  
  rep(i,n){
    ll x; cin >> x; 
    if(x % 2 == 0) cnt0++;
    else cnt1++;
  }
  
  nCrprep();
  
  if(p == 0){
    for(ll i=0; i <= cnt1; i+=2){
      cnt += nCrcheep(cnt1,i);
    }
  }
  else{
    for(ll i=1; i <= cnt1; i+=2){
      cnt += nCrcheep(cnt1,i);
    }
  }
  ll power = 1;
  rep(i,cnt0){
    power *= 2;
  }
  cout << cnt*power  << endl;
  
  
}

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

int main(){
  int st,en,i;
  int tot,n,cnt;
  while(1){
    cin >> n;
    if (n==0) break;
    if (n==1){
      cout << 0 << endl;
      continue;
    }
    cnt=0;
    tot=0;
    for (i=1;tot<n;i++)tot+=i;
    st=1;
    en=i-1;
    while(1){
      if (tot==n){
	cnt++;
	en++;
	tot+=en;
      }else{
	if (tot<n){
	  en++;
	  tot+=en;
	}else{
	  tot-=st;
	  st++;
	}
      }
      if (st==en)break;
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 3072
N = int(input())

Flag = False
total = N
for i in range(N):
    total = N
    if total != 0:
        total -= 4 * i
    else:
        Flag = True
        break
    for j in range(N):
        if total != 0:
            total -= 7 * j
        else:
            Flag = True
            break

if Flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<numeric>
#define rep(i,n) for(int i=0;i<n;++i)
#define mod 1000000007
using namespace std;
int main(){
    int n;  cin>>n;
    vector<int> num(n);
    long long sum=0;
    rep(i,n){
        cin>>num[i];
        sum+=num[i];
    }
    cout<<*min_element(num.begin(),num.end())<<" "<<*max_element(num.begin(),num.end())<<" "<<sum<<endl;
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

int main(void){
    int n,q;
    cin >> n >> q;
    int a[n+1],b[n+1];
    int p[q],x[q];
    
    vector<vector<int>> s(n+1);
    vector<bool> seen;
    vector<int> num(n+1,0);
    seen.assign(n+1,false);
    
    for(int i = 1;i < n;i++){
        cin >> a[i] >> b[i];
        s[a[i]].push_back(b[i]);
        s[b[i]].push_back(a[i]);
    }
    for(int i = 0;i < q;i++){
        cin >> p[i] >> x[i];
        num[p[i]] += x[i];
    }
    
    queue<int> que;
    que.push(1);
    while(!que.empty()){
        int t = que.front();
        que.pop();
        seen[t] = 1;
        for(auto v:s[t]){
            if(!seen[v]){
                num[v] += num[t];
                que.push(v);
            }
        }
    }
    for(int i = 1;i <= n;i++)cout <<  num[i] << " ";
    
    
}

Measured memory_bytes: 19816
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	int n, i;
	cin >> n;
	int a[n + 1], b[n + 1], c[n + 1], dp[n + 1][3];
	foe(i, 1, n)
	cin >> a[i] >> b[i] >> c[i];
	dp[1][0] = a[1], dp[1][1] = b[1], dp[1][2] = c[1];
	foe(i, 2, n)
	{
		dp[i][0] = max((i > 2 ? dp[i - 2][0] : 0), a[i] + max(dp[i - 1][1], dp[i - 1][2]));
		dp[i][1] = max((i > 2 ? dp[i - 2][1] : 0), b[i] + max(dp[i - 1][0], dp[i - 1][2]));
		dp[i][2] = max((i > 2 ? dp[i - 2][2] : 0), c[i] + max(dp[i - 1][0], dp[i - 1][1]));
	}
	cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
}

Measured memory_bytes: 2560
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

struct edge {
  int src, dst;
  ll cost;
};

int main() {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<edge> es(M);
  FOR(e,es) {
    cin >> e.src >> e.dst >> e.cost;
    e.src--;
    e.dst--;
  }
  VL score(N, -1e13);
  score[0] = 0;
  bool inf = false;
  REP(i,0,N) {
    FOR(e,es) {
      if(score[e.dst] < score[e.src] + e.cost) {
        score[e.dst] = score[e.src] + e.cost;
        if(i == N - 1 && e.dst == N - 1) {
          inf = true;
          break;
        }
      }
    }
  }
  if(inf) {
    cout << "inf" << endl;
  } else {
    cout << score[N - 1] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

a,b,m = l_in()
A = l_in()
B = l_in()

res = min(A)+min(B)

for _ in range(m):
    x,y,c = l_in()
    res = min(res, A[x-1]+B[y-1]-c)
print(res)


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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  
  sort(a.begin(), a.end());
  
  int ans = 0;
  ans = a[n-1] - a[0];
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 1000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

int match[10];
int dp[10000 + 10];
vi A;

signed main(void) {
    match[1] = 2;
    match[2] = 5;
    match[3] = 5;
    match[4] = 4;
    match[5] = 5;
    match[6] = 6;
    match[7] = 3;
    match[8] = 7;
    match[9] = 6;
    int N, M;
    cin >> N >> M;

    rep(i, M) {
        int a; cin >> a;
        A.push_back(a);
    }
    sort(all(A));
    
    dp[0] = 0;
    REP(i, 1, N) {
        dp[i] = -1;
        rep(j, M) {
            if (i - match[A[j]] == 0) {
                dp[i] = max(dp[i], 1LL);
            } else if (i - match[A[j]] > 0){
                if (dp[i - match[A[j]]] != -1) {
                    dp[i] = max(dp[i], dp[i - match[A[j]]] + 1);
                }
            }
        }
    }
    // REP(i, 0, N) {
    //     cout << i << ":" << dp[i] << endl;
    // }

    int rem_d = dp[N];
    int rem_m = N;
    string str = "";
    while(rem_d > 0) {
        // cout << "rem_d:" << rem_d << endl;
        // cout << "rem_m:" << rem_m << endl;
        for(int i=M-1; i>=0; i--) {
            // cout << "match[" << A[i] << "]=" << match[A[i]] << endl;
            if (rem_m >= match[A[i]]) {
                if (dp[rem_m - match[A[i]]] == rem_d - 1) {
                    // cout << A[i];
                    str += to_string(A[i]);
                    rem_m -= match[A[i]];
                    rem_d--;
                    break;
                }
            }
        }
    }
    cout << str << endl;
    
    // map<int, int> m;
    // rep(i, str.size()) {
    //     m[str[i]-'0']++;
    // }
    // for (auto itr = m.begin(); itr!=m.end(); itr++) {
    //     cout << "m[" << itr->fi << "] = " << itr->se << endl;
    // }

    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    string s,t;cin>>s>>t;
    int len=s.length();
    for(int i=0;i<len;i++){
        if(s==t){
            cout<<"Yes"<<endl;
            return 0;
        }
        s = s[len-1] + s.substr(0,len-1);
        //cout<<s<<endl;
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize(3)
#include<iostream>
using namespace std;
int N,M,sum,xi,Map[55][55],visit[55];
main(){
cin>>N>>M;
for(int i=1;i<=M;i++){
int a,b;cin>>a>>b;
visit[a]++,visit[b]++;
Map[a][b]=Map[b][a]=1;}
bool falg=true;
while(1){
falg=true;
for(int i=1;i<=N;i++){
if(visit[i]==1){
sum++,xi=i,falg=false,visit[i]--;break;}}
if(falg)break;
for(int i = 1;i<=N;i++){
if(Map[xi][i]==1)
visit[i]--;}}
cout<<sum<<endl;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long  
 
int32_t main(){
 
    IOS;
    int t, o;
    cin >> t >> o;
    cout << t*o << endl;
    return 0;
}
 

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

using namespace std;

int main() {
    long int a,b;
   cin>>a>>b;
    long int arr[a];
   for(long int i=0;i<a;i++)
   {
       cin>>arr[i];
   }
   int n = sizeof(arr)/sizeof(arr[0]); 
    sort(arr, arr+n); 
    long int d = a-1;
   while(b>0)
   {
       arr[d] = 0;
       d--;
       b--;
   }
    long int sum=0;
   for(long int i=0;i<a;i++)
   {
       sum = sum + arr[i];
   }
   cout<<sum;
}

Measured memory_bytes: 1792
using System;

namespace abc123_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] ant = new int[5];
            int ans = 0;
            for(int i = 0; i < 5; i++)
            {
                ant[i]=Convert.ToInt32(Console.ReadLine());
            }
            int k =Convert.ToInt32(Console.ReadLine());
            for(int i = 0; i < 5; i++)
            {
                for(int n = 0 ; n < 5; n++)
                {
                    if (i < n) {
                        if (ant[n] - ant[i] > k)
                        {
                            ans++;
                        }
                      }
                }
            }
            if (ans == 0)
            {
                Console.WriteLine("Yay!");
            }
            else
            {
                Console.WriteLine(":(");
            }
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	ll x, y;
	cin >> x >> y;
	ll power = 1;
	while (x <= 10e18 / power) {
		x *= power;
		if (x % y == 0) power++;
		else {
			cout << x << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>

int main()
{
  char s[10];
  scanf("%s", s);
  scanf("%s", s + strlen(s));
  int n = atoi(s);
  puts(std::sqrt(n) == std::floor(std::sqrt(n)) ? "Yes" : "No");
  return 0;
}

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

using namespace std;

#define fill(A, val) memset(A,val,sizeof(A))
#define rep(i, a, n) for (int (i)=a;(i)<n;++(i))
#define per(i, n, a) for (long long (i)=n-1;(i)>=a;--(i))
#define all(V) V.begin(),(V).end()
#define sz(V) (int)(V).size()
#define pb push_back
#define fi first
#define se second
#define ret return
#define tr true
#define fl false
#define _ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef pair<ll, ll> pll;                                                                                                                                                        
typedef pair<ld, ld> pdd;                                  						
typedef map<int, int> mii;
typedef map<ll, ll> mll;                    
typedef pair<string,int> si;
const double eps = 1e-8;                        
const double Pi = 3.14159265358979323846264338327950288419716939937510;
const long long INF = 1LL << 60;
const long long MAX3 = 1005;
const long long MAX4 = 10005;
const long long MAXN = 100005;
const long long MAX6 = 1000005;
const long long MOD = 1e9 + 7;
const long long N = (int)1e7;
const int Grn = 10000;

ll n,a[5555555],mx =-INF,mn = INF;
ll x,ans,cnt = INF;

ll f(ll x){
ll sum = 0;
for(int i = 1; i <= n; ++ i){
 sum+=(a[i]-x)*(a[i]-x);
}
return sum;
}
int main()
{_
cin>>n;
for(int i  =1; i <= n; ++ i){
 cin>>a[i];
mx = max(mx,a[i]);
mn = min(mn,a[i]);
}
ll l = mn;
ll r = mx;

for(int i = 1; i <= 100; ++ i){
ll m1 = (2*l+r)/3;
ll m2 = (2*r+l)/3;

if(f(m1)<=f(m2))r = m2;
else l = m1;
}

for(int i = l; i <= r; ++ i){
cnt = min(cnt,f(i));
}
cout<<cnt;
return 0;
}

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

int main(){
	string s;
	cin>>s;
	int i;
	int n=s.size();
	int num=0;
	if(n%2){
		for(i=0;i<n/2;i++){
			if(s[i]!=s[n-1-i]){
				num++;
			}
		}
	}
	else{
		for(i=0;i<n/2;i++){
			if(s[i]!=s[n-1-i]){
				num++;
			}
		}
	}
	cout<<num;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{ int a,b,c,d,e,x,y;
cin>>a>>b>>c>>d>>e;
if(a<=b&&a<=c){x=a;}
if(b<=a&&b<=c){x=b;}
if(c<=a&&c<=b){x=c;}
if(d<=e){y=d;}
if(e<d){y=e;}
cout<<x+y-50<<"\n";
 return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;

const int N = 1e5 + 123;
int n, m, h[N];
vi adj[N];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
	}
	while (m--) {
		int x, y;
		cin >> x >> y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int bad = 0;
		for (int to : adj[i]) {
			if (h[to] >= h[i]) {
				bad = 1;
			}
		}
		if (!bad) {
			ans++;
		}
	}
	cout << ans;
}


Measured memory_bytes: 9096
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<cstdlib>
#include<cctype>
#include<ctime>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e5 + 5;
const ll maxm = 1e3 + 5;
template<class T>
inline T qread(T &IEE){
	register T x = 0, f = 1;
	register char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-'){
			f = -f;
		}
		ch = getchar();
	}
	while(isdigit(ch)){
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar();
	}
	return IEE = x * f;
}
template<class T>
inline void qwrite(T a){
	if(!a){
		putchar('0');
		return ;
	}
 	if(a < 0){
		putchar('-');
		a = -a;
	}
	if(a > 9) qwrite(a / 10);
	putchar(a % 10 + 48);
	return ;
}
template<class T>
inline T ab(T a){
	return (a > 0) ? a : -a;
}
template<class T>
inline void swa(T &a, T &b){
	a ^= b ^= a ^= b;
	return ;
}
ll x;
int main(){
//	freopen("1.in", "r", stdin);
//	freopen("1.out", "w", stdout);
	qread(x);
	for(ll i = -1000;i <= 1000;i++){
		for(ll j = -1000;j <= 1000;j++){
			ll sum = i * i * i * i * i - j * j * j * j * j;
			if(sum == x){
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3636
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int t = sc.nextInt();
        int time = t;
        while(x < n){
            n -= x;
            time += t;
        }
        System.out.println(time);
    }
}

Measured memory_bytes: 35620
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()

class SegmentTree(object):
    def __init__(self,A,dot,e):
        n=2**((len(A)-1).bit_length())
        self.__n=n
        self.__dot=dot
        self.__e=e
        self.__node=[e]*(2*n)
        for i in range(len(A)):
            self.__node[i+n]=A[i]
        for i in range(n-1,-0,-1):
            self.__node[i]=dot(self.__node[2*i],self.__node[2*i+1])

    def update(self,i,c):
        i+=self.__n
        node=self.__node
        node[i]=c
        while(i!=1):
            i//=2
            node[i]=self.__dot(node[2*i],node[2*i+1])

    def sum(self,l,r):
        vl,vr=self.__e,self.__e
        l+=self.__n; r+=self.__n
        while(l<r):
            if(l%2==1):
                vl=self.__dot(vl,self.__node[l])
                l+=1
            l//=2
            if(r%2==1):
                r-=1
                vr=self.__dot(self.__node[r],vr)
            r//=2
        return self.__dot(vl,vr)

def resolve():
    n,m=map(int,input().split())
    S=list(map(lambda x:int(x),input()))
    dp=[INF]*(n+1)
    dp[-1]=0
    tree=SegmentTree(dp,min,INF)
    for i in range(n-1,-1,-1):
        if(S[i]): continue
        s=tree.sum(i,min(i+m+1,n+1))
        dp[i]=s+1
        tree.update(i,s+1)

    if(dp[0]==INF):
        print(-1)
        return

    now=0
    val=dp[0]
    path=[]
    for i,x in enumerate(dp):
        if(x==INF): continue
        if(x<val):
            path.append(i-now)
            now=i
            val=x

    print(*path)
resolve()

Measured memory_bytes: 77788
a,b,x=map(int,input().split())

div=a/b

from math import tan
from math import degrees
from math import pi

l=0
r=pi/2
for i in range(10000):
    mid=(l+r)/2
    t=tan(mid)
    if t<=div:
        f=a*b*b*t/2
    else:
        f=a*a/2*(2*b-a/t)
    if f<=x:
        l=mid
    else:
        r=mid

print(90-degrees(r))


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

int main(){
  int N, Q, count=0;
  int l, r;
  string str;
  cin >> N >> Q;
  cin >> str;
  vector<int> ans(N,0);
  
  for(int i=0; i<N-1; i++){
    if(str[i]=='A' && str[i+1]=='C') count++;
    ans[i]=count;
  }
  
  for(int i=0; i<Q; i++){
    cin >> l >> r;
    cout << ans[r-2]-ans[l-2] << endl;
  }
  return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;

class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int i;
        int y;
        int p;
        while (n != 0) {
            int a[] = new int[n];
            int g = 1000000;
            for (i = 0; i < n; i++) {
                a[i] = sc.nextInt();
            }

            for (i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (i != j) {
                        y = a[i] - a[j];
                        if (y < 0) {
                            y = y * -1;
                        }
                        if (y < g) {
                            g = y;
                        }

                    }
                }
            }

            System.out.println(g);
            n = sc.nextInt();
        }
    }
}



Measured memory_bytes: 51096
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void pV(vector<ll> A){
    cout << "[vector]";
    for(int i=0; i<A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    // input
    ll N;
    cin >> N;

    if(N%2==0){
        p(N);
    }else{
        p(2*N);
    }
    
    return 0;
}

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

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

using ll = long long;
using P = pair<int,int>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

int main() {
    ll N,K;
    cin>>N>>K;
    vector<ll> v(N);
    rep(i,N) cin>>v[i];
    for(ll i = K; i < N; i++){
        if(v[i-K]<v[i]) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

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

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

int main( void ){
    ll n;
    cin >> n;
    ll a[n];
    for (int i=0; i<n; i++) cin >> a[i];

    ll ans = a[0];
    for (int i=1; i<n; i++){
        ans = gcd(a[i], ans);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K, A, B;
  cin >> K >> A >> B;

  for (int i = A; i <= B; i++) {
    if (i%K == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;



int main(){

    string s;
    cin >> s;
    string t;
    cin >> t;

    int s_count ;
    cin >> s_count;

    int t_count;
    cin >> t_count;

    string u;
    cin >> u;

    if(u==s){
        s_count--;
    }else{
        t_count--;
    }
    cout << s_count << " " << t_count;

}

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

int main() {
    int64 N, P;
    cin >> N >> P;
    if(N == 1) {
        cout << P << '\n';
        return 0;
    }
    if(P == 1) {
        cout << 1 << '\n';
        return 0;
    }
    int64 n = P, ans = 1;
    for(int64 i = 2; i * i <= n; ++i) {
        int64 cnt = 0;
        while(n % i == 0) {
            n /= i, ++cnt;
            if(cnt == N) ans *= i, cnt = 0;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>


using namespace std;

long long H;



int main()
{


	cin >> H;
	long long num = 1;
	long long ans = 1;

	long long h = H;
	while (h>1) {
		h /= 2;

		num *= 2;
		ans += num;
	}

	cout << ans << endl;

	return 0;
}



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

using namespace std;

struct data
{
    int num;
    int ini;
    char c;
};

void swap(struct data *a, struct data *b)
{
    struct data temp = *a;
    *a = *b;
    *b = temp;
}

int partition(struct data A[], int p, int r)
{
    int x = A[r].num;
    int i = p - 1;
    for (int j = p; j < r; j++)
    {
        if (A[j].num <= x)
        {
            i++;
            swap(&A[i], &A[j]);
        }
    }
    swap(&A[i + 1], &A[r]);
    return i + 1;
}

void quicksort(struct data A[], int p, int r)
{
    if (p < r)
    {
        int q = partition(A, p, r);
        quicksort(A, p, q - 1);
        quicksort(A, q + 1, r);
    }
}

int main()
{
    int n;
    scanf("%d", &n);
    struct data array[n];
    for (int i = 0; i < n; i += 1)
    {
        //printf("%d\n", i);
        //scanf("%c %d", &array[i].c, &array[i].num);
        cin >> array[i].c >> array[i].num;
        array[i].ini = i;
    }

    quicksort(array, 0, n - 1);

    int f = 1;
    for (int i = 1; i < n; i++)
    {
        if (array[i - 1].num < array[i].num || (array[i - 1].num == array[i].num && array[i - 1].ini < array[i].ini))
        {
            continue;
        }
        else
        {
            f = 0;
            break;
        }
    }
    if (f)
    {
        puts("Stable");
    }
    else
    {
        puts("Not stable");
    }

    for (int i = 0; i < n; i++)
    {
        printf("%c %d\n", array[i].c, array[i].num);
    }

    return 0;
}


Measured memory_bytes: 4328
def solve(x):
    result = 0
    fh_yen = x // 500
    x -= 500 * fh_yen
    result += 1000 * fh_yen
    f_yen = x // 5
    result += 5 * f_yen
    return result


if __name__ == "__main__":
    print(solve(int(input())))


Measured memory_bytes: 2940
from functools import reduce
from operator import mul
from collections import Counter


def generate_primes(n):
    """Returns list of primes <= n."""
    from math import sqrt
    isprime = [True] * n
    isprime[0] = False
    for i in range(2, 1+round(sqrt(n))):
        if not isprime[i-1]:
            continue
        for j in range(2, 1 + n // i):
            isprime[i*j-1] = False
    p = [i+1 for i, v in enumerate(isprime) if v]
    return p


def fact_in_primes(n, primes):
    """primes must be sorted."""
    # assert 1 not in primes
    from collections import Counter
    c = Counter()
    for p in primes:
        if n < p:
            break
        while n % p == 0:
            n //= p
            c[p] += 1
    assert n == 1
    return c


N = int(input())
primes = generate_primes(N)
c = sum([fact_in_primes(n, primes) for n in range(2, N + 1)], Counter())
ans = reduce(mul, [n + 1 for n in c.values()], 1) % 1000000007
print(ans)


Measured memory_bytes: 3868
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    s.erase(unique(s.begin(),s.end()),s.end());
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 3728
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	ans := 0
	for i := 1; i*i < n; i++ {
		if n%i == 0 {
			if i != 1 {
				if n%(i-1) == n/(i-1) {
					ans += i - 1
				}
			}
			j := n / i
			if n%(j-1) == n/(j-1) {
				ans += j - 1
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    s = input()


    for i in range(len(s)//2):
        if s[i] != s[len(s)-1 -i]:
            print('No')
            return
    
    print('Yes')

solve()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define INF 1023456789
#define sacnf scanf
#define CRLF <<'\n';
#define PRPAIR(x) x.first << x.second
#define DEBUG(x) do { std::cerr <<(x)<<'\n'; } while (0)
#define rep(i,a,b) for(int i=(a);i!=(int)b-((a)>(b));(a)>(b)?--i:++i)
#define trav(it,v) for(typeof(v.begin()) it = v.begin(); it != v.end(); ++it)

using namespace std;
typedef pair<int,int> ii;
typedef pair<int,ii> pip;
typedef vector<int> vi;
typedef long long ll;

int main(){
    int n;
    scanf("%d",&n);
    string pos[] = {"AC","WA","TLE","RE"};
    map<string,int> m;
    for(auto p: pos){
        m[p]=0;
    }
    string s;
    rep(i,0,n){
        cin >> s;
        m[s]++;
    }
    for(auto p: pos){
        cout << p << " x " << m[p] CRLF
    }

}


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

int main(){
	int h,w;
	while(1){
		cin >> h >> w;
		if(h+w==0) break;
		char a[w][h];
		bool p[w][h];
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin >> a[j][i];
				p[j][i] = false;
			}
		}
		int x = 0;
		int y = 0;
		bool loop = false;
		while(1){
			if(p[x][y]){ loop = true; break;}
			p[x][y] = true;
			if(a[x][y]=='.') break;
			else if(a[x][y]=='>') x++;
			else if(a[x][y]=='<') x--;
			else if(a[x][y]=='^') y--;
			else if(a[x][y]=='v') y++;
		}
		if(loop) cout << "LOOP" << endl;
		else cout << x << " " << y << endl;
	}
}

Measured memory_bytes: 1176
mod = 10 ** 9 + 7
s = input()
dp = [[0] * 4 for i in range(len(s) + 1)]
dp[len(s)][3] = 1
for i in range(len(s))[::-1]:
    for j in range(4)[::-1]:
        if s[i] == "?":
            dp[i][j] = dp[i + 1][j] * 3
        else:
            dp[i][j] = dp[i + 1][j]
        if j < 3:
            if s[i] == "?" or s[i] == "ABC"[j]:
                dp[i][j] += dp[i + 1][j + 1]
        dp[i][j] %= mod
print(dp[0][0])

Measured memory_bytes: 32024
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    map<string, int> m;
    vector<string> v = {"AC", "WA", "TLE", "RE"};

    REP(i, N) {
        string s;
        cin >> s;
        m[s]++;
    }

    for(auto e: v) {
        cout << e << " x " << m[e] << endl;
    }
}


Measured memory_bytes: 3660
import java.util.*
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }
fun listOfLong() =listOfString().map { it.toLong() }
fun listOfDouble() =listOfString().map { it.toDouble() }
fun main(args:Array<String>){
  var n = nextInt()
  var dp = Array<Int>(110000,{2000000000})
  var h = listOfInt()
  dp[0] = 0
  dp[1] = h[1]-h[0]
  if(dp[1]<0)dp[1] *= -1
  for(i in 2..n-1){
    dp[i] = Math.min(dp[i-1]+Math.abs(h[i]-h[i-1]),
    dp[i-2]+Math.abs(h[i]-h[i-2]))
  }
  println(dp[n-1])
}


Measured memory_bytes: 51904
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

#include <boost/heap/fibonacci_heap.hpp>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

template <class T>
ostream &operator<<(ostream &os, const set<T> &st) {
	for (const auto &e : st) os << e << " ";
	return os;
}

template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
	for (const auto &e : mp) os << e << " ";
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T = lint>
struct Edge {
	int to;
	T cost;
	int tank;
	Edge() {}
	Edge(int to, T cost, int tank = 0) : to(to), cost(cost), tank(tank) {}
	bool operator>(const Edge &r) const { return this->cost > r.cost; }
};

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M, L;
	cin >> N >> M >> L;

	vector<vector<Edge<int>>> edges(N);
	for (int i = 0; i < M; i++) {
		int u, v, len;
		cin >> u >> v >> len;
		u--, v--;
		if (len > L) continue;
		edges[u].emplace_back(v, len);
		edges[v].emplace_back(u, len);
	}

	auto dijkstra = [&](int st) {
		vector<pair<int, int>> dp(N, { -INF, 0 });
        vector<int> used(N, 0);
		dp[st] = { 0, L };
		using ppi = pair<pair<int, int>, int>;
		boost::heap::fibonacci_heap<ppi> que;
        vector<decltype(que)::handle_type> handles(N);
        for (int v = 0; v < N; v++) handles[v] = que.emplace(dp[v], v);
		for (int k = 0; k < N; k++) {
			auto now = que.top();

			for (const auto &e : edges[now.second]) {
				if (used[e.to]) continue;
              
				auto tmp = now.first;
				if (e.cost > tmp.second) {
					tmp.first--;
					tmp.second = L - e.cost;
				}
				else tmp.second -= e.cost;

				if (tmp > dp[e.to]) {
					dp[e.to] = tmp;
					que.update(handles[e.to], ppi(tmp, e.to));
				}
			}
            used[now.second] = 1;
            que.update(handles[now.second], ppi({-INF-1, 0}, now.second));
		}
		return dp;
	};

	vector<vector<pair<int, int>>> memo(N);
	for (int i = 0; i < N; i++) memo[i] = dijkstra(i);

	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int s, t;
		cin >> s >> t;
		s--, t--;
		auto tmp = memo[s][t].first;
		if (tmp != -INF) cout << -tmp << "\n";
		else cout << -1 << "\n";
	}

	return 0;
}


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

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


    for(int i = 0 ; i < s.size() ; i++){
        if(s[i] != t[i]){ 
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3596
x,k,d=map(int,input().split())

x=abs(x)
ans=0
if x>=d*k:
  ans=x-k*d
else:
  e= int(x/d)
  k-=e
  x-=e*d
  if k%2==1:
    x=abs(x-d)
  ans=x

print(ans)

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

int main(){
    int N,M,X,Y;
    cin >> N >> M >> X >> Y;
    int x[N];
    int y[M];
    for(int i=0;i<N;i++){
        cin >> x[i];
    }
    for(int i=0;i<M;i++){
        cin >> y[i];
    }
    sort(x,x+N);
    sort(y,y+M);
    for(int z=-100;z<=100;z++){
        if(X<z&&z<=Y){
            if(x[N-1]<z&&z<=y[0]){
                cout << "No War" << endl;
                return 0;
            }
        }
    }
    cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long h;
    cin>>h;
    long long count=1;
    long long ans=0;
    while(h>0)
    {
        ans+=count;
        count*=2;
        h=h/2;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int f(char a[],int l){
	int i;
	int flag=1;
	
	l++;
	if(l%2)
		return 0;
	for(i=0;a[i+l/2]!=0;i++){
		if(a[i]!=a[i+l/2]){
			flag=0;
			break;
		}
	}
	return flag;
}


int main(void){
	char a [205];
	int l,i;
	
	scanf("%s",a);
	l=strlen(a);
	for(i=l-1;i>=0;i--){
		a[i]=0;
		if(f(a,i-1)==1){
			break;
		}
	}
	printf("%d",i);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){

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

  int sum = 0;
  int same = 0;
  for (int i = 0; i < n; i++) {
    sum += d[i];
    same += d[i]*d[i];
  }

  int all = sum*sum;
  int answer = all-same;
  answer /= 2;
  printf("%d\n", answer);

  return 0;
}

Measured memory_bytes: 128
N = int(input())
T = [int(input()) for i in range(N)]
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

print(lcm_list(T))

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

using namespace std;

int w,h;
bool field[50][50];
vector<int> ans;

void dfs(int i,int j);

int main(){
	while(1){
		for(int i = 0;i < 50;i++){
			for(int j = 0;j < 50;j++){
				field[i][j] = false;
			}
		}
		cin >> w >> h;
		if(w + h == 0) break;
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				int f;
				cin >> f;
				if(f == 1) field[i][j] = true;
			}
		}
		int count = 0;
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				if(field[i][j]){dfs(i,j);count++;}
			}
		}
		ans.push_back(count);
	}
	for(int i = 0;i < ans.size();i++) cout << ans[i] << endl;
	return 0;
}

void dfs(int i,int j){
	field[i][j] = false;
	if(i != 0 	&& j != 0 	&& field[i-1][j-1])dfs(i-1,j-1);
	if(i != 0 				&& field[i-1][j])dfs(i-1,j);
	if(i != 0 	&& j != w-1 && field[i-1][j+1])dfs(i-1,j+1);
	if(			   j != w-1 && field[i][j+1])dfs(i,j+1);
	if(i != h-1 && j != w-1 && field[i+1][j+1])dfs(i+1,j+1);
	if(i != h-1 			&& field[i+1][j])dfs(i+1,j);
	if(i != h-1 && j != 0 	&& field[i+1][j-1])dfs(i+1,j-1);
	if(			   j != 0 	&& field[i][j-1])dfs(i,j-1);
}

Measured memory_bytes: 3360
import Data.List

f :: Int -> [Int] -> [Int]
f n xs = [if x <= a then b else a | x <- xs]
  where
    [a,b] = take 2 $ drop (div n 2 - 1) (sort xs)
  
main = do
  n <- readLn
  xs <- (map read . words) <$> getLine
  mapM_ print $ f n xs

Measured memory_bytes: 102140
#include <bits/stdc++.h>
#define inf (long long)1e10
using  namespace std;

long long l;
vector<long long> a;
// 0,4: 1,3: even 2: odd
vector<vector<long long>> dp;


long long  solve();

int main(){
    cin >> l;
    a.resize(l);
    for(long long i = 0;i < l;++i)cin >> a[i];
    cout << solve() << endl;
}

long long solve(){
    long long ans = inf;
    dp.assign(l + 1,vector<long long>(5,inf));
    for(int i = 0;i < 5;++i)dp[0][i] = 0;
    for(long long i = 0;i < l;++i)
        for(int j = 0;j < 5;++j)
            for(int k = 0;k <= j;++k){
                long long now;
                if(j == 0 || j == 4)now = a[i];
                else if(j == 1 || j == 3){
                    now = a[i] % 2;
                    if(a[i] == 0)now = 2;
                }
                else now = (a[i] % 2) ^ 1LL;
                dp[i+1][j] = min(dp[i+1][j],dp[i][k] + now);
            }
    for(int i = 0;i < 5;++i)ans = min(ans,dp[l][i]);
    return ans;
}

Measured memory_bytes: 15872
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define wl() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

///////////////////////////////////////////////////////////////////////////////////////

ll n, x, m[110];
ll t, minm = 1100, ans;

int main() {
	cin >> n >> x;
	t = x;
	repi(i, 0, n) {
		rd(m[i]);
		t -= m[i];
		minm = min(minm, m[i]);
	}
	wrln(n + t / minm);
	return 0;
}


Measured memory_bytes: 256