akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(){

  int A, B;

  scanf("%d %d", &A, &B);

  if(A+B >= A-B){
    if(A*B >= A+B){
      printf("%d", A*B);
    } else {
      printf("%d", A+B);
    }
  } else {
    if(A*B >= A-B){
      printf("%d", A*B);
    } else {
      printf("%d", A-B);
    }
  }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<P,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

int main(){
    ll N;
    cin >> N;
    ll M;
    cin >> M;
    ll C;
    cin >> C;
    ll ans=0;
    vector<ll> B(M,0);
    for(ll i=0;i<M;i++)cin>>B[i];
    vector<vector<ll>> A(N, vector<ll>(M, 0));
    for(ll i=0;i<N;i++)
        for(ll j=0;j<M;j++)cin>>A[i][j];
    for(ll i=0;i<N;i++){
        ll d=0;
        for(ll j=0;j<M;j++){
            d+=B[j]*A[i][j];
        }
        if(d>-C)ans++;
    }
    print(ans)

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define MAX 400
using namespace std;
int n,a[MAX];
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;n*=2;
	for (int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	int ans=0;
	for (int i=1;i<=n;i+=2) ans+=a[i];
	cout<<ans<<'\n';
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <bitset>
using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

const double PI=3.14159265358979323846;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REP1(i, n) for(int i = 1; i <= (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())
#define ZERO(a) memset(a, 0, sizeof(a))

#define RAD(d) (PI * (d) / 180)
#define DEG(r) (180.0 * (r) / PI)

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

template<class T> void dump(const vector<T> &v)
{
	REP(i, SZ(v)-1){ cout << v[i] << " "; }
	cout << v[SZ(v)-1] << endl;
}

template<class T> void dump(int w, int h, const vector<T> &v)
{
	REP(j, h){
		REP(i, w-1){ cout << v[j * w + i] << " "; }
		cout << v[j * w + w-1] << endl;
	}
}

template<class T> T accumulate(const vector<T> &v)
{
	T sum = 0;
	REP(i, SZ(v)){ sum += v[i]; }
	return sum;
}

template<class T> struct Matrix
{
	T w, h;
	vector<T> A;
	Matrix(T w_, T h_) : w(w_), h(h_), A(w * h) {}
	T get(T x, T y) const { return A[y * w + x]; }
};

template<class T> void input(Matrix<T> &m)
{
	REP(j, m.h){
		REP(i, m.w){
			cin >> m.A[j * m.w + i];
		}
	}
}

template<class T> Matrix<T> prod(const Matrix<T> &a, const Matrix<T> &b)
{
	Matrix<T> m(b.w, a.h);

	REP(j, m.h){
		REP(i, m.w){
			ll c = 0;
			REP(k, a.w){
				c += a.A[j * a.w + k] * b.A[k * b.w + i];
			}
			m.A[j * m.w + i] = c;
		}
	}

	return m;
}

void dump(const Matrix<ll> &m)
{
	REP(j, m.h){
		REP(i, m.w-1){ printf("%lld ", m.A[j * m.w + i]); }
		printf("%lld\n", m.A[j * m.w + m.w-1]);
	}
}

void dump(const Matrix<double> &m)
{
	REP(j, m.h){
		REP(i, m.w-1){ printf("%f ", m.A[j * m.w + i]); }
		printf("%f\n", m.A[j * m.w + m.w-1]);
	}
}

string &to_upper(string &s)
{
	REP(i, s.length()){
		if('a' <= s[i] && s[i] <= 'z'){
			s[i] -= 32;
		}
	}

	return s;
}

string &to_lower(string &s)
{
	REP(i, s.length()){
		if('A' <= s[i] && s[i] <= 'Z'){
			s[i] += 32;
		}
	}

	return s;
}

int getACGT(const string &s, int offset)
{
	for(int i = offset; i < LEN(s); i++){
		char c = s[i];
		if(c != 'A' && c != 'C' && c != 'G' && c != 'T')
			return i - offset;
	}

	return LEN(s) - offset;
}

int main()
{
	string S;
	cin >> S;

	int max_len = 0;
	for(int i = 0; i < LEN(S);){
		int len = getACGT(S, i);
		if(len > 0){
			chmax(max_len, len);
			i += len;
		}
		else{
			i++;
		}
	}

	cout << max_len << endl;

	return 0;
}


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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int temprature = Integer.valueOf(br.readLine());

		if(temprature >= 30) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 32608
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 10010;

int n;
int ans[maxn];

int32_t main() {
	cin >> n;
	for (int x = 1; x <= 100; x++) {
		for (int y = 1; y <= 100; y++) {
			for (int z = 1; z <= 100; z++) {
				int sum = (x*x + y*y + z*z + x*y + y*z + z*x);
				if (sum < maxn) ans[sum]++;
			}
		}
	}
	
	for (int i =1; i<= n;i++) {
		cout << ans[i] << "\n";
	}

	
}




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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;    
using pll = pair<ll, ll> ;

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define ar array
#define endl '\n'
#define all(x) x.begin(), x.end()
#define sz(x) ((long long)x.size())


template<typename T> void umin(T& a,T b){a = min(a,b);}
template<typename T> void umax(T& a,T b){a = max(a,b);}

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

ll fast(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        y >>= 1;
    }
    return res;
}

ll inv(ll n){
    return fast(n,mod-2);
}


void pre(){


}

void solve(){    

    int n,x,t;
    cin >> n >> x >> t;
    int cnt = (n+x-1)/x;
    int ans = cnt*t;
    cout << ans;

}

int32_t main(){
    #ifndef ONLINE_JUDGE
    freopen("input00.txt","r",stdin);
    #endif
    IOS;
    pre();
    ll T = 1;
    //cin >> T;
    while(T--){
        solve();   
    }
    return 0;
}

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

const int P=1e9+7;
const int N=1e5+10;

typedef long long LL;

int a[N],n,b[N];

LL p[N],ni[N];


LL ksm(LL x,LL n)
{
	LL Ans=1;
	for(;n;n>>=1,x=x*x%P)
		if(n&1) Ans=Ans*x%P;
	return Ans;
}

LL C(int n,int m)
{
	if(m>n) return 0;
	if(!n||!m) return 1;
	if(n<0||m<0) return 0;
	return (p[n]*ni[m]%P)*ni[n-m]%P;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n+1;i++) scanf("%d",&a[i]),b[a[i]]++;
	p[0]=1;
	for(int i=1;i<=n+1;i++) p[i]=p[i-1]*i%P;
	ni[n+1]=ksm(p[n+1],P-2);
	ni[0]=1;
	for(int i=n;i;i--) ni[i]=ni[i+1]*(i+1)%P;
	int now;
	for(int i=1;i<=n;i++) if(b[i]>1) now=i;
	int l,r;
	l=r=0;
	for(int i=1;i<=n+1;i++) 
	if(a[i]==now)
	{
		if(!l) l=i;
		else r=i;
	}
	LL L=0;
	int m=n-(r-l+1)+1;
	for(int i=1;i<=n+1;i++)
	{
		printf("%lld\n",((C(n+1,i)-C(m,i-1))%P+P)%P);
		//cout<<C(n+1,i)<<' '<<C(m,i-1)<<endl;
	}
}		
	

Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<string>
#include<set>
#include<cstdlib>

using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<ll> cou(100001,0);
  ll sum=0;
  for(int i=0;i<n;++i){
    int a;
    cin >> a;
    cou[a]++;
    sum += a;
  }
  int q;
  cin >> q;
  for(int i=0;i<q;++i){
    int b,c;
    cin >> b >> c;
    sum += (c-b)*cou[b];
    cou[c] += cou[b];
    cou[b] = 0;
    cout<<sum<<endl;
  }

}



Measured memory_bytes: 4052
#include<iostream>
#include<string>
using namespace std;
int main() {
	string l[8];
	for (int i = 0; i < 8; i++){
		cin >> l[i];
	}
	cout << 90 << endl;;
	for (int i = 0; i < 8; i++){
		cout << l[7][i];
		cout << l[6][i];
		cout << l[5][i];
		cout << l[4][i];
		cout << l[3][i];
		cout << l[2][i];
		cout << l[1][i];
		cout << l[0][i];
		cout << endl;
	}
	cout << 180 << endl;
	for (int i = 0; i < 8; i++){
		cout << l[7 - i][7];
		cout << l[7 - i][6];
		cout << l[7 - i][5];
		cout << l[7 - i][4];
		cout << l[7 - i][3];
		cout << l[7 - i][2];
		cout << l[7 - i][1];
		cout << l[7 - i][0];
		cout << endl;
	}
	cout << 270 << endl;
	for (int i = 0; i < 8; i++){
		cout << l[0][7 - i];
		cout << l[1][7 - i];
		cout << l[2][7 - i];
		cout << l[3][7 - i];
		cout << l[4][7 - i];
		cout << l[5][7 - i];
		cout << l[6][7 - i];
		cout << l[7][7 - i];
		cout << endl;
	}
	char c;
	cin >> c;
	return 0;
}

Measured memory_bytes: 3188
import java.io.*;
import java.util.*;
 
 
class Main{
   public static void main(String[] args) {
      FastScanner sc = new FastScanner();
      out = new PrintWriter(new BufferedOutputStream(System.out));
      String s = sc.next();
      if(isUpperCase(s)) {
        out.println("A");
      }else {
        out.println("a");
      }
      out.close();
   }
   
   public static boolean isUpperCase(String s)
   {
       for (int i=0; i<s.length(); i++)
       {
           if (!Character.isUpperCase(s.charAt(i)))
           {
               return false;
           }
       }
       return true;
   }

     

   //-----------PrintWriter for faster output---------------------------------
   public static PrintWriter out;
      
   //-----------MyScanner class for faster input----------
   public static class FastScanner {
      BufferedReader br;
      StringTokenizer st;
 
      public FastScanner() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }
 
      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }
 
      int nextInt() {
          return Integer.parseInt(next());
      }
 
      long nextLong() {
          return Long.parseLong(next());
      }
 
      double nextDouble() {
          return Double.parseDouble(next());
      }
 
      String nextLine(){
          String str = "";
      try {
         str = br.readLine();
      } catch (IOException e) {
         e.printStackTrace();
      }
      return str;
      }

   }
}


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

int main() {
  int N;
  std::cin >> N;
  std::vector<int> v_array(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> v_array.at(i);
  }

  std::sort(v_array.begin(), v_array.end(), std::greater<int>());

  double sum = 0.0;
  double pow = 1.0;
  for (int i = 0; i < N; ++i) {
    if (i != N - 1) {
      pow *= 0.5;
    }
    sum += v_array.at(i) * pow;
  }
  std::cout << sum << std::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[] strArr = new String[3];

		for (int i = 0; i < 3; i++) {
			strArr[i] = s.next();
		}
		for (int j = 0; j < 3; j++) {
			System.out.print(strArr[j].substring(j, j+1));
		}
	}
}

Measured memory_bytes: 22228
import copy

N = int(input())

A = []
for n in range(N):
    a = int(input())
    A.append(a)

m = max(A)
flag = 1
for n in range(N):
    if flag == 1 and A[n] == m:
        t = copy.deepcopy(A)
        del t[n]
        print(max(t))
        flag = 0
        continue

    print(m)

Measured memory_bytes: 14684
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <thread>

using namespace std;

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

	int c_r = 0;
	int c_b = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') c_r++;
		if (s[i] == 'B') c_b++;
	}

	if (c_r > c_b) cout << "Yes" << endl;
	else           cout << "No" << endl;

	return 0;
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> a(n+1);
	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i];
	}
	
	sort(a.begin(), a.end());
	
	bool flag = false;
	for (int i = 1; i <= n; ++i)
	{
		if (a[i] == a[i+1])
		{
			flag = true;
			break;
		}
	}
	
	if (flag)
	{
		cout << "NO" << endl;
	}
	else
	{
		cout << "YES" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 1024
using System;
using System.Text;

namespace ALDS1_9_A
{
    class Program
    {
        static int parent(int i) { return i / 2; }
        static int left(int i) { return 2 * i; }
        static int right(int i) {return 2*i+1;}
        static void Main(string[] args)
        {
            var sb = new StringBuilder();
            var H = scan()[0];
            var A = new int[1000];
            var b = scan();
            for (int i = 1; i <= H; i++)
            {
                A[i] = b[i - 1];
            }
            for (int i = 1; i <= H; i++)
            {
                sb.Append("node " + i + ": key = " + A[i] + ", ");
                if (parent(i) >= 1) sb.Append("parent key = " +A[parent(i)]+", ");
                if (left(i) <= H) sb.Append("left key = " + A[left(i)] + ", ");
                if (right(i) <= H) sb.Append("right key = " + A[right(i)] + ", ");
                sb.AppendLine();
            }
            Console.Write(sb);
        }
        static int[] scan()
        {
            return Array.ConvertAll
                (Console.ReadLine().Split(' '),int.Parse);
        }
    }
}

Measured memory_bytes: 9208
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>

using namespace std;
int main(){
    
    int a=0,b,c,x=0;
    string s;
    cin >> s;
    x=s.size();
    for(int i=0;i<=(x/2)-1;i++){
        if(s.at(i)!=s.at(x-1-i)){
            a+=1;
        }
    }
    cout << a <<endl;




}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    int N;
    cin >> N;
    vector<int> p(N);
    REP(i, N) cin >> p[i];
    int ans = 0;
    REP(i, N-1) {
        if (p[i] == i + 1) {
            swap(p[i], p[i+1]);
            ans++;
        }
    }
    if (p.back() == N) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<map>
#include<cassert>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pii;
const int N = 500;
char m[N][N+1];
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};

bool cango(int r,int c,int y,int x,int ty,int tx){
  rep(i,4){
    int ddx=x+dx[i],ddy=y+dy[i];
    while(ddy != -1 && ddx != -1 && ddy != r && ddx != c){
      if (m[ddy][ddx] != '.')break;
      if (ddy == ty && ddx == tx)return true;
      ddx+=dx[i];
      ddy+=dy[i];
    }
  }
  return false;
}

bool erase(int r,int c,int y1,int x1,int y2,int x2){
  vector<int> tx,ty;
  if (y1 == y2){
    tx.push_back(x1 < x2?x1+1:x2+1);
    ty.push_back(y1);
  }else if (x1 == x2){
    tx.push_back(x1);
    ty.push_back(y1 < y2?y1+1:y2+1);
  }else {
    tx.push_back(x1);
    ty.push_back(y2);
    tx.push_back(x2);
    ty.push_back(y1);
  }
  bool isok=false;
  rep(i,(int)tx.size()){
    if (cango(r,c,y1,x1,ty[i],tx[i]) && 
	cango(r,c,y2,x2,ty[i],tx[i])){isok=true;break;}
  }
  if (isok)m[y1][x1]=m[y2][x2]='.';
  return isok;
}

main(){
  int r,c;
  while(cin>>r>>c){
    rep(i,r)cin>>m[i];
    vector<pii> in[26];
    rep(i,r){
      rep(j,c){
	if (!isalpha(m[i][j]))continue;
	in[m[i][j]-'A'].push_back(make_pair(i,j));
      }
    }
    int ans=0;
    while(true){
      bool iserased=false;
      rep(i,26){
	if (in[i].size() == 0)continue;
	if (abs(in[i][0].first-in[i][1].first)+abs(in[i][0].second-in[i][1].second) == 1)in[i].clear();
	if (erase(r,c,in[i][0].first,in[i][0].second,in[i][1].first,in[i][1].second))ans+=2,iserased=true,in[i].clear();
      }
      if (!iserased)break;
    }
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;

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

    vector <long long> A(N), B(N);
    for (int i = 0; i < N; i++){
        cin >> A[N - 1 - i] >> B[N - 1 - i];
    }

    long long ans = 0;
    for (int i = 0; i < N; i++){
        long long num = A[i] + ans;

        if (num % B[i] != 0){
            ans += B[i] - (num % B[i]);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		char[] str = sc.next().toCharArray();
		
		if(str[0] == '7' || str[1] == '7' || str[2] == '7') {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 26836
n = int(input())
hn = [int(num) for num in input().split()]

for i in range(n-1,0,-1):
  if hn[i-1] > hn[i]:
    hn[i-1] -= 1
    if hn[i-1] > hn[i]:
      print("No")
      exit()
            
print("Yes")

Measured memory_bytes: 20416
#include<bits/stdc++.h>
using namespace std;
#define int long long
int a[200005],sum[200005];
signed main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>a[i],sum[i]=sum[i-1]+a[i];
	int ans=1e18;
	for(int i=1;i<=n;++i){
		int l=sum[i],r=sum[n]-sum[i];
		ans=min(ans,abs(r-l));
	}
	cout<<ans;
	return 0;	
}

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

using namespace std;

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

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

struct BinGraph;
struct BinGraph {
    ll val;
    BinGraph *lch, *rch;
    BinGraph(ll val, BinGraph* lch, BinGraph* rch) : val(val), lch(lch), rch(rch) {}
    void out() {
        cout << "(";
        if (lch != NULL) lch->out();
        cout << ")";
        cout << "[";
        cout << val;
        cout << "]";
        cout << "(";
        if (rch != NULL) rch->out();
        cout << ")";
    }
};

BinGraph* merge(BinGraph* g1, BinGraph* g2) {
    if (g1 == NULL) return NULL;
    if (g2 == NULL) return NULL;
    return new BinGraph(g1->val+g2->val, merge(g1->lch, g2->lch), merge(g1->rch, g2->rch));
}

class Perser {
    const string s;
    ll pos;
public:
    Perser(const string& s) : s(s), pos(0) {}
    BinGraph* perse() {
        return G();
    }
    BinGraph* G() {
        assert(pos < s.size());
        if (s[pos] == ')') {
            return NULL;
        }
        else {
            read_char('(');
            BinGraph* lch = G();
            read_char(')');
            read_char('[');
            ll val = number();
            read_char(']');
            read_char('(');
            BinGraph* rch = G();
            read_char(')');
            return new BinGraph(val, lch, rch);
        }
    }
    ll number() {
        string res = "";
        while (pos < s.size() && isdigit(s[pos])) {
            res += s[pos];
            ++pos;
        }
        return stoll(res);
    }
    void read_char(char c) {
        assert(pos < s.size() && s[pos] == c);
        ++pos;
    }
};

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    string s1, s2; cin >> s1 >> s2;
    BinGraph* G1 = Perser(s1).perse();
    BinGraph* G2 = Perser(s2).perse();
    merge(G1, G2)->out();
    cout << endl;
}

Measured memory_bytes: 3212
//美しい文字列

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end()
#define pb push_back
const int inf = 2147483647;

int main (){
    string s;cin>>s;
    map<char,int>m{};
    rep(i,0,s.size()){
        m[s[i]]++;
    }
    bool flag = true;
    rep(i,0,m.size()){
        if(m[i]%2!=0)flag= false;
    }
    cout << (flag ? "Yes" : "No")<< endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const int INF=100100100;
const double PI=3.141592653589;

ll gcd(ll a,ll b){
  if(a<b) swap(a,b);
  ll c=a%b;
  if(c==0)
  return b;
  else
  return gcd(b,c);
}

int main(){
  ll a,b,c,d; cin>>a>>b>>c>>d;
  ll ans=0;
  ll f=gcd(c,d);
  f=f*(c/f)*(d/f);
  ans=(b-a+1)-(b/c-a/c)-(b/d-a/d)+(b/f-a/f);

  // cout<<f<<endl;
  if(a%c==0)
  ans-=1;
  if(a%d==0)
  ans-=1;
  if(a%f==0)
  ans+=1;
  // cout<<(b-a+1)<<" "<<b/c-a/c<<" "<<b/d-a/d<<" "<<b/(c*d)-a/(c*d)<<endl;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
fn main() {
    let sc = std::io::stdin();
    let mut sc = Scanner { reader: sc.lock() };
    let l: usize = sc.read();

    let mut r = 0;
    while (1 << (r + 1)) <= l {
        r += 1;
    }

    let initial_length = 1 << r;
    let n = r + 1;
    let mut graph = vec![vec![]; n];
    for i in 0..r {
        graph[i].push((i + 1, 1 << i));
        graph[i].push((i + 1, 0));
    }

    let mut l = l;
    for i in (0..(n - 1)).rev() {
        if l >= initial_length + (1 << i) {
            let t = l - (1 << i);
            graph[i].push((n - 1, t));
            l = t;
        }
    }

    let mut ans = vec![];
    for i in 0..n {
        for &(next, w) in graph[i].iter() {
            ans.push((i, next, w));
        }
    }

    println!("{} {}", n, ans.len());
    for &(i, next, w) in ans.iter() {
        println!("{} {} {}", i + 1, next + 1, w);
    }
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
#include <omp.h>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
int main() {
	int n;
	cin >> n;
	vector<int> a;
	REP(i, n) {
		int tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	vector<int> ans;
	for (int i = 0; i < n; ++i) {
		for (int q = a.size() - 1; q >= 0; --q) {
			if (a[q] == q+1) {
				ans.push_back(q+1);
				a.erase(a.begin() + q);
				break;
			}
		}
	}
	if (ans.size() == n) {
		REP(i, n) {
			cout << ans[n - 1 - i] << endl;
		}
	}
	else {
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] av){
	Scanner sc=new Scanner(System.in);
	int n=sc.nextInt();
	int[] a=new int[n];
	for(int i=0;i<n;i++){
	    a[i]=sc.nextInt();
	}
	for(int i=n-1;i>=0;i--){
	    if(i!=0){
	    System.out.print(a[i]+" ");
	    }else{
		System.out.print(a[i]);
	    }
	}
	System.out.println();
    
    }
}



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

int main()
{

	int a, b;
	int mid;
	cin >> a >> b;
	while (!(a == 0 && b == 0))
	{
		if (a > b)
		{
			mid = a;
			a = b;
			b = mid;
		}


		cout << a << " " << b << endl;

		cin >> a >> b;

	}


	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long
map<char, int> m;
signed main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int wc = 0;
    int rc = 0;
    rep(i,n) {
        if(s[i]=='W') wc++;
        else rc++;
    }
    
    int ans = 0;
    FOR(i,rc,n) {
        if(s[i]=='R') ans++;
    }
    cout << ans << endl;

  return 0; 
}



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

using namespace std;
using ll = long long;
const int maxn = 2e5 + 5;
ll tree[4 * maxn], lazy[4 * maxn];
const ll Inf = 1e18;

void push(int pos, int tl, int tr) {
    if (lazy[pos] != 0){
        tree[pos] += lazy[pos];
        if (tl != tr){
            lazy[2 * pos] += lazy[pos];
            lazy[2 * pos + 1] += lazy[pos];
        }
        lazy[pos] = 0;
    }
}

void update(int pos, int tl, int tr, int l, int r, ll val) {
    push(pos, tl, tr);
    if(tl > tr or tl > r or tr < l)
        return;
    if(tl >= l && tr <= r) {
        tree[pos] += val;
        if (tl != tr) {
            lazy[pos * 2] += val;
            lazy[2 * pos + 1] += val;
        }
    } else {
        int tm = (tl + tr) / 2;
        update(2 * pos, tl, tm, l, r, val);
        update(2 * pos + 1, tm + 1, tr, l, r, val);
        tree[pos] = max(tree[2 * pos], tree[2 * pos + 1]);
    }
}

ll query(int pos, int tl, int tr, int l, int r) {
    if(tl > tr || tl > r || tr < l)
        return -Inf;
    push(pos, tl, tr);
    if(tl >= l && tr <= r)
        return tree[pos];
    int tm = (tl + tr) / 2;
    ll leftSubtree = query(2 * pos, tl, tm, l, r);
    ll rightSubtree = query(2 * pos + 1, tm + 1, tr, l, r);
    return max(leftSubtree, rightSubtree);
}


vector<vector<pair<int, int>>> add;
vector<vector<pair<int, int>>> del;

int main()
{
    int n, m;
    cin >> n >> m;
    add.assign(n + 1, vector <pair<int, int>>());
    del.assign(n + 1, vector <pair<int, int>>());
    for (int i = 0; i < m; i++){
        int L, R, a;
        cin >> L >> R >> a;
        add[L].emplace_back(L - 1, a);
        del[R].emplace_back(L - 1, a);
    }
    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
      for (auto &p : add[i]) {
         int x = p.first, val = p.second;
         update(1, 0, n, 0, x, 1ll * val);
      }

      ll res = query(1, 0, n, 0, i - 1);
      ans = max(res, ans);
        update(1, 0, n, i, i, res);

      for (auto &p : del[i]) {
         int x = p.first, val = p.second;
         update(1, 0, n, 0, x, -1ll * val);
      }
   }
   cout << ans << '\n';
    return 0;
}


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

int main()
{
double n,k;
cin>>n>>k;

double ans=0;

for(double index=1;index<=n;index++)
{
    int curr=0;
    double copie = index;
    
    while(copie <k)
    {
        curr++;
        copie*=2;
    }
    
   // cout<<curr<<endl;
    ans+=1/(pow(2,curr));
}

printf("%.12f",ans*(1/n));
//cout<<ans*(1/n)<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
r=lambda:sys.stdin.readline().strip()
while 1:
 n=int(r())
 if n==0:break
 d={}
 for _ in[0]*n:
  k,v=r().split()
  d[k]=v
 a=''
 for _ in[0]*int(r()):
  e=r()
  a+=d[e]if e in d else e
 print(a)


Measured memory_bytes: 6476
def LI():
  return [int(s) for s in input().split()]

N,X = LI()
L_s = LI()

D = [0]*(N+1)

count = 1

for i in range(1,N+1):
  D[i] = D[i-1] + L_s[i-1]
  if D[i] <= X:
  	count += 1
  
print(count)

Measured memory_bytes: 3060
def enum_divisors(n):
    res = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            res.append(i)
            if i != n // i:
                res.append(n // i)
    return res


N = int(input())
ans = 0
for i in enum_divisors(N):
    d = N // i - 1
    if d == 0 or N // d != N % d:
        continue
    ans += d
print(ans)


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

using namespace std;

int D[11][11];
char str[11][11];
int n,m,cnt;

int main()
{
	int i,j;
	
	scanf("%d%d",&n,&m);
	
	for(i=0;i<n;i++){
		scanf("%s",str[i]);
		for(j=0;j<m;j++) cnt += str[i][j] == '#';
	}
	
	if(cnt != n+m-1){
		printf("Impossible\n");
		return 0;
	}
	
	D[0][0] = 1;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++) if(str[i][j] == '#'){
			if(i) D[i][j] += D[i-1][j];
			if(j) D[i][j] += D[i][j-1];
		}
	}
	
	printf("%s\n",D[n-1][m-1] == 1? "Possible" : "Impossible");
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
typedef long long ll;
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0;}

int main() {
  int N;
  ll K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, 0, N) cin >> A[i];
  ll dp[100][2];
  memset(dp, -1, sizeof(dp));
  dp[0][0] = 0;
  rep(i, 0, 50) {
    ll mask = 1LL << (50 - i - 1);
    int cnt = 0;
    rep(j, 0, N) if (A[j] & mask) cnt++;
    ll cost[2] = {mask * cnt, mask * (N - cnt)};
    bool OK = (K & mask) ? 1 : 0;
    rep(d, 0, 2) rep(p, 0, 2) {
      if (dp[i][p] != -1) chmax(dp[i + 1][p | (!d & OK)], dp[i][p] + cost[p ? d : d & OK]);
    }
  }
  cout << max(dp[50][0], dp[50][1]) << endl;
  return 0;
}


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

int main(){
    long N, M;
    cin >> N >> M;
    vector<pair<long, long>> edge(M);
    for(auto& i : edge)cin >> i.first >> i.second;

    class union_find{
    public:
        vector<long> v;
        union_find(size_t n) : v(n, -1){}
        long root(long i){
            while(v[i] >= 0)i = v[v[i]] >= 0 ? v[i] = v[v[i]] : v[i];
            return i;
        }
        long unite(long a, long b){
            a = root(a);
            b = root(b);
            if(a == b)return 0;

            long ret(v[a] * v[b]);

            if(v[a] > v[b])swap(a, b);

            v[a] += v[b];
            v[b] = a;

            return ret;
        }
    };

    reverse(edge.begin(), edge.end());

    union_find uf(N + 1);
    vector<long> ans({N * (N - 1) / 2});

    for(const auto& i : edge){
        long t = *ans.rbegin();
        ans.push_back(t - uf.unite(i.first, i.second));
    }
    ans.pop_back();
    reverse(ans.begin(), ans.end());
    for(const auto i : ans)cout << i << endl;

    return 0;
}

Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,i,j,a[10],flag;
    string str;
    fill(a,a+10,0);
    cin>>n>>k;
    for(i=1;i<=k;i++)
    {
        cin>>j;
        a[j]=1;
    }
    for(i=n;;i++)
    {
        flag=0;
        std::string str = std::to_string(i);
        for(j=0;str[j];j++)
        {
            if(a[str[j]-'0']==1)
            {
                flag=1;
                break;
            }
        }

        if(flag==0)
        {
            cout<<str<<endl;
            break;
        }
    }
}


Measured memory_bytes: 256
cook_list = []
cook_list_2 = []

for i in range(5):
    cook_list.append(int(input()))

for c in cook_list:
    cook_list_2.append(((c+9)//10)*10)
    
max_diff = 0
for j in range(5):
    if cook_list_2[j] - cook_list[j] >= max_diff:
        max_diff = cook_list_2[j] - cook_list[j]
    
ans = sum(cook_list_2) - max_diff
print(ans)

Measured memory_bytes: 8968
use proconio::input;
use std::cmp::*;

fn solve(h: usize, w: usize, mut c: Vec<Vec<i32>>, a: &[Vec<i32>]) -> i32 {
    for k in 0..10 {
        for i in 0..10 {
            for j in 0..10 {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }
    (0..h)
        .map(|row| {
            (0..w)
                .map(|col| {
                    if a[row][col] >= 0 {
                        c[a[row][col] as usize][1]
                    } else {
                        0
                    }
                })
                .sum::<i32>()
            })
        .sum::<i32>()
}

fn main() {
    input! {
        h: usize,
        w: usize,
        c: [[i32; 10]; 10],
        a: [[i32; w]; h],
    }
    let r = solve(h, w, c, &a);
    println!("{}", r);
}


Measured memory_bytes: 2432
n,m=map(int,input().split())
L=[]
for i in range(m):
    l=[i]+list(map(int,input().split()))+[0]
    L.append(l)
LS=sorted(L,key=lambda x:(x[1],x[2]))
LS[0][3]=1
for i in range(m-1):
    if LS[i][1]==LS[i+1][1]:
        LS[i+1][3]=LS[i][3]+1
    else:
        LS[i+1][3]=1
LR=sorted(L,key=lambda x:x[0])
for a,b,c,d in LR:
    print(str(b).zfill(6)+str(d).zfill(6))

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

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		int n=in.nextInt(),A[][][]=new int[4][3][10];
		for(int i=0;i<n;i++) {
			int b=Integer.parseInt(in.next()), f=Integer.parseInt(in.next()), r=Integer.parseInt(in.next()), v=Integer.parseInt(in.next());
			A[b-1][f-1][r-1]+=v;
		}
		
		for(int i=0;i<4;i++) {
			for(int j=0;j<3;j++) {
				for(int k=0;k<10;k++) {
					out.print(" "+A[i][j][k]);
				}
				out.println();
			}
			if(i<3)out.println("####################");
		}
		out.flush();
	}

}



Measured memory_bytes: 28844
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
const int maxn = 100900;
int vis[maxn + 1] = { 1,1 };
int prime[maxn + 1];
int pri[maxn + 10];
int re[maxn + 10];
int cnt = 0;

void eratosthenes()
{
	int i, j;
	int m = sqrt(maxn + 0.5);
	for (i = 2; i <= m; i++) {
		if (!vis[i]) {
			for (j = i * i; j <= maxn; j += i) vis[j] = 1;
		}
	}
	for (i = 2; i <= maxn; i++)
		if (!vis[i]) prime[cnt++] = i;
}

int main()
{
	int Q;
	int l, r;
	eratosthenes();
	memset(pri, 0, sizeof(pri));
	for (int i = 0; i<cnt; i++)
		pri[prime[i]] = 1;
	re[1] = 0;
	for (int i = 2; i <= 1e5 + 10; i++) {
		re[i] = re[i - 1];
		if (pri[i] && pri[(i + 1) / 2]) re[i]++;
	}

	scanf("%d", &Q);
	while (Q--)
	{
		scanf("%d%d", &l, &r);
		int ans = 0;
		if (l == r) {
			if (pri[l] && pri[(l + 1) / 2]) ans = 1;
		}
		else
		{
			ans = re[r] - re[l];
			if (pri[l] && pri[(l + 1) / 2]) ans ++;
		
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 1792
n = int(input())
l = list(map(int, input().split()))
dp = [0]*n

for i in range(1,n):
  d1 = dp[i-1] + abs(l[i] - l[i-1])
  if i > 1:
    d2 = dp[i-2] + abs(l[i] - l[i-2])
    if d1 > d2:
      d1 = d2
  dp[i] = d1
print(dp[-1])



Measured memory_bytes: 13980
import java.util.*;

class Main{

    int[] cnt;
    int n,m,kk;
    int INF = Integer.MAX_VALUE;

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            n = sc.nextInt();
            m = sc.nextInt();
            kk = sc.nextInt();
            if(n==0 && m==0 && kk==0) break;

            double mn = Math.pow(m,n);

            int[][] dp = new int[2][n*m+1];

            for(int i=1; i<=m; i++) dp[0][i] = 1;
            for(int i=0; i<n-1; i++){
                for(int k=1; k<=m; k++){
                    for(int j=0; j+k<=n*m; j++){
                        dp[(i+1)%2][j+k] += dp[i%2][j];
                    }
                }
                Arrays.fill(dp[i%2], 0);
            }

            double ans = 0.0;
            for(int i=1; i<=n*m; i++){
                if(dp[(n-1)%2][i]==0) continue;
                ans += ((double)dp[(n-1)%2][i]/mn) * Math.max(1, i-kk);
            }

            System.out.println(ans);
        }
    }

    public static void main(String[] args){
        new Main().solve();

    }
}

Measured memory_bytes: 23708
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();

		int[] t = new int[n];

		for (int i = 0; i < n; i++) {
			t[i] = sc.nextInt();
		}

		int max = (int) Math.pow(10, 9) * -1;
		int min = t[0];

		for (int i = 1; i < n; i++) {
			if (max < t[i] - min) {
				max = t[i] - min;
			}
			min = min > t[i] ? t[i] : min;
		}
		System.out.println(max);
	}

}

Measured memory_bytes: 100776
import sys
readline = sys.stdin.readline
from heapq import heapify, heappush, heappop


def dijkstra(path, N, start):
    """
    Args:
        path (list): [[(cost, node), (cost, node), ...], [], [], ...]
    """
    visited = [False] * N
    que = [(0, start)]
    heapify(que)  # 始点aから各頂点への(距離, 頂点ID)
    dist = [-1] * N  # 始点aから各頂点への距離
    dist[start] = 0  # 始点aからaへの距離は0
    while que:
        d, v = heappop(que)  # 始点から最短距離の頂点を(確定ノード)を取り出す
        visited[v] = True  # 確定フラグを立てる
        # 接続先ノードの情報を更新する
        for d, to in path[v]:
            cost = dist[v] + d
            if dist[to] < 0 or cost < dist[to]:
                dist[to] = cost
                if not visited[to]:
                    heappush(que, (cost, to))

    return dist


def main():
    N = int(readline())
    path = [[] for _ in range(N)]

    for _ in range(N-1):
        a, b, c = map(int, readline().rstrip().split())
        path[a-1].append((c, b-1))
        path[b-1].append((c, a-1))
    
    Q, K = map(int, readline().rstrip().split())
    dist = dijkstra(path, N, K-1)

    for _ in range(Q):
        x, y = map(int, readline().rstrip().split())
        print(dist[x-1] + dist[y-1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 51240
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	unsigned long ans=1;
	int N, K;
	cin >> N >> K;
	for (int i=0; i < N; i++) {
		if (i == 0) {
			ans = ans * K;
		}
		else {
			ans = ans * (K - 1);
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c;
	int i,count=0;
	int p[11];
	while(scanf("%d %d %d",&a,&b,&c)!=EOF){
		for(i=1;i<11;i++){
			p[i]=i;
			if(p[i]==a||p[i]==b||p[i]==c){
				p[i]=0;
			}
			if(a+b+p[i]>20){
				count=count+1;
			}
		}
		if(count<4){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
		count=0;
	}
	return 0;
}

Measured memory_bytes: 580
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef int64_t lint;
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using lb = long double;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SI(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define debug(x) cerr << #x << ": " << x << "\n"//手動デバッグ
#define debugV(x) for(int i=0;i<((ll)(x).size());i++)cerr << #x <<"at:"<<i<< ": " << x[i] << "\n"//手動デバッグ 
#define YES(c) cout<<((c)?"YES\n":"NO\n"),0
#define Yes(c) cout<<((c)?"Yes\n":"No\n"),0
#define O(p) cout<<p<<"\n",0
#define OS(p) cout<<p<<" ",0
#define ON(p) cout<<p,0
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define endl "\n"//endlを置き換える
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定

const int dy[4]={1,0,-1,0};
const int dx[4]={0,1,0,-1};//^>v<

template<class T=int> T in(){
    T x;
    cin>>x;
    return (x);
}
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;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
//------------------------------------------------------------





//------------------------------------------------------------
int main() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
//------------------------------------------------------------
    string s;cin>>s;
    ll t=s.size();
    //if(t==0){O("")return 0;}
    ll ans=0;
    rep(i,t){
        char tmp=s[i];
        string ss="";
        ss+=tmp;
        ans+=stoi(ss);
    }
    if(ans%9==0){
        O("Yes");
    }else{
        O("No");
    }
    
    
    
    
//------------------------------------------------------------
	return 0;
}


Measured memory_bytes: 3760
n,h=map(int,input().split())
A=list(map(int,input().split()))

A= [i-h for i in A]
dp=[[0]*5100 for i in range(n+1)]
dp[0][2500]=1

for i in range(n):
    for j in range(5100):
        if not dp[i][j]: continue
        dp[i+1][j] += dp[i][j]
        #if A[i]==0:continue
        dp[i+1][j+A[i]] +=dp[i][j]

print(dp[n][2500]-1)

Measured memory_bytes: 11728
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<map>
#include<iomanip>

using namespace std;
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define RED 3
int N;
int ans=0;

void dfs(vector<int> A){
 bool check7=false;
 bool check5=false;
 bool check3=false;
 long long int number=0;
 long long int digit=1;

 for(int i=A.size()-1; i>=0; i--){
  number+=(A[i]*digit); 
  digit*=10;
  if(A[i]==7)check7=true;
  else if(A[i]==5)check5=true;
  else if(A[i]==3)check3=true;
 }
 if(number>N)return ;
 else if(check7 && check5 && check3==true)ans++;
  
 A.push_back(7);
 dfs(A);
 A.pop_back();

 A.push_back(5);
 dfs(A);
 A.pop_back();
 
 A.push_back(3);
 dfs(A);
 A.pop_back();
 return ;
}
int main(void){
 vector <int> A;
 cin>>N;
 dfs(A);

 std::cout<<ans<<std::endl;
 return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//define
#define int long long
#define vint vector<int>
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
#define pb() push_back()
#define mod 100000007
#define elif else if
#define str string
//main
signed main(){
  int N,M,O,P,Q,count=0,count2=0,count3=0;
  double D=0;
  int c='A'-'a';
  //char C;
  str S,T;
  cin>>N;
  vint A(N);
  rep(0,N)cin>>A[i];
  sort(all(A));
  reverse(all(A));
  for(int i=0;i<N;i++){
    if(i%2==0){
      count+=A[i];
    }
    elif(i%2==1){
      count-=A[i];
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
int s[100009];
int main()
{
    int n,ls,fi;
    ll sc;
    int maxn=-1;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&ls);
        if(i==1)
            fi=ls;
        s[ls]++;
        if(ls>maxn)
            maxn=ls;
    }
    int flag=1;
    if(fi!=0||s[0]>1)
        cout<<0<<endl;
    else
    {
         sc=1;
        for(int i=2;i<=maxn;i++)
        {
            if(s[i]==0)
            {
                flag=0;
                break;
            }
            for(int j=1;j<=s[i];j++)
            sc=(sc*s[i-1])%998244353;
        }
        if(flag==0)
            cout<<0<<endl;
        else
        cout<<sc<<endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main() {
	int a;
	cin >> a;
	if (a == 25) {
		cout << "Christmas";
	}
	else if (a == 24) {
		cout << "Christmas Eve";
	}
	else if (a == 23) {
		cout << "Christmas Eve Eve";
	}
	else if (a == 22) {
		cout << "Christmas Eve Eve Eve";
	}
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

long long M=1000000007;
int main(int argc, char const *argv[]) {
  int n;cin>>n;
  vector<long long> a(n);
  for(int i=0;i<n;++i){
    cin>>a[i];
  }
  long long su,res1=0,res2=0;
  su=0;
  for(int i=0;i<n;++i){
    su+=a[i];
    if(i%2==0){
      if(su<=0){
        res1+=1+abs(su);
        su=1;
      }
    }
    else{
      if(su>=0){
        res1+=1+abs(su);
        su=-1;
      }
    }
    // cout<<su<<" "<<res1<<endl;
  }
  su=0;
  for(int i=0;i<n;++i){
    su+=a[i];
    if(i%2==1){
      if(su<=0){
        res2+=1+abs(su);
        su=1;
      }
    }
    else{
      if(su>=0){
        res2+=1+abs(su);
        su=-1;
      }
    }
    // cout<<su<<" "<<res2<<endl;
  }
  cout<<min(res1,res2)<<endl;
  return 0;
}


Measured memory_bytes: 1024
n, m, k = gets.split.map(&:to_i)
as = [0] + gets.split.map(&:to_i)
bs = [0] + gets.split.map(&:to_i)

for i in 1..n
    as[i] += as[i-1]
end

for i in 1..m
    bs[i] += bs[i-1]
end

ib = m
ans = 0
for ia in 0..n
    th = k - as[ia]
    ib.downto(0) do
        if bs[ib] > th
            ib -= 1
        else
            #puts "#{ia} #{ib}"
            ans = [ans, ia + ib].max
            break
        end
    end
end

puts ans

Measured memory_bytes: 49040
//code by smigwump
//https://codeforces.com/blog/entry/62393
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define REP(i,a,b) for(int i = a; i <= b; i++)

typedef long long ll;

using namespace std;

int main() {
	// #ifndef ONLINE_JUDGE
	//     freopen("input.txt", "r", stdin);
	//     freopen("output.txt", "w", stdout);
	// #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vector<int> a(5);
    REP(i,0,4) {
    	cin>>a[i];
    	if(a[i]==0) {
    		cout<<i+1<<"\n";
    	}
    }
	return 0;
}

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

int main(){
    int n, a;
    int times = 0;
    cin >> n;
    int num[n];
    for(int i = 0; i < n; i++){
        cin >> num[i];
    }
    
    int flag = 1;
    while(flag == 1){
        flag = 0;
        for(int j = n-1; j > 0; j--){
            if(num[j] < num[j-1]){
                a = num[j];
                num[j] = num[j-1];
                num[j-1] = a;
                times++;
                flag = 1;
            }
        }
    }
    cout << num[0];
    for(int i = 1; i < n; i++){
        cout << " " << num[i];
    }
    cout << endl;
    cout << times << endl;
    
    return 0;
}


Measured memory_bytes: 3112