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

int main() {
  long long N,K;
  cin >>N>>K;
  vector<long>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  
  long long a=0;
  long long b=0;
  
   for(int j=0;j<K;j++){
     a+=A[j];
   }
  
  for(int i=0;i<=N-K;i++){
    if(i==0){
      b=a;
      a-=A[0];
      a+=A[K];
    }
    else if(i>0){
      if(b<a){
        cout<<"Yes"<<endl;
        b=a;
        a-=A[i];
        a+=A[K+i];
      }
      else{
        cout<<"No"<<endl;
        b=a;
        a-=A[i];
        a+=A[K+i];
      }
    }
  }
}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string S;cin >> S;
  list<char> l;
  rep(i,S.length()) l.emplace_back(S[i]);
  int isfront=1;
  int Q;cin >> Q;
  rep(q,Q){
    int T;cin >> T;
    if(T==1) isfront = isfront^1;
    else{
      int F;char C;cin >> F >> C;
      int inputback=0;
      if(F==2)inputback = 1;
      if(isfront^inputback) l.emplace_front(C);
      else l.emplace_back(C);
    }
  }
  if(isfront==0)l.reverse();
  for(char c : l) cout << c;
  cout << endl;

  return 0;
}


Measured memory_bytes: 10064
#include<stdio.h>

long long fun(long long x,long long y){
	long long xl=0,yl=0;
	while(x > 0){xl++;x/=10;}
	while(y > 0){yl++;y/=10;}
	if(xl > yl){return xl;}
	return yl;
}

int main(void){
	long long n,i,mf=810,x;
	scanf("%lld",&n);
	for(i = 1;i <= 114514;i++){
		if(n%i){continue;}
		x = fun(i,n/i);
		if(x < mf){mf = x;}
	}
	printf("%lld\n",mf);
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1);





int main() 
{
  string S; cin>>S;
  ll K; cin>>K;
  vector<ll> vec(1,1);
  rep(i,S.size()-1)
  {
    if(S.at(i)==S.at(i+1)) {vec.at(vec.size()-1)++; continue;}
    vec.push_back(1);
  }
  if(vec.size()==1)
  {
    cout<<S.size()*K/2<<endl;
    return 0;
  }  
  ll ans=0;
  if(S.at(0)!=S.at(S.size()-1))
  {
    ans+=vec.at(0)/2*K+vec.at(vec.size()-1)/2*K;
  }
  else
  {
    ans+=vec.at(0)/2+vec.at(vec.size()-1)/2+(vec.at(0)+vec.at(vec.size()-1))/2*(K-1);
  }
  for(int i=1;i<vec.size()-1;i++)
  {
    ans+=vec.at(i)/2*K;
  }
  cout<<ans<<endl;
  return 0;
}

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

int main(void) {
  int S, W;
  cin >> S >> W;
  if (W >= S) {
    cout << "unsafe" << endl;
  } else {
    cout << "safe" << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int q,n,x;
    vector<int> v(0);
    cin >> n;
    for(int i=0; i<n; i++){
        cin>>q;
        if(q==0){
            cin >> x;
            v.push_back(x);
        }
        else if(q==1){
            cin >> x;
            cout << v[x] << endl;
        }
        else{
            v.pop_back();
        }
    }
    return 0;
}



Measured memory_bytes: 3872
N = int(input())
SP = []
for i in range(N):
    SP.append(input().split())
    SP[i][1] = int(SP[i][1])
    SP[i].append(i)

SP = sorted(SP, key=lambda x:(x[0],-x[1]))

for j in range(N):
    print(SP[j][2]+1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int X;
  cin>>X;
  int q=X%100,p=X/100,count=0;
  for(int i=5;i>0;i--){
    while(q>=i){
      q-=i;
      count++;
    }
  }
  if(count<=p)
    cout<<1;
  else
    cout<<0;
}

Measured memory_bytes: 3588
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <bitset>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;
// const ll mod =  998244353 ;
const ll mod =  1000000007 ;
const ll inf = 1e18;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};


#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define REP_REV(i, n) for (ll i = n-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) ll(x.size())

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

using Pair = pair<ll, ll>;

vector<ll> a;

ll count(ll x) {
    ll ret = 0;
    REP(i ,sz(a)) {
        if(a[i] > 0) {
            int lft = -1;
            int rgt = sz(a);
            while(rgt - lft > 1) {
                int mid = (lft + rgt) / 2;
                if(a[i] * a[mid] <= x) {
                    lft = mid;
                }
                else {
                    rgt = mid;
                }
            }
            ret += rgt;
            if(a[i] * a[i] < x) ret--;
        }
        else if(a[i] == 0) {
            if(x >= 0)ret += sz(a) - 1;
        }
        else {
            int lft = -1;
            int rgt = sz(a);
            while(rgt - lft > 1) {
                int mid = (lft + rgt) / 2;
                if(a[i] * a[mid] > x) {
                    lft = mid;
                }
                else {
                    rgt = mid;
                }
            }
            ret += sz(a) - rgt;
            if(a[i] * a[i] < x) ret--;
        }
    }
    return ret / 2;
}


signed main() {
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, k;
    cin >> n >> k;
    REP(i, n) {
        ll x;
        cin >> x;
        a.push_back(x);

    }
    sort(all(a));
    ll lft = -inf;
    ll rgt = inf;
    while(rgt - lft > 1) {
        ll mid = (rgt + lft) / 2;
        ll tmp = count(mid);
        if(tmp < k) {
            lft = mid;
        }
        else {
            rgt = mid;
        }
    }
    cout << lft + 1 << endl;
    return 0;
}


Measured memory_bytes: 3444
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;





int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	int i,ans=INF,n;
	string s;
	cin>>n>>s;
	int w=0,b=0;
	int le[2]={0},ri[2]={0};
	rep(i,n){
		if(s[i]=='.')w++;
		else b++;
	}
	ans=min(w,b);
	rep(i,n-1){
		if(s[i]=='.'){
			le[0]++;
		}
		else{
			le[1]++;
		}
		ri[0]=w-le[0];
		ri[1]=b-le[1];
		ans=min(ans,le[1]+ri[0]);
	}
	fin(ans);
//////////////////////////////////////////////////////
	return 0;
}







Measured memory_bytes: 720
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
template<class T>inline void out(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr long long INF = 1e9;



signed main(){
	string s;
	cin>>s;
	REP(i,s.size()){
		s[i] = 'x';
	}
	out(s);
}


Measured memory_bytes: 256
s=input()
N=len(s)
K=int(input())
a="abcdefghijklmnopqrstuvwxyz"
S=[]
A=list(a)
for i in range(N-1):
  if s[i]!="a":
    k=A.index(s[i])
    if K>=26-k:
      S.append("a")
      K-=26-k
    else:
      S.append(s[i])
  else:
    S.append("a")
if K>=0:
  k=A.index(s[N-1])
  S.append(A[(k+K)%26])
print("".join(S))
      
  

Measured memory_bytes: 46660
A,B,C=[int(i) for i in input().split(" ")]
memo={}
n=0
while A%2==0 and B%2==0 and C%2==0:
    A,B,C=B/2+C/2,A/2+C/2,A/2+B/2
    n+=1
    if (A,B,C) in memo:
        print(-1)
        break
    else:
        memo[(A,B,C)]=1
        memo[(A,C,B)]=1
        memo[(B,A,C)]=1
        memo[(B,C,A)]=1
        memo[(C,A,B)]=1
        memo[(C,B,A)]=1
else:
    print(n)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int n;
int old_a, old_b, old_c;
int new_a, new_b, new_c;

int main()
{
    cin >> n;
    cin >> old_a >> old_b >> old_c;
    int i, a, b, c;
    for(i = 1; i < n; ++i){
        cin >> a >> b >> c;
        new_a = a + max(old_b, old_c);
        new_b = b + max(old_a, old_c);
        new_c = c + max(old_a, old_b);
        old_a = new_a;
        old_b = new_b;
        old_c = new_c;
    }
    int max_happiness = max(old_a, max(old_b, old_c));
    cout << max_happiness << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
T = []
for _ in range(N-1):
    c,s,f = map(int,input().split())
    T.append([c,s,f])
for i in range(1,N):
    t =0
    for j in range(i-1,N-1):
        c,s,f = T[j]
        if t <=s: t =s+c
        elif t%f==0: t += c
        else: t += f -(t%f) + c
    print(t)

print(0)

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  int x;
  cin >> x;
  ll res = 0;
  res += (x/500)*1000;
  x %= 500;
  res += (x/5)*5;
  cout << res << endl;



  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("5");
            WillReturn.Add("3");
            WillReturn.Add("2");
            WillReturn.Add("4");
            WillReturn.Add("3");
            WillReturn.Add("5");
            //7
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("10");
            WillReturn.Add("123");
            WillReturn.Add("123");
            WillReturn.Add("123");
            WillReturn.Add("123");
            WillReturn.Add("123");
            //5
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("10000000007");
            WillReturn.Add("2");
            WillReturn.Add("3");
            WillReturn.Add("5");
            WillReturn.Add("7");
            WillReturn.Add("11");
            //5000000008
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        long N = long.Parse(InputList[0]);
        long A = long.Parse(InputList[1]);
        long B = long.Parse(InputList[2]);
        long C = long.Parse(InputList[3]);
        long D = long.Parse(InputList[4]);
        long E = long.Parse(InputList[5]);

        long MinVal = Math.Min(A, B);
        MinVal = Math.Min(MinVal, C);
        MinVal = Math.Min(MinVal, D);
        MinVal = Math.Min(MinVal, E);

        if (MinVal >= N) {
            Console.WriteLine(5);
            return;
        }
        long Syou = N / MinVal;
        long mod = N % MinVal;
        if (mod > 0) Syou++;
        Console.WriteLine(5 + Syou - 1);
    }
}


Measured memory_bytes: 11220
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int A = scan.nextInt();

		int a = N % 500;
		if(A>=a) {
			System.out.println("Yes");
		}else {
			System.out.println("No");

		}
	}

}


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

int main() {
    lint n, m;
    cin >> n >> m;

    vector<lint> a(n);
    for(auto& elem : a)  cin >> elem;

    sort(a.rbegin(), a.rend());
    lint sum = accumulate(a.begin(), a.end(), 0LL);

    cout << (a[m-1] * 4 * m < sum ? "No" : "Yes") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <string>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
  string s1,s2;
  cin>>s1>>s2;
  int dp[s1.size()+1][s2.size()+1];
  REP(i,s1.size()+1)REP(j,s2.size()+1)dp[i][j]=1e9;
  for(int i=0;i<=s1.size();i++)dp[i][0]=i;
  for(int i=0;i<=s2.size();i++)dp[0][i]=i;
  for(int i=1;i<=s1.size();i++){
    for(int j=1;j<=s2.size();j++){
      if(s1[i-1]==s2[j-1])dp[i][j]=min(dp[i][j],dp[i-1][j-1]);
      else dp[i][j]=min(dp[i][j],dp[i-1][j-1]+1);
      dp[i][j]=min(dp[i][j],dp[i-1][j]+1);
      dp[i][j]=min(dp[i][j],dp[i][j-1]+1);
    }
  }
  cout<<dp[s1.size()][s2.size()]<<endl;
}

Measured memory_bytes: 7096
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define mod 1000000007

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}


int main(){
  int i,N,K,a[200000];
  cin>>N;
  vector<int> v(N);
  rep(i,N){
    cin>>v[i];
  }
  sort(v.begin(),v.end());
  cout<<v[N-1]-v[0]<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a,b,gcd,lcm,tema,temb,r;
  while(scanf("%d %d",&a,&b)!=EOF){
     tema=a;
     temb=b;
     while(tema%temb!=0){
       r=tema%temb;
       tema=temb;
       temb=r;
     }
     gcd=temb;
     lcm=a/gcd*b;
     printf("%d %d\n",gcd,lcm);
   }
   return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;
    ll N;
    cin >> N;
    vector<string> S(N);
    rep(i, N) cin >> S[i];

    vector<ll> cnt(5, 0);
    rep(i, N) {
        if (S[i][0] == 'M') {
            cnt[0]++;
        } else if (S[i][0] == 'A') {
            cnt[1]++;
        } else if (S[i][0] == 'R') {
            cnt[2]++;
        } else if (S[i][0] == 'C') {
            cnt[3]++;
        } else if (S[i][0] == 'H') {
            cnt[4]++;
        }
    }

    ll total = 0;
    rep(i, 5) {
        if (cnt[i] > 0) {
            total++;
        }
    }

    // repv(cnt) cout << *it << " ";
    // cout << endl;

    if (total < 3) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;
    rep(i, 5) {
        reps(j, i + 1, 5) {
            reps(k, j + 1, 5) { ans += cnt[i] * cnt[j] * cnt[k]; }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6332
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int trie[1000005][27];
int F[1000005];
int main(){
    int n;
    cin>>n;
    int id=1;
    V<V<int>> node(n);
    V<string> s(n);
    for(int i=0;i<n;i++){
        cin>>s[i];
        reverse(all(s[i]));
        int node_id=0;
        for(char c:s[i]){
            if(trie[node_id][c-'a']==0){
                trie[node_id][c-'a']=id++;
            }
            node[i].push_back(node_id);
            node_id=trie[node_id][c-'a'];
        }
        F[node_id]=true;
        reverse(all(s[i]));
        reverse(all(node[i]));
    }
    int ans=0;
    for(int i=0;i<n;i++){
        set<char> suf;
        for(int j=0;j<s[i].size();j++){
            suf.insert(s[i][j]);
            int  node_id=node[i][j];
            for(char c:suf){
                ans+=F[trie[node_id][c-'a']];//共通suffixから受理される文字
            }
        }
    }
    cout<<ans-n<<"\n";
}

Measured memory_bytes: 118716
#include<bits/stdc++.h>
using namespace std;
int n,k;
int main(){
	scanf("%d%d",&n,&k);
	int e=(n-1)*(n-2)/2;
	if(k>e){
		printf("-1\n");
		return 0;
	}
	int m=n-1+(e-k);
	printf("%d\n",m);
	for(int i=1;i<n;i++)printf("%d %d\n",i,n);
	m-=(n-1);
	for(int i=1;i<n;i++)for(int j=i+1;j<n;j++){
		if(!m)return 0;
		printf("%d %d\n",i,j);
		m--;
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	char c;
	cin>>c;
	switch(c){
		case 'S':
			cout<<"Cloudy"<<endl;
			return 0;
		case 'C':
			cout<<"Rainy"<<endl;
			return 0;
		case 'R':
			cout<<"Sunny"<<endl;
			return 0;
		
	}
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define lli long long int
typedef pair<int,int> p;

int main()
{
  int n,m;
  cin>>n;
  vector<int> t(n+1);
  lli sum = 0;
  for(int i=1;i<=n;i++) { cin>>t[i]; sum+=t[i]; }

  cin>>m;
  vector<p> drinks(m);
  for(int i=0;i<m;i++)
  {
    int a,b;
    cin>>a>>b;
    drinks[i] = mp(a,b);
  }
  //cout<<drinks.size()<<"\n";
   for(auto i:drinks)
  {
  //  cout<<i.first<<" "<<i.second<<"\n";
    cout<<sum-t[i.first]+i.second<<"\n";
  }

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <stack>
#include <algorithm>
#include <utility>

using namespace std;

// Find Maximum Size Rectangle
int main() {
    int h, w;
    cin >> h >> w;

    int G[h][w];
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            int x;
            cin >> x;
            G[i][j] = x;
        }
    }

    int dp[h][w+1];
    fill(&dp[0][0], &dp[h-1][w] + 1, 0);
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (!G[i][j]) {
                dp[i][j] = i > 0 ? dp[i-1][j] + 1 : 1;
            }
        }
    }

    int maxv = 0;
    stack<pair<int, int>> S;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j <= w; ++j) {
            auto rect = make_pair(dp[i][j], j);
            if (S.empty()) {
                S.push(rect);
            } else {
                if (S.top().first < rect.first) {
                    S.push(rect);
                } else if (S.top().first > rect.first) {
                    auto pos = j;
                    while (!S.empty() && S.top().first >= rect.first)  {
                        auto pre = S.top(); S.pop();
                        auto area = pre.first * (j - pre.second);
                        maxv = max(maxv, area);
                        pos = pre.second;
                    }
                    rect.second = pos;
                    S.push(rect);
                }
            }
        }
    }
    cout << maxv << endl;

    return 0;
}

Measured memory_bytes: 18396
//author: toruneko
// 2020/04/27 18:39
//vertict: 

#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }

ll e;

void solve() {
  ll ans = INF;
  rep(z, e + 1) {
    ll res = z * z * z;
    if (res > e) break;
    rep(y, e + 1) {
      ll res2 = res + y * y;
      if (res2 > e) break;
      ll x = e - res2;
      chmin(ans, x + y + z);
    }
  }
  cout << ans << '\n';
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  while (cin >> e) {
    if (e == 0) break;

    solve();
  }




  
  return 0;
}


Measured memory_bytes: 3064
#include <iostream>
#include <string>

int main()
{
  std::string input;
  std::cin >> input;
  int a[4];
  for ( int i = 0; i < 4; i++ ) a[i] = input[i] - '0';

  for ( int x = 0; x < 8; x++ ) {
    int sum = a[0];
    std::string S;
    S += (char)('0' + a[0]);
    for ( int i = 0; i < 3; i++ ) {
      if ( x & (1<<i) ) {
        sum += a[i+1];
        S += '+';
        S += (char)('0' + a[i+1]);
      } else {
        sum -= a[i+1];
        S += '-';
        S += (char)('0' + a[i+1]);
      }
    }
    if ( sum == 7 ) {
      std::cout << S << "=7" << std::endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

using namespace std;

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

long long int INF = 2147483647;
int const TREE_SIZE = 1 << 20;
long long int seg_tree[TREE_SIZE];
long long int T[TREE_SIZE];

int find(int a){
	
	a += TREE_SIZE / 2;
	
	int ret = seg_tree[a];
	int tmax = T[a];
	
	for(int x = a / 2; x > 0; x /= 2){
		if(T[x] > tmax){
			tmax = T[x];
			ret = seg_tree[x];
		}
	}
	return ret;
}

void update(int a, int b, int index, int num, int time, int l, int r){
	
	// 外からは query(a, b, 1, 0, TREE_SIZE / 2) のように呼ぶ
	
	if(r <= a || b <= l){
		return;
	}
	if(a <= l && r <= b){
		seg_tree[index] = num;
		T[index] = time;
		return;
	}
	update(a, b, index * 2, num, time, l, (l + r) / 2);
	update(a, b, index * 2 + 1, num, time, (l + r) / 2, r);
	return;
}

int main(){
	
	int n, q;
	cin >> n >> q;
	
	for(int i = 0; i < TREE_SIZE; i++){
		seg_tree[i] = INF;
		T[i] = -1;
	}
	
	for(int i = 0; i < q; i++){
		long long int num, a, b, c;
		cin >> num;
		if(num == 0){
			cin >> a >> b >> c;
			update(a, b + 1, 1, c, i, 0, TREE_SIZE / 2);
		}else{
			cin >> a;
			cout << find(a) << endl;
		}
		/*
		for(int j = 0; j < n; j++){
			cout << find(j) << " ";
		}
		cout << endl;
		*/
	}
	
	return 0;
}


Measured memory_bytes: 19504
n,k=map(int,input().split())
p=input().split()
p2=[]
for i in range(n):
  p3=int(p[i])
  p2.append(p3)
p1=sorted(p2)
c = 0
for i in range(k):
  c += int(p1[i])
print(c)

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

using namespace std;

#define int long long
#define x first
#define y second
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define sz(a) (int)(a.size())

typedef long long ll;typedef vector<int> vi;
typedef pair<int,int> ii;typedef vector<ii> vii;
typedef vector<vi> vvi;

signed main(){
	IOS
	int n,m,k;cin>>n>>m>>k;
	vi a(n),b(m);
	forn(i,n) {
		cin>>a[i];
		if(i)
			a[i]+=a[i-1];
	}
	forn(i,m) {
		cin>>b[i];
		if(i)
			b[i]+=b[i-1];
	}
	int ans = 0;
	for(int i=0;i<=n;i++){
		int left = k;
		if(i)
			left-=a[i-1];
		if(left<0)
			continue;
		int ind = upper_bound(all(b),left)-b.begin();
		ans = max(ans,i+ind);
	}
	cout<<ans;
}

Measured memory_bytes: 6368
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  rep(i,N) cin >> v[i];
  sort(v.begin(), v.end());
  double cur = v[0];
  for (int i = 1; i < N; ++i) {
    cur += v[i];
    cur /= 2.0;
  }
  cout << fixed << setprecision(10) << cur << endl;
  return 0;
}

Measured memory_bytes: 3264
#include <bits/stdc++.h>
#include <stdio.h>
#include <cmath>

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

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

int main() {
    int n,l,sum=0;
    cin>>n>>l;

    vector<int>L(n);
    rep(i,n){
        L[i]=l+i;
        sum+=L[i];
    }

    int MINabs=1000,MIN=0;
    rep(i,n){
        if(MINabs>abs(L[i])){
                MINabs=abs(L[i]);
                MIN=L[i];
        }
    }

    cout<<sum-MIN<<endl;

}





Measured memory_bytes: 256
/**
 *   created: 07 July 2019  21:24:36
**/
#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef vector< pair<int , int> > vii;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long , long long> pll;
typedef vector< pair<long long , long long> > vll;

#define PB push_back
#define PPB pop_back
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define rrep(i,a,b) for(int i = (int)(a-1); i>=(int)(b); i--)
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================
int main()
{
	optimizeIO();
	int tt=1;
	//cin>>tt;
	while(tt--){
		int n;
		cin>>n;
		vi v(n);
		rep(i,0,n)
			cin>>v[i];
		int s1=0,s2=0;
		rep(i,0,n){
			if(i%2)
				s2+=v[i];
			else
				s1+=v[i];
		}
		int temp = s1-s2;
		rep(i,0,n){
			cout<<temp<<" ";
			temp = 2*(v[i] - temp/2);
		}
	}
	return 0;
}


Measured memory_bytes: 1792
from sys import stdin
import math
import itertools


def makeIntMatrix(lines):
    intMatrix = []
    for a in makeStringMatrix(lines):
        intMatrix.append([int(b) for b in a])
    return intMatrix
 
 
def makeStringMatrix(lines):
    stringMatrix = [line.split() for line in lines]
    return stringMatrix
 
 
def makeInt(line):
    return int(line.rstrip())
 
 
def makeMultiInteger(line):
    return [int(x) for x in line.rstrip().split()]


def solve(input_string):
    A, B, C = makeMultiInteger(input_string[0])
    if A == B and B == C:
        return "Yes"
    return "No"


def main():
    input_lines = stdin.readlines()
    answer = solve(input_lines)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int main() {
    int r , d , a;
    cin >> r >> d >> a;
    for(int i = 0; i < 10; i++){
        a = r * a - d;
        cout << a << endl;
    }
}

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

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

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

  int N, X;
  cin >> N >> X;
  vector<int> L(N, 0);
  rep(i, N) { cin >> L[i]; }

  int count = 1;
  int d = 0;
  for (int i = 0; i < N; i++) {
    if (X < d + L[i]) {
      break;
    }
    d = d + L[i];
    count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
        String line=s.nextLine();
        String[] SNum=line.split(" ");
        int[] num=new int[SNum.length];
        for(int i=0;i<SNum.length;i++){
            num[i]=Integer.parseInt(SNum[i]);
        }

        int sum;
        if(num[3]<=num[0]){
            sum=num[3];
        }else if(num[3]<=num[1]){
            sum=num[0];
        }else{
            sum=num[0]-(num[3]-num[0]-num[1]);
        }

        System.out.println(sum);
    }
}

Measured memory_bytes: 35768
# 埋める配列
# dp[x] = 足場0からスタートして足場xに着地するときに足場xまでに払うコストの最小値

# 計算方法
# dp[0] = 0
# dp[x] = min(dp[x - 1] + |h[x] - h[x - 1]|, dp[x - 2] + |h[x] - h[x - 2]|)

# 埋める順番
# xが小さい順

N = int(input())
H = list(map(int, input().split()))

dp = [0] * (N + 5)

for i in range(1, N):
    if i == 1:
        dp[i] = dp[i - 1] + abs(H[i] - H[i - 1])
    else:
        dp[i] = min(dp[i - 1] + abs(H[i] - H[i - 1]),
            dp[i - 2] + abs(H[i] - H[i - 2]))

print(dp[N - 1])

Measured memory_bytes: 13928
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        p: [usize; n],
    }
    let mut ip = p.iter().enumerate().collect::<Vec<_>>();
    ip.sort_by_key(|&(_, pi)| pi);
    let mut count = 0;
    for (j, &(i, _)) in ip.iter().enumerate() {
        if i != j {
            count += 1;
        }
    }
    if count > 2 {
        println!("NO");
    } else {
        println!("YES");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cstring>

using namespace std;

int main(){
    int n , m;
    cin >> n >> m;
    int r_min, l_max;
    l_max = 0;
    r_min = 100005;
    for(int i = 0; i < m; i++){
        int r,l;
        cin >> l >> r;
        l_max = max(l_max , l);
        r_min = min(r_min , r);
    }
    int ans = 0;
    ans = r_min - l_max + 1;
    if(ans < 0){
        cout << "0" << endl;
    }else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int N;
    scanf("%d",&N);
    char picked_arare;
    int flag = 0;
    for (int i = 0; i < N;i++){
        scanf("%c",&picked_arare);
        if(picked_arare == 'Y'){
            flag = 1;
        }
    }
    if(flag == 0){
        printf("Three");
    }
    else if (flag == 1){
        printf("Four");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
int main(){
   ll n, h; cin >> n >> h;
   vector<pair<ll,ll>> a(n);
   vector<pair<ll,ll>> b(n);
   rep(i, n){
       cin >> a[i].first >> a[i].second;
       b[i].first = a[i].second;
       b[i].second = a[i].first;
   }
   sort(a.begin(), a.end(), greater<>());
   sort(b.begin(), b.end(), greater<>());
   vector<ll> use;
   ll sum = 0;
   ll count = 0;
   rep(i, n){
       if(a[0].first < b[i].first){
           use.push_back(b[i].first);
           sum += b[i].first;
           count++;
           if(sum >= h){
               cout << count << endl;
               return 0;
           }
       }
    }
    count += (h - sum + a[0].first - 1) / a[0].first;
    cout << count << endl;
}

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

using namespace std;
// using Graph = vector<vector<ll>>;

typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

const ll MOD = 1000000007;
const ll INF = 1e18; //1*10^18
const double PI = 3.14159265;

int ctoi(char c)
{
  if (c >= '0' && c <= '9')
  {
    return c - '0';
  }
  return 0;
}

ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
//最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//最小公倍数

ll powll(ll a, ll n)
{ //O(log n)
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a;
    }
    a = a * a;
    n >>= 1; //(n & 1)=(n % 2 !=0)
  }
  return res;
}

ll modpow(ll a, ll n, ll mod) //O(log n)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a % mod;
    }
    a = a * a % mod;
    n >>= 1; //(n>>=1)=(n/2)
  }
  return res;
}

int ReturnDigit(ll num)
{
  string number = to_string(num);
  return number.length();
}

const ll MAX = 1e4;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int 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;
  }
}

// 二項係数計算
long long COM(int n, int k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind
{
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N)
  { //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++)
      par[i] = i;
  }

  int root(int x)
  { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y)
  {                   // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry)
      return;     //xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y)
  { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main()
{
  // srand((unsigned int)time(NULL));//--> rand()
  ll i, j, k, l, ans = 0;
  ll s, w;
  cin >> s >> w;

  if (s <= w)
  {
    cout << "unsafe" << endl;
  }
  else
  {
    cout << "safe" << endl;
  }
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) ((x).begin()),((x).end())
#define int ll
using pii = pair <int, int>;
#define INF 0x7f7f7f7f7f7f7f7f
const bool debug = 0;
const int mod = 1000000007;

const int MAX_N = 505020;
ll modpow(ll x, ll y, ll p = mod)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

int fact[MAX_N+5];
int invfact[MAX_N+5];

int binom(int n, int r)
{
    int t = (fact[n]*(invfact[r]))%mod;
    return (t*invfact[n-r])%mod;
}

void precompute()
{
    fact[0] = 1; invfact[0] = 1;
    for (int i = 1; i<=MAX_N; i++)
    {
        fact[i] = fact[i-1]*i;
        fact[i] %= mod;
    }
    invfact[MAX_N] = modpow(fact[MAX_N],mod-2);
    for (int i = MAX_N-1; i>=1; i--)
    {
        invfact[i] = invfact[i+1]*(i+1);
        invfact[i] %= mod;
    }
}

int frac(int a, int b)
{
    return (a*(modpow(b,mod-2)))%mod;
}

int find(int n, int k)
{
    vector <int> v;
    set <vector <int>> st;
    for (int i = 0; i<n; i++)
        v.push_back(i+1);
    int ct = 0;
    
    do
    {
        vector <int> tmp;
        for (int i = 0; i<k; i++) tmp.push_back(v[i]);
        st.insert(tmp);
    } while (next_permutation(all(v)));
    for (auto vit : st)
    {
        bool flag = 0;
        for (int i = 0; i<k; i++)
        {
            if (vit[i]==i+1) flag = true;
        }
        if (flag)
            ct++;
    }
    int total = fact[n] / fact[n-k];
    //printf("%lld %lld : %lld invalids out of %lld\n",n,k,ct,total);
    return total - ct;
}
int Tfun(int n, int k)
{
    int res = 0;
    for (int i = 0; i<=k; i++)
    {
        int r = fact[n-i];
        int v = binom(k, i);
        int u = (r*v)%mod;
        if (i%2) 
        {
            u = mod-u;
        }
        res = (res+u)%mod;
    }
    res *= invfact[n-k];
    res %= mod;
    return res;
}
int32_t main()
{
    precompute();
    int n, m; cin >> n >> m;
    int x = Tfun(m, n);
    int res = fact[m]*invfact[m-n] % mod;
    res *= x;
    res %= mod;
    cout << res << '\n';
}

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

int main()
{
	ll n, m;
	cin >> n >> m;
	ll mod = 1000000007;

	ll fn = 1;
	for (int i = 2; i <= n; i++) fn = (fn * i) % mod;
	ll fm = 1;
	for (int i = 2; i <= m; i++) fm = (fm * i) % mod;
	ll ans = 0;
	if (abs(n - m) == 0) ans = ((fn*fm) % mod * 2) % mod;
	else if (abs(n - m) == 1) ans = (fn*fm) % mod;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define XX first
#define YY second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

int N, K;
LL M;
LL dp1[314][314];
LL dp2[314][314];
LL dp3[314][314];
LL comb[314][314];
bool calced[314][314];

void Add(LL &v, LL t) {
  v += t;
  while (v >= M) v -= M;
}

LL Comb(int n, int k) {
  if (k < 0 || n < k) return 0;
  if (k == 0 || n == k) return 1;
  if (calced[n][k]) return comb[n][k];
  calced[n][k] = 1;
  Add(comb[n][k], Comb(n-1, k-1));
  Add(comb[n][k], Comb(n-1, k));
  return comb[n][k];
}

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);

  cin >> N >> K >> M;
  dp1[0][K] = 1;
  reps(v, 0, K+2) {
    dp3[0][v] = 1;
  }
  reps(n, 1, N+1) {
    rreps(v, 1, K+1) {
      Add(dp2[n][v], dp2[n][v+1]);
      Add(dp2[n][v], dp1[n-1][v]);
    }
    rreps(v, 1, K+1) {
      Add(dp3[n][v], dp3[n][v+1]);
      Add(dp3[n][v], dp2[n][v]);
    }
    reps(v, 1, K+1) {
      reps(k, 1, n+1) {
        Add(dp1[n][v], dp3[n-k][v+1] * dp2[k][v] % M * Comb(n, k) % M);
      }
    }
    rreps(v, 1, K+1) {
      dp3[n][v] = dp3[n][v+1];
      Add(dp3[n][v], dp1[n][v]);
    }
  }
  LL ans = dp3[N][1];
  cout << ans << endl;
  //rep(n, N+1) {
  //  rep(v, K+1) {
  //    cout << "dp1[" << n << "][" << v << "]=" << dp1[n][v] << " ";
  //  }cout << endl;
  //  rep(v, K+1) {
  //    cout << "dp2[" << n << "][" << v << "]=" << dp2[n][v] << " ";
  //  }cout << endl;
  //  rep(v, K+1) {
  //    cout << "dp3[" << n << "][" << v << "]=" << dp3[n][v] << " ";
  //  }cout << endl;
  //}
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=200005;
int num,head[maxn],t[maxn<<2],ne[maxn<<2],col[maxn<<2];
bool vis[maxn];
inline void addedge(int x,int y,int z){
	ne[++num]=head[x];head[x]=num;t[num]=y;col[num]=z;
	ne[++num]=head[y];head[y]=num;t[num]=x;col[num]=z;
}
int n,d[maxn],st,ed,v[maxn];
inline void dfs(int x){
	d[x]--;
	for(int &i=head[x];i!=-1;i=ne[i])if(!vis[i>>1]){
		if(col[i]==1){
			v[x]--;v[t[i]]++;
		}vis[i>>1]=1;
		dfs(t[i]);
		if(i==-1)break;
	}
}
int main(){
	read(n);rep(i,1,n)head[i]=-1;num=1;
	rep(i,1,n){
		int x;read(x);
		if(x==-1){
			st=i;
			continue;
		}
		d[x]++;
		addedge(x,i,1);
	}
	rep(i,1,n){
		int x;read(x);
		if(x==-1){
			ed=i;
			continue;
		}
		d[x]++;
		addedge(x,i,2);
	}
	rep(i,1,n)if(d[i]%2!=0){
		puts("IMPOSSIBLE");
		return 0;
	}v[st]=1;d[st]++;d[ed]++;
	dfs(st);
	rep(i,1,n)if(d[i]!=0)dfs(i);
	puts("POSSIBLE");
	rep(i,1,n)printf("%d ",v[i]);
	return 0;
}


Measured memory_bytes: 12416