akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

ll INF = 1LL << 40;

class SegmentTree{
public:
  int N;
  vector<ll> node;

  //コンストラクタ
  SegmentTree(vector<ll> v){
    int sz = v.size();
    N = 1;
    while(N < sz) N *= 2;
    node.resize(2 * N - 1, INF);

    for(int i = 0; i < sz; i++){
      int k = i + N - 1;
      node[k] = v[i];
      while(k > 0){
        k = (k - 1) / 2;
        node[k] = min(node[k * 2 + 1], node[k * 2 + 2]);
      }
    }
  }

  //k番目の値(0_indexed)をaに変更
  void update(int k, ll a){
    //葉の節点
    k += N - 1;
    node[k] = a;
    //登りながら更新
    while(k > 0){
      k = (k - 1) / 2;
      node[k] = min(node[k * 2 + 1], node[k * 2 + 2]);
    }
  }

  //[a,b)の最小値
  ll query(int a, int b){
    return Query(a, b, 0, 0, N);
  }

  ll Query(int a, int b, int k, int l, int r){
    if(r <= a || b <= l) return INF;
    if(a <= l && r <= b) return node[k];
    else{
      ll v1 = Query(a, b, k * 2 + 1, l, (l + r) / 2);
      ll v2 = Query(a, b, k * 2 + 2, (l + r) / 2, r);
      return min(v1, v2);
    }
  }

  void print(){
    for(int i = 0; i < 2 * N - 1; i++){
      cout << "node[" << i << "] " << node[i] << endl;
    }
  }
};

//==========================================================

int main(){
    int N, M;
    cin >> N >> M;
    string s;
    cin >> s;

    vector<ll> a(N + 1, INF);
    a[N] = 0;

    SegmentTree sg = SegmentTree(a);

    for(int i = N - 1; i >= 0; i--){
        if(s[i] != '1'){
            ll mn = sg.query(i + 1, min(N + 2, i + M + 1));
            sg.update(i, mn + 1);
            //cout << "hoge" << endl;
        }
    }

    if(sg.query(0, 1) >= INF){
        cout << -1 << endl;
        return 0;
    }

    vector<int> ans;
    int p = 0;
    while(p != N){
        int cnt = 0;
        int val = sg.query(p, p + 1);
        while(sg.query(p, p + 1) != val - 1){
            p++;
            cnt++;
            //cout << "hoge" << endl;
        }
        ans.push_back(cnt);
    }

    /*for(int i = 0; i < N + 1; i++){
        cout << i << " " << sg.query(i, i + 1) << endl;
    }

    cout << endl;*/

    for(int i = 0; i < (int)ans.size(); i++){
        cout << ans[i] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 4336
#include <stdio.h>
int main()
{
    int n,i,ttl=0,high=0,ttl2,x;
    scanf("%d",&n);
    for(x=1;x<=n;x++)
    {
        scanf("%d",&i);
        if(i>high)
        {
            high=i;
        }
        ttl=i+ttl;
    }
    ttl2=ttl-(high/2);
    printf("%d",ttl2);
    return 0;
}


Measured memory_bytes: 1708
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        String first;
        char table[] = new char[20000];
 
        int M,h,left,right;
 
 
        try {
 
            while(!(first = br.readLine()).equals("-")){
 
                for(int i = 0; i < first.length(); i++){
                    table[i] = first.charAt(i);
                }
 
                left = 0;
                right = first.length()-1;
 
                M = Integer.parseInt(br.readLine());
 
                for(int loop = 0; loop < M; loop++){
                    h = Integer.parseInt(br.readLine());
 
                    for(int i = 0; i < h; i++){
                        table[right+1+i] = table[left+i];
                    }
                    left += h;
                    right += h;
                }
 
                for(int i = left; i <= right; i++){
                    System.out.printf("%c", table[i]);
                }
                System.out.printf("\n");
            }
 
 
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


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

double c[100][100];
double dp[100][100];//i??\??????j???????????¬
signed main() {
	int a, b;
	while(scanf("%d%d", &a, &b),a|b) {
		for (int d = 0; d < a; d++) {
			for (int e = 0; e < a; e++) {
				scanf("%lf", &c[d][e]);
			}
		}
		for (int d = 0; d < b; d++) {
			for (int e = 0; e < a; e++) {
				if (d == 0)dp[d][e] = 1;
				else dp[d][e] = -(1 << 15);
			}
		}
		for (int d = 0; d < a; d++)dp[0][d] = 1;
		for (int d = 1; d < b; d++) {
			for (int e = 0; e < a; e++) {//????????\
				for (int f = 0; f < a; f++) {//????????\
					dp[d][e] = max(dp[d][e], dp[d - 1][f] * c[f][e]);
				}
			}
		}
		double MAX = -(1 << 15);
		for (int d = 0; d < a; d++) {
			MAX = max(MAX, dp[b - 1][d]);
		}
		printf("%.2lf\n", MAX);
	}
}

Measured memory_bytes: 3344
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pranay2516
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt(), a[] = in.readIntArray(n), mod = (int) 1e9 + 7;
            long[] pref = new long[n];
            pref[n - 1] = a[n - 1];
            for (int i = n - 2; i >= 0; --i) pref[i] = ((pref[i + 1] + a[i]) + mod) % mod;
            long sum = 0;
            for (int i = 0; i < n - 1; ++i) sum = ((sum % mod) + ((pref[i + 1] * a[i] + mod) % mod) + mod) % mod;
            out.println(sum);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int[] readIntArray(int size) {
            int[] array = new int[(int) size];
            for (int i = 0; i < size; i++) array[i] = nextInt();
            return array;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 36388
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort()
q.sort()

for _ in range(x):
    r.append(p.pop())

for _ in range(y):
    r.append(q.pop())

r.sort()
ans = 0

for _ in range(x+y):
    ans += r.pop()

print(ans)


Measured memory_bytes: 23688
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

template<int mod>
struct ModInt{
    int x;

    ModInt() : x(0) {}
    
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    
    ModInt &operator+=(const ModInt &p){
        if((x += p.x) >= mod)   x -= mod;
        return *this;
    }
    
    ModInt &operator-=(const ModInt &p){
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt &operator*=(const ModInt &p){
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }

    ModInt &operator/=(const ModInt &p){
        *this *= p.inverse();
        return *this;
    }
    
    ModInt operator-() const {return ModInt(-x);}

    ModInt operator+(const ModInt &p) const {return ModInt(*this) += p;}

    ModInt operator-(const ModInt &p) const {return ModInt(*this) -= p;}

    ModInt operator*(const ModInt &p) const {return ModInt(*this) *= p;}

    ModInt operator/(const ModInt &p) const {return ModInt(*this) /= p;}

    bool operator==(const ModInt &p) const {return x == p.x;}

    bool operator!=(const ModInt &p) const {return x != p.x;}

    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0){
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const{
        ModInt ret(1), mul(x);
        while(n > 0){
            if(n & 1)   ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p){
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a){
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }

    static int get_mod() {return mod;}
};

using modint = ModInt<mod>;

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

    int n;
    cin >> n;
    vector<int> ZeroCnt(60, 0), PopCnt(60, 0);
    for(int i = 0; i < n; ++i){
        ll a;
        cin >> a;
        for(int d = 60; d >= 0; --d){
            if((a >> d) & 1)    ++PopCnt[d];
            else    ++ZeroCnt[d];
        }
    }
    modint ans = 0;
    for(int i = 0; i < 60; ++i){
        modint add = (ll)ZeroCnt[i] * PopCnt[i];
        add *= 1LL << i;
        ans += add;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import bisect
def make_divisors(N):
    divisors = []
    for i in range(1, int(N**0.5)+1):
        if N % i == 0:
            divisors.append(i)
            if i != N // i:
                divisors.append(N//i)
    divisors.sort()
    return divisors
N, M = map(int, input().split())
lst = make_divisors(M)
print(lst[bisect.bisect_right(lst, M//N)-1])

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

template<class T, class Cond>
struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  bool operator()(T& a, const T& b) const {
    if(cond(a, b)) { a = b; return true; }
    return false;
  }
};
template<class T, class Cond>
chain<T, Cond> make_chain(Cond cond) { return chain<T, Cond>(cond); }

vector<vector<i64>> G;

int main() {
  i64 N, M;
  cin >> N >> M;
  G.resize(N);
  rep(i,0,M) {
    i64 a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  queue<int> que;

  vector<int> from(N, -1);

  que.push(0);
  while(!que.empty()) {
    int v = que.front();
    que.pop();
    for(auto t: G[v]) {
      if(from[t] != -1) continue;
      from[t] = v;
      que.push(t);
    }
  }

  std::cout << "Yes" << std::endl;
  rep(i,1,N) {
    std::cout << from[i] + 1 << "\n";
  }
}


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

using namespace std;

void solve()
{
    int n, k;
    cin >> n >> k;
    vector<int> as(n);
    for (int i = 0; i < n; i++)
    {
        cin >> as[i];
    }
    int ans = n + 1, r = -1, cnt = 0;
    vector<int> bincnt(k + 1);
    for (int l = 0; l <= n - k; l++)
    {
        while (r < l || (cnt < k && r + 1 < n))
        {
            if (1 <= as[r + 1] && as[r + 1] <= k)
            {
                if (!bincnt[as[r + 1]])
                {
                    cnt++;
                }
                bincnt[as[r + 1]]++;
            }
            r++;
        }
        //cout << l << ' ' << r << endl;
        if (cnt == k)
        {
            ans = min(ans, r - l + 1);
        }
        if (1 <= as[l] && as[l] <= k)
        {
            if (--bincnt[as[l]] == 0)
            {
                cnt--;
            }
        }
    }
    if (ans == n + 1)
    {
        ans = 0;
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}



Measured memory_bytes: 3584
A = input()
B = input()
if len(A)>len(B):
    print('GREATER')
elif len(A)<len(B):
    print('LESS')
else:
    for i in range(len(A)):
        if int(A[i])>int(B[i]):
            print('GREATER')
            exit()
        elif int(A[i])<int(B[i]):
            print('LESS')
            exit()
    print('EQUAL')

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

int main() {
    int x, y;
    cin >> x >> y;
    for(int i = min(x, y); i >= 2; i--) {
        if(x % i == 0 && y % i == 0) {
            cout << x + y - i + 1 << endl;
            return 0;
        }
    }
    cout << x + y << endl;
}


Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <queue>


using namespace std;

template<class T> inline bool chmin(T& a, T b) {
  //aの方が大きければ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 main(){
  int n,m;
  cin >> n >> m;
  int a[m],b[m],d[m];
  int i,j;
  for(i=0;i<m;i++){
    d[i] = 0;
  }
  int key;
  for(i=0;i<m;i++){
    cin >> a[i] >> b[i];
    for(j=0;j<b[i];j++){
      cin >> key;
      d[i] += (1 <<(key-1));
    }
  }
  int N = (1<<n)+1;
  int dp[m+1][N];
  int INF = 1e9;
  for(i=0;i<m+1;i++){
    for(j=0;j<N;j++){
      dp[i][j] = INF;
    }
  }
  for(i=0;i<m+1;i++){
    dp[i][0] = 0;
  }
  for(i=0;i<N;i++){
    if((i&d[0]) == i){
      dp[1][i] = a[0];
    }
    else{
      dp[1][i] = INF;
    }
  }

  for(i=2;i<m+1;i++){
    for(j=0;j<N-1;j++){
      if(dp[i-1][j] != INF) chmin(dp[i][j],dp[i-1][j]);
      chmin(dp[i][(j|d[i-1])], dp[i-1][j]+a[i-1]);
      chmin(dp[i][(j|d[i-1])],dp[i-1][(j|d[i-1])]);
    }
  }



  if(dp[m][N-2] == INF) cout << -1 << endl;
  else cout << dp[m][N-2] << endl;




}


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

int main(int argc, char const *argv[]) {
  int n;
  cin>>n;
  if(n==1){
    cout<<"Hello World"<<endl;
  }
  if(n==2){
    int x,y;
    cin>>x>>y;
    cout<<x+y<<endl;
  }
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll N, P; cin >> N >> P;
  ll A[N]; rep(i,N) { cin >> A[i]; A[i] %= 2; }
  ll dp[N+1][2] = {}; dp[0][0] = 1;
  rep(i,N) {
    if (A[i]%2==0) {
      dp[i+1][0] = dp[i][0]*2; 
      dp[i+1][1] = dp[i][1]*2;
    }
    else {
      dp[i+1][0] = dp[i][0] + dp[i][1];
      dp[i+1][1] = dp[i][0] + dp[i][1];
    }
  }

  ll result = dp[N][P];
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>

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

const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

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

    std::cout << 3*r*r << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#define INF (1 << 28)

using namespace std;

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

struct data_t {
	int row;
	int col;
	int dir;
	int cost;

	bool operator<(const data_t& right) const {
		return (cost > right.cost);
	}
};

int main(void) {
	while (cin >> w >> h, w) {
		vector< vector<int> > s(h+2,vector<int>(w+2));
		for (int i = 0; i < h+2; ++i) {
			for (int j = 0; j < w+2; ++j) {
				if (i == 0 || i == h+1 || j == 0 || j == w+1) {
					s[i][j] = -1;
				}
				else {
					cin >> s[i][j];
				}
			}
		}

		vector<int> c(4);
		for (int i = 0; i < 4; ++i) {
			cin >> c[i];
		}

		int cost[h+2][w+2][4];
		for (int i = 0; i < h+2; ++i) {
			for (int j = 0; j < w+2; ++j) {
				for (int k = 0; k < 4; ++k) {
					cost[i][j][k] = INF;
				}
			}
		}

		priority_queue<data_t> pq;
		pq.push((data_t){1,1,0,0});
		cost[1][1][0] = 0;
		while (!pq.empty()) {
			data_t sn = pq.top();
			pq.pop();
			if (sn.row == h && sn.col == w) {
				cout << sn.cost << endl;
				break;
			}
			else {
				for (int op = 0; op < 4; ++op) {
					int d = (sn.dir + op) % 4;
					if (sn.row+dy[d] > 0 && sn.row+dy[d] <= h && sn.col+dx[d] > 0 && sn.col+dx[d] <= w) {
						if (s[sn.row][sn.col] == op) {
							if (sn.cost < cost[sn.row+dy[d]][sn.col+dx[d]][d]) {
								cost[sn.row+dy[d]][sn.col+dx[d]][d] = sn.cost;
								pq.push((data_t){sn.row+dy[d],sn.col+dx[d],d,sn.cost});
							}
						}
						else {
							if (sn.cost+c[op] < cost[sn.row+dy[d]][sn.col+dx[d]][d]) {
								cost[sn.row+dy[d]][sn.col+dx[d]][d] = sn.cost + c[op];
								pq.push((data_t){sn.row+dy[d],sn.col+dx[d],d,sn.cost+c[op]});
							}
						}
					}
				}
			}
		}
	}
	return 0;
}

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

int main() {
    int x;
    cin >> x;
    if(x == 3 || x == 5 || x == 7) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    string t;
    cin >> t;
    int n = t.length();
    for(int i = 0; i < n; ++i){
        if(t[i] == '?') t[i] = 'D';
    }
    cout << t << endl;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;cin>>s;
  if(s.back()=='2' or s.back()=='4' or s.back()=='5' or s.back()=='7' or s.back()=='9')
   cout<<"hon";
  else if(s.back()=='0' or s.back()=='1' or  s.back()=='6' or  s.back()=='8') 
    cout<<"pon";
  else cout<<"bon";
  return 0;
}

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

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

	vector<int> d(n);

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

	int total=0;

	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			total += d.at(i)*d.at(j);
		}
	}

	cout<<total<<endl;

	return 0;
}

Measured memory_bytes: 3584
#include <iostream>

int main(){
  int N = 0;
  int H[100];
  int takai = 0;
  int count= 0;
  std::cin >> N;

  for(int i = 0; i < N; i++){
    std::cin >> H[i];
    if(takai <= H[i]){
      takai = H[i];
      count++;
    }
  }
  std::cout << count << std::endl;


}


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

signed main()
{
  int D, E;
  
  while(cin >> D >> E, D || E) {
    double minv = 1e15;

    for(int i = 0; i <= D; i++) {
      double val = sqrt((double)(i * i + (D - i) * (D - i))) - (double)E;
      if(val < 0) val = -val;

      minv = min(val, minv);
    }

    printf("%.10f\n", minv);

  }

  return 0;
}
  
  

Measured memory_bytes: 3148
from heapq import heappush, heappop
INF = 10 ** 20

n, m, c = map(int, input().split())
edges = [[] for _ in range(n)]
edges_dict = {}
d_cost = 0
for _ in range(m):
  a, b, d = map(int, input().split())
  a -= 1
  b -= 1
  edges[a].append((b, d))
  edges[b].append((a, d))
  edges_dict[(a, b)] = d
  d_cost += d

dist = [INF] * n
dist[0] = 0
que = []
heappush(que, (0, 0))
while que:
  total, node = heappop(que)
  for to, d in edges[node]:
    if dist[to] > total + d:
      dist[to] = total + d
      heappush(que, (total + d, to))

removal = {}
for t, d in edges_dict.items():
  max_d = max(dist[t[0]], dist[t[1]])
  if max_d in removal:
    removal[max_d] += d
  else:
    removal[max_d] = d

ans = d_cost
for k, v in sorted(removal.items()):
  d_cost -= v
  if d_cost + k * c < ans:
    ans = d_cost + k * c

print(ans)


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    string s;
    cin >> s;

    rep(i, 1, s.size()) {
        if (s[i] == s[i - 1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll m,k;
	cin>>m>>k;
	ll mx = 1ll<<m;
	if(mx<=k){
		puta(-1);
		return 0;
	}
	vl ans;
	if(k==0){
		rep(i,mx){
			ans.push_back(i);
		}
		rrep(i,mx){
			ans.push_back(i);
		}
		puta(ans);
		return 0;
	}
	ll x=0;
	rep(i,mx){
		if(i==k)continue;
		x^=i;
	}
	if(x!=k){
		puta(-1);
		return 0;
	}

	rep(i,mx){
		if(i!=k) ans.push_back(i);
	}
	ans.push_back(k);
	rrep(i,mx){
		if(i!=k) ans.push_back(i);
	}
	ans.push_back(k);
	puta(ans);
	return 0;
}

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

int main()
{
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    int result = s.compare(u);
    if (result == 0)
    {

        cout << a - 1 << " " << b << endl;
    }
    else
    {
        // string aa = a + " a";
        cout << a << " " << b - 1 << endl;
    }
    return 0;
}

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  
  rep(i,n) cin >> a[i];
  
  ll ans=1;
  rep(i,n) ans = lcm(ans,a[i]);
  
  cout << ans << endl;
  
  return(0);
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll>P;

int main(){
    
    ll N, T;
    cin >> N >> T;
    ll ans = 1919;
    for(ll i = 0; i < N; i++){
        ll c, t;
        cin >> c >> t;
        if(t <= T)ans = min(ans, c);
    }
    if(ans == 1919)cout << "TLE" << endl;
    else cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <string.h>
#include <math.h>
#include <map>

using namespace std;

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

	for (int i = 0; i < s.size(); ++i){
		if (s[i] == '1')
			cout << '9';
		else
			cout << '1';
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

toBin(n) = map(parseInt,split(lpad(bin(n),10,0), ""))

function main()
	n = readline() |> parseInt
	f = Array{Int}(10,n)
	for i in 1:n
		f[:,i] = readline() |> split |> parseMap
	end
	p = Array{Int}(11,n)
	for i in 1:n
		p[:,i] = readline() |> split |> parseMap
	end
	sum = 0
	p1 = [0,0,0,0,0,0,0,0,0,1]
	v = p1'*f
	for i in 1:n
		sum += p[v[i]+1,i]
	end
	for i in 2:1023
		temp = 0
		p1 = toBin(i)
		v = p1'*f
		for i in 1:n
			temp += p[v[i]+1,i]
		end
		sum = max(sum, temp)
	end
	print(sum)
end

main()

Measured memory_bytes: 137532
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define ld          long double

const ll N=2e5+5;
const ll S=4*N;

ll t[S];
ll bit[N];
ll a[N], h[N], dp[N];
ll n;
ll ans;

void build(ll v, ll tl, ll tr, ll pos, ll val)
{
	if(tl==tr)
	{
		t[v]=max(t[v], val); return;
	}
	ll tm=(tl+tr)/2;
	if(pos<=tm)
	{
		build(v+v, tl, tm, pos, val);
	}
	else
	{
		build(v+v+1, tm+1, tr, pos, val);
	}
	t[v]=max(t[v+v], t[v+v+1]);
}

ll get(ll v, ll tl, ll tr, ll l, ll r) // tl, tr -> tree range
{
	if(l > r) return 0;
	if(l==tl and r==tr) { return t[v]; }
	ll tm=(tl + tr)/2;
	ll op1=get(v+v, tl, tm, l, min(r, tm));
	ll op2=get(v+v+1, tm+1, tr, max(tm+1, l), r);
	return max(op1, op2);
}

void solve()
{
	cin>>n;
	for(ll i=1; i<=n; i++) cin>>h[i];
	for(ll i=1; i<=n; i++) cin>>a[i];
	for(ll i=1; i<=n; i++)
	{
		dp[i]=get(1, 1, n, 1, h[i] - 1) + a[i];
		build(1, 1, n, h[i], dp[i]);
	}
	for(ll i=1; i<=n; i++) ans=max(ans, dp[i]);
	cout<<ans<<endl;
}
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
	ll T = 1;
	//cin>>T;
	while(T--)
	    solve();
	return 0;
}


Measured memory_bytes: 12544
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
using namespace std;

int main()
{
	int32_t N, K;
	cin >> N >> K;

	int32_t res = 1;
	N -= K;
	while (N > 0) {
		N -= K - 1;
		res++;
	}

	cout << res << endl;

	return 0;
}


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

const double PI = 3.14159265358979323846;
int main(){
  // 標準入力高速化のおまじない
  // scanfとの同期を切る。以降紛らわしいのでscanf使用不可。
  ios::sync_with_stdio(false);
  // // cin前の自動flashをやめる
  cin.tie(nullptr);

  int A,B,C,K;
  cin >> A >> B >> C >> K;
  ll result;

  if(K-A <= 0){
    cout << K << endl;
    return 0;
  }
  if(K-A-B <= 0){
    cout << A << endl;
    return 0;
  }
  cout << A-(K-A-B) << endl;

  return 0;
}

Measured memory_bytes: 3612
import java.util.Scanner;

/**
 * B - Strings with the Same Length
 * 英小文字のみからなる長さ N の文字列 S, T が与えられます。
 * S の 1 文字目、T の 1 文字目、S の 2 文字目、T の2 文字目、S の 3 文字目、...、S のN 文字目、T のN 文字目というように、
 * S の各文字と T の各文字を先頭から順に交互に文字を並べ、新しい文字列を作ります。この新しくできた文字列を出力してください。
 */
public class Main {

    public static void main( String[] args ) {

        Scanner sc = new Scanner( System.in );
        // 入力値
        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();

        StringBuilder result = new StringBuilder();
        for( int i = 0; i < n; i++ ) {
            result.append( s[i] ).append( t[i] );
        }

        System.out.println( result );

        sc.close();
    }
}

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

#define ll long long
#define ld long double
#define db double
#define str string
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define rall(v) rbegin(v),rend(v)
#define selp(a) for(auto i:a)cout<<i<<" ";cout<<nl;
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

int main(){
    nimble;
    int tt=1;//cin>>tt;
    while(tt--){
        int n,m;
        cin>>n>>m;
        int c=0;/*
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if((i+j)%2==1)c++;
            }
        }*/
        c+=(n*(n-1))/2;
        c+=(m*(m-1))/2;
        cout<<c<<nl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

struct Graph {
    struct Vertex { int n; };
    struct Edge { int i, n, k; };
    Graph(int n, int m) : v(n, { -1 }), e(m), n(n), m(0) {}
    void add_edge(int i, int j, int k) {
        e[m] = { j, v[i].n, k };
        v[i].n = m;
        m++;
    }
    bool dfs(int i, int p) {
        if (i == g) return true;
        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge &o = e[j];
            if (o.i == p) continue;
            if (dfs(o.i, i)) {
                t ^= 1LL << o.k;
                return true;
            }
        }
        return false;
    }
    ll foo(int u, int v) {
        t = 0; g = v;
        dfs(u, -1);
        return t;
    }
    vector<Vertex> v;
    vector<Edge> e;
    int n, m;
    ll t;
    int g;
};

using ull = unsigned long long;
constexpr ull f(int i) {
    return -1 / (1 + (1ULL << (1 << i)));
}
int popcnt(ull t) {
    t = (t & f(0)) + (t >>  1 & f(0));
    t = (t & f(1)) + (t >>  2 & f(1));
    t = (t & f(2)) + (t >>  4 & f(2));
    t = (t & f(3)) + (t >>  8 & f(3));
    t = (t & f(4)) + (t >> 16 & f(4));
    t = (t & f(5)) + (t >> 32);
    return t;
}

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

    Graph g(n, (n - 1) * 2);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;

        g.add_edge(a, b, i);
        g.add_edge(b, a, i);
    }

    int m;
    cin >> m;

    vector<ll> x(m), y(1 << m);
    vector<char> z(1 << m);
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--; v--;

        x[i] = y[1 << i] = g.foo(u, v);
        z[1 << i] = 1;
    }
    y[0] = 0;
    z[0] = -1;

    ll r = 0;
    for (int k = 1; k < 1 << m; k++) {
        int o = k & -k;
        y[k] = y[k ^ o] | y[o];
        z[k] = -z[k ^ o];

        int c = (n - 1) - popcnt(y[k]);
        r += (ll)z[k] << c;
    }

    r = (1LL << (n - 1)) - r;
    cout << r << endl;

    return 0;
}

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

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

using namespace std;
using ll=long long;
const ll INF = 100000000;

int main() {
    int tmp=0,res=1;
    rep(i,5) {
        cin >> tmp;
        if (tmp==0){
            cout << res;
            return 0;
        } else{
            res++;
        }
    }

    return 0;
}


Measured memory_bytes: 3636
/**
 *    author:  FromDihPout
 *    created: 2020-05-30
**/

#include <bits/stdc++.h>
using namespace std;

const int MAX_PRIME = 1e5 + 3;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int x;
    cin >> x;
    vector<bool> primes(MAX_PRIME, 1);
    for (int i = 2; i <= MAX_PRIME; i++) {
        if (i >= x && primes[i]) {
            cout << i << endl;
            return 0;
        }
        for (int j = 1; i*j <= MAX_PRIME; j++) {
            primes[i*j] = 0;
        }
    }
    return 0;
}

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

using namespace std;

const int N = 100005;

priority_queue < int > pq;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; ++i) {
        int x;
        cin >> x;
        pq.push(x);
    }
    for(int i = 1; i <= m; ++i) {
        int x = pq.top();
        pq.pop();
        x /= 2;
        pq.push(x);
    }
    long long ans = 0;
    while(!pq.empty()) ans += 1LL * pq.top(), pq.pop();
    cout << ans;
    return 0;
}


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

int main(int argc, const char * argv[]) {



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

    /////////////////////
    // Write code below /
    /////////////////////
    double N,cnt = 0;
    
    cin>>N;

    for(int i=1;i<=N;i++){
        if(i%2==1){
            cnt++;
        }
    }
    cout<< cnt/N<<endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  	int A,B;
  	cin>>A>>B;
  	if(A==2&&B==3||A==3&&B==2){
      	cout<<"1";
    }
     else if(A==1&&B==3||A==3&&B==1){
       	cout<<"2";
     }
      else if(A==1&&B==2||A==2&&B==1){
        cout<<"3";
      }
  	return 0;
}

Measured memory_bytes: 256
def main18():
    num = int(input(""));
    strbuf = input("");
    strbufs = strbuf.split();
    num2 = num*2
    buf = [];
    for i in range((num2)):
        buf.append(int(strbufs[i]));
    buf.sort();
    result = 0;
    for i in range(num):
        result += buf[2*i];
    print(result);


if __name__ == '__main__':
    main18()

Measured memory_bytes: 3060
N, K = map(int, input().split())
X = list(map(int, input().split()))
ans = 10**9
for x1, x2 in zip(X, X[K-1:]):
    if x2 < 0 or 0 < x1:
        ans = min(ans, max(abs(x1), abs(x2)))
    else:
        xm = min(abs(x1), abs(x2))
        ans = min(ans, xm + abs(x1) + abs(x2))
print(ans)

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int a[220000];
signed main() {
  cin>>N;
  reps(i,N){cin>>a[i];}
  int k=1;
  reps(i,N){
    if(a[i]==k){
      k++;
    }
  }
  int ans=N-(k-1);
  if(ans==N)cout<<-1<<endl;
  else cout<<ans<<endl;
}

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

using namespace std;

int main(){
    std::string r, g, b;
    cin >> r >> g >> b;
    std::string str = r + g + b;
    if(stoi(str) % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF = 1e18;
#define pow10(n) int(1e##n + n)

void solve()
{
    int N;
    cin >> N;
    map<int, int> mp;

    REP0(i, N)
    {
        int A;
        cin >> A;
        if (mp.find(A) != mp.end())
        {
            cout << "NO" << endl;
            return;
        }
        mp[A] = 1;
    }

    cout << "YES" << endl;
    return;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <string>
#include <vector>
#include <string>

std::string S;

int main() {
  std::cin >> S;
  if (S[2] == S[3] && S[4] == S[5]) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using longlong=long long;

[[maybe_unused]]auto cmn=[](auto&& a,auto b){if(a>b){a=b;return true;}return false;};
[[maybe_unused]]auto cmx=[](auto&& a,auto b){if(a<b){a=b;return true;}return false;};

int main(){
    std::cin.tie(nullptr);std::cin.sync_with_stdio(false);
    int n; std::cin >> n;
    int max=std::numeric_limits<int>::min();
    int min=std::numeric_limits<int>::max();
    for(int i=0;i<n;i++){
        int x; std::cin >> x;
        cmx(max,x);
        cmn(min,x);
    }
    std::cout << max-min << std::endl;
}

Measured memory_bytes: 256
N = int(input())
a = [int(input()) for _ in range(N)]

pos = 1
route = []
success = False
"""
while 1:
    route.append(pos)
    pos = a[pos - 1]
    if pos == 2:
        print(len(route))
        break
        
    if pos in route:
        print(-1)
        break
"""
for i in range(N):
    pos = a[pos - 1]
    if pos == 2:
        success = True
        print(i+1)
        break
if not(success):
    print(-1)

Measured memory_bytes: 49368
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
typedef pair<int, int> P;
typedef pair<P, int>PP;
const long long mod = 998244353;
vector<int>G[3][100005];
int G2[3][500];
int grundy[3][100005];
int n;

int modpow(int a, int x) {
	int res = 1;
	while (x) {
		if (x & 1)res = res*a%mod;
		a = a*a%mod;
		x >>= 1;
	}
	return res;
}

signed main() {
	 cin >> n;

	 rep(i, 3) {
		 int m; cin >> m;
		 rep(j, m) {
			 int a, b; cin >> a >> b; a--; b--;
			 if (a > b)swap(a, b);
			 G[i][a].push_back(b);
		 }
		 rep(j, n)grundy[i][j] = -1;
		 for (int j = n - 1; j >= 0; j--) {
			 set<int>S;
			 for (int k : G[i][j])S.insert(grundy[i][k]);
			 int a = 0;
			 while (S.count(a))a++;
			 grundy[i][j] = a;
		 }
		 rep(j, n) {
			 G2[i][grundy[i][j]] += modpow(10, 18*(j + 1));
			 G2[i][grundy[i][j]] %= mod;
		 }
	 }

	int ans = 0;

	rep(i, 500) {
		rep(j, 500) {
			int k = i^j;
			ans += G2[0][i] * G2[1][j] %mod* G2[2][k]%mod;
			ans %= mod;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 15616
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N;
signed main() {
    cin >> N;
    int ub = N, lb = 0;
    while(ub - lb > 1) {
        int mid = (ub + lb) / 2;
        int val = mid * (mid + 1) / 2;
        if(N <= val) ub = mid;
        else lb = mid;
    }
    int diff = ub * (ub + 1) / 2 - N;
    repq(i,1,ub) {
        if(diff != i) cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	double a; cin >> a;
	double pi = 3.141592653589793238462643383279502884197169;
	printf("%.10f %.10f\n", a * a * pi, a * 2 * pi);
	cin >> a;
}


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

vector<string> maze(50);

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

int main() {
    int H,W; cin >> H >> W;
    rep(i,H) cin >> maze.at(i);
    int ans = 0;
    int wall_count = 0;

    rep(i,H)rep(j,W) {
        if(maze.at(i).at(j) == '#')
            wall_count++;
    }
        
    vector<vector<int>> dist(H,vector<int>(W,-1));
    queue<pair<int,int>> que;

    dist.at(0).at(0) = 0;
    que.push(make_pair(0,0));

    while(!que.empty()) {
        pair<int,int> v = que.front();
        que.pop();
        for(int dir = 0; dir < 4; dir++) {
            int nx = v.second + dx[dir];
            int ny = v.first + dy[dir];
            if(nx < 0 || nx >= W || ny < 0 || ny >= H)continue;
            if(maze.at(ny).at(nx) == '#') continue;
            if(dist.at(ny).at(nx) != -1) continue;
            dist.at(ny).at(nx) = dist.at(v.first).at(v.second) + 1;
            que.push(make_pair(ny,nx));
        }
    }
    //cout << wall_count << endl;
    //cout << dist.at(H-1).at(W-1) << endl;
    if(dist.at(H-1).at(W-1) != -1)
        cout << H * W - dist.at(H-1).at(W-1) - 1 - wall_count << endl;
    else 
        cout << "-1" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string S, T;
  cin >> S >> T;
  int i;

  for (i = 0; i < S.length(); i++){
    if (S[i] != T[i]){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

}

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

bool check(vector<P> s) {
    int h = 0;
    for (P p : s) {
        int b = h + p.first;
        if (b < 0) {
            return false;
        }
        h += p.second;
    }
    return true;
}

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

    int n;
    cin >> n;
    vector<P> up, down;
    int total = 0;

    REP(i, n) {
        string s;
        cin >> s;
        int h = 0, b = 0;
        for (char c : s) {
            if (c == '(') {
                h++;
            } else {
                h--;
            }
            b = min(b, h);
        }
        if (h > 0) {
            up.emplace_back(b, h); // 左側から見たときのボトムと高さを入れる
        } else {
            down.emplace_back(b - h, -h); // 右側から見たときのボトムと高さを入れる
        }
        total += h;
    }

    sort(up.rbegin(), up.rend());
    sort(down.rbegin(), down.rend());
    if (check(up) && check(down) && total == 0) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }
    return 0;
}

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

public class Main {

	public static void main(String[] args) {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = null;
		try {
			input = br.readLine();
			br.close();
		} catch (IOException e) {
		}

		String [] abc = input.split(" ");

		int a = Integer.parseInt(abc[0]);
		int b = Integer.parseInt(abc[1]);
		int c = Integer.parseInt(abc[2]);
		
	    if (a > b){
	        int tem = a;
	        a = b;
	        b = tem;
	    }
	    if (a > c){
	        int sam = a;
	        a = c;
	        c = sam;
	    }
	    if (b > c){
	        int dam = b;
	        b = c;
	        c = dam;
	    }
	    System.out.println(a + " " + b + " " + c);
	}
}



Measured memory_bytes: 24208