akhauriyash/Code-Regression huggingface dataset:
//****************************//
/**********  main *************/
//****************************//
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i, n) for(i = 0; i < n; i++)
#define FOR(i, a, b) for(i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())

double pi = 3.141592653589793;

int gcd(int a, int b) {
    if(a % b == 0) {
        return (b);
    } else {
        return (gcd(b, a % b));
    }
}

int main() {

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

    // int tmp;
    string tmp;
    int itmp;
    int count;
    int res;
    int sum;
    bool flag;

    string n;

    cin >> n;

    if( n == "0"){
        std::cout << "Yes" << endl;
        return 0;
    }

    sum = 0;
    for(int i=0 ; i<n.length();i++){
        tmp = n.substr(i,1);
        itmp = stoi(tmp);
        sum = sum + itmp;
    }

    if(sum % 9 == 0) {
        std::cout << "Yes" << endl;
    } else{
        std::cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();

int main(){
    string a, b;
    cin >> a >> b;

    string s1 = "";
    string s2 = "";
    rep(i,stoi(b)) s1 += a;
    rep(i,stoi(a)) s2 += b;


    if(s1 <= s2) cout << s1;
    else cout << s2;
    cout << endl;

    return 0;
    
}

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

int main() {
	int hand=2;
	int hands = 2;
	int counts = 0;
	int i;
	string side;
	while (1) {
		cin >> side;
		if (side == "#") { break; }
		for(i = 0; side[i] != '\0'; i++ ) {
			if (side[i] == 'y'|| side[i] == 'h'|| side[i] == 'n'
				|| side[i] == 'u'|| side[i] == 'j'|| side[i] == 'm'
				|| side[i] == 'i'|| side[i] == 'k'|| side[i] == 'o'
				|| side[i] == 'l'|| side[i] == 'p') {			hand = 0;
			}
			else { hand = 1; }
			if (hand != hands) { counts += 1; }
			hands = hand; }
		cout << counts - 1<<endl;
		counts = 0;
		hands = 2;
}
	return 0;}

Measured memory_bytes: 3208
#include<iostream>
#include<cmath>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#define P pair<long long, long long>


using namespace std;
const long long int MOD=1e9+7;

int main(){
  int a[4][4],n,b[11];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> a[i][j];
    }
  }
  cin >> n;
  set<int> s;
  for(int i=0;i<n;i++){
    cin >> b[i];
    s.insert(b[i]);
  }
  for(int i=0;i<3;i++){
    bool yes=true;
    for(int j=0;j<3;j++){
      if(s.find(a[i][j]) == s.end()){
        yes=false;
        break;
      }
    }
    if(yes){
      cout << "Yes" << endl;
      return 0;
    }
  }
  for(int j=0;j<3;j++){
    bool yes=true;
    for(int i=0;i<3;i++){
      if(s.find(a[i][j]) == s.end()){
        yes=false;
        break;
      }
    }
    if(yes){
      cout << "Yes" << endl;
      return 0;
    }
  }
  bool yes=true;
  for(int i=0;i<3;i++){
    if(s.find(a[i][i])==s.end()){
        yes=false;
        break;
    }
  }
  if(yes){
    cout << "Yes" << endl;
    return 0;
  }
  yes = true;
  for(int i=0;i<3;i++){
    if(s.find(a[i][2-i])==s.end()){
        yes=false;
        break;
    }
  }
  if(yes){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
n500 = int(input())
n100 = int(input())
n50 = int(input())
X=int(input())
count = 0
for i500 in range(n500+1):
    for i100 in range(n100+1):
        for i50 in range(n50+1):
            if i500*500+i100*100+i50*50==X:
                count+=1
print(count)


Measured memory_bytes: 3060
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    int n = read();
    if (n & 1) {
        int a = n / 2 + 1;
        printf("%.7lf\n", 1.0 * a / n);
    }else{
        printf("%.7lf\n", 0.5);
    }

    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())

query = []
for i in range(H):
    if i%2==0:
        lis = [(i, j) for i, j in enumerate(list(map(int, input().split())))]
    else:
        lis = [(i, j) for i, j in enumerate(list(map(int, input().split())))][::-1]
    query += lis

odd = 0
move = []
last = (0, 0)
for i, (w, q) in enumerate(query):
    if odd:
        move.append((last[0], last[1], i//W+1, w+1))
        if q%2==1:
            odd = 0
        else:
            last = (i//W+1, w+1)
    else:
        if q%2==1:
            odd = 1
            last = (i//W+1, w+1)

print(len(move))
for l in move:
    print(*l)

Measured memory_bytes: 45928
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[1000000],n,k,i;
    a[0]=1;
    cin>>n>>k;
    for (i=1;i<=n;i++)
    a[i]=min(a[i-1]+k,a[i-1]*2);
    cout<<a[n]<<endl;
    return 0;
}

Measured memory_bytes: 256
N = input()
A, B, C, D = N[0], N[1], N[2], N[3]

def fn(op1, op2, op3):
    msg = A + op1 + B + op2 + C + op3 + D
    if eval(msg) == 7:
        print(msg + "=7")
        exit()


for op1 in ("+","-"):
    for op2 in ("+","-"):
        for op3 in ("+","-"):
            fn(op1, op2, op3)


Measured memory_bytes: 3060
#include <stdio.h>
main()
{
    int    x;
    int    i;
    int    ans;

    scanf("%d", &x);

    ans = 1;
    for (i=0; i < 3; i++) {
        ans = ans * x;
    }
    printf ("%d\n", ans);
    exit(0);
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
  string S;
  cin>>S;
  
  int ans=0;
  for(int i=0;i<4;++i){
    if(S[i]=='+')
      ++ans;
    if(S[i]=='-')
      --ans;
  }
  
  cout<<ans<<endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    string ans = "";
    ans += s1[0];
    ans += s2[0];
    ans += s3[0];
   transform(ans.begin(), ans.end(), ans.begin(), ::toupper); 
   cout << ans << endl;

    return 0;
}

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

int main(){
  vector<int> N(4);
  for(int i=0; i<4; i++){
    cin >> N.at(i);
  }
  sort(N.begin(), N.end());
  if(N.at(0)==1 && N.at(1)==4 && N.at(2)==7 && N.at(3)==9){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

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

int main() 
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;cin>>n;
	ll t[n];
	for (int i = 0; i < n; i++)cin>>t[i];
	ll g = __gcd(t[0],t[1]);
	for (int i = 2; i < n; i++)
	{
		g=__gcd(g,t[i]);
	}
	cout << g;
}

Measured memory_bytes: 4432
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,S,p,A ;
  cin >> N ;
  A=N;
  S=0;
  p=100000000;
  
  for (int i=0;i<9;i++){
    S += N/p ;
    N -= (N/p)*p ;
    p /= 10 ;
  }
  if (A%S==0){
    cout << "Yes" <<endl;
  }
  else {
    cout << "No" <<endl;
  }
 
}

Measured memory_bytes: 256
import sys
import numpy as np


def main():
    MOD = int(1e9 + 7)

    n, k = map(int, input().split())
    can = [[int(c) for c in input().split()] for _ in range(n)]
    can = np.matrix(can, 'O')

    # for i in range(n):
    #     for j, e in enumerate(int(c) for c in input().split()):
    #         can[i, j] = e

    # b = np.eye(n, n, 0, 'O')
    # while k:
    #     b = [b, b*can % MOD][k & 1]
    #     can = can*can % MOD
    #     k >>= 1

    # print(b.sum() % MOD)

    answer = np.eye(n, dtype=int)
    while k:
        if k % 2:
            answer = answer * can % MOD
        can = can * can % MOD
        k //= 2

    total = 0
    for i in range(n):
        for j in range(n):
            total += answer[i,j]
            if total >= MOD:
                total -= MOD

    print(total)


if __name__ == "__main__":
    main()


Measured memory_bytes: 12516
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc139
{
    class abc139a
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();
            var r = Solve(s, t);
            Console.WriteLine(r);
        }

        static int Solve(string s, string t)
        {
            var r = 0;
            for(var i = 0; i!=s.Length; ++i) {
                if(s[i] == t[i])
                    ++r;
            }
            return r;
        }
    }
}


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int N;
vector<P> G[100000];
vector<bool> visit(100000, false);
vector<ll> dist(100000); // ある頂点から頂点Kまでの最短距離
int Q, K;

void dfs(int cur)
{
  visit[cur] = true;
  REP(i, G[cur].size())
  {
    int to = G[cur][i].first;
    int d = G[cur][i].second;
    if (visit[to])
      continue;
    dist[to] = dist[cur] + d;
    dfs(to);
  }
}

int main()
{
  cin >> N;
  REP(i, N - 1)
  {
    int a, b;
    ll c;
    cin >> a >> b >> c;
    a--, b--;
    G[a].push_back(P(b, c));
    G[b].push_back(P(a, c));
  }
  cin >> Q >> K;
  K--;
  dist[K] = 0;
  dfs(K);
  REP(i, Q)
  {
    int x, y;
    cin >> x >> y;
    x--, y--;
    cout << dist[x] + dist[y] << endl;
  }
  return 0;
}

Measured memory_bytes: 14336
<?php
$N = trim(fgets(STDIN));
$x = 0;
$max = 100;
for($i = 0;$i<$N;$i++){
$P = trim(fgets(STDIN));
$x +=$P;
if ($max <$P){
$max = $P;
}
}
$max /= 2;
$x -= $max;
echo $x;


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = 1<<29;
typedef long long ll;



int dp[100][2][100];//dp[keta][未満である][0でない数の個数]


struct UnionFind {
  vi parent;
  UnionFind(int N) : parent(N) {
    rep(i, N)parent[i] = i;
  }

  int getRoot(int child){
    return ((parent[child] == child) ? child : parent[child] = getRoot(parent[child]));
  }
  void unite(int x, int y){
    int root_x = getRoot(x);
    int root_y = getRoot(y);
    if(root_x == root_y)return;
    parent[root_x] = parent[root_y];
  }
  bool isSame(int x, int y){
    return getRoot(x) == getRoot(y);
  }
};
int main(){
  int H, W, N;cin >> H >> W >> N;
  H = max(H, W);
  cout << ((N % H) ? N/H + 1 : N/H);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<set>
#include<algorithm>
#include <queue>

using ll =  long long;
#define rep(i,n) for(int i= 0; i< (n); i++)
using namespace std;
using Graph = vector<vector<int>>;

int main(){

    string s;
    cin >> s;    
    int cnt=0,ans=0;
    rep(i,s.size()){
        if(s[i]=='A'||s[i]=='G'||s[i]=='C'||s[i]=='T'){
            cnt++;
            ans=max(cnt,ans);
        }else{
            cnt=0;
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int i,a,c = 0,d,e = 0,q;

  cin >> a;
  int b[a];
  for(i = 0;i < a;i++){
    cin >> b[i];
    c = c + b[i];
  }
  d = c / a;
  q = c * 10 / a - (10 * d);
  if(q >= 5){
    d += 1;
  }
  for(i = 0;i < a;i++){
    if(b[i] < d){
      e = e + ((d - b[i]) * (d - b[i]));
    }
    else{
      e = e + ((b[i] - d) * (b[i] - d));
    }
  }
  cout << e << endl;
}

  

Measured memory_bytes: 256
# AOJ 0538: IOIOI
# Python3 2018.7.1 bal4u

while True:
	n = int(input())
	if n == 0: break
	m = int(input())
	s = input().strip()
	ans = cnt = i = 0
	while i < m:
		if i+1 < m and s[i:i+2] == 'IO':
			cnt += 1
			i += 1
		elif cnt > 0:
			if s[i] == 'O': cnt -= 1
			if cnt >= n: ans += cnt-n+1
			cnt = 0
		i += 1
	print(ans)



Measured memory_bytes: 7296
fun main(args: Array<String>) {
    val S = readLine()!!
    val T = readLine()!!
    val dic0 = mutableSetOf<Char>()
    var cnt = 0
    for (c in 0 until 26) {
        val dic = mutableSetOf<Char>()
        for (i in 0 until S.length) {
            if (T[i] == 'a'+c) {
                dic.add(S[i])
                dic0.add(S[i])
            }
        }
        if (dic.size > 1) {
            println("No")
            return
        }
        if (dic.size == 1) cnt++
    }
    if (dic0.size == cnt) println("Yes")
    else println("No")
}

Measured memory_bytes: 40192
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using Pair = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;

/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 

int main(){
  int n,k;
  cin >> n>> k;
  vector<int> a(n);
  vector<int> s,t;
  rep(i,n){
    cin >> a[i];
    if(a[i] < 0) t.push_back(a[i]);
    else s.push_back(a[i]);
  }
  int S = s.size();
  int T = t.size();
  bool ok = false;
  if (S > 0) {
    if (n == k) ok = (T%2==0);
    else ok = true;
  } else {
    ok = (k%2==0);
  }
 
  mint ans = 1;
  if (!ok) {
    sort(a.begin(), a.end(), [](int x, int y) {
      return abs(x) < abs(y);
    });
    rep(i,k) ans *= a[i];
  } else {
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    if (k%2 == 1) {
      ans *= s.back();
      s.pop_back();
    }
    vector<ll> p;
    while (s.size() >= 2) {
      ll x = s.back(); s.pop_back();
      x *= s.back(); s.pop_back();
      p.push_back(x);
    }
    while (t.size() >= 2) {
      ll x = t.back(); t.pop_back();
      x *= t.back(); t.pop_back();
      p.push_back(x);
    }
    sort(p.rbegin(), p.rend());
    rep(i,k/2) ans *= p[i];
  }
 
  cout << ans << endl;
  return 0;

}

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

#define ll long long int

using namespace std;

ll sum(int n, int m, vector<ll> x, vector<ll> y, vector<ll> z) {
  vector<ll> t;
  for(int i=0;i<n;i++) {
    t.push_back(x[i]+y[i]+z[i]);
  }
  sort(t.begin(), t.end(), greater<ll>());
  ll sum = 0;
  for(int i=0;i<m;i++) {
    sum += t[i];
  }
  return sum;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<ll> x, y, z, xminus, yminus, zminus;
  for(int i=0;i<n;i++) {
    ll p, q, r;
    cin >> p >> q >> r;
    x.push_back(p);
    xminus.push_back(-p);
    y.push_back(q);
    yminus.push_back(-q);
    z.push_back(r);
    zminus.push_back(-r);
  }

  ll result = 0;

  //+++
  result = sum (n, m, x, y, z);
  //++-
  result = max(result, sum (n, m, x, y, zminus));
  //+-+
  result = max(result, sum (n, m, x, yminus, z));
  //+--
  result = max(result, sum (n, m, x, yminus, zminus));
  //-++
  result = max(result, sum (n, m, xminus, y, z));
  //-+-
  result = max(result, sum (n, m, xminus, y, zminus));
  //--+
  result = max(result, sum (n, m, xminus, yminus, z));
  //---
  result = max(result, sum (n, m, xminus, yminus, zminus));
  
  cout << result << endl;
  
  
}

Measured memory_bytes: 384
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#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 int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

int gcd(int a,int b){return b ? gcd(b,a%b) : a;} 
int lcm(int a,int b){return a/gcd(a,b)*b;}

signed main(){
    int n;
    cin >> n;
    if(n == 25) cout << "Christmas\n";
    else if(n == 24) cout << "Christmas Eve\n";
    else if(n == 23) cout << "Christmas Eve Eve\n";
    else cout << "Christmas Eve Eve Eve\n";
    return 0;
}


Measured memory_bytes: 256
def main():
    num = int(input())

    inf = 10 ** 10
    ans = 1
    for b in range(2, inf):
        for p in range(2, inf):
            kari = b ** p
            if kari > num:
                break
            if kari <= num and kari > ans:
                ans = kari
        if b ** 2 > num:
            break

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define mod 1000000007
#define inf 1e18
#define w(x) int x; cin>>x; while(x--)
using namespace std;
bool sieve[100007];
void sieve_make() 
{
	memset(sieve,true,sizeof(sieve));
	sieve[0]=sieve[1]=false;
	for(int i=2;i*i<=100006;i++)
	{
		if(sieve[i])
		{
			for(int j=2*i;j<=100006;j+=i)
				sieve[j]=false;
		}
	}
}

int max(int a,int b)
{
	if(a>b)
		return a;
	return b;
}
int min(int a,int b)
{
	if(a<b)
		return a;
	return b;
}
int modexp(int a,int b,int c)
{
	if(a==0) return 0;
	if(b==0) return 1;

	int ans;
	if(b%2==0)
	{
		int small=modexp(a,b/2,c);
		ans=(small*small)%c;
	}
	else
	{
		int small=modexp(a,b-1,c);
		ans=(a%c);
		ans=(small*ans)%c;
	}
	return (ans+c)%c;
}

string rev(string s)
{
	reverse(s.begin(), s.end());
	return s;
}
bool sign(int x)
{
	if(x>0)
		return true;
	return false;
}

int base3(string b)
{
	int ans=0,c=0;
	for(int i=b.length()-1;i>=0;i--)
	{
		ans+=(b[i]-'0')*pow(3,c++);
	}
	return ans;
}
int dp[501][501];
int solve(int* a,int i,int j)
{
	if(i>=j)
		return 0;
	int ans=INT_MAX;
	if(dp[i][j]!=-1)
		return dp[i][j];
	for(int k=i;k<j;k++)
	{
		int temp=solve(a,i,k)+solve(a,k+1,j)+a[i-1]*a[k]*a[j];
		ans=min(ans,temp);
	}
	return dp[i][j]=ans;
}

int32_t main()
{
	ios::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
	
	
	int n;
	cin>>n;
	int a=n%10;
	if(a==2 or a==4 or a==5 or a==7 or a==9)
		cout<<"hon"<<endl;
	else if(a==0 or a==1 or a==6 or a==8)
		cout<<"pon"<<endl;
	else
		cout<<"bon"<<endl;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)     for(long long int i=a; i<n; i++)
#define loop(i,a,n)     for(long long int i=a; i>=n; i--) 

int main()
{
	ios_base :: sync_with_stdio(false),cin.tie(NULL);
	
	string s;
	cin>>s;
	int a=0;
	forr(i, 0, s.size())
		a+=s[i]-'0';
	if(a%9==0)
		cout<<"Yes";
	else
		cout<<"No";
	
	return 0;
}

Measured memory_bytes: 3768
#include <stdio.h>

int main(){
  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

  if(x+r<=W && y+r<=H){
    if(x+r<=0 || y+r<=0){
      printf("No\n");
    }
    else{
      printf("Yes\n");
    }
  }
  else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 584
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]
# @lru_cache(None)






N=l()[0]
A=l()
ans=10**10
for i in range(-100,101):
    x=sum([(ele-i)**2 for ele in A])
    ans=min(ans,x)
print(ans)

Measured memory_bytes: 5104
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <sstream>
#include <cassert>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <chrono>
#include <ctime>

using namespace std;

#define en '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) int((x).size())

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 7;
const ll INFLL = 1e18;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;
const int MAX_SIZE = 5e5;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

bool IS_ONE_TEST = 1;
ld START_TIME, TIME;

void fast_in_out() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void solve() {
    int x, n;
    cin >> x >> n;
    vector<int> a(n), used(102, 1);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        used[a[i]] = 0;
    }
    int ans = INF;
    for (int i = 0; i <= 101; ++i) {
        if (!used[i]) continue;
        if (abs(x - i) < abs(x - ans)) {
            ans = i;
        }
    }
    cout << ans << en;
}

int main() {
    START_TIME = clock();
    fast_in_out();
    int TESTS = 1;
    if (!IS_ONE_TEST) cin >> TESTS;
    while (TESTS--) { solve(); }
#ifdef __APPLE__
    TIME = (clock() - START_TIME) / CLOCKS_PER_SEC;
    cerr << en << TIME * 1000 << " ms." << en;
#endif
    return 0;
}

/*
     ▄▀▀▀▄
▄███▀░◐░░░▌
    ▌░░░░░▐
    ▐░░░░░▐
    ▌░░░░░▐▄▄
    ▌░░░░▄▀▒▒▀▀▀▀▄
   ▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
   ▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
    ▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
      ▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
           ▌▌░▌▌
           ▌▌░▌▌
         ▄▄▌▌▄▌▌        */


Measured memory_bytes: 3640
#include<stdio.h>
#include<math.h>
 
#define N 200000
#define AMAX 1000000

int extDivisor(int t, int *listDivisor){
  int iDivisor=0;
  int a = sqrt(t);
  for(int j=2; j<=a; j++){
    if(t%j==0){
      if(j*j==t){
         listDivisor[iDivisor] = j;
         iDivisor++;
      }
      else{
        listDivisor[iDivisor] = j;
        listDivisor[iDivisor+1] = t/j;
        iDivisor+=2;
      }
    }
  }
//  printf("%d ",t); for(int j=0; j<iDivisor; j++){printf("%d ",listDivisor[j]);} printf("\n");
  return iDivisor;
}

int compare_int(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}
 
int main(){
  // 数列の確保量ミス
  int n, a[N], cnt[AMAX]={0}, nDivisor, listDivisor[2000]={0}, isDivide[AMAX]={0}, sum=0, maxNo=0;
  scanf("%d", &n);
  for(int i=0; i<n; i++){
    scanf("%d", &a[i]);
  }
  
  // 入力数列にどの数字がいくつあるか
  for(int i=0; i<n; i++){
    cnt[a[i]-1]++;
    if(a[i]>maxNo){
      maxNo=a[i];
    }
  }
  // 数列に1があれば面倒な処理いらない
  if(cnt[0]==1){
    printf("%d",1);      
    return 0;
  }
  else if(cnt[0]>1){
    printf("%d",0);      
    return 0;
  }
//  for(int i=0; i<maxNo; i++){printf("%d ",cnt[i]);} printf("\n");
  // 入力数列に含まれる数字に対し、約数を全出力し、入力数字に存在するか調べる
  for(int i=2; i<=maxNo; i++){
    if(cnt[i-1]==0){
      continue;
    }
    if(cnt[i-1]>1){
      isDivide[i-1]=1; 
    }
    nDivisor = extDivisor(i, listDivisor); // 約数のリスト作成(1と自分自身はリストに含まない)
//    printf("%d ",i); for(int j=0; j<nDivisor; j++){printf("%d ",listDivisor[j]);} printf("\n");
    for(int j=0; j<nDivisor; j++){
//      printf("%d %d\n", i, listDivisor[j]);
      if(cnt[listDivisor[j]-1]!=0){  // 約数の中に入力数値が含まれている場合
//        printf("%d %d\n", i+1, listDivisor[j]);
        isDivide[i-1]=1;               // 割り切れる数は存在する
        break;
      }
    }     
  }

  for(int i=0; i<maxNo; i++){
//    printf("%d ",isDivide[i]);   
    if(isDivide[i]==0){
      sum += cnt[i];
    }
  }
  
  printf("%d",sum);      
  return 0;
}

Measured memory_bytes: 10704
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	double r, men, en;
	scanf("%lf", &r);
	men = r * r * 3.14159265359;
	en = 2 * r * 3.14159265359;
	printf("%f %f\n", men, en);
	return 0;
}


Measured memory_bytes: 2092
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;

	vector <int> ar(n);
	for(int &x: ar) cin >> x;
	for(int i=1; i<n; i++) ar[i] += ar[i-1];
	int res = INT_MAX;
	for(int i=1; i<n; i++){
		res = min(res, abs(ar[n-1]-ar[i]-ar[i]));
	}	
	cout << res;
	return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        
        Map<Character, String> s = new HashMap<>();
        s.put('a', stdin.nextLine());
        s.put('b', stdin.nextLine());
        s.put('c', stdin.nextLine());
        
        char turn = 'a';
        while (!s.get(turn).isEmpty()) {
            String t = s.get(turn);
            s.put(turn, t.substring(1));
            turn = t.charAt(0);
        }
        
        System.out.println(Character.toUpperCase(turn));
    }
}


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

int main(){
  string s;
  cin>>s;
  if(s[3]==s[2]||s[2]==s[1]||s[1]==s[0]){
    cout<<"Bad"<<endl;
  }
  else{
    cout<<"Good"<<endl;
  }
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define N 10000005
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
typedef long long ll;
ll a[N],b[N];
int main()
{
    FAST;
    ll n,m,k;
    cin>>n>>m>>k;
    for(ll i=1;i<=n;i++) {
        cin>>a[i];
    }
    for(ll i=1;i<=m;i++) {
        cin>>b[i];
        b[i] += b[i-1];
    }
    ll ans=0LL;
    ll sum=0LL;
    ll j=m;
    for(ll i=0;i<=n;i++) {
        sum += a[i];
        if(sum > k) break;
        while(sum + b[j] > k) j--;
        ans=max(ans,i+j);
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6776
#![allow(unused_imports)]
use std::io::{ self, Write };
use std::str::FromStr;
use std::cmp::{ min, max };
use std::collections::{ BinaryHeap, VecDeque };

#[allow(unused_macros)]
macro_rules! trace {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var);
    };
    ($($args:expr),*) => { trace!(($($args),*)) }
}

#[allow(unused_macros)]
macro_rules! put {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stdout(), "{}", $var);
    };
    ($var:expr, $($args:expr),*) => {
        let _ = write!(&mut std::io::stdout(), "{} ", $var);
        put!($($args),*);
    };
}

const M: usize = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let s: Vec<_> = sc.cin::<String>().chars().collect();
    let t: Vec<_> = sc.cin::<String>().chars().collect();
    let mut len = vec![vec![0; t.len()+1]; s.len()+1];
    let mut src = vec![vec![None; t.len()+1]; s.len()+1];

    len[0][0] = 0;
    for i in 1..s.len()+1 {
        for j in 1..t.len()+1 {

            len[i][j] = len[i-1][j];
            src[i][j] = Some((i-1, j));

            if len[i][j] < len[i][j-1] {
                len[i][j] = len[i][j-1];
                src[i][j] = Some((i, j-1));
            }

            if s[i-1] == t[j-1] && len[i][j] < 1 + len[i-1][j-1] {
                len[i][j] = len[i-1][j-1] + 1;
                src[i][j] = Some((i-1, j-1));
            }
        }
    }

    // for i in 0..s.len()+1{trace!(&len[i]);}
    // for i in 0..s.len()+1{trace!(&src[i]);}

    let mut ans = vec![];
    {
        let mut i = s.len();
        let mut j = t.len();
        while let Some((u, v)) = src[i][j] {
            if len[u][v] < len[i][j] {
                ans.push(s[i-1]);
            }
            i = u; j = v;
        }
    }

    for c in ans.iter().rev() {
        print!("{}", &c);
    } println!("");
}

#[allow(dead_code)]
struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn reserve(&mut self) {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        self.reserve();
        match self.buffer.pop_front().unwrap().parse::<T>() {
            Ok(a) => a,
            Err(_) => panic!("parse err")
        }
    }
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    vec a(N);
    rep(i, N) cin >> a[i];

    unordered_map<int, int> um;
    rep(i, N){
        if(um[a[i]]){
            cout << "NO" << endl;
            return;
        }
        um[a[i]]++;
    }
    
    cout << "YES" << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 13384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
ll a[100005];
int main(){
	int n;
	while(cin >> n){
		for(int i = 1; i <= n; i++)	
			cin >> a[i];
		int maxn = 0, sum;
		for(int i = 1; i < n; i++){
			if(a[i+1] <= a[i]){
				int j = i;
				sum = 0;
				while(a[j+1] <= a[j] && j < n){
					j++;
					sum++;
				}
				
				i = j;
				//cout << j << endl;
				if(sum > maxn) maxn = sum;
			}
		}
		cout << maxn << endl;	
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;
    set<ll> S;
    ll a, max1 = 0, max2 = 0;
    S.insert(1000000001);
    rep(i, n){
        cin >> a;
        if(S.find(a) == S.end()){
            S.insert(a);
        }else{
            if(max1 < a){
                max2 = max1;
                max1 = a;
            }else if(max2 < a){
                max2 = a;
            }
            S.erase(a);
        }
        //cout << max1 << " " << max2 << endl;
    }
    cout << max1 * max2 << endl;
}

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

class Dice{
public:
  //Dice();
  void input();
  void routen(char ch);
  int upnum(){
    return d[0];
  }
  int find(int, int);
  void get(int [6]);
private:
  int tmp[6], d[6];
};

void Dice::input(){
  for(int i=0;i<6;i++){
    cin >> d[i];
  }
}

int Dice::find(int up, int forward){
  char v[5] = "SSSW";
  for(int k=0;k<7;k++){
    for(int i=0;i<4;i++){
      if(d[0] == up && d[1] == forward){
        return d[2];
      }else if(d[1] == up && d[0] == forward){
        return d[3];
      }
      routen(v[i]);
    }
  }
  return 0;
}

void Dice::get(int dice[6]){
  for(int i=0;i<6;i++){
    dice[i] = d[i];
  }
}

void Dice::routen(char ch){
  for(int i=0;i<6;i++){
    tmp[i] = d[i];
  }
  switch(ch){
    case 'E':
      d[0] = tmp[3];
      d[2] = tmp[0];
      d[3] = tmp[5];
      d[5] = tmp[2];
    break;
    case 'W':
      d[0] = tmp[2];
      d[2] = tmp[5];
      d[3] = tmp[0];
      d[5] = tmp[3];
    break;
    case 'S':
      d[0] = tmp[4];
      d[1] = tmp[0];
      d[5] = tmp[1];
      d[4] = tmp[5];
    break;
    case 'N':
      d[0] = tmp[1];
      d[1] = tmp[5];
      d[5] = tmp[4];
      d[4] = tmp[0];
    break;
  };
}

bool check(int d1[], int d2[]){
  for(int i=0;i<6;i++){
    if(d1[i] != d2[i]){
      return false;
    }
  }
  return true;
}

int main(){
  int N, forward, up;
  int d1[6], d2[6];
  vector<int> v;

  cin >> N;
  vector<Dice> dice(N);
  for(int i=0;i<N;i++){
    dice[i].input();
  }


  for(int k=0;k<N;k++){
    for(int l=k+1;l<N;l++){
      dice[k].get(d1);
      char str[] = "WWWWSWWWW";
      for(int i=0;i<9;i++){
        dice[l].get(d2);
        if(d2[0] == d1[0] && d2[5] == d1[5]){
          break;
        }
        if(i == 8){
          continue;
        }
        dice[l].routen(str[i]);
      }
      char str1[] = "SWN";
      for(int i=0;i<4;i++){
        dice[l].get(d2);
        if(check(d1, d2)){
          cout << "No" << endl;
          return 0;
        }
        for(int j=0;j<3;j++){
          dice[l].routen(str1[j]);
        }
      }
    }
  } 

  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pi;
int h,w;
int arr[105][105];
bool visited[105][105];
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int main(){
	int white=0;
	cin>>h>>w;
	for(int i=1; i<=h; i++){
		string s;
		cin>>s;
		for(int j=0; s[j]; j++){
			if(s[j]=='.'){
				arr[i][j+1] = 1;
				white++;
			}
		}
	}
	queue<pair<pi,int> >q;
	q.push(make_pair(pi(1,1),1));
	visited[1][1] = true;
	while(!q.empty()){
		pair<pi,int> curr = q.front();
		int y = curr.first.first;
		int x = curr.first.second;
		int d = curr.second;
		q.pop();
		if(y==h && x==w){
			cout<<white-d;
			return 0;
		}
		for(int i=0; i<4; i++){
			int yy = y+dy[i];
			int xx = x+dx[i];
			if(yy<1 || xx<1 || yy>h || xx>w) continue;
			if(!visited[yy][xx] && arr[yy][xx]){
				visited[yy][xx] = true;
				q.push(make_pair(pi(yy,xx),d+1));
			}
		}
	}
	cout<<-1;
}

Measured memory_bytes: 3652
#include <stdio.h>
int main(void){
  int W,H,x,y,r;
  scanf("%d",&W);
  scanf("%d",&H);
  scanf("%d",&x);
  scanf("%d",&y);
  scanf("%d",&r);
  if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H)
  puts("Yes");
  else
  puts("No");
   return 0;
}



Measured memory_bytes: 2128
N = int(input())

data = [[] for _ in range(N+1)]

for i in range(N-1):
    a, b, c = map(int, input().split())

    data[a].append((b,c))
    data[b].append((a,c))


ans = [0] * (N+1)
went = [False] * (N+1)

went[0] = True
went[1] = True
go = [1]

while len(go) > 0:
    before = go.pop()
    for i, c in data[before]:
        if not went[i]:
            went[i] = True
            if c % 2 == 0:
                ans[i] = ans[before]
            else:
                ans[i] = 1 - ans[before]
            go.append(i)

for i in range(1, N+1):
    print(ans[i])

Measured memory_bytes: 39596
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    string s;
    cin >> s;
    
    cout << s.replace(s.end() - 8 , s.end(), "") << endl;

    return 0;
}


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

int main(void) {
	int N, M;
	vector<int> A;
	cin >> N >> M;

	A.resize(N);
	int sum = 0;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		sum += A[i];
	}

	bool ans = false;
	int cnt = 0;
	for (int i = 0; i < N; ++i) {
		if (4 * M * A[i] >= sum)
			++cnt;
		if (cnt >= M) {
			ans = true;
			break;
		}
	}

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
string str, res;
int main(void){
    // Your code here!
    cin >> str;
    for (int i = 0; i < str.length(); i++) {
        if (str[i] == '0') res.push_back('0');
        if (str[i] == '1') res.push_back('1');
        if (res.empty()) continue;
        if (str[i] == 'B') res.pop_back();
    }
    cout << res << endl;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.replace(/\n$/,"")).split("\n");
while(true){
   var str=Arr.shift();
   if(str=="END OF INPUT")break;
   var arr=str.split(" ");
   arr.forEach(function(v,i){arr[i]=v.length;});
   console.log(arr.join(""));
}

Measured memory_bytes: 7644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define pq priority_queue
#define bcnt(n) __builtin_popcountll(n)

using ll = long long;  // long longをllだけにした
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using mll = map<long long, long long>;
using pll = pair<long long, long long>;
using sll = set<long long>;
using vpll = vector<pair<long long, long long>>;
using mlv = map<long long, vector<long long>>;

int main() {
	ll const mod = 1e9 + 7;
	string p;
	ll d;
	cin >> p >> d;
	ll n = p.size();
	vll k(n);
	rep(i, n) k[i] = p[i] - '0';
	vvvll dp(n + 1, vvll(d, vll(2, 0)));  //[][][1]は未満フラグtrue
	dp[0][0][0] = 1;
	// cout << "#" << endl;
	rep(i, n) {
		rep(j, d) {
			ll w = (j + k[i]) % d;
			dp[i + 1][w][0] += dp[i][j][0];
			dp[i + 1][w][0] %= mod;
			rep(r, k[i]) {
				ll l = (j + r) % d;
				dp[i + 1][l][1] += dp[i][j][0];
				dp[i + 1][l][1] %= mod;
			}
			rep(r, 10) {
				ll l = (j + r) % d;
				dp[i + 1][l][1] += dp[i][j][1];
				dp[i + 1][l][1] %= mod;
			}
		}
	}
	ll res = (dp[n][0][0] + dp[n][0][1] - 1 + mod) % mod;
	cout << res << endl;
}


Measured memory_bytes: 55424
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int N, D;
  cin >> N >> D;
  // t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
  //       x        x
  // D = 3
  // (D + 1) + x*(2D + 1) <= N
  // x <= (N - D - 1) / (2D + 1)
  int rsl = 1;
  int cur = D + 1;
  while(1) {
      if(cur + D + 1 <= N) {
          rsl++;
          cur += 2 * D + 1;
          if(cur > N){
              cout << rsl << endl;
              return 0;
          }
      } else {
          cout << rsl << endl;
          return 0;
      }
  }
}


Measured memory_bytes: 256