akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;


int one[5];
int te[5];
int han[3];

main(){
	int n;
	
	while(cin>>n){
		if(n==0)break;
		
		for(int i=0;i<5;i++){
			one[i]=te[i]=0;
		}
		
		one[0]=n;
		++te[n];
		
		for(int i=1;i<5;i++){
			cin>>n;
			one[i]=n;
			++te[n];
		}
		
		int hiki=0;
		for(int i=1;i<=3;i++){
			if(te[i]==5)hiki+=10;
		}
		
		for(int i=1;i<=3;i++){
			if(te[i])++hiki;
		}
		
		if(hiki/10 || hiki%10==3){
			for(int i=0;i<5;i++){
				puts("3");
			}
			continue;
		}
		
		if(te[1]==0){
			han[1]=3;
			han[2]=1;
			han[3]=2;
		}else if(te[2]==0){
			han[1]=2;
			han[2]=3;
			han[3]=1;
		}else{
			han[1]=1;
			han[2]=2;
			han[3]=3;
		}
		
		for(int i=0;i<5;i++){
			printf("%d\n",han[one[i]]);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    ll n;
    ll co =0;
    cin >> n;
    vector<ll> p(n);
    for(ll i=0;i<n;i++)cin >> p.at(i);
    for(ll i=0;i<n-2;i++){
        vector<ll> tmp(3);
        for(ll j=0;j<3;j++)tmp.at(j)=p.at(i+j);
        ll max = *max_element(tmp.begin(),tmp.end());
        ll min = *min_element(tmp.begin(),tmp.end());
        if(p.at(i+1)!=max&&p.at(i+1)!=min){
            co++;
        }
    }
    cout << co << endl;
    return 0;
} 

Measured memory_bytes: 256
import sys
from collections import deque

def main():
    input = sys.stdin.readline
    N = int(input())
    A = [[] for _ in range(N+1)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        A[a].append(b)
        A[b].append(a)

    dist_one = [-1 for _ in range(N+1)]
    dist_one[1] = 0

    dist_n = [-1 for _ in range(N+1)]
    dist_n[N] = 0

    qo = deque()
    qo.append(1)
    while len(qo) > 0:
        i = qo.popleft()
        for j in A[i]:
            if dist_one[j] != -1:
                continue

            dist_one[j] = dist_one[i] + 1
            qo.append(j)

    qn = deque()
    qn.append(N)
    while len(qn) > 0:
        i = qn.popleft()
        for j in A[i]:
            if dist_n[j] != -1:
                continue

            dist_n[j] = dist_n[i] + 1
            qn.append(j)

    co, cn = 0, 0
    for i in range(1, N+1):
        if dist_one[i] <= dist_n[i]:
            co += 1
        else:
            cn += 1

    if co > cn:
        return 'Fennec'
    else:
        return 'Snuke'


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 29492
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    
    int n;
    cin >> n;
    
    string ans = "No";
    
    for(int i=0; i<3; i++){
        if(n%10 == 7){
            ans = "Yes";
            break;
        }
        n /= 10;
    }
    
    cout << ans << endl;
    
}

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

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

const int MAX_N = 3010;
int n;
ll a[MAX_N];

ll dp[MAX_N][MAX_N][2];
bool used[MAX_N][MAX_N][2];

ll calcSecond(int l, int r);

ll calcFirst(int l, int r) {
    if (used[l][r][0]) return dp[l][r][0];
    used[l][r][0] = true;
    auto& ret = dp[l][r][0];
    ret = -1e18;
    if(r - l == 1) ret = a[l];
    else {
        chmax(ret, a[l] + calcSecond(l+1, r));
        chmax(ret, a[r-1] + calcSecond(l, r-1));
    }
    return ret;
}
ll calcSecond(int l, int r) {
    if (used[l][r][1]) return dp[l][r][1];
    used[l][r][1] = true;
    auto& ret = dp[l][r][1];
    ret = 1e18;
    if(r - l == 1) ret = -a[l];
    else {
        chmin(ret, -a[l] + calcFirst(l+1, r));
        chmin(ret, -a[r-1] + calcFirst(l, r-1));
    }
    return ret;
}

int main() {
    cin >> n;
    rep(i, n) cin >> a[i];
    cout << calcFirst(0, n) << endl;
    // rep(i, n+1) {
    //     rep(j, n+1) printf("%4lld", dp[i][j][0]);
    //     cout << endl;
    // }
    // cout << endl;
    // rep(i, n+1) {
    //     rep(j, n+1) printf("%4lld", dp[i][j][1]);
    //     cout << endl;
    // }
    return 0;
}

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

int main()
{
  int n;
  cin>>n;
  vector<int> v(n+1);
  for(int i=1;i<=n;i++)
  {
    int k;
    cin>>k;
    v[k]=i;
  }
  for(int i=1;i<=n;i++)
    cout<<v[i]<<" ";
  
  return 0;
}

Measured memory_bytes: 1152
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

    int a[3][3];

    REP(i, 3) REP(j, 3) {
        cin >> a[i][j];
    }
    
    int N;
    cin >> N;

    REP(i, N) {
        int b;
        cin >> b;
        REP(i, 3) REP(j, 3) {
            if (a[i][j] == b) a[i][j] = 0;
        }
    }

    bool f = false;

    REP(i, 3) {
        if (a[i][0] + a[i][1] + a[i][2] == 0) f = true;
        if (a[0][i] + a[1][i] + a[2][i] == 0) f = true;
    }

    if (a[0][0] + a[1][1] + a[2][2] == 0) f = true;
    if (a[0][2] + a[1][1] + a[2][0] == 0) f = true;

    if (f) cout << "Yes" << endl;
    else cout << "No" << endl;

    
}


Measured memory_bytes: 256
<?php

$list = explode(" ", trim(fgets(STDIN)));

$five = 0;
$seven = 0;
for ($i=0; $i<3; $i++){
  if($list[$i]==5){
    $five++;
  } else if ($list[$i]==7){
    $seven++;
  }
}

if ($five==2 && $seven==1) {
  echo 'YES';
} else {
  echo 'NO';
}

?>

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

int main()
{
  string X, Y;
  cin >> X >> Y;
  int n = X.size(), m = Y.size();
  vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
  for (int i = 1; i <= n; i++)
  {
    dp[i][0] = i;
  }
  for (int j = 1; j <= m; j++)
  {
    dp[0][j] = j;
  }
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < m; j++)
    {
      dp[i + 1][j + 1] = min(min(dp[i + 1][j], dp[i][j + 1]), dp[i][j]) + 1;
      if (X[i] == Y[j])
      {
        dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j]);
      }
    }
  }
  cout << dp[n][m] << endl;
}


Measured memory_bytes: 6816
#include <stdio.h>

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

Measured memory_bytes: 580
#include <iostream>
#include <atcoder/fenwicktree>

using namespace std;

int main(){
    int N, Q; cin >> N >> Q;
    atcoder::fenwick_tree<long long> bit(N);
    for(int i=0;i<N;i++){
        int t; cin >> t;
        bit.add(i, t);
    }
    for(int i=0;i<Q;i++){
        int t, l, r; cin >> t >> l >> r;
        if(t == 0){
            bit.add(l, r);
        } else {
            cout << bit.sum(l, r) << endl;
        }
    }

}

Measured memory_bytes: 8224
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

ll n, t[1000], a[1000];
ll ta, aa;

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

	ta = t[0], aa = a[0];
	for (int i = 1; i < n; i++) {
		/*ll b1 = ta, b2 = ta, c1 = aa, c2 = aa;

		if (ta%t[i] != 0)b1 = (ta / t[i] + 1) * t[i];
		c1 = b1 / t[i] * a[i];
		if (c1 < aa) c1 = 1000000000;

		if (aa%a[i] != 0)c2 = (aa / a[i] + 1) * a[i];
		b2 = c2 / a[i] * t[i]; 
		if (b2 < ta) b2 = 1000000000;

		ta = (b1 + c1 < b2 + c2)?b1:b2;
		aa = (b1 + c1 < b2 + c2)?c1:c2;*/

		ll x = ta / t[i] + ((ta%t[i]) ? 1 : 0);
		ll y = aa / a[i] + ((aa%a[i]) ? 1 : 0);
		ta = max(x, y)*t[i];
		aa = max(x, y)*a[i];
	}

	cout << ta + aa << endl;
}

Measured memory_bytes: 256
// import chie template :) {{{
import std.stdio,
       std.algorithm,
       std.array,
       std.string,
       std.math,
       std.conv,
       std.range,
       std.container,
       std.bigint,
       std.ascii;
// }}}

void main() {
  int[] t = readln.chomp.split.to!(int[]);
  dchar[] s = readln.chomp.to!(dchar[]);
  if (s.length != t[0] + t[1] + 1) {
    writeln("No");
    return;
  }
  uint idx = 0;
  for (; idx < t[0]; ++idx) {
    if (!s[idx].to!string.isNumeric) {
      writeln("No");
      return;
    }
  }
  if (s[idx] != '-') {
    writeln("No");
    return;
  }
  ++idx;
  for (; idx < s.length; ++idx) {
    if (!s[idx].to!string.isNumeric) {
      writeln("No");
      return;
    }
  }

  writeln("Yes");
}


Measured memory_bytes: 256
#pragma GCC optimize("O3") //コンパイラ最適化用

#define _GLIBCXX_DEBUG //配列に[]でアクセス時のエラー表示
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはメントされる
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--) //ループ変数は1ずつデクリ
#define FOR(i, a, b) for (ll i = a; i < ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i > ll(b); i--) //ループ変数は1ずつデクリ
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end() // sortなどの引数を省略したい
#define SIZE(x) ll(x.size())      // sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 // 10^12:極めて大きい値,∞
#define MOD 1000000007    // 10^9+7:合同式の法
#define MAXR 100000 // 10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back // vectorヘの挿入
#define MP make_pair // pairのコンストラクタ
#define F first      // pairの一つ目の要素
#define S second     // pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000

int main() {

    ll n;
    cin >> n;

    set<int> s;
    REP(i, n) {
        ll val;
        cin >> val;
        s.insert(val);
    }

    cout << s.size() << endl;
}


Measured memory_bytes: 3584
#include<time.h>
#include<stdio.h>
#include<unistd.h>
#include<string.h>
#include<stdlib.h>
#include<stdint.h>
#include<stdarg.h>
#include<tgmath.h>
#include<assert.h>
#include<iso646.h>
#include<stdbool.h>

//fast(?) Input
#define buf_sz 1<<24
char buf[buf_sz];
unsigned int nextint(){
	static int idx = 0, sz;
	if(idx == 0)sz = read(0, buf, buf_sz);
	unsigned int res = 0;
	while(idx<sz && buf[idx]<'0' || '9'<buf[idx])idx++;
	while(idx<sz && '0'<=buf[idx] && buf[idx]<='9'){
		res *= 10;
		res += buf[idx++] - '0';
	}if(idx>=sz)exit(1);
	return res;
}

int d[] = {[0 ... 1<<17] -1};
int find(int x){
	if(d[x] < 0) return x;
	return d[x] = find(d[x]);
}
bool unite(int x, int y){
	x = find(x); y = find(y);
	if(x == y)return false;
	if(d[x] > d[y]){
		int tmp = x;
		x = y;
		y = tmp;
	}
	d[x] += d[y];
	d[y] = x;
	return true;
}
bool same(int x, int y){return find(x) == find(y);}
int size(int x){return -d[find(x)];}

int main(){
	int N = nextint();
	int M = nextint();
	while(M--)unite(nextint(), nextint());
	int ans = 0;
	for(int i=1; i<=N; i++)ans += unite(1, i);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3132
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
 
ll i,j,k,ii,jj;
ll n,m,sum,num;
ll a,b,c,d,e,ans=0;
ll x[100005],y[100005],z[100005];
vector<ll> p[3];
bool dpx[100005],dpy[100005];
char s[100005];

int main(){
	cin>>n>>m>>a;
	for(i=0;i<m;i++){
		cin>>b;
		if(b<=a)ans++;
	}
	p(min(ans,m-ans));
	return 0;
}

Measured memory_bytes: 5504
#!/usr/bin/env python3
import sys
from collections import defaultdict
from collections import deque

INF = float("inf")


class Graph(object):
    def __init__(self, N):
        self.N = N
        self.E = defaultdict(list)

    def add_edge(self, f, t, w=1):
        self.E[f].append((t, w))


def Topological_sorting(g):
    in_deg = [0]*g.N
    for i in range(g.N):        # ２重ループでO(E)
        for to_, _ in g.E[i]:
            in_deg[to_] += 1

    ans = [v for v in range(g.N) if in_deg[v] == 0]
    deq = deque(ans)

    while deq:                  # O(V+E)
        v = deq.popleft()
        for t, _ in g.E[v]:
            in_deg[t] -= 1
            if in_deg[t] == 0:
                ans.append(t)
                deq.append(t)
    if len(ans) != g.N:
        return False
    return ans


def solve(N: int, M: int, x: "List[int]", y: "List[int]"):
    g = Graph(N)
    for xx, yy in zip(x, y):
        g.add_edge(xx-1, yy-1)

    tsg = Topological_sorting(g)

    DP = [0]*N
    for i in tsg:
        for to, _ in g.E[i]:
            DP[to] = max(DP[i]+1, DP[to])
    print(max(DP))

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    x = [int()] * (M)  # type: "List[int]"
    y = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, M, x, y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 45856
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int, int> P;

int main()
{
    int n;
    cin >> n;
    int a[100002], b[100002];
    vector<P> v[100002];
    for(int i = 0; i < n - 1; i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        v[a[i]].push_back(P(b[i], i));
        v[b[i]].push_back(P(a[i], i));
    }
    int k = 0;
    for(int i = 0; i < n; i++){
        k = max(k, (int)v[i].size());
    }
    cout << k << endl;
    bool used[100002] {0};
    int c[100002];
    used[0] = true;
    queue<int> que;
    int ans[100002];
    for(int i = 0; i < (int)v[0].size(); i++){
        used[v[0][i].first] = true;
        ans[v[0][i].second] = i;
        c[v[0][i].first] = i;
        que.push(v[0][i].first);
    }
    while(que.size()){
        int u = que.front();
        que.pop();
        int j = 0;
        for(int i = 0; i < (int)v[u].size(); i++){
            if(!used[v[u][i].first]){
                if(j == c[u]) j++;
                used[v[u][i].first] = true;
                ans[v[u][i].second] = j;
                c[v[u][i].first] = j;
                que.push(v[u][i].first);
                j++;
            }
        }
    }
    for(int i = 0; i < n - 1; i++) cout << ans[i] + 1 << endl;
}

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

class Main{
    public static void main(String[] a){
        for(int i = 1; i <= 9; i++){
            for(int j = 1; j <= 9; j++){
                System.out.println(i+"x"+j+"="+i*j); 
            }
        }
    }   
}

Measured memory_bytes: 16852
"use strict";

main(require("fs").readFileSync("/dev/stdin", "UTF-8"));

function main(input) {
  input = input.split("\n");

  const takoyaki_num = parseInt(input[0]);
  let recover_num = 0;

  let delicious_point = input[1];
  delicious_point = delicious_point.split(" ").map(p => parseInt(p));

  for (let i = 0; i < takoyaki_num - 1; i++) {
    for (let f = i + 1; f < takoyaki_num; f++) {
      recover_num += delicious_point[i] * delicious_point[f];
    }
  }
  console.log(recover_num);
}


Measured memory_bytes: 7372
#include <stdio.h>
int main(void){

    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b){
        printf("a < b\n");
    } else if(a>b){
        printf("a > b\n");
    } else if(a==b){
        printf("a == b\n");
    }
    return 0;
}


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

int main() {
	
	int n;
	cin >> n;
	vector<int>fib(n+1);
	fib.at(0)=1;
	fib.at(1)=1;
	for(int i=2; i<=n; i++) fib.at(i) = fib.at(i-1) + fib.at(i-2);
	cout << fib.at(n) << endl;
}



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

using namespace std;

const int max_n = 100011, mod = 1000000007;

int n, cnt[33];
char s[max_n];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d%s", &n, s);
    for (int i = 0; i < n; ++i) {
        ++cnt[s[i] - 'a'];
    }
    int ans = 1;
    for (int i = 0; i < 26; ++i) {
        ans = (1LL * ans * (cnt[i] + 1)) % mod;
    }
    ans += mod - 1;
    ans %= mod;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 384
N, X = map(int, input().split())
L = list(map(int, input().split()))
M = [abs(i-X) for i in L if i-X != 0]
n = len(M)
old = M[0]
def gcd(a, b):
    if min(a, b) == 0:
        return max(a, b)
    else:
        m = max(a, b)
        n = min(a, b)
        return gcd(n, m%n)
if n > 1:
    for i in range(n-1):
        new = M[i+1]
        old = gcd(old, new)
print(old)

Measured memory_bytes: 14252
H, W = map(int, input().split())
bl_H = [False for i in range(H)]
bl_W = [False for j in range(W)]

A = []
for i in range(H):
  A_i = input()
  A.append(A_i)
  for j, a in enumerate(A_i):
    if a == "#":
      bl_H[i] = True
      bl_W[j] = True

for i, h in enumerate(bl_H):
  for j, w in enumerate(bl_W):
    if h and w:
      print(A[i][j], end="")
  if h:
    print()  


Measured memory_bytes: 4468
#include <stdio.h>

#define max(a, b) ((a) > (b) ? a : b)

int a[100000], b[100000];

int main(void) {
	int i, j;
	int n, k;
	int num_bit, l;
	long long ans, cand;

	scanf("%d %d", &n, &k);

	num_bit = 0;
	for (i = 1; i <= k; i <<= 1)
		num_bit += !!(k & i);

	for (i = 0; i < n; i++)
		scanf("%d %d", a + i, b + i);

	ans = 0;
	l = 0;
	for (j = 0; j < num_bit; j++) {
		int msb, mask;

		for (msb = 1; msb <= k; msb <<= 1) ;
		msb >>= 1;

		mask = l + msb - 1;

		cand = 0;
		for (i = 0; i < n; i++)
			if (a[i] <= mask) {
				int x, ok;

				ok = 1;
				for (x = 1; x <= mask; x <<= 1)
					if (!(mask & x))
						ok &= !(a[i] & x);
				if (ok)
					cand += b[i];
			}

		l += msb;
		k -= msb;

		ans = max(ans, cand);
	}

	cand = 0;
	for (i = 0; i < n; i++)
		if (a[i] <= l) {
			int x, ok;

			ok = 1;
			for (x = 1; x <= l; x <<= 1)
				if (!(l & x))
					ok &= !(a[i] & x);
			if (ok)
				cand += b[i];
		}

	ans = max(ans, cand);

	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[n];
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
    }
    int ans = INT32_MAX;
    for(int i = -100;i <= 100;i++)
    {
        int sum = 0;
        for(int j = 0;j < n;j++)
        {
            sum += int(pow(i - a[j],2));
        }
        if(sum < ans)
        {
            ans = sum;
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

array = [a, b, c, d, e]

last = 10
time = 0

for item in array:
	r = item%10
	if r != 0:
		time += (int(item/10)+1)*10
		last = min(last, r)
	else:
		time += item

print(time-10+last)

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

int main() {
	long long N, ANS = 0;
	string S, X, Y;
	map<pair<string, string>, long long> mp;
	cin >> N >> S;
	X = S.substr(0, N);
	Y = S.substr(N, N);
	reverse(Y.begin(), Y.end());
	for (long long i = 0; i < 1LL << N; i++) {
		long long I = i;
		string R = "", B = "";
		for (int j = 0; j < N; j++) {
			if (I % 2 == 0) R += X[j];
			else B += X[j];
			I /= 2;
		}
		mp[{R, B}]++;
	}
	for (long long i = 0; i < 1LL << N; i++) {
		long long I = i;
		string R = "", B = "";
		for (int j = 0; j < N; j++) {
			if (I % 2 == 0) R += Y[j];
			else B += Y[j];
			I /= 2;
		}
		ANS += mp[{R, B}];
	}
	cout << ANS << endl;
}

Measured memory_bytes: 91904
// Problem : D - Replacing
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

int n;
ll a[N];
int q;
ll b,c;
map<ll,ll> mp;

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
	cin>>n;
	 ll sum=0;
	 for(int i=1;i<=n;++i){
	 	cin>>a[i];
	 	sum+=a[i];
	 	mp[a[i]]++;
	 }
	 cin>>q;
	 for(int i=1;i<=q;++i){
	 	cin>>b>>c;
	 	ll cnt=mp[b];
	 	sum=sum-cnt*b+cnt*c;
	 	mp[b]=0;
	 	mp[c]+=cnt;
	 	cout<<sum<<endl;
	 }
	
    return 0;
}


Measured memory_bytes: 10264
# AOJ 0529: Darts
# Python3 2018.7.1 bal4u

import bisect
while True:
	n, m = map(int, input().split())
	if n == 0: break
	p = [int(input()) for i in range(n)]
	p.append(0)
	p.sort()
	s = [i+j for i in p for j in p if i <= j]
	s.sort()
	t = bisect.bisect_left(s, m)
	h = bisect.bisect_left(s, m>>1, 0, t)
	if t < len(s):
		if s[t] == m:
			print(m);
			continue
		s = s[:t]
	ans = 0
	for i in range(h-1, len(s)):
		t = bisect.bisect_left(s, m-s[i])
		if s[i]+s[t-1] > ans: ans = s[i]+s[t-1]
	print(ans)


Measured memory_bytes: 47292
from collections import Counter
from itertools import permutations
N, C = map(int, input().split())
D = [list(map(int, input().split())) for i in range(C)]
c_field = [list(map(int, input().split())) for i in range(N)]

mod = [[] for _ in range(3)]

for i in range(N):
    for j in range(N):
        mod[(i+j+2)%3].append(c_field[i][j])

for i in range(3):
    mod[i] = Counter(mod[i])

def calc(p):
    ret = 0
    for j in range(3):
        for i, v in mod[j].items():
            if i == p[j]: continue
            ret += D[i-1][p[j]-1] * v
    return ret

ans = 10 ** 30
for p in permutations(range(1,C+1), 3):
    ans = min(ans, calc(p))

print(ans)


Measured memory_bytes: 56156
a=int(input())
b=int(input())
c=int(input())
x=int(input())
s=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
             if 500*i+100*j+50*k==x:
                 s+=1
print(s)


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

using namespace std;

int main(){
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int ans = 0;
    for(int i=0; i<=A; i++){
        for(int j=0; j<=B; j++){
            for(int k=0; k<=C; k++){
                if (500 * i + 100 * j + 50 * k == X) ans ++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  char al[100];

  rep(i,26){
    al[i] = 'A' + i;
  }

  //cout << al[3] << endl;

  int n; cin >> n;
  string s; cin >> s;
  rep(i,s.length()){
    int a = 'A';
    int j;
    for(j=0; j<30; j++){
      if(s[i] == al[j]) break;
    }
    char ans = 'A' + (j+n)%26;
    cout << ans;
  }
}


Measured memory_bytes: 256
n=int(input())
ans=0
s=list(map(int,input().split()))
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            a,b,c=s[i],s[j],s[k]
            if a!=b!=c!=a and a+b>c and a+c>b and c+b>a:ans+=1
print(ans)

Measured memory_bytes: 9212
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
		long a = long.Parse(input[0]);
		long b = long.Parse(input[1]);
    long c = long.Parse(input[2]);
    long d = Math.Abs(a-b);
    long e = Math.Abs(b-c);
    long answer = 0;
    if(a%2==1 || b%2==1 || c%2==1) Console.WriteLine(0);
    else if(d == 0 && e == 0) Console.WriteLine(-1);
    else
    {
      while(d % 2 == 0 && e % 2 == 0)
      {
        answer++;
        d /= 2;
        e /= 2;
      }
      Console.WriteLine(answer);
    }

	}
}

Measured memory_bytes: 13140
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        h: usize, a: usize
    };

    let res = (h + a - 1) / a;
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2236
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;
static const int NMAX = 20;
static const int NMAX_OFFSET = 5; // log2(NAMX)
int data[NMAX];
int ndata;

map<int, int> answers;

int makekey(int a, int b) { return (b << NMAX_OFFSET) + a; }

bool solve(int p, int t) {
  if (t == 0)
    return true;

  if (p >= ndata)
    return false;

  if (answers.find(makekey(p, t)) != answers.end()) {
    return answers[makekey(p, t)];
  }

  bool res = solve(p + 1, t) || solve(p + 1, t - data[p]);
  answers[makekey(p, t)] = res;
  return res;
}

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

  int q, nq;
  cin >> nq;
  for (int i = 0; i < nq; i++) {
    cin >> q;
    cout << (solve(0, q) ? "yes" : "no") << endl;
  }
}

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

long long N, H, W, A, B, cnt;

int main() {
	cin >> N >> H >> W;
	for (int i = 1; i <= N; i++) {
		cin >> A >> B;
		if (A >= H && B >= W) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

vector<string> split(string &s, char delimiter) {
    stringstream ss(s);
    string elem;
    vector<string> elems;
    auto inserter = back_inserter(elems);

    while (getline(ss, elem, delimiter)) {
        *(inserter) = elem;
    }

    return elems;
}

#define MAX 8001
bool dpx[MAX][2 * MAX], dpy[MAX][2 * MAX];
int x, y;
string s;

int main() {
    cin >> s >> x >> y;
    vector<string> words = split(s, 'T'), words_x, words_y;

    for (int i = 0; i < words.size(); ++i) {
        if (i % 2 == 0) {
            words_x.push_back(words.at(i));
        } else {
            words_y.push_back(words.at(i));
        }
    }

    dpx[1][MAX + words_x[0].size()] = true;

    for (int i = 1; i < words_x.size(); ++i) {
        for (int j = 0; j < 2 * MAX; ++j) {
            if (dpx[i][j]) {
                dpx[i + 1][j - words_x[i].size()] = true;
                dpx[i + 1][j + words_x[i].size()] = true;
            }
        }
    }

    dpy[0][MAX] = true;

    for (int i = 0; i < words_y.size(); ++i) {
        for (int j = 0; j < 2 * MAX; ++j) {
            if (dpy[i][j]) {
                dpy[i + 1][j - words_y[i].size()] = true;
                dpy[i + 1][j + words_y[i].size()] = true;
            }
        }
    }

    if (dpx[words_x.size()][x + MAX] && dpy[words_y.size()][y + MAX]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 125824
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)
#define Inf 10000000000000000

bool f = true;

void dfs(vector<long long> &A,vector<vector<int>> &E,int now,int parent){
	long long sum = 0;
	long long maxi = 0;
	int cnt = 0;
	for(int i=0;i<E[now].size();i++){
		int to = E[now][i];
		if(to==parent)continue;
		dfs(A,E,to,now);
		sum += A[to];
		maxi = max(maxi,A[to]);
		cnt++;
	}
	
	if(cnt==0)return;
	if(cnt==1){
		if(A[now]!=sum)f=false;
		return;
	}
	
	if(sum<A[now]){
		f=false;
		return;
	}
	
	long long x = sum-A[now];
	A[now] -= x;
	
	if(sum-maxi<x){
		f=false;
		return;
	}
	if(x*2>sum){
		f=false;
		return;
	}
	
	if(now==0&&A[now]!=0)f=false;
	
}

int main() {
	
	int N;
	cin>>N;
	
	vector<long long> A(N);
	for(int i=0;i<N;i++)cin>>A[i];
	
	vector<vector<int>> E(N,vector<int>());
	
	for(int i=0;i<N-1;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		
		E[u].push_back(v);
		E[v].push_back(u);
	}
	
	dfs(A,E,0,-1);
	
	if(f)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
#define rep1(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const ll mod = 998244353;
const double e = 0.000000001;

int main(){
  ll n,p; cin >> n >> p;
  ll n0=0,n1=0;
  rep(i,n){
    ll a; cin >> a;
    if(a%2==0) n0++;
    else n1++;
  }
  if(n1%2==1){
    printf("%.0f",pow(2,n0)*pow(2,n1-1));
    return 0;
  }
  ll choosesum=0;
  ll prev = 1;
  rep(i, (p%2==0 ? (n1/2)+1 : n1/2)){
    ll r = i*2+p;
    if(i!=0){
      prev *= (n1-r+2)*(n1-r+1);
      prev /= r*(r-1);
    }else{
      if(p==1){
        prev *= n1;
      }
    }
    choosesum+=prev;
  }
  printf("%.0f",pow(2,n0)*choosesum);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+2;
map<int,int> idx;
vector<pair<int,int> > ans;
int n,ar[N],sz[N],sz1[N],ar1[N];
vector<int> adj[N];
void dfs(int x,int p){
	sz[x]=1;
	for(int i:adj[x]){
		if(i!=p){
			dfs(i,x);
			sz[x]+=sz[i];
			sz1[x]+=sz1[i]+sz[i];
		}
	}
}
void dfs1(int x,int p){
	for(int i:adj[x]){
		if(i!=p){
			sz1[i]=sz1[x]+n-2*sz[i];
			dfs1(i,x);
		}
	}
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int m,i,j,k,l;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>ar[i];
		ar1[i]=ar[i];
		idx[ar[i]]=i;
		sz[i]=1;
	}
	sort(ar+1,ar+1+n);
	for(i=n;i>1;i--){
		k=idx[ar[i]]; j=ar[i]+2*sz[k]-n; l=idx[j];
		if(!l||j>=ar[i]){
			cout<<"-1";
			return 0;
		}
		adj[l].push_back(k);
		adj[k].push_back(l);
		sz[l]+=sz[k];
		ans.push_back({k,l});
	}
	dfs(1,1);
	dfs1(1,1);
	for(i=1;i<=n;i++){
		if(sz1[i]!=ar1[i]){
			cout<<"-1";
			return 0;
		}
	}
	for(i=0;i<ans.size();i++){
		cout<<ans[i].first<<' '<<ans[i].second<<'\n';
	}
}

Measured memory_bytes: 22384
#include <iostream>
#include <cstdio>

#define INF 99999
#define MAX 20

using namespace std;

int grapha[MAX + 1][MAX + 1];
bool visited[MAX + 1];
int v[MAX + 1];
int n,m;

int Dijkstra( int start, int goal ){ // ダイクストラ法


  for( int i = 0 ; i <= MAX ; i++ ){ // 初期化
    v[i] = INF;
    visited[i] = false;
  }

  v[start] = 0; // スタート地点を0にする
  while(1){
    int mn = INF;
    int MN;
    for( int i = 1 ; i <= n ; i++ ){
      if( v[i] < mn && !visited[i] ){
	mn = v[i];
	MN = i;
      }
    }
    if( mn == INF ) break; // すべて訪問(INFが変わらなかった)したのでbreak
    visited[MN] = true; // 訪問済みにする

    for( int i = 1 ; i <= n ; i++ ){
      if( grapha[MN][i] + v[MN] < v[i] ){ // 小さい方を代入
	v[i] = v[MN] + grapha[MN][i];
      }
    }
  }
  return v[goal];
}

int main(void){

  int a,b,c,d;
  int x1,x2,y1,y2;

  cin >> n >> m;

  for( int i = 0 ; i <= MAX ; i++ )
    for( int j = 0 ; j <= MAX ; j++ )
      grapha[i][j] = INF; //  grapha初期化

  for( int i = 0 ; i < m ; i++ ){ // i番目の街道の情報を読む
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);
    grapha[a][b] = c;
    grapha[b][a] = d;
  }
  scanf("%d,%d,%d,%d",&x1,&x2,&y1,&y2); 
  // 大工の出発点、柱のある点、殿からもらったお金、柱の代金

  int ans = y1;
  ans -= Dijkstra(x1,x2);
  // cout << Dijkstra(x1,x2) << endl;
  ans -= Dijkstra(x2,x1);
  // cout << Dijkstra(x2,x1) << endl;
  ans -= y2;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1240
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n, x = map(int, input().strip().split())
  Ls   = list(map(int, input().strip().split()))
  d = 0
  count = 1
  for L in Ls:
    d += L
    if d <= x:
      count += 1
    else:
      break
  print(count)

if __name__=='__main__':
  main()



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

#define Task "abc"
#define mp make_pair

typedef long long ll;

const int maxn = 2e5 + 5;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

vector<int> vec;
int t[maxn], a[maxn], b[maxn];

struct Tree{
  int len;
  vector<int> bit;
  vector<ll> sum;
  Tree(int n = 0) : len(n), bit(n+1, 0), sum(n+1, 0) {}

  void Update(int p){
    for (int i = p; i <= len; i += i & (-i)) bit[i]++, sum[i] += vec[p-1];
  }

  int Get_Num(int i){
    int ret = 0;
    for (; i > 0; i -= i & (-i)) ret += bit[i];
    return ret;
  }

  int Get_Median(int p){
    int k = (p + 1) / 2;
    int l = 1, r = len;
    while (l <= r){
      int mid = (l + r) / 2;
      if (Get_Num(mid) >= k) r = mid - 1;
      else l = mid + 1;
    }
    return r + 1;
  }

  ll Get_Sum(int i){
    ll ret = 0;
    for (; i > 0; i -= i & (-i)) ret += sum[i];
    return ret;
  }

};

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);  freopen(Task".out", "w", stdout);
  int q; cin >> q;

  for (int i = 1; i <= q; ++i){
    cin >> t[i];
    if (t[i] == 1){
      cin >> a[i] >> b[i];
      vec.push_back(a[i]);
    }
  }
  sort(vec.begin(), vec.end());

  vec.erase(unique(vec.begin(), vec.end()), vec.end());

  int len = vec.size();

  Tree f(len);
  ll total = 0, c = 0;
  int n = 0;

  for (int i = 1; i <= q; ++i){
    if (t[i] == 1){
      int pos = lower_bound(vec.begin(), vec.end(), a[i]) - vec.begin();
      f.Update(pos + 1);
      total += a[i]; c += b[i];
      ++n;
    } else {
      int pos = f.Get_Median(n);

      int numLeft = f.Get_Num(pos), numRight = n - numLeft;
      ll sumLeft = f.Get_Sum(pos), sumRight = total - sumLeft;
      ll median = vec[pos-1];

      cout << median << ' ' << median * numLeft - sumLeft + sumRight - numRight * median + c << '\n';
    }

  }
  return 0;
}


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

/*
        @@@@@@           @@@@@@
      @@@@@@@@@@       @@@@@@@@@@ 
    @@@@@@@@@@@@@@   @@@@@@@@@@@@@@
  @@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
      @@@@@@@@@@@@@@@@@@@@@@@@@@@
        @@@@@@@@@@@@@@@@@@@@@@@
          @@@@@@@@@@@@@@@@@@@
            @@@@@@@@@@@@@@@
              @@@@@@@@@@@
                @@@@@@@
                  @@@
                   @ 
*/
public class Main {
	public static void main(String[] args) throws Exception{
		int a = i(); int b = i();
		int[] arr = new int[3];
		arr[0] = a+b;
		arr[1] = a-b;
		arr[2] = a*b;
		Arrays.sort(arr);
		System.out.println(arr[2]);
	}
	
	static BufferedReader in;
	static StringTokenizer st = new StringTokenizer("");
	static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	static {
		in = new BufferedReader(new InputStreamReader(System.in));
	}
	static void check() throws Exception {
		while (!st.hasMoreTokens()) st = new StringTokenizer(in.readLine());
	}
	static String s() throws Exception { check(); return st.nextToken(); }
	static int i() throws Exception { return Integer.parseInt(s()); }
	static long l() throws Exception { return Long.parseLong(s()); }
	static double d() throws Exception { return Double.parseDouble(s()); }
}


Measured memory_bytes: 21204
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	var n int
	fmt.Scan(&n)
	c := make([]int, 10000+1)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	var v, maxv int
	maxv = -1
	for i := 0; i < n; i++ {
		sc.Scan()
		v, _ = strconv.Atoi(sc.Text())
		c[v]++
		maxv = max(v, maxv)
	}
	// bFirstBlank := false
	cnt := 0
	wtr := bufio.NewWriter(os.Stdout)
	for i := 0; i < 10001; i++ {
		if c[i] > 0 {
			for j := 0; j < c[i]; j++ {
				if j > 0 {
					fmt.Fprintf(wtr, " ")
				}
				fmt.Fprintf(wtr, "%d", i)
				cnt++
			}
			if cnt < n {
				fmt.Fprintf(wtr, " ")
			}
		}
	}
	fmt.Fprintln(wtr)
	wtr.Flush()
}



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

using namespace std;

int main(int argc, const char *argv[]) {
  string s;
  cin >> s;

  bool ans = false;
  for (int i = 0; i < 2; ++i) {
    if (s[i] == s[i + 1] && s[i + 1] == s[i + 2]) {
      ans = true;
      break;
    }
  }

  cout << (ans ? "Yes" : "No") << '\n';
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{   ll n,m,k,t,t1;
   char a[10];
   while(cin>>a)
   {
   t=strlen(a);
   if(t!=6)
    cout<<"No"<<endl;
    else
    { if(a[2]==a[3]&&a[4]==a[5])
       cout<<"Yes"<<endl;
       else
       cout<<"No"<<endl;
	}
}
}

Measured memory_bytes: 256
from math import *
from copy import deepcopy
A,B = map(int,input().split())
C = gcd(A,B)
E = deepcopy(C)
D = set()
for i in range(2,floor(sqrt(E))+1):
    while True:
        if C/i != (C/i)//1:
            break
        D.add(i)
        C /= i
if C != 1:
    D.add(int(C))
print(len(D)+1)

Measured memory_bytes: 9388
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
typedef long long ll;
const ll MOD = 1e9+7;

int main(){
    ll a,b,c,x,y; cin >> a >> b >> c >> x >> y;
    if(a+b <= 2*c){
        cout << a*x + b*y << endl;
    }else{
        if(x >= y){
            if(2*c > a) cout << (x-y)*a + 2*y*c << endl;
            else cout << 2*x*c << endl;
        }else{
            if(2*c > b) cout << (y-x)*b + 2*x*c << endl;
            else cout << 2*y*c << endl;
        }
    }
}

Measured memory_bytes: 256
S = input().strip()

a = ("dream", "dreamer", "erase", "eraser")

while True:
    if S == "":
        break
    flg = False
    for aa in a:
        if S.endswith(aa):
            S = S[:-len(aa)]
            flg = True
    if flg:
        continue
    break

if S == "":
    print("YES")
else:
    print("NO")


Measured memory_bytes: 134552
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e6 + 13;
vector<int> wn[N], ls[N];
int dfs(int v)
{
    vector<int> uwu;
    for (int i : wn[v])
    {
        uwu.push_back(dfs(i));
    }
    sort(uwu.rbegin(), uwu.rend());
    int ans = 0;
    for (int i = 1; i <= uwu.size(); i++)
    {
        ans = max(ans, i + uwu[i - 1]);
    }
    return ans;
}
signed main()
{
#ifdef home
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
#else
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    for (int i = 2; i <= n; i++)
    {
        int v;
        cin >> v;
        wn[v].push_back(i);
        ls[i].push_back(v);
    }
    cout << dfs(1);
}

Measured memory_bytes: 62720
#include<bits/stdc++.h>
using namespace std;
main(){
  int s;
  string str;
  cin>>str;
  int cnt=0;
  if(str[0]=='o') cnt++;
  if(str[1]=='o') cnt++;
  if(str[2]=='o') cnt++;
  cout<<100*cnt+700<<endl;
  return 0;
}

Measured memory_bytes: 768
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
  
n, p = map(int, input().split())
c = collections.Counter(prime_factorize(p))
ans = 1
for a, b in c.items():
  ans *= a ** (b//n)
print(ans)

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

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

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

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

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

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

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

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

fn main() {
    use std::cmp::min;

    input! {
        N: usize,
        W: i64,
        item: [(i64, usize); N],
    }

    const MAX_V: usize = 100000;

    let mut dp: Vec<Vec<i64>> = vec![vec![std::i64::MAX / 200; (MAX_V + 1)]; (N + 1)];
    dp[0][0] = 0;

    for i in 1..N + 1 {
        let (w, v) = item[i - 1];
        for j in 0..MAX_V + 1 {
            dp[i][j] = min(dp[i][j], dp[i - 1][j]);
            if j >= v {
                dp[i][j] = min(dp[i][j], dp[i - 1][j - v] + w);
            }
        }
    }

    for v in (0..MAX_V + 1).rev() {
        if dp[N][v] <= W {
            println!("{:?}", v);
            break;
        }
    };
}

Measured memory_bytes: 106748
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
//1~n個のノードのダイクストラ
long long inf=10000000000000007;
class Edge{
public:
int s;
int t;
long long len;
};
class Node{
    public:
    int num;//node番号
    long long dist;//startからの距離
    vector<Edge> edge;//自分から生えている辺
    bool comp;//dijkstra中で到達しているかどうか
    void in_edge(Edge &edge_in){
        edge.push_back(edge_in);
    }  
};
bool operator >(const Node& a,const Node &r){
        return a.dist > r.dist;
    }
void dijkstra(vector<Node> &node,int s,int t,int n){
    //n個のノードでできたグラフのsからtまでの最短距離を計算する
    //この時各要素のdistの値はsからの最短距離となる
    for(int i=1;i<=n;i++){
        //初期化
        node[i].dist=inf;
        node[i].num=i;
        node[i].comp=true;
    }
    node[s].dist=0;
    priority_queue<Node,vector<Node>,greater<Node>> que;
    que.push(node[s]);
    while(!que.empty()){
        Node buf;
        buf=que.top();//
        que.pop();
        int k=buf.num;
        if(node[k].comp){
            node[k].comp=false;
            int edge_num=buf.edge.size();
            for(int i=0;i<edge_num;i++){
                int buf_t=node[k].edge[i].t;
                int buf_len=node[k].edge[i].len;
                node[buf_t].dist=min(node[buf_t].dist,node[k].dist+buf_len);
                que.push(node[buf_t]);
            }
        }
    }
}
int main(){
    int n,s,t,m;
    cin>>n>>m;
    s=1;
    t=n;
    vector<Node> node(n+1);
    for(int i=n;i>1;i--){
        Edge pri;
        pri.s=i;
        pri.t=i-1;
        pri.len=0;
        node[i].in_edge(pri);
    }
    for(int i=0;i<m;i++){
        int a,b;
        long long l;
        cin>>a>>b>>l;
        Edge in;
        in.s=a;
        in.t=b;
        in.len=l;
        node[a].in_edge(in);//有向グラフの場合ここまで
        in.s=b;
        in.t=a;
        node[b].in_edge(in);//無向グラフの場合こっちも
    }
    dijkstra(node,s,t,n);
    if(node[t].dist==inf)node[t].dist=-1;
    cout<<node[t].dist<<endl;
    return 0;
}

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

int main(){
    int r,g,b;
    cin >> r >> g >> b;
    string ans;
    if ( (r*100 + g * 10 + b) % 4 ==0 ){
        ans = "YES";
    }
    else ans = "NO";

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
const int maxn = 1e5 + 5;
int pre[maxn], sum[maxn], x[maxn], y[maxn];
long long ans[maxn];
int find(int x)
{
    return x == pre[x] ? x : pre[x] = find(pre[x]);
}
void join(int a, int b)
{
    a = find(a), b = find(b);
    if(a != b)
    {
        sum[a] += sum[b];
        sum[b] = 0;
        pre[b] = a;
    }
}
int main()
{
    int n, m;
    while(cin >> n >> m)
    {
        for(int i = 0; i < maxn; i++) sum[i] = 1, pre[i] = i;
        memset(ans, 0, sizeof(ans));
        for(int i = 1; i <= m; i++)
        {
            scanf("%d%d", &x[i], &y[i]);
        }
        long long cnt = n;
        ans[m+1] = cnt * (cnt-1) / 2;
        for(int i = m; i >= 2; i--)
        {
            int xx = find(x[i]), yy = find(y[i]);
            if(xx != yy)
            {
                ans[i] = ans[i+1] - sum[xx] * sum[yy];
                join(x[i], y[i]);
            }
            else
                ans[i] = ans[i+1];
        }
        for(int i = 2; i <= m+1; i++)
            printf("%lld\n", ans[i]);
    }

    return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	rep(i, n) cin >> p[i];
	int cnt = 0;
	for (int i = 1; i < n-1; i++) {
		if (p[i] > p[i - 1] && p[i + 1] > p[i])cnt++;
		if (p[i] < p[i - 1] && p[i + 1] < p[i])cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

int main() {
    ll x;
    cin>>x;
    for(ll i = -1000;i<=1000;i++){
        for(ll j = -1000;j<=1000;j++){
            if(i*i*i*i*i - j*j*j*j*j == x){
                cout<<i<<" "<<j;
                return 0;
            }
        }
    }
    return 0;
}


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

int main() {
  int N, x;
  cin >> N >> x;
  
  vector<int> vec(N);
  for(int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
 int count = 0;
  for(int i = 0; i < N; i++) {
    if(i == N - 1) {
      if(x == vec.at(i)) {
        count++;
        break;
      }
    }
   else if(x >= vec.at(i)) {
     x -= vec.at(i);
     count++;
   }
     else {
       break;
     }
  }
  cout << count << endl;
    
}
    

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

using namespace std;

int main() {
	int a[3];

	cin >> a[0] >> a[1] >> a[2];

	sort(a, a + 3);

	int ans = (a[2] - a[1]) + (a[1] - a[0]);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,e;
  int x,y,t;
  cin >> a >> b >> c >> d >> e;
  
  if(a+1==c && b>d){
    x=0;
    y=60-(b-d);
    t=y-e;
    cout << t << endl;
  }else if(b>d){
    x=(c-a-1)*60;
    y=60-(b-d);
    t=x+y-e;
    cout << t << endl;
  }
  else{
    x=(c-a)*60;
    y=abs(b-d);
    t=x+y-e;
    cout << t <<endl;
  }
}

Measured memory_bytes: 3624