akhauriyash/Code-Regression huggingface dataset:
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
 
ll pwr(ll base, ll p, ll mod=MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 
 
ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}


const int N = 100005;
int n, arr[N];
ll fac[N], invFac[N];

ll C(int n, int r){
    if(r < 0 || r > n)  return 0;
    ll ans = fac[n];
    ans = (ans * invFac[r]) % MOD;
    ans = (ans * invFac[n-r]) % MOD;
    return ans;
}



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

    fac[0] = invFac[0] = 1;
    for(int i=1;i<N;i++){
        fac[i] = (i * fac[i-1]) % MOD;
        invFac[i] = pwr(fac[i], MOD-2);
    }

    scanf("%d", &n);
    ll sum = 0;
    for(int i=1;i<=n+1;i++){
        scanf("%d", &arr[i]);
        sum += arr[i];
    }
    sum -= 1LL*n*(n+1)/2;
    
    int pos1 = -1, pos2 = -1;
    for(int i=1;i<=n+1;i++)
        if(arr[i] == sum){
            if(pos1 == -1)  pos1 = i;
            else    pos2 = i;
        }

    for(int k=1;k<=n+1;k++){

        ll ans = C(n-1, k);
        ans %= MOD;
        ans += C(n-1, k-1)*2 - C(n-1-(pos2-pos1-1), k-1);
        ans %= MOD;
        ans += C(n-1, k-2);
        ans %= MOD;
        ans += MOD;
        ans %= MOD;
        printf("%lld\n", ans);
    }

    return 0;
}









Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#define sz(x) (int)(x).size()
/* --- */
int main() {
int n,sum=0;
cin>>n;
int arr[n];

for(int i =0; i<n; i++)
{
	cin>>arr[i];
	sum+=arr[i];	
}

int temp=round((float)sum/(float)n);
//cout<<temp<<endl;
sum=0;

for(int i=0;i<n; i++)
{
	sum+=round(pow((temp-arr[i]),2));
//	cout<<i<<"="<<pow((temp-arr[i]),2)<<endl;
}

cout<<sum<<endl;
}



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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

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

class trie{
public:
    trie* next[26];
    int size;
    bool f;

    trie(){
        fill(next,next+26,(trie*)0);
        size=0;
        f=false;
    }
    void insert(const string &str){
        insert(str,0);
    }
    int count(const string &str,vector<vector<int>> &cnt){
        return count(str,0,cnt);
    }
    void insert(const string &str,const int idx){
        if(idx==str.size()){
            ++size;
            f=true;
            return;
        }
        if(this->next[str[idx]-'a']==NULL) this->next[str[idx]-'a']=new trie();
        ++size;
        this->next[str[idx]-'a']->insert(str,idx+1);
    }
    int count(const string &str,const int idx,vector<vector<int>> &cnt){
        if(idx==str.size()) return 0;
        if(this->next[str[idx]-'a']==NULL) return 0;
        int contain=0;
        if(f) ++contain;
        rep(i,0,26){
            if(this->next[i]!=NULL) cnt[i][str[idx]-'a']+=this->next[i]->size;
        }
        return contain+this->next[str[idx]-'a']->count(str,idx+1,cnt);
    }
};

void solve(){
    int n;
    cin >> n;
    vector<string> s(n);
    trie t;
    rep(i,0,n){
        cin >> s[i];
        t.insert(s[i]);
    }

    vector<vector<pair<int,string>>> queries(n);
    int q;
    cin >> q;
    rep(i,0,q){
        int k;
        string p;
        cin >> k >> p;
        queries[k-1].push_back(make_pair(i,p));
    }

    vector<int> ans(q);
    rep(i,0,n){
        vector<vector<int>> cnt(26,vector<int>(26));
        int k=t.count(s[i],cnt);
        for(auto &query:queries[i]){
            vector<int> index(26);
            rep(j,0,26) index[query.second[j]-'a']=j;
            rep(j,0,26){
                rep(k,0,26){
                    if(index[j]<index[k]) ans[query.first]+=cnt[j][k];
                }
            }
            ans[query.first]+=k;
        }
    }
    rep(i,0,q) cout << ans[i]+1 << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 97280
#include <cstdio>
#include <algorithm>
using namespace std;
int n,i;
char s[100050];
int main()
{
	scanf("%d",&n);
	scanf("%s",s);int cnt1=0,cnt2=0;
	for (i=0;i<n;i++) if (s[i]=='>') break;else cnt1++;
	for (i=n-1;i>=0;i--) if (s[i]=='<') break;else cnt2++;
	printf("%d\n",n-min(cnt1,cnt2));
	return 0;
}


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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

bool calc(int i, int n) {
    while(true) {
        n -= i;
        if(n==0) return true;
        if(n<0) return false;
        i++;
    }
}

int solve(int n) {
    int ans = 0;
    for(int i=1; i<n; ++i) {
        if(calc(i, n)) ans++;
    }
    return ans;
}

int main()
{
    int n;
    while(cin>>n, n) {
        cout << solve(n) << endl;
    }
    return 0;
}

Measured memory_bytes: 2980
import collections

n = int(input())
v = list(map(int, input().split()))
v1 = v[0::2]
v2 = v[1::2]
c1 = collections.Counter(v1)
c2 = collections.Counter(v2)
best_v1_val = c1.most_common()[0][0]
best_v2_val = c2.most_common()[0][0]
best_v1_cnt = c1.most_common()[0][1]
best_v2_cnt = c2.most_common()[0][1]

if best_v1_val != best_v2_val:
  cnt = n//2 - best_v1_cnt + n//2 - best_v2_cnt
else:
  if len(c1) != 1:
    sec_best_v1_cnt = c1.most_common()[1][1]
  else:
    sec_best_v1_cnt = 0
  if len(c2) != 1:
    sec_best_v2_cnt = c2.most_common()[1][1]
  else:
    sec_best_v2_cnt = 0
  cnt = min(n//2 - best_v1_cnt + n//2 - sec_best_v2_cnt, n//2 - sec_best_v1_cnt + n//2 - best_v2_cnt,)
print(cnt)

Measured memory_bytes: 19032
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
    
int main(){
  string s;
  cin >> s;
  string S;
  for(int i = 0; i < s.size(); i += 2){
    S += s[i];
  }
  cout << S << endl;
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  int N = s.size();
  int k = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      if (s.at(i) == '1') {
        k++;
      }
    }
    else {
      if (s.at(i) == '0') {
        k++;
      }
    }
  }
  int w = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      if (s.at(i) == '0') {
        w++;
      }
    }
    else {
      if (s.at(i) == '1') {
        w++;
      }
    }
  }
  cout << min(k, w) <<endl;
}

Measured memory_bytes: 512
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mat = lambda x, y, v: [[v]*y for _ in range(x)]
ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
A = rl()

pref = []
s = 0
for a in A:
	s += a
	pref.append(s)
ans = 0
for i in range(N-1):
	ans += pref[i] * A[i+1]
	ans = ans % mod
print(ans)


Measured memory_bytes: 105424
#include <bits/stdc++.h>
//g++ -std=c++11
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

vector < vector <int> > g(200005);
bool used[200005];
int ans[200005];
queue <int> q;
int d[200005];

int main() {

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

    int n,m,a,b;
    cin >> n >> m;
    memset(used, false, sizeof used);
    for (int i=0; i<m; i++) {
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    q.push(1);
    d[1] = 0;
    used[1] = true;
    while(!q.empty()) {
        int u = q.front();
        q.pop();
        for(int v : g[u]) {
            if(!used[v]) {
                used[v] = true;
                q.push(v);
                d[v] = d[u]+1;
                ans[v] = u;
            }
        }
    }

    bool sepuede = true;
    for(int i=1; i<=n; i++) {
        if(!used[i])
            sepuede = false;
    }

    if(sepuede) {
        cout << "Yes" << endl;
        for (int i=2; i<=n; i++) {
            cout << ans[i] << "\n";
        }
    } else {
        cout << "No" << "\n";
    }

    return 0;
}

Measured memory_bytes: 13060
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    
    vector<int> h(n);
    int i;
    for(i=0; i<n; i++) {
        scanf("%d", &h[i]);
    }

    for(i=0; i<n; i++) {
        if(i==0 || h[i-1]<h[i]) {
            h[i]--;
        }
        if(i>0 && h[i-1]>h[i]) {
            printf("No\n"); return 0;
        }
    }
    printf("Yes\n");

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <string.h>
#include <string>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;
int curpass, num;
string u;
int n, a, b;

int main(void)
{
	cin>>n>>a>>b>>u;
	for(int i=0 ; i<=n-1 ; i++)
	{
		if(u[i]=='c')
		{
			cout<<"No"<<endl;
			continue;
		}
		if(u[i]=='a')
		{
			if(curpass<a+b)
			{
				cout<<"Yes"<<endl;
				curpass++;
			}
			else
			{
				cout<<"No"<<endl;
			}
			continue;
		}
		if(u[i]=='b')
		{
			num++;
			if(curpass<a+b && num<=b)
			{
				cout<<"Yes"<<endl;
				curpass++;
			}
			else
			{
				cout<<"No"<<endl;
			}
			continue;
		}
	}
}

Measured memory_bytes: 896
#include<stdio.h>

int main()
{
  
  int i,j,tmp,count=0,N,flag;
  int A[100];

  scanf("%d",&N);
  
  for(i=0;i<N;i++) scanf("%d",&A[i]);
  
 
  for(i=0;i<=N-1;i++){
    for(j=N-1;j>=0;j--){
      if(A[j]<A[j-1]){
	tmp = A[j];
	A[j] = A[j-1];
	A[j-1] = tmp;
	count++;
      }
    }
  }
   for(i=0;i<N;i++){
      printf("%d",A[i]);
    if(i != N-1) printf(" ");   
    }  
   printf("\n");

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

  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  ll N, K;
  ll res=0;
  cin >> N>>K;

  ll a = N/K;
  res = a*a*a;

  if(K%2==0){
    if(N%K >=  K/2) a++;
    res += a*a*a;
  }

  cout << res << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int n;
  char s[4];
  scanf("%s",s);
  n=strlen(s);
  if(n==2)
    printf("%s\n",s);
  else{
    for(int i=2;i>=0;i--)
      printf("%c",s[i]);
    printf("\n");
  }
}

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

int main(){

    int a, b, c;
    int x;
    int res=0;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> x;

    for(int i=0; i<=a; i++){
        for(int j=0; j<=b; j++){
            for(int k=0; k<=c; k++){
                if(500*i + 100*j + 50*k == x)
                    res++;
            }
        }
    }
    cout << res << endl;
}

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

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

  sort(a, a + n);

  cout<<a[n/2] - a[n/2-1]<<endl;
}

Measured memory_bytes: 640
#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...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(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 A, B;
    cin >> A >> B;

    if (B % A == 0) {
        cout << A + B << endl;
    } else {
        cout << B - A << endl;
    }


}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>

using namespace std;

int main(){

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

	return 0;
}

Measured memory_bytes: 256
N=int(input())
B = list(map(int, input().split()))
B.append(-1)
A =[-1]*N
result=0

for i in range(N):
    if i==0:
        A[0]=B[0]
    else:
        if B[i]==-1:
            A[i]=B[i-1]
        else:
            if B[i]>=B[i-1]:
                A[i]=B[i-1]
            else:
                A[i]=B[i]
    result += A[i]

print(result)


Measured memory_bytes: 3064
N, K = gets.split.map(&:to_i)
S = gets.chomp.chars.take(N)
zero_list = []
zero_start = nil
S.each.with_index do |ch, i|
  if ch == '0'
    zero_start = i unless zero_start
    if i == S.size - 1
      zero_list.push([zero_start, i])
    end
  else
    if zero_start
      zero_list.push([zero_start, i - 1])
      zero_start = nil
    end
  end
end

if zero_list.empty?
  puts N
  exit
end
ans = 0
(0..(zero_list.size - 1)).each do |i|
  s = if i == 0
    0
  else
    zero_list[i - 1][1] + 1
  end
  e = if i + K > zero_list.size - 1
    N - 1
  else
    zero_list[i + K][0] - 1
  end
  count = (e - s) + 1
  ans = count if count > ans
end
puts ans


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

using namespace std;

int N;
long long X;
long long x[100000];

int main() {
    cin >> N >> X;
    for (int i = 0; i < N; i++) {
        cin >> x[i];
        x[i] -= X;
    }
    sort(x, x + N);

    /*
    int temp = 0;
    long long Dmax;
    while(x[temp] <= 0) {
        temp++;
        if(temp == N - 1) break;
    }
    Dmax = x[temp];
    if(Dmax < 0) Dmax = -Dmax;
    */

    long long Dmax = 1000000000;
    for (int i = 0; i < N - 1; i++) {
        if(Dmax > x[i + 1] - x[i]) Dmax = x[i + 1] - x[i];
    }
    for (int i = 0; i < N; i++) {
        if(Dmax > abs(x[i])) Dmax = abs(x[i]);
    }

    //cout << "Dmax = " << Dmax << endl;

    while(1){
        bool flag = true;
        for (int i = 0; i < N; i++) {
            if(x[i] % Dmax != 0) flag = false;
        }
        if(flag) break;
        else Dmax--;
    }

    cout << Dmax << endl;
    return 0;

}

Measured memory_bytes: 1024
s = input()
t = input()

sList = ["" for i in range(len(s))]
tList = ["" for i in range(len(t))]
for i in range(len(s)):
    sList[i] = (ord(s[i])-ord("a"))
for i in range(len(t)):
    tList[i] = (ord(t[i])-ord("a"))
sList = sorted(sList)
tList = sorted(tList)[::-1]

for i in range(min(len(sList), len(tList))):
    if sList[i] < tList[i]:
        print("Yes")
        exit()
    elif sList[i] > tList[i]:
        print("No")
        exit()
if len(sList) < len(tList):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,k;
    cin >> n >> k;
    vi a(n);
    cin >> a;
    vl sum(n+1,0);
    rep(i,n) sum[i+1] = sum[i]+a[i];
    ll ans = 0;
    map<int,int> mp;
    vi v(n+1);
    rep(i,n+1) {
        if(i >= k) mp[v[i-k]]--;
        int now = (sum[i]-i)%k;
        if(mp.count(now)) ans += mp[now];
        mp[now]++;
        v[i] = now;
    }
    cout << ans << endl;
}


Measured memory_bytes: 12800
// Otoshidama

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

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

    int tens = pow(10, 3);
    if (y % tens != 0) {
        cout << "-1 -1 -1" << endl;
        return 0;
    }
    y /= tens;

    for (int n_10 = 0; n_10 <= n && n_10*10 <= y; n_10++) {
        for (int n_5 = 0; n_10+n_5 <= n && n_10*10 + n_5*5 <= y; n_5++) {
            for (int n_1 = 0; n_10+n_5+n_1 <= n && n_10*10 + n_5*5 + n_1*1 <= y; n_1++) {
                if (n_10 + n_5 + n_1 == n && n_10*10 + n_5*5 + n_1*1 == y) {
                    cout << n_10 << " " << n_5 << " " << n_1 << endl;
                    return 0;
                }
            }
        }
    }
    cout << "-1 -1 -1" << endl;

    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void) {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if ((b - a > 0) && (c - b > 0)) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}

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

using namespace std;

using ll = long long;

constexpr ll mod = 1e9 + 7;

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

  string k;
  int d;
  cin >> k >> d;

  int n = k.size();

  vector<vector<vector<ll>>> dp(n + 1, vector<vector<ll>>(10, vector<ll>(d)));
  vector<ll> prev(d);
  
  ll total = 0;
  for (int len = 1; len <= n; ++len) {
    total = prev[0];
    for (int i = 0; i < 10; ++i) {
      for (int dig = 0; dig < d; ++dig) {
        dp[len][i][(dig + i) % d] += prev[dig];
      }
      ++dp[len][i][i % d];
    }
    for (int dig = 0; dig < d; ++dig) {
      for (int i = 1; i < 10; ++i) {
        dp[len][i][dig] %= mod;
        prev[dig] += dp[len][i][dig];
      }
      prev[dig] %= mod;
    }
  }

  ll offset = 0;
  for (int i = 0; i < n; ++i) {
    for (int digit = i == 0; digit < k[i] - '0'; ++digit) {
      total += dp[n - i][digit][((-offset) % d + d) % d];
    }
    total = (total + mod) % mod;
    offset += k[i] - '0';
  }
  if (offset % d == 0) {
    ++total;
  }
  cout << total % mod << '\n';

  return 0;
}


Measured memory_bytes: 82688
use std::thread;

/// ローカル環境なら _in.txt から入力を受ける
fn read_input() -> String {
    use std::fs::File;
    use std::io::Read;
    let mut s = String::new();
    match option_env!("LOCAL") {
        Some(_) => File::open("src/_in.txt")
            .expect("File not found")
            .read_to_string(&mut s)
            .unwrap(),
        None => std::io::stdin().read_to_string(&mut s).unwrap(),
    };
    s
}

fn main() {
    thread::Builder::new()
        .stack_size(32 * 1024 * 1024) // 32MB
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

fn run() {
    let input = read_input();
    let mut input = input.split_whitespace();
    let in_s = input.next().unwrap();

    let v: Vec<char> = in_s.chars().filter(|&c| c == 'C' || c == 'F').collect();
    let ok = v
        .windows(2)
        .filter(|cf| cf[0] == 'C' && cf[1] == 'F')
        .count()
        >= 1;
    println!("{}", if ok { "Yes" } else { "No" });
}


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

int s(char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

int main(){
  string N;
  cin >> N;
  int S;
  S=0;
  for(long unsigned int i=0; i<(N.size()); i++){
    S +=s(N.at(i));
  }
  if((S%9)==0){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" <<endl;
  }
}


Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
    static const double pi = 3.141592653589793;
 typedef pair<int64_t,int64_t> P;
#define rep(i, n) for (int i = 0; i < (n); i++)
 #define all(v) (v).begin(),(v).end()
 using ll = long long;
using Graph = vector<vector<int>>;
const int MAX = 510000;
const int MOD = 1000000007;



int main(){
ll o;
  cin>>o;
  o--;
vector<ll>op(32);
  rep(i,32) op.at(i)=1;
  op.at(3)=2;
  op.at(5)=2;
  op.at(7)=5;
  op.at(8)=2;
  op.at(9)=2;
op.at(11)=5;
  op.at(13)=2;
  op.at(15)=14;
 op.at(17)=5;
  op.at(19)=5;
  op.at(20)=2;
  op.at(21)=2;
  op.at(23)=15;
  op.at(24)=2;
  op.at(25)=2;
  op.at(26)=5;
  op.at(27)=4;
  op.at(29)=4;
  op.at(31)=51;
  cout<<op.at(o);
}
 





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}
const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  ll n,a,b;cin>>n>>a>>b;
  ll ans=0;
  ll tot=powm(2,n,mod);
  ll nCa=1;
  for(int i=0;i<a;i++){
    nCa*=n-i;
    nCa%=mod;
  }
  ll nCa_sub=1;
  for(int i=0;i<a;i++){
    nCa_sub*=a-i;
    nCa_sub%=mod;
  }
  nCa_sub=powm(nCa_sub,mod-2,mod);
  nCa*=nCa_sub;
  nCa%=mod;

  //nCb
  ll nCb=1;
  for(int i=0;i<b;i++){
    nCb*=n-i;
    nCb%=mod;
  }
  ll nCb_sub=1;
  for(int i=0;i<b;i++){
    nCb_sub*=b-i;
    nCb_sub%=mod;
  }
  nCb_sub=powm(nCb_sub,mod-2,mod);
  nCb*=nCb_sub;
  nCb%=mod;

  ans=tot-nCa-nCb-1;
  ans%=mod;
  if(ans<0)ans+=mod;
  cout<<ans<<endl;
  return 0;
}


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

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int ans = k;
      for (int i = 1; i < n; i++) {
        ans *= (k - 1);
      }
      System.out.println(ans);

  }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll sum = 0;
  map<ll, ll> cnt;
  ll ans = 0;
  cnt[0]++;
  rep(i, n) {
    sum += a[i];
    ans += cnt[sum];
    cnt[sum]++;
  }
  cout << ans << endl;

}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;

	vector<int> number(N);

	for (int i = 0; i < N; i++) {
		cin >> number.at(i);
	}

	sort(number.begin(), number.end());
	reverse(number.begin(), number.end());

	int Alicep = 0;
	int Bobp = 0;

	for (int i = 0; i < N; i += 2) {
		Alicep += number.at(i);
	}
	for (int i = 1; i < N; i += 2) {
		Bobp += number.at(i);
	}

	cout << Alicep - Bobp << endl;
}

Measured memory_bytes: 3644
s = list(str(input()))

ln2 = s[0:(len(s) - 1)//2]
ln3 = s[(len(s) + 3)//2 - 1:len(s)]

r_s = s[::-1]
r_ln2 = ln2[::-1]
r_ln3 = ln3[::-1]
if s == r_s and ln2 == r_ln2 and ln3 == r_ln3:
    print('Yes')
else:
    print('No')

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

l = ["Alice", "Bob", "Draw"]

if a > b:
    if a == 13 and b == 1:
        idx = 1
    else:
        idx = 0
elif a < b:
    if a == 1 and b == 13:
        idx = 0
    else:
        idx = 1
else:
    idx = 2

print(l[idx])


Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static final Scanner sc  = new Scanner(System.in);
    static final int     MOD = (int) 1E9 + 7;

    public static void main(String[] args) {
        int N = nint();
        int W = nint();
        int[] ws = new int[N+1];
        int[] vs = new int[N+1];
        for (int i = 0; i < N; i++) {
            ws[i+1] = nint();
            vs[i+1] = nint();
        }
        
        long[][] sum = new long[N+1][W+1];
        for (int n = 1; n <= N; n++) {
            for (int w = 1; w <= W; w++) {
                long sumWithN = w - ws[n] >= 0 ? sum[n-1][w-ws[n]] + vs[n] : 0;
                long sumWithoutN = sum[n-1][w];
                sum[n][w] = max(sumWithN, sumWithoutN);
            }
        }
        
        System.out.println(sum[N][W]);
    }

    @Deprecated
    static int nint() {
        return sc.nextInt();
    }

    @Deprecated
    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    @Deprecated
    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    static long nlong() {
        return sc.nextLong();
    }

    static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    static double ndouble() {
        return sc.nextDouble();
    }

    static double[] ndoubles(int n) {
        return ndoubles(n, 0, 0);
    }

    static double[] ndoubles(int n, int padL, int padR) {
        double[] d = new double[n + padL + padR];
        for (int i = 0; i < n; i++) {
            d[padL + i] = ndouble();
        }
        return d;
    }

    static String nstr() {
        return sc.next();
    }

    static char[] nchars() {
        return sc.next().toCharArray();
    }

    static char[] nchars(int padL, int padR) {
        char[] temp = sc.next().toCharArray();
        char[] ret = new char[temp.length + padL + padR];
        System.arraycopy(temp, 0, ret, padL, temp.length);
        return ret;
    }

    static char[][] nchars2(int h, int w) {
        return nchars2(h, w, 0, 0);
    }

    static char[][] nchars2(int h, int w, int padLU, int padRD) {
        char[][] a2 = new char[h + padLU + padRD][w + padLU + padRD];
        for (int i = 0; i < h; i++)
            System.arraycopy(nchars(), 0, a2[padLU + i], padLU, w);
        return a2;
    }

    static long min(long... ls) {
        return Arrays.stream(ls).min().getAsLong();
    }

    static long max(long... ls) {
        return Arrays.stream(ls).max().getAsLong();
    }

    static long abs(long a) {
        return Math.abs(a);
    }
}


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

int main(){
  string s1,s2 ;
  cin >> s1 >> s2 ;
  if(s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0])
    cout << "YES" << endl;
  else
    cout << "NO" << endl ;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


bool isVowel(char c){
    return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
}


bool prime[1000050];
void sieve() {
    fill(prime, prime + 1000050, 1);
    prime[0] = prime[1] = 0;

    for (int i = 2; i < 1000050; i++) {
        if (prime[i]) {
            for (int j = i * 2; j < 1000050; j += i) {
                prime[j] = 0;
            }
        }
    }
}

void mul(ll a[2][2], ll b[2][2]) {
    ll p = a[0][0] * b[0][0] + a[0][1] * b[1][0];
    ll q = a[0][0] * b[0][1] + a[0][1] * b[1][1];
    ll r = a[1][0] * b[0][0] + a[1][1] * b[1][0];
    ll s = a[1][0] * b[0][1] + a[1][1] * b[1][1];

    a[0][0] = p % mod;
    a[0][1] = q % mod;
    a[1][0] = r % mod;
    a[1][1] = s % mod;
}



int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    int a, b, c;
    cin >> a >> b >> c;
    cout << (a == b && b == c ? "Yes" : "No");


}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 312345;
int A[MAX_N];
int F[MAX_N];
ll memo[MAX_N];

int main2() {
  CLR(F, 0);
  CLR(memo, -1);

  int N = nextInt();
  REP(i, N) A[i] = nextInt();
  REP(i, N) F[A[i]]++;
  map<int, int> FC;
  REP(i, N+1) if (F[i] > 0) FC[ F[i] ]++;
  vector<pair<int,int>> F;
  for (auto it = FC.begin(); it != FC.end(); ++it) F.push_back({it->first, it->second});

  auto calc = [&](const int ans) -> ll {
    if (memo[ans] != -1) return memo[ans];
    ll res = 0;
    for (auto p : F) {
      res += min(p.first, ans) * p.second;
    }
    return memo[ans] = res;
  };

  for (int K = 1; K <= N; K++) {
    int hi = N / K + 1;
    int lo = 0;
    while (hi - lo > 1) {
      int mid = (hi + lo) / 2;
      bool possible = (mid * (ll)K <= calc(mid));
      if (possible) { lo = mid; } else { hi = mid; }
    }
    int ans = lo;
    printf("%d\n", ans);
  }
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 5760
package main

import (
	"fmt"
)

const mod = 1000000007

func main() {
	var n int
	fmt.Scan(&n)

	ans := (powmod(10, n) - powmod(9, n) - powmod(9, n) + powmod(8, n)) % mod
	if ans < 0 {
		ans += mod
	}
	fmt.Println(ans)
}

func powmod(x, n int) int {
	res := 1
	for i := 0; i < n; i++ {
		res *= x
		res %= mod
	}
	return res
}


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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
#define HYPP(x) hypot(x.first,x.second)

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;



int main() {
	int A, B;
	cin >> A >> B;
	if (A > 9 || B > 9)cout << -1 << endl;
	else cout << A * B << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1

int main() {
int N;
  cin >> N ;
  int P[N];
  rep(i, N)
    cin >> P[i];
  int ans =0;
  lli check = MAX_INF;
  rep(i, N){
    if(check > P[i]){
    check = P[i];
      ans ++;
    }
    
  }cout << ans << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<algorithm>
using namespace std;
int n, w[110], M, a, b, C[110];
int main(){
    int i;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&w[i]);
        M = max(M,w[i]);
        C[w[i]]++;
    }
    for(i=1;i<=n;i++){
        if(M==w[i]){
            if(!a)a=i;
            else b=i;
        }
    }
    C[M]-=2;
    if(M>n-1 || !b){
        printf("Impossible\n");
        return 0;
    }
    for(i=1;i<M;i++){
        if(!C[max(i,M-i)]){
            printf("Impossible\n");
            return 0;
        }
        C[max(i,M-i)]--;
    }
    for(i=1;i<=M;i++){
        if(C[i]){
            if(i*2<=M+1){
                printf("Impossible\n");
                return 0;
            }
        }
    }
    printf("Possible\n");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 1000000000000000005
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
int abs(int x){
	if(x>0) return x;
	return -x;
}
int main(){
	int a,b,c,d;
	while(~scanf("%d%d%d%d",&a,&b,&c,&d)){
		if(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d)) puts("Yes");
		else puts("No");
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sat Mar 28 21:00:08 JST 2020
 **/

signed main() {
    Int X, Y, A, B, C;
    std::cin >> X >> Y >> A >> B >> C;
    std::vector<Int> p(A), q(B), r(C);
    REP(i, A) std::cin >> p[i];
    REP(i, B) std::cin >> q[i];
    REP(i, C) std::cin >> r[i];
    sort(p.begin(), p.end());
    sort(q.begin(), q.end());
    sort(r.begin(), r.end());
    std::priority_queue<Int, std::vector<Int>, std::greater<Int>> pq;
    REP(i, X) {
        pq.push(p.back());
        p.pop_back();
    }
    REP(i, Y) {
        pq.push(q.back());
        q.pop_back();
    }
    while (r.size() && r.back() > pq.top()) {
        pq.pop();
        pq.push(r.back());
        r.pop_back();
    }
    Int ans = 0;
    while (pq.size()) {
        ans += pq.top();
        pq.pop();
    }
    std::cout << ans << std::endl;
}


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

int main() {

  char s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  int N = 0;
  if (s1 == '1') {
    N++;
  }
  if (s2 == '1') {
    N++;
  }
  if (s3 == '1') {
    N++;
  }
  
  cout << N << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>

using namespace std;

using P = pair<int, int>;
using i64 = int64_t;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;

template<typename T>
void warshal_floyd(std::vector<std::vector<T>>& graph) {
    size_t V = graph.size();
    for (size_t i = 0; i<V; ++i) {
        for (size_t j = 0; j<V; ++j) {
            for (size_t k = 0; k<V; ++k) {
                graph[j][k] = min(graph[j][k], graph[j][i] + graph[i][k]);
            }
        }
    }
}

template<typename T>
void count_supply(std::vector<std::vector<T>>& graph, int L) {
    size_t V = graph.size();
    for (size_t i = 0; i<V; ++i) {
        for (size_t j =0; j<V; ++j) {
            if (i == j) {
                graph[i][j] = 0;
                continue;
            }
            graph[i][j] = graph[i][j] <= L ? 1 : int_max;
        }
    }
}

void print_graph(std::vector<std::vector<i64>>& graph) {
    for (auto row : graph) {
        for (auto val : row) {
            cout << val << " ";
        }
        cout << endl;
    }
}

int main(int argc, char **argv) {
    int n, m, l;
    cin >> n >> m >> l;

    std::vector<std::vector<i64>> graph(n+1, std::vector<i64>(n+1, int_max));

    int a, b, c;
    for (int i=0; i<graph.size(); ++i) {
        graph[i][i] = 0;
    }

    for (int i=0; i<m; ++i) {
        cin >> a >> b >> c;
        graph[a][b] = graph[b][a] = c;
    }

    std::vector<P> query;
    int q;
    cin >> q;
    int s, t;
    for (int i = 0; i<q; ++i) {
        cin >> s >> t;
        query.push_back(make_pair(s, t));
    }

    auto shortest = graph;
    warshal_floyd<i64>(shortest);
    auto supply_graph = shortest;
    count_supply<i64>(supply_graph, l);
    auto ans_graph = supply_graph;
    warshal_floyd<i64>(ans_graph);
    //print_graph(ans_graph);

    for (P p : query) {
        int ans = ans_graph[p.first][p.second];
        cout << (ans == int_max ? -1 : ans-1) << endl;
    }

    return 0;
}

Measured memory_bytes: 4092
n=gets.to_i
n.times{
  s=gets.split()
  3.times{|i|
    s[i]=s[i].to_i
  }
  s.sort!
  if s[2]**2==(s[0]**2)+(s[1]**2)
    puts "YES"
  else
    puts "NO"
  end
}

Measured memory_bytes: 2540
# E - League
import sys
from collections import deque
from typing import Deque, List

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    N = int(readline())
    A: List[Deque[int]] = [deque()] + [
        deque(map(int, line.split())) for line in readlines()
    ]
    matched_games_cnt = 0
    next_games_opponent, last_games_day = [0] * (N + 1), [0] * (N + 1)
    queue = deque(list(range(1, N + 1)))
    while queue:
        player = queue.popleft()
        if not A[player]:  # The player has finished all games.
            continue
        opponent = A[player].popleft()

        # The opponent will have another game before playing against x.
        if next_games_opponent[opponent] != player:
            next_games_opponent[player] = opponent
            continue

        # The opponent's next game is against the player and vice versa.
        matched_games_cnt += 1
        last_games_day[player] = last_games_day[opponent] = (
            max(last_games_day[player], last_games_day[opponent]) + 1
        )
        # No next game is currently planned.
        next_games_opponent[player] = next_games_opponent[opponent] = 0
        queue.append(player), queue.append(opponent)

    print(max(last_games_day) if matched_games_cnt == N * (N - 1) // 2 else -1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 46208
#include <bits/stdc++.h>
using namespace std;
using lint = long long;

signed main(){
  lint N; cin >> N;
  vector<lint> a(N);
  lint sum = 0, num = 0, p = 1e9;
  for(lint i = 0; i < N; i++){
    cin >> a[i];
    if(a[i] < 0) num++;
    sum += abs(a[i]);
    p = min(abs(a[i]), p);
  }
  if(count(a.begin(), a.end(), 0) != 0) cout << sum << endl;
  else{
    if(num % 2 == 0) cout << sum << endl;
    else cout << sum - 2*p << endl;
  }
}

Measured memory_bytes: 1024
C=list(list(map(int,input().split())) for i in range(3))
for a in range(3):
    if (C[a][0]-C[a][1]!=C[0][0]-C[0][1] or C[a][1]-C[a][2]!=C[0][1]-C[0][2]):
        print("No")
        exit()
for b in range(3):
    if (C[0][b]-C[1][b]!=C[0][0]-C[1][0] or C[1][b]-C[2][b]!=C[1][0]-C[2][0]):
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 3064
#include <cstdio>

int main () {
    unsigned int a, b, d, r;
    double f;
    scanf("%d %d", &a, &b);

    d = a / b;
    r = a % b;
    f = (double)a / (double)b;
    printf("%d %d %f\n", d, r, f);
    return 0;
}

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

const int mod = 1000000007;
long long f(long long n)
{
	if (n == 0) return 1;
	long long x = f(n / 2);
	x *= x;
	if (n % 2 != 0) x *= 2;
	return x % mod;
}

signed main(void)
{
	int n, m;
	map<int, int> mp;
	bool ok;

	cin >> n;
	rep(i, n)
	{
		int a;
		cin >> a;
		mp[a]++;
	}
	m = n;
	ok = true;
	for (auto p : mp)
	{
		auto k = p.first;
		auto v = p.second;
		if (m == n)
		{
			if (n % 2 == 0)
			{
				if (v != 2)
					ok = false;
			}
			else
				if (v != 1)
					ok = false;
		}
		else
		{
			if (!(k == n - m && v != 2))
				ok == false;
		}
		m -= 2;
	}
	if (!ok)
		cout << 0 << endl;
	else
	{
		cout << f(n / 2) << endl;
	}
	return 0;
}


Measured memory_bytes: 3200
#include<math.h>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include <array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
//AtCoderC++.cpp

using namespace std;

int main() {
	int N; cin >> N;
	auto ps = vector<int>(N);
	for (size_t i = 0; i < N; i++) {
		cin >> ps[i];
	}
	int answer = 0;
	for (size_t i = 1; i < N - 1; i++) {
		if (ps[i] > min(ps[i - 1], ps[i + 1]) && ps[i] < max(ps[i - 1], ps[i + 1]))answer++;
	}
	cout << answer << endl;

}



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void run(void){
  char *s=(char *)calloc(100000+1,sizeof(char));
  scanf("%s",s);
  int n=strlen(s);
  int *stack=(int *)calloc(n,sizeof(int));
  int top=0;
  for(int i=0;i<n;i++){
    stack[top++]=s[i];
    while(top>=2 && stack[top-1]!=stack[top-2]){
      top-=2;
    }
  }
  printf("%d\n",n-top);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 100009;
long double t,x;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>t>>x;
    cout<<setprecision(4)<<fixed<<t / x;
    return 0;
}

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

#define MOD 998244353

#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))

typedef long long int64;

int main(void){
    char s;
    int patA=0,patB=0;
    for(int i=0;i<100000;i++){
        s=3;
        scanf("%c",&s);
        if(s=='0'){
            if(i%2) patA++;
            else patB++;
        }else if(s=='1'){
            if(i%2) patB++;
            else patA++;
        }else{
            break;
        }
    }
    
    printf("%d",MIN(patA,patB));
    
    
    return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String line = br.readLine();
		//Scanner scan = new Scanner(System.in);

	String[] ana = new String[4];
	ana = line.split(" ");
	String a =ana[1].substring(0,1);

				System.out.println("A" + a + "C");

	}
}


Measured memory_bytes: 23252
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Data.Char (isSpace)

main :: IO ()
main = do
  n <- readLn :: IO Int
  vec <- VU.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine :: IO (VU.Vector Int)
  let scan =  VU.init $ VU.tail $ VU.scanl (+) 0 vec
  print $ solve (VU.sum vec) scan

solve :: Int -> VU.Vector Int -> Int
solve s xs
  | VU.length xs == 1 = abs (s - 2*(VU.last xs))
  | otherwise = min (abs (s-2*(VU.head xs))) (solve s $ VU.tail xs)

Measured memory_bytes: 10620