akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <cmath>
#include <math.h>
#include <ctime>
#include <cstring>
#include <climits>
#include <sstream>
#include <array>
#include <tuple>
#include <set>
#include <iterator>
#include <cstdio>
#include <string>
#include <stack>
#include <valarray>
#include <utility>
#include <iomanip>
#include <list>
#include <numeric>
#include <regex>
#include <map>
#include <queue>
#include <deque>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll          long long
#define PI          3.1415926535
#define pb          push_back
#define ins         insert
#define INF         LLONG_MAX
#define mk          make_pair
#define lb(v,x)     lower_bound(all(v),x)
#define ub(v,x)     upper_bound(all(v),x)
#define ff          first
#define ss          second
#define rev         reverse
#define uset        unordered_set
#define umap        unordered_map
#define endl        "\n"
#define max3(x,y,z)  max(x,max(y,z))
#define min3(x,y,z)  min(x,min(y,z))
#define sz(a)       (ll)a.size()
#define double      long double
#define minpq       priority_queue <ll,vector<ll>,greater<ll> > 
#define fill(x,y)   memset(x,y,sizeof(x))
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define MOD         1000000007 //1e9+7
#define bp(n)       __builtin_popcountll(n)
#define mxt(a)      *(max_element(a.begin(),a.end()))
#define mnt(a)      *(min_element(a.begin(),a.end())
#define unique_sort(c) (sort(all(c)), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define rep(i, a, b) for(ll i = (a); i<= (b); ++i)
#define trav(a, x) 	 for(auto &a : x)
#define re(i,n)      for(ll i = 0; i < n; ++i) 
const ll N = 2e5 + 7;
typedef pair<ll,ll>   pii;
typedef vector<pii>   vpii;
typedef vector<ll>    vll;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x);y=y>>1;x=(x*x);}return res;}
template<typename T> T gcd(T a,T b){ if(a==0) return b; return gcd(b%a,a); }
template<typename T> T powm(T a,T b, ll m){T cnt=1; while(b>0){ if(b%2==1) cnt=(cnt*a)%m; b/=2; a=(a*a)%m; }return cnt%m;}
ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
ll sqr(ll x) { return x * x;}
// always use 1ll*ans to avoid signed integer overflow; 
void prec(){
	
}
void solve(){
	int n;
	cin>>n;
	int x=n%10;
	if(x==3) cout<<"bon\n";
	else if(x==2 ||x==4 ||x==5|| x==7 ||x==9) cout<<"hon\n";
	else cout<<"pon\n";
}
int main()
{
    ios;
    int tc=1;
    //cin>>tc;
    prec();
    while(tc--)
    	solve();
    return 0; 
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin >> N;
  if(N.length() == 2){
  	cout << N << endl;
  }else{
  	for(int i = 0; i < N.length(); i++){
    	cout << N.at(2-i);
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static final Scanner     sc = new Scanner(System.in);
    static final PrintStream so = System.out;

    public static void main(String[] args) {
        int N = nint();
        int[] A = nints(N);
        int[] sorted = Arrays.copyOf(A, N);
        Arrays.sort(sorted);
        int m = sorted[N-1];
        int n = sorted[N-2];
        for (int a: A) {
            so.println(a == m ? n : m);
        }
    }

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

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

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

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

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

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

    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;
    }

    private 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;
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    }

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

    private static char[][] nsToChars2D(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}


Measured memory_bytes: 93704
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int L = sc.nextInt();
		int min = L;
		int sum = 0;
		
		for (int i = 1; i <= N; i++) {
			if (Math.abs(min) > Math.abs(L + i - 1)) {
				min = L + i - 1;
			}
			sum += L + i - 1;
		}
		System.out.println(sum - min);
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 1000000007
//#define mod2 20071027
//#define MOD 998244353
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a) for(int i=1;i<=a;i++)
#define base 139
//#define mod 1000074259
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case #%lld: ", ++c)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
const ll N=100010, M=N-5;
ll n, k, st[N], res, com;
///BIGMOD*********************************************
///mod inverse --> bigmod(num, mod-2, mod) where mod and num are coprime
ll bigmod(ll num, ll power, ll mod)
{
    if(power==0)return 1;
    ll x=bigmod(num,power/2,mod);
    x= (x*x)%mod;
    if(power%2) x= (x*num)%mod ;
    return x;
}
int main()
{
    in2(n,k);
    for(ll i=k;i>0;i--)
    {
        ll dv = k/i, val=i;
        st[i] = bigmod(dv, n, MOD);///dv^n
        while(val+i<=k)
        {
            val+=i;
            st[i]=(st[i]-st[val])%MOD;
        }
        res = (res+(i*st[i])%MOD)%MOD;
        com = (com+st[i])%MOD;
    }
    ll x = bigmod(k, n, MOD)-com;
    res=(res+x)%MOD;
    if(res<0) res+=MOD;
    printf("%lld\n",res);
    return 0;
}

/*

*/


Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  cin >> N;
  vector<string> s(N);
  
  for (int i = 0; i < N; i++) {
    cin >> s.at(i);
  }
  
  int M;
  cin >> M;
   vector<string> t(M);
  for (int i = 0; i < M; i++) {
    cin >> t.at(i);
  }
  
  int A, B;
  A = 0;
  
  for (int i = 0; i < N; i++) {
    B = 1;
    
    for (int j = i + 1; j < N; j++) {      
      if (s.at(i) == s.at(j)) {
        B++;
      }       
    }
    //同じのがあったら増やす
    
    for (int j = 0; j < M; j++) {
      if (s.at(i) == t.at(j)) {
        B--;
      }
    }
    //同じのがあったら減らす
    
    if (A < B) {
      A = B;
    }
  }  
  
  
  cout << A << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main()
{
    int N;
    cin >> N;
    long long waru = 1000000007;
    int flag;
    int prime[1000];
    int index = 0;
    for (int i = 2; i <= 1000; ++i)
    {
        flag = 0;
        for (int j = 2; j < i; ++j)
        {
            if (i % j == 0)
            {
                flag = 1;
                break;
            }
        }
        /* 判定結果を出力 */
        if (flag == 0){
        prime[index] = i;
        index++;
        }
    }
    int primes[index];
    for (int i = 0; i < index; i++)
    {
        primes[i] = 0;
    }
    for (int i = 1; i <= N; i++)
    {
        // prime tasu
        int tmp = i;
        while (tmp != 1)
        {
            for (int j = 0; j < index; j++)
            {
                if (tmp % prime[j] == 0)
                {
                    primes[j]++;
                    tmp /= prime[j];
                    break;
                }
            }
        }
    }
    long long ans = 1;
    for (int i = 0; i < index; i++)
    {
        ans = ans * (primes[i] + 1) % waru;
    }
    cout << ans << endl;
    return 0;
}

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

void prians(bool answer) {
  if(answer)
    cout << "First" << endl;
  else
    cout << "Second" << endl;
}

string s;

int main() {
  cin >> s;
  prians(((s.size() % 2 == 0) ^ (s[0] != s[s.size() - 1])));
  return 0;
}


Measured memory_bytes: 512
import math


a, b, h, m = map(int, input().split())

tyo = 360 * h / 12 + 30 * m / 60
tan = 360 * m / 60
theta = tyo - tan

print((a ** 2 + b ** 2 - 2 * math.cos(math.radians(theta)) * a * b) ** 0.5)

Measured memory_bytes: 62324
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    int n;
    vector<ll> h;
    cin>>n;
    for(int i=0;i<n;i++){
        ll tmp;
        cin>>tmp;
        h.push_back(tmp);
    }
    ll start,end;
    start = 0;
    end = 0;
    int diff=0;
    int max=0;
    int k=0;

    while(k < n){
        while(k < n && h[end] >= h[k]) end = k++;
        diff = end - start;
        if(diff > max) max = diff;
        start = k;
        end = k;
    }

    cout << max << endl;
}


/*
#include <iostream>
#include <vector>
using namespace std;
typedef long long int ll;
int main(){
    int n;
    cin>>n;
    vector<ll> h;
    for(int i=0;i<n;i++){
        ll th=0;
        cin>>th;
        h.push_back(th);
    }
    vector<int> order;
    order.push_back(0);
    for(int i=0;i<n-1;i++){
        if(h[i]<h[i+1]){
            order.push_back(i+1);
        }
    }
    int ans=0;
    for(int i=1;i<n;i++){
        int diff=order[i]-order[i-1]-1;
        if(diff>ans){
            ans=diff;
        }
    }
    cout <<ans<<endl;
}
*/


Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <string>
 
using namespace std;
 
#define rip(i, n, s) for (int i = (s);i < ( int )( n ); i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll; 

template<typename T>
void vdeb(vector<T> &da){
    int size=da.size();
    for(int i=0;i<size;i++){
        if(i==size-1){
            cout << da[i] << endl;
        }
        else{
            cout << da[i] << ' ';
        }
    }
}
template<typename T>
void vvdeb(vector<T> &da){
    int size=da.size();
    for(int i=0;i<size;i++){
        vdeb(da[i]);
    }
}

int main(){
	int n;
	ll a,b,c,d;
	cin >> n >> a >> b >> c >> d;
	if(a-(n-1)*d > b){
		cout << "NO" << endl;
		return 0;
	}
	if(a+(n-1)*d < b){
		cout << "NO" << endl;
		return 0;
	}
	int ok=0,ng=n;
	while(ng-ok!=1){
		int now=(ok+ng)/2;
		if(a+now*c-(n-now-1)*d > b){
			ng=now;
		}
		else{
			ok=now;
		}
	}
	a+=ok*c-(n-ok-1)*d;
	b-=a;
	if(b <= (n-1)*(d-c)){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int X,N;
    cin >> X >> N;
    vector<int> p(N);
    for (int i = 0; i < N; i++) {
        cin >> p[i];
    }
    SORT(p);
    REP(i, 100){
        if(!FIND(p, X-i)){
            pr(X-i);
            return 0;
        }else if(!FIND(p, X+i)){
            pr(X+i);
            return 0;
        }
    }
}

Measured memory_bytes: 3628
#include <cstdio>
#include <algorithm>
using namespace std;

const int A=0,B=99;



int rec(char *s,int &i,int a,int b,bool t,bool &f)
{
  int ret;
  if(s[i]=='_'){
    i+=2;
    int x=rec(s,i,a,-1,0,f);
    if(f){
      return x;
    }
    i++;
    int b2=(t?x:-1);
    if(x>=b&&(b2==-1||b2>=b)){
      b2=b;
    }
    int y=rec(s,i,a,b2,t,f);
    if(f){
      return min(x,y);
    }
    ret=min(x,y);
    i++;
  }
  else if(s[i]=='^'){
    i+=2;
    int x=rec(s,i,-1,b,0,f);
    if(f){
      return x;
    }
    i++;
    int a2=(t?x:-1);
    if(x<=a&&(a2==-1||a2<=a)){
      a2=a;
    }
    int y=rec(s,i,a2,b,t,f);
    if(f){
      return max(x,y);
    }
    ret=max(x,y);
    i++;
  }
  else{
    int k=s[i]-'0';
    i++;
    if(t&&k==0){
      f=1;
      return k;
    }
    if(a!=-1&&(k>0?10*k+9:0)<=a){
      f=1;
      return k;
    }
    if(b!=-1&&k>=b){
      f=1;
      return k;
    }
    int x,p;
    if('0'<=s[i]&&s[i]<='9'){
      x=10*k+(s[i]-'0');
      i++;
      p=0;
    }
    else{
      x=k;
      p=1;
    }
    if(t||(a!=-1&&x<=a)||(b!=-1&&x>=b)){
      f=1;
      i+=p;
      return x;
    }
    ret=x;
  }
  return ret;
}

int main()
{
  int q;
  scanf("%d",&q);
  while(q--){
    char s[1001];
    scanf("%s",s);
    int i=0;
    bool f=0;
    int x=rec(s,i,A,B,1,f);
    printf("%d %d\n",x,i);
  }
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
int main(){
    int N,Sum,i,one,two;
    
    int S[10]={0};
    Sum=0;
    
    scanf("%d",&N);
    
        one = N;

    for (i=1;i<11;i++) {

        two = one/pow(10,i);
        two = two*pow(10,i);
        
        S[i] = (one - two)/pow(10,i-1);
        
        

        Sum = Sum + S[i];
        
        one = two;
    }
    


    
    if (N%Sum == 0) {
       printf("Yes\n");
    } else if (N%Sum != 0) {
           printf("No\n");
    }
    
        

    
    return 0;
    
}


Measured memory_bytes: 128
n = int(input())
a = [list(map(int, input().split())) for i in range(2)]

max = 0
up_count = 0
count = 0
for i in range(n):
    up_count += a[0][i]
    count = up_count
    for j in range(i, n):
        count += a[1][j]
        if (count > max):
            max = count

print(max)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);                \
    cout.tie(NULL);
#define endl '\n'
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define fr1(i, a, b) for (ll i = a; i >= b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector<pair<ll, ll>>
#define viii vector<pair<ll, pair<ll, ll>>>
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define mp(i, j) make_pair(i, j)
#define fi first
#define se second
#define input(a, n) fr(i, 0, n) cin >> a[i]
#define output(a, n) fr(i, 0, n) cout << a[i] << " "
#define dbg cout << "hurr" << endl;
#define dbg2 cout << "hurr2" << endl;
#define md 1000000007
#define inf 999999999999999999
#define sp << " " <<
#define pi 3.14159265358979323846
#define fixd(x) cout << fixed << setprecision(x);
#define sz size()

int main()
{
    fast;
    ll n,x,t;
    cin>>n>>x>>t;
    ll a = n/x;
    if(n%x!=0)
    {
      a++;
    }
    cout<<a*t;


return 0;}


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

using namespace std;

const int INF = 1e9;
const int N = 1e5;
const int MOD = 1e9 + 7;

const double PI = acos(-1);


char getC(char c) {
    if (c == 's')
        return 'r';
    if (c == 'p')
        return 's';
    return 'p';
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n, k, r, s, p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;
    map<char, int> mp;
    mp['r'] = r; mp['s'] = s; mp['p'] = p;
    char res[n];
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        char c = t[i];
        if (i - k >= 0 && t[i - k] == c && res[i - k] == getC(c)) {
            res[i] = c;
        } else {
            res[i] = getC(c);
            ans += mp[getC(c)];
        }
    }
    cout << ans;
}

Measured memory_bytes: 592
N = input()
S = input()
max_num = 0
current_num = 0
for i in S:
    if i == "I":
        current_num += 1
    else:
        current_num -= 1
    
    if max_num < current_num:
        max_num = current_num
    else:
        pass
    
print(max_num)

Measured memory_bytes: 2940
a = []
a.append( list( map( int, input().split())))
a.append( list( map( int, input().split())))
a.append( list( map( int, input().split())))
 
n = int( input())
c = [[0,0,0],[0,0,0],[0,0,0]]
for _ in range(n):
  b = int( input() )
  for i in range(3):
    for j in range(3):
      if a[i][j] == b:
        c[i][j] = 1
        break

bingo_flg = False
if c[1][0] + c[2][0] + c[0][0] == 3:
  bingo_flg= True
  
if c[1][1] + c[2][1] + c[0][1] == 3:
  bingo_flg= True

if c[1][2] + c[2][2] + c[0][2] == 3:
  bingo_flg= True

if c[0][0] + c[0][1] + c[0][2] == 3:
  bingo_flg= True

if c[1][0] + c[1][1] + c[1][2] == 3:
  bingo_flg= True
  
if c[2][0] + c[2][1] + c[2][2] == 3:
  bingo_flg= True
  
if c[0][0] + c[1][1] + c[2][2] == 3:
  bingo_flg= True
    
if c[2][0] + c[1][1] + c[0][2] == 3:
  bingo_flg= True
  
if bingo_flg:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a>b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD =1000000007;//1e9 + 7;


int n,p,q;
vector<ll> ans;
ll a1,a2;
ll cnt;
void d(ll f,int c,ll sum){
	if(c==0){
		if(sum==p)a1=cnt;
		if(sum==q)a2=cnt;
		cnt++;
		return;
	}
	rep(i,n){
		if(f&(1<<i))continue;
		
		d(f+(1<<i),c/10,(i+1)*c+sum);
	}
}

int main(){
	
	cin>>n;
	ll c=1;
	p=q=0;
	rep(i,n-1)c*=10;
	ll o=c;
	rep(i,n){
		int A;
		cin>>A;
		p+=A*o;
		o/=10;
	}
	o=c;
	rep(i,n){
		int A;
		cin>>A;
		q+=A*o;
		o/=10;
	}
	
	cnt=1;
	d(0,c,0);
	bool b1=1,b2=1;
	cout<<abs(a1-a2)<<endl;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main()
{
	int n,a,b,c,x,cnt=0,ans;
	int y[10000];
	while(1){
		cin >> n >> a >> b  >> c  >> x;
		if(n==0 && a==0 && b==0 && c==0 && x==0){
			return 0;
		}
		for(int i=0;i<n;i++){
			cin >> y[i];
			while(cnt<=10000){
				if(i==0 && y[i]==x){
					break;
				}
				ans=(a*x+b)%c;
				cnt++;
				if(ans==y[i]){
					x=ans;
					break;
				}
				x=ans;
			}
		}
		if(cnt>10000)
			cout << -1 << endl;
		else
			cout << cnt << endl;
		cnt=0;
		ans=0;
	}
	return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    long N, K;
    cin >> N >> K;
    long ans = (N / K) * (N / K) * (N / K);
    if(K % 2 == 0){
        ans += ((N + K / 2) / K) * ((N + K / 2) / K) * ((N + K / 2) / K);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
/*
    Author:    DreamCat4er
    Created:   29.08.2020 16:04:02
*/
#include <bits/stdc++.h>
using namespace std;

const int N = (int)(2e5 + 500);

int n, m, cnt;
bool mk[N];
vector <int> g[N];

void dfs(int v, int pr = -1) {
    if (mk[v])
        return;
    mk[v] = 1;
    ++cnt;

    for (int u : g[v]) {
        if (u == pr)
            continue;

        dfs(u, v);
    }
}

void solve() {
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        --x, --y;

        g[x].push_back(y);
        g[y].push_back(x);
    }

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        cnt = 0;
        dfs(i);
        ans = max(ans, cnt);
    }

    cout << ans << "\n";

    for (int i = 0; i < n; ++i)
        g[i].clear(), mk[i] = 0;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
                
    #ifdef _LOCAL
        int t;
        cin >> t;
        for (int _t = 0; _t < t; ++_t) {
            cout << "Case " << _t << " :\n";
            solve();
            cout << "\n";
        }
    #else
        solve();
    #endif // _LOCAL

    return 0;
}

Measured memory_bytes: 24120
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;



int main() {
	int N, T;
	cin >> N >> T;
	int ans = 0;
	vector<int>data(N + 1);
	for (int i = 0; i < N; i++) {
		cin >> data[i];
	}
	data[N] = data[N - 1] + T;
	for (int i = 0; i < N; i++) {
		if (data[i + 1] - data[i] >= T) {
			ans += T;
		}
		else {
			ans += data[i + 1] - data[i];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template<typename T> using v2 = vector<vector<T>>;

const ld PI = acosl(-1.0L);

void solve(){
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    ld angh = 2*PI * (h + m/60.0L)/12;
    ld angm = 2*PI * m/60.0L;
    ld d = sqrtl(a*a + b*b - 2*a*b*cos(abs(angh-angm)));
    cout << fixed << setprecision(15) << d << '\n';
}

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


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

using namespace std;

int main(void){
    int n;
    cin >> n;
    set<string> m;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        if(m.count(s) == 0)m.insert(s);
    }
    cout << m.size() << endl;
}

Measured memory_bytes: 19204
A, B, C = map(int, input().split())
c = 0
if A == B == C:
  print(0)
else:
  while(True):
    if max(A, B, C) >= 2 + min(A, B, C):
      A, B, C = max(A, B, C), A + B + C - max(A, B, C) - min(A, B, C), min(A, B, C) + 2
    else:
      A, B, C = max(A, B, C), A + B + C - max(A, B, C) - min(A, B, C) + 1, min(A, B, C) + 1
    c += 1
    if A == B == C:
      break
  print(c)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
 
#define REP(i, n) for(ll i = 0;i < n;i++)
#define REP1(i, n) for(ll i = 1;i < n;i++)
#define REPR(i, n) for(ll i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
 
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
 
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
 
#define pb(a) push_back(a)
 
int now,n,k;
 
 
int main(){
  int ans=0;
  
  vector<int> ain(6);
  vector<int> a(4);
  REP(i,6){
    cin>>n;
    a[n-1]+=1;
  }
  
  n=0;
  REP(i,4){
    if (a[i]>=3){n=1;}
    if (a[i]==0){n=1;}
  }
 
  if (n==0){
    cout <<"YES"<<endl;
  }else{
    cout <<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int powint(int a, int x){
	int res = 1;
	REP(i,x){
		res = res *a; 
	}
	return res;
}

using namespace std;

int main(){
	int N;
	cin>>N;
	vector<int> D(N);
	REP(i,N){
		cin>>D[i];
	}
	int M;
	cin>>M;
	vector<int> T(M);
	REP(i,M){
		cin>>T[i];
	}
	sort(D.begin(),D.end());
	sort(T.begin(),T.end());
	
	int j=0;
	bool ans=true;
	REP(i,M){
		while(true){
			if(T[i]==D[j]){
				j++;
				break;
			} else {
				j++;
			}
			if(j==N){
				ans=false;
				break;
			}
		}
		if(!ans){
			break;
		}
	}
	if(ans){
		cout<<"YES"<<endl;
	} else {
		cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod = 1e9 + 7;

int main() {
	ll n, sum = 0LL, curr;
	cin>>n;

	ll result = 0LL;
	for(int i=0;i<n;i++) {
		cin>>curr;
		result += (curr * sum) % mod;
		if(result > mod) result -= mod;

		sum += 1LL * curr;
		if(sum > mod) sum -= mod;
	}
	cout<<result<<"\n";
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		int count = 0;
		for(int i = Math.min(a, b); i >= 1; i--) {
			if(a % i == 0 && b % i == 0) count++;
			if(count == k) {
				System.out.println(i);
				break;
			}
		}
	}
}

Measured memory_bytes: 22740
#include <algorithm>
#include <iostream>
#include <vector>

using std::cin;
using std::cout;

int main()
{
  std::vector<std::vector<int>> lists;
  std::vector<bool> targets;

  int n, m;
  cin >> n >> m;

  lists.resize(n);
  targets.resize(m, true);

  for (size_t i = 0; i < n; ++i)
  {
    int k;
    cin >> k;
    lists[i].resize(k);
    for (size_t j = 0; j < k; ++j)
    {
      int a;
      cin >> lists[i][j];
    }
  }

  for (size_t i = 0; i < lists.size(); ++i)
  {
    for (size_t j = 0; j < targets.size(); ++j)
    {
      if (std::count(lists[i].begin(), lists[i].end(), j + 1) != 0)
      {
        targets[j] = targets[j] && true;
      }
      else
      {
        targets[j] = targets[j] && false;
      }
    }
  }

  std::cout << std::count(targets.begin(), targets.end(), true) << "\n";

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>

#define X first
#define Y second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())


//INT_MAX
//INT_MIN
//LLONG_MAX
//LLONG_MIN
//DBL_MIN
//DBL_MAX
//LDBL_MIN
//LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '1') {
            cout << '9';
        }else if(s[i] == '9'){
            cout << '1';
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<bits/stdc++.h>

using namespace std;

typedef pair<long long,bool> Pair;
const long long INF = 1LL<<60;

int main(){

long long K,N;
long long ans = INF;
long long total = 0;

cin >> K >> N;

vector<long long> A(N);

for(long long i = 0; i < N; ++i) cin >> A[i];

A.push_back(A[0]+K);

long long l = 0;

for(long long i = 0; i < A.size(); ++i){

    l = max(l,A[i+1] - A[i]);

}

cout << K - l << endl;

return 0;

}   


Measured memory_bytes: 4608
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;

int main(){
    ll a=0,b=0,c=0,d=0,e,l,m,n,k,o=0,p,q,x,y,z,max1=0,ans,r,g;
    string s,t,u;

    cin>>n>>k;
    if(k==1)cout<<0<<endl;
    else cout<<n-k<<endl;
}




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

namespace ABC070
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
			if (input[2] > input[1] || input[0]>input[3]) {
				Console.WriteLine("0");
			}
			else {
				input.Sort();
				Console.WriteLine("{0}", input[2] - input[1]);
			}
		}
	}
}


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

typedef long long LL;
const int MAXN=1e5+5;

LL dp[200],x[10],n;

int main(){
	for(int i=1;i<=4;i++) scanf("%d",&x[i]);
	scanf("%d",&n); n*=4;
	dp[0]=0;
	LL ans=1e18;
	for(int i=1;i<=150;i++){
		dp[i]=1e18;
		for(int j=1;j<=4;j++)
			if (i-(1<<(j-1))>=0) dp[i]=min(dp[i],dp[i-(1<<(j-1))]+x[j]);
	}
	for(int i=1;i<=min(150LL,n);i++){
		LL sum=dp[i]*(n/i);
		LL pos=(n/i)*i;
		sum+=dp[n-pos];
		ans=min(ans,sum);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
a,b,q=map(int,input().split())
s=[int(input()) for _ in range(a)]
t=[int(input()) for _ in range(b)]
x=[int(input()) for _ in range(q)]
from bisect import bisect_left
for xi in x:
  ans=float('inf')
  si=bisect_left(s,xi)
  ti=bisect_left(t,xi)
  # 東に進むだけ
  if xi<=s[-1] and xi<=t[-1]:
    ans=min(ans,max(s[si]-xi,t[ti]-xi))
  # 西に進むだけ
  if xi>=s[0] and xi>=t[0]:
    ss=0 if si<a and xi-s[si]==0 else xi-s[si-1]
    tt=0 if ti<b and xi-t[ti]==0 else xi-t[ti-1]
    ans=min(ans,max(ss,tt))
    
  # 東に進んだあと西 or 西に進んだあと東
  # 西の神社、東の寺
  if s[0]<=xi and xi<=t[-1]:
    w=xi-s[si-1]
    e=t[ti]-xi
    tmp=2*min(w,e)+max(w,e)
    ans=min(ans,tmp)
  # 西の寺、東の神社
  if t[0]<=xi and xi<=s[-1]:
    w=xi-t[ti-1]
    e=s[si]-xi
    tmp=2*min(w,e)+max(w,e)
    ans=min(ans,tmp)
  print(ans)


Measured memory_bytes: 106560
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t;
    }
    return n*rep_jijo(n,x-1);
}

int main(){
    int x,y;
    cin >> x >> y;
    for(int i = 0; i <= x; i++){
        int sum = i*2+(x-i)*4;
        if(sum == y){
            cout << "Yes" <<endl;
            return 0; 
        }
    }
    cout << "No" <<endl;
   return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int>,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

void go()
{
    ll int n,d,ans=0;
    cin>>n>>d;
    vector<pair<ll int,ll int> > a(n);
    for(int i=0;i<n;i++)
    {
        ll int p,q;
        cin>>p>>q;
        if(sqrt(p*p+q*q) <=d )
            ans++;
    }
    cout<<ans;
}
int main()
{
    FIO;
//    int t;
//    cin>>t;
//    while(t--)
        go();
    return 0;
}


Measured memory_bytes: 6376
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF=1<<30;


int main(void) {

    string S; cin>>S;

    int red=0,blue=0;
    for (int i = 0; i < S.length(); ++i) {
        if(S[i]=='0') red++;
        else blue++;
    }
    cout<<min(red, blue)*2<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
int A[999999], W[999999];
long long merge_and_count(int l, int r) { // range [l,r)
	if (l+1 >= r) return 0; // empty
	if (l+2 == r) { // [l,r) == [l,l+1] 要素2つだけ
		if (A[l] <= A[l+1]) return 0; // 逆転はなし
		std::swap(A[l], A[l+1]);
		return 1; // 逆転一つ
	}
	int m = (l+r)/2; // [l,r) == [l,m) + [m,r)
	long long cl = merge_and_count(l, m); // 左半分を再帰的に数える
	long long cr = merge_and_count(m, r); // 右半分を再帰的に数える
	long long c = 0; // 左と右を混ぜるときの逆転数
	int i=l, j=m; // iは[l,m)を動き, jは[m,r)を動いて、
	int k=l; // 小さいものから W[k] に書き込む
	while (i<m && j<r) { // A[i]とA[j]を比べながら進む
		if (A[i] <= A[j]) W[k++] = A[i++]; // 左半分の方が小さく逆転なし
		else {
			W[k++] = A[j++];
			c += m-i; // 左半分の方が大きい、左半分で未処理の要素だけ飛び越える
		}
	}
	while (i<m) W[k++] = A[i++]; // 左半分が余った場合
	while (j<r) W[k++] = A[j++]; // 右半分が余った場合
	//assert(k == r);
	std::copy(W+l, W+r, A+l);
	return cl + cr + c;
}

// cpp_binarysearch (C) @cielavenir under Boost Software License.
// returns the smallest value satisfying the predicate.

#include <functional>
template<typename T,typename F=std::function<bool(T)>>
T binarysearch(T lo,T hi,const T eps,const F &predicate){
	T r=hi+eps;
	for(;lo<hi+eps;){
		T mi=eps!=1||(lo<0)==(hi<0) ? lo+(hi-lo)/2 : (lo<-hi) ? -((-lo-hi-1)/2+1) : (lo+hi)/2;
		if(predicate(mi)){
			r=mi;
			hi=mi-eps;
		}else{
			lo=mi+eps;
		}
	}
	return r;
}

int main(){
	int T,i,N;
	scanf("%d",&N);std::vector<int>v(N);for(T=i=0;i<N;i++){scanf("%d",&v[i]);if(v[i]>T)T=v[i];}
	printf("%d\n",binarysearch(0,T,1,[&](int m){
		A[0]=0;
		for(i=1;i<=N;i++)A[i]=A[i-1]+(v[i-1]>m?1:-1);
		return merge_and_count(0,N+1)>=(long long)(N+1)*N/4+1;
	}));
}

Measured memory_bytes: 5120
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set,multiset
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
const int MOD = 1000000007;
typedef pair<long long,long long> P;

void chmax(long long &a,long long b){if(a < b) a = b;}
void chmin(long long &a,long long b){if(a > b) a = b;}

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //When end-of-a bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int N;cin >> N;
    vector<long long> A(N),B(N);
    long long sumA = 0,sumB = 0;
    for(int i = 0;i<N;i++){
        cin >> A.at(i);
        sumA += A.at(i);
    }
    for(int i = 0;i<N;i++){
        cin >> B.at(i);
        sumB += B.at(i);
    }
    if(sumA > sumB){
        cout << "No" << endl;
        return 0;
    }
    long long cnt = sumB-sumA;
    long long remainA = cnt,remainB = cnt;
    for(int i = 0;i<N;i++){
        if(A.at(i) > B.at(i)){
            remainB -= A.at(i)-B.at(i);
        }
        else if(A.at(i) < B.at(i)){
            remainA -= (B.at(i)-A.at(i)+1)/2;
        }
        //cout << remainA << " " << remainB << endl;
    }
    if(remainA >= 0 && remainB >= 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3704
n = int(input())
d = n % 10
hon_list = [2, 4, 5, 7, 9]
pon_list = [0, 1, 6, 8]
bon_list = [3]
if d in hon_list:
  print('hon')
elif d in pon_list:
  print('pon')
elif d in bon_list:
  print('bon')

Measured memory_bytes: 9128
let _ =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let vertex = ref [] in
  for i = 0 to n - 1 do
    Scanf.scanf (if i <> n - 1 then "%d " else "%d\n")
      (fun v -> vertex := v::!vertex)
  done;
  !vertex
  |> List.sort (fun a b -> 1 - compare a b)
  |> (fun ls ->
    let longest = List.hd ls in
    let others = List.fold_left (fun acc e -> acc + e) 0 (List.tl ls) in
    (if longest < others then "Yes" else "No")
    |> print_string)

Measured memory_bytes: 2432
#include<stdio.h>
#include<math.h>
int main()
{
    int N,i;
    while(~scanf("%d",&N))
    {
        for(i=N; i>=1; i--)
        {
            if(sqrt(i)-(int)sqrt(i)==0)
                break;
        }
        printf("%d\n",i);
    }
    return 0;
}


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

int main(){
    int n;
    cin>>n;
    vector<long long int> a(n-1);
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==0){
            cout<<0<<endl;
            return 0;
        }
    }
    for(int j=1;j<n;j++){
        if(a[j]>1000000000&&a[j-1]>=1000000000){
            cout<<-1<<endl;
            return 0;
        }
        else if(a[j]>=1000000000&&a[j-1]>1000000000){
            cout<<-1<<endl;
            return 0;
        }
        if(a[j]*a[j-1]>1000000000000000000){
            cout<<-1<<endl;
            return 0;
        }
        a[j]*=a[j-1];
    }
    cout<<a[n-1]<<endl;
}


Measured memory_bytes: 4048
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main()
{
    string s;
    s.reserve(10000);
    cin >> s;
    ll q;
    cin >> q;

    string b;
    getline(cin, b);
    bool is_reverse = false;
    for (auto i = 0; i < q; i++)
    {
        string qs;
        getline(cin, qs);

        if (qs[0] == '1')
        {
            is_reverse = !is_reverse;
        }
        else
        {
            auto f = qs[2];
            auto c = qs[4];

            if (f == '1')
            {
                if (!is_reverse)
                {
                    s.insert(s.begin(), c);
                }
                else
                {
                    s.push_back(c);
                }
            }
            else
            {
                if (!is_reverse)
                {
                    s.push_back(c);
                }
                else
                {
                    s.insert(s.begin(), c);
                }
            }
        }
    }

    if (is_reverse)
    {
        reverse(s.begin(), s.end());
    }

    cout << s << endl;
    return 0;
}


Measured memory_bytes: 908
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
	int num[26] = {0};
	char alpha[1000];
	
	cin >> alpha;
	
	for (int i = 0; i < (int)strlen(alpha); i++) {
		num[alpha[i] - 'a']++;
	}
	
	for (int i = 0; i < 26; i++) {
		if (num[i] % 2 != 0) {
			cout << "No" << endl;
			return (0);
		}
	}
	
	cout << "Yes" << endl;
	
	return (0);
}

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

using namespace std;

typedef long long int ll;

const int mod=1e9+7;



int main()
{
    ios::sync_with_stdio(false);
    char ch;
    cin>>ch;
    if(ch-'A'>=0&&ch-'A'<=26){
        cout<<'A';
    }
    else{
        cout<<'a';
    }
}


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

typedef vector<int> vi;

int N;
vector<vi> dp;

void input_init(void) {
	cin >> N;
	dp.resize(N + 1, vi(3, 0));
	for (int j = 0; j < 3; ++j)
		cin >> dp[1][j];
}

void solve(void) {
	int s[3];
	for (int i = 2; i <= N; ++i) {
		for (int j = 0; j < 3; ++j)
			cin >> s[j];
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + s[0];
		dp[i][1] = max(dp[i - 1][2], dp[i - 1][0]) + s[1];
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + s[2];
	}
}

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

	input_init();
	solve();
	int ans = max(dp[N][0], max(dp[N][1], dp[N][2]));
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 5760
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));

     // 標準入力を1行ずつ読み出す。
     String line;
     while ((line = stdin.readLine()) != null) {
         String[] lines = line.split(" ");
         if(Integer.parseInt(lines[0]) <= Integer.parseInt(lines[2]) &&
                 Integer.parseInt(lines[2]) <= Integer.parseInt(lines[1])){
                 System.out.println("Yes");
         }
         else {
             System.out.println("No");
             }
     }
    }
}

Measured memory_bytes: 32616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(){   
  set<int> st;
  int N,K;
  cin >> N >> K;
  for(int i = 0; i < K; i++){
    int d;
    cin >> d;
    vector<int> vec(d);
    for(int t = 0; t < d; t++){
      cin >> vec.at(t);
      st.insert(vec.at(t));
    }
  }
  cout << N - st.size() << endl;
  
}


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

int x,y,r,count =0;
cin>>x>>y;
for(int i=0;i<10000;i++){
    if(x>0){
        r = x-y;
        x=r;
        count++;


    }



}
cout<<count;





}


Measured memory_bytes: 3596
#include <iostream>

using namespace std;

typedef long long ll;

ll num[100005];
const ll mod = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  ll ans = 1;
  num[0] = 3;
  for(int i = 0; i < n; i++) {
    ll a;
    cin >> a;
    a++;
    ans = ans * num[a-1] % mod;
    num[a-1]--;
    num[a]++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String[] args) {
      String str = "";  
      BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        
        try {
            str = reader.readLine();
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
      switch (str) {
       case "SUN":
           System.out.println("7");
          break;
       case "MON":
           System.out.println("6");
          break;
       case "TUE":
           System.out.println("5");
          break;
       case "WED":
           System.out.println("4");
          break;
       case "THU":
           System.out.println("3");
          break;
       case "FRI":
           System.out.println("2");
          break;
       case "SAT":
           System.out.println("1");
          break;
        default:
          break;
     }
}
}

Measured memory_bytes: 21204
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef long long int keytype;

//quicksort(<#keytype *a#>, <#int first#>, <#int last#>)

void quicksort(keytype a[], long long int first, long long int last){
    long long int i, j;
    keytype x, t;
    
    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int main() {
    long long int n,i,m=0;
    long long int a[200000];
    scanf("%lld",&n);
    for (i=0; i<n; i++) {
     scanf("%lld",&a[i]);
    }
    quicksort(a, 0, n-1);
    for (i=1;i<n;i++) {
        if (a[i]==a[i-1]) {
            printf("NO");
            m=1;
            break;
        }
    }
    if (m==0) {
        printf("YES");
    }
    
    
    return 0;
}


Measured memory_bytes: 1664
import sys

sys.setrecursionlimit(10 ** 7)

N = int(input())
edges = [[] for _ in range(N)]
for _ in range(N-1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append((b, c))
    edges[b].append((a, c))

depth = [0] * N

def dfs(v, p, d):
    depth[v] = d
    for e in edges[v]:
        if e[0] == p:
            continue
        dfs(e[0], v, d + e[1])


Q, K = map(int, input().split())
K -= 1

dfs(K, -1, 0)

for i in range(Q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    print(depth[x] + depth[y])



Measured memory_bytes: 131632