akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

struct UnionFind
{
  vector<int> par;
  vector<int> sizes;
  UnionFind(int n) : par(n), sizes(n, 1) {
    rep(i,n) par[i] = i;
  }
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  int size(int x) {
    return sizes[find(x)];
  }
};

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    UnionFind u(n+1);
    vi b(n+1,0);
    rep(i,m){
        int p,q;
        cin>>p>>q;
        u.unite(p,q);
        b[p]++;
        b[q]++;
    }
    rep(i,k){
        int r,s;
        cin>>r>>s;
        if(u.same(r,s)){
            b[r]++;
            b[s]++;
        }
    }
    for(int i=1;i<=n;++i){
        cout<<u.size(i)-b[i]-1<<endl;
    }
}

Measured memory_bytes: 2048
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 500005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int a, b;
    cin >> a >> b;
    if( a >= 10 || b >= 10 ) cout << -1;
    else cout << a * b;
    cout << endl;

    return 0;
}



Measured memory_bytes: 256
using System;

namespace QuestionA
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] dts = Console.ReadLine().Split(' ');
            float d = float.Parse(dts[0]); //距離
            float t = float.Parse(dts[1]); //制限時間
            float s = float.Parse(dts[2]); //速度

            if(d / s <= t)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

const int N = 1e5+10;
int a[N],b[N];

signed main(){

  int n,h;  cin >> n >> h;
  for(int i = 0; i < n; i++){
    cin >> a[i] >> b[i];
  }

  sort(a,a+n),sort(b,b+n);
  int cnt = 0;
  for(int i = n-1; a[n-1] <= b[i]; i--){
    h -= b[i];
    cnt++;
    if(h <= 0) break;
  }
  if(h > 0) cnt += (h+a[n-1]-1)/a[n-1];
  cout << cnt << endl;

  return 0;
}


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

using namespace std;

long long f(long long b, long long n) {
    if (b <= 1) return -1;
    if (n < b) return n;
    else return f(b, n / b) + n % b;
}
int main() {
    long long n, s;

    scanf("%lld%lld", &n, &s);
    long long res = 1e13 + 1;

    if (n == s) {
        cout << n + 1 << endl;
        return 0;
    }

    if (s > n) {
        cout << -1 << endl;
        return 0;
    }

    for (long long b = 2; b * b < n; ++b) {
        if (f(b, n) == s) {
            cout << b << endl;
            return 0;
        }
    }

    long long sqrt = 0;
    for (; sqrt * sqrt <= n; sqrt++)
        ;
    for (long long p = sqrt; p > 0; --p) {
        long long r = s - p;
        long long b = (n - r) / p;
        if (b == 1) continue;
        if (f(b, n) == s) {
            cout << b << endl;
            return 0;
        }
    }

    cout << -1 << endl;


    return 0;
}



Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
string s; int dp[200009], nxt[27][200009];
int main() {
	cin >> s; s = (char)(97 + 26) + s;
	int n = s.size();
	for (int i = 0; i < 26; i++) {
		nxt[i][n] = -1;
		for (int j = n - 1; j >= 0; j--) {
			if (s[j] == i + 97) nxt[i][j] = j;
			else nxt[i][j] = nxt[i][j + 1];
		}
	}
	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < n; j++) {
			if (nxt[i][j] != nxt[i][j + 1]) nxt[i][j] = nxt[i][j + 1];
		}
	}
	for (int i = n - 1; i >= 0; i--) {
		bool f = false; int a = 0;
		for (int j = 0; j < 26; j++) {
			if (nxt[j][i] == -1) f = true;
			a = max(a, nxt[j][i]);
		}
		if (f) dp[i] = 0;
		else dp[i] = dp[a] + 1;
	}
	string ret;
	int pos = 0; bool flag = false;
	while(!flag) {
		for (int j = 0; j < 26; j++) {
			if (nxt[j][pos] == -1 || dp[nxt[j][pos]] == dp[pos] - 1) {
				ret += j + 97;
				pos = nxt[j][pos];
				if (pos == -1) flag = true;
				break;
			}
		}
	}
	cout << ret << endl;
	return 0;
}

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

int main(){
    int N;
    cin>>N;
    
    vector<tuple<string,int,int>> data;
    for(int i=1;i<=N;i++){
        string S;
        int P;
        cin>>S>>P;
        P=101-P;
        data.push_back(tie(S,P,i));
    }
    sort(data.begin(),data.end());

    for(int i=0;i<N;i++){
        cout<<get<2>(data.at(i))<<endl;
    }
}

Measured memory_bytes: 256
import scala.collection.JavaConverters._

object Main extends App {
  val scanner = new java.util.Scanner(System.in).asScala

  val data = scanner.map { x =>
    val y = scanner.next
    (x.toInt, y.toInt)
  }.takeWhile(t => !(t._1 == 0 && t._2 == 0)).toList

  data.foreach {
    case (x, y) =>
      val result = if(x < y) {
          s"$x $y"
        } else {
          s"$y $x"
        }
      println(result)
  }
}

Measured memory_bytes: 56960
N, A, B, C, D = map(int, input().split(' '))
S = input()

flag = True
isSharp = False
for i in range(A, max(C, D)):
    if S[i] == '#':
        if isSharp is False:
            isSharp = True
        else:
            flag = False
            break
    else:
        isSharp = False

if D < C:
    cnt = 0
    isCons = False
    for i in range(B-2, D+1):
        if S[i] == '.':
            cnt += 1
            if cnt == 3:
                isCons = True
                break
        else:
            cnt = 0
    if isCons is False:
        flag = False

if flag is True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3572
n, a, b, c, d = [int(i) for i in input().split()]
s = input()
res = "Yes"
e = max(c,d)
if "##" in s[a-1:e-1]:
	res = "No"
elif c > d:
	if "..." not in s[b-2:d+1]:
		res = "No"
print(res)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  string S,T;
  cin >> S >> T;
  int N = S.size();
  bool ans = true;
  rep(i,N)
  {
    if(S[i]!=T[i])
    {
      ans = false;
    }
  }
  if(ans==true)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
// const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse

// UnionFind tree(n);  と宣言

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        siz.assign(sz_, 1LL);  // assign: 再代入
        par.resize(sz_);  // resize: 再確保
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

map<P,int> ma;

int main () {

    int n,k,l;cin>>n>>k>>l;

    UnionFind tree1(n);
    UnionFind tree2(n);

    rep(i,k) {
        ll p,q;cin>>p>>q;
        p--;q--;
        if (!tree1.issame(p,q)) tree1.merge(p,q);
    }

    rep(i,l) {
        ll p,q;cin>>p>>q;
        p--;q--;
        if (!tree2.issame(p,q)) tree2.merge(p,q);
    }

    for (ll i =0;i<n;i++) {
        ma[P(tree1.root(i),tree2.root(i))]++;
    }

    for (ll i=0;i<n;i++) {
        cout<<ma[P(tree1.root(i),tree2.root(i))]<<" ";
        if (i==n-1) cout<<endl;
    }

}

Measured memory_bytes: 18048
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n;
	cin >> n;
	vector<int> d(n);
	for(int i = 0; i < n; i++){
		cin >> d[i];
	}
	sort(all(d));
	reverse(all(d));
	int ans = 1;
	for(int i = 1; i < n; i++){
		if(d[i] != d[i-1]) ans++;
	}
	cout << ans << endl;

	return 0;
}

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

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)998244353;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N, s = 0, ans = 1;
  cin >> N;
  vector<int> a(N + 1, 0);
  for (int i = 1; i <= N; i++) {
    cin >> a[i];
    s += a[i];
    ans = (ans * 3) % MOD;
  }

  static int dp[310][90010];
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;

  for (int i = 1; i <= N; i++) {
    for (int r = 0; r <= s; r++) {
      dp[i][r] = (dp[i][r] + dp[i - 1][r] * 2 % MOD) % MOD;
      if (r - a[i] >= 0) dp[i][r] = (dp[i][r] + dp[i - 1][r - a[i]]) % MOD;
    }
  }

  int res = 0;
  for (int r = (s + 1) / 2; r <= s; r++) {
    res = (res + dp[N][r] * 3 % MOD) % MOD;
  }

  if (s % 2 == 0) {
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;

    for (int i = 1; i <= N; i++) {
      for (int r = 0; r <= s; r++) {
        dp[i][r] = (dp[i][r] + dp[i - 1][r]) % MOD;
        if (r - a[i] >= 0) dp[i][r] = (dp[i][r] + dp[i - 1][r - a[i]]) % MOD;
      }
    }

    res = (res - dp[N][s / 2] * 3 % MOD + MOD) % MOD;
  }

  cout << (ans - res % MOD + MOD) % MOD << endl;
  return 0;
}


Measured memory_bytes: 218240
#include <iostream>

using namespace std;

typedef long long ll;

ll dp[100005][3];

int main(int argc, char *argv[])
{
	int N, a[100005] = {0}, b[100005] = {0}, c[100005] = {0};

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	for (int i = 0; i < N; i++) {
		dp[i + 1][0] = max(dp[i][1] + a[i + 1], dp[i][2] + a[i + 1]);
		dp[i + 1][1] = max(dp[i][0] + b[i + 1], dp[i][2] + b[i + 1]);
		dp[i + 1][2] = max(dp[i][0] + c[i + 1], dp[i][1] + c[i + 1]);
	}

	cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;

	return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    float a, b; cin >> a >> b;
    cout << (int)ceil((a+b)/2) << endl;
}

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

    solve();

    return 0;
}

Measured memory_bytes: 384
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        m: usize,
        abc: [(i64, i64, i64); n],
        def: [(i64, i64, i64); m],
    }

    let mut mp_x = std::collections::BTreeMap::new();
    let mut mp_y = std::collections::BTreeMap::new();
    for &(a,b,c) in &abc {
        mp_x.insert(a, 0);
        mp_x.insert(b, 0);
        mp_y.insert(c, 0);
    }
    for &(d,e,f) in &def {
        mp_y.insert(e, 0);
        mp_y.insert(f, 0);
        mp_x.insert(d, 0);
    }
    mp_x.insert(0, 0);
    mp_y.insert(0, 0);
    
    let (mut xs, mut ys) = (vec![], vec![]);
    for (x, n) in &mut mp_x {
        *n = xs.len();
        xs.push(*x);
    }
    for (y, n) in &mut mp_y {
        *n = ys.len();
        ys.push(*y);
    }

    let w = xs.len() * 2;
    let h = ys.len() * 2;
    let mut map = vec![vec![true; w]; h];
    for (a,b,c) in abc {
        let a = mp_x.get(&a).unwrap() * 2;
        let b = mp_x.get(&b).unwrap() * 2;
        let c = mp_y.get(&c).unwrap() * 2;
        for x in a..=b {
            map[c][x] = false;
        }
    }
    for (d,e,f) in def {
        let e = mp_y.get(&e).unwrap() * 2;
        let f = mp_y.get(&f).unwrap() * 2;
        let d = mp_x.get(&d).unwrap() * 2;
        for y in e..=f {
            map[y][d] = false;
        }
    }
    
    let mut res = 0;
    let mut q = std::collections::VecDeque::new();
    let d = [(1, 0), (0, 1), (-1, 0), (0, -1)];
    q.push_back((*mp_x.get(&0).unwrap() * 2, *mp_y.get(&0).unwrap() * 2));
    while let Some(pos) = q.pop_front() {
        if pos.0 %2 != 0 && pos.1 %2 != 0 {
            let dx = xs[pos.0/2 + 1] - xs[pos.0/2];
            let dy = ys[pos.1/2 + 1] - ys[pos.1/2];
            res += dx*dy;
        }
        map[pos.1][pos.0] = false;
        for &d in &d {
            let (nx,ny) = (pos.0 as isize + d.0, pos.1 as isize + d.1);
            if nx < 0 || w as isize <= nx || ny < 0 || h as isize <= ny {
                continue;
            }
            let (nx, ny) = (nx as usize, ny as usize);
            if !map[ny][nx] {
                continue;
            }
            if nx == 0 || nx == w-1 || ny == 0 || ny == h-1 {
                println!("INF");
                return;
            }
            map[ny][nx] = false;
            q.push_back((nx, ny));
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 37724
import numpy as np
n, k = map(int,input().split())
p = list(map(int,input().split()))

e = [(i+1)/2 for i in p]
e = np.cumsum(e)
e = np.append(0,e)
ans = 0
for i in range(n-k+1):
    ans = max(e[i+k]-e[i],ans)
print(ans)

Measured memory_bytes: 33732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
const int inf=1000000001;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846

int main(){
	int key;
	string order;
	priority_queue<int> pq;
	while(1){
		cin>>order;
		if(order=="insert"){
			cin>>key;
			pq.push(key);
		}else if(order=="extract"){
			cout<<pq.top()<<endl;
			pq.pop();
		}else{
			break;
		}
	}
}

Measured memory_bytes: 7040
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;

#define PI 3.14159265358979323846264338327950L

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

	int A, B, H, M;
	cin >> A >> B >> H >> M;

	double mi = H * 60 + M;
	double a = M * 6;
	double b = mi / 2;

	double d = a - b;

	if (d < 0)d *= -1;//負だったら正にする
	if (d > 180.0)d = 360 - d;//小さいほうの角を取る

	double ans = A * A + B * B - 2 * A * B * cos(d*PI / 180);//余弦定理

	ans = pow(ans, 0.5);//平方根

	printf("%.20f\n", ans);
	return 0;
}



Measured memory_bytes: 4312
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll dp[2][100010] = {};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    ll a[110];
    rep(i,0,N) cin >> a[i];
    dp[0][0] = 1;
    ll cur = 0, nxt = 1;
    rep(i,0,N){
        rep(j,0,K+1) dp[nxt][j] = 0;
        rrep(j,K,0){
            dp[nxt][j] += dp[cur][j];
            dp[nxt][j] %= MOD;
            if(j + a[i] + 1 <= K+1) dp[nxt][j+a[i]+1] = (dp[nxt][j+a[i]+1] - dp[cur][j] + MOD) % MOD;
        }
        rep(j,0,K+1) (dp[nxt][j+1] += dp[nxt][j]) %= MOD;
        nxt ^= 1; cur ^= 1;
    }
    print(dp[cur][K]);
    

}


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



int main (void){
    ll n,m;
    cin >> n >> m;
    bool b[n+5]={};
    int a;

    rep(i,m){
        cin >> a;
        b[a]=true; 
    }

    ll dp[n+5]={};

    dp[0]=1;
    if(!b[1])dp[1]=1;

    for(int i=2;i<=n;i++){
        if(b[i]){
            dp[i]=0;
            continue;
        }

        dp[i]=(dp[i-1]+dp[i-2])%1000000007;
    }

    cout << dp[n] << endl;
   return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
   void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int N;
vec<vec<int>> G;

void dfs(int pos, int par, int cost, vec<int>& dist) {
   dist[pos] = cost;
   for (int to : G[pos]) {
      if (to != par) {
         dfs(to, pos, cost+1, dist);
      }
   }
}

int main() {
   cin >> N;
   G = vec<vec<int>>(N);
   rep (i, N-1) {
      int a, b;
      cin >> a >> b;
      a--, b--;
      G[a].push_back(b);
      G[b].push_back(a);
   }
   vec<int> dist1(N), dist2(N);
   dfs(0, -1, 0, dist1);
   dfs(N-1, -1, 0, dist2);

   int b = 0, w = 0;
   rep (i, N) {
      if (dist1[i] <= dist2[i]) {
         b++;
      } else {
         w++;
      }
   }

   if (b > w) {
      puts("Fennec");
   } else {
      puts("Snuke");
   }

   return 0;
}

Measured memory_bytes: 12800
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <iomanip>
#include <map>
#include <stack>
#include <sstream>

using namespace std;


int main()
 {
	
	unsigned long int n;
	cin >> n;
	
	int d = n / 1000 ;
	if (n % 1000 != 0)
	{
		int x = (d + 1) * 1000;
		cout << x-n;
	}
	else
	{
		int x = d  * 1000;
		cout << x - n;

	}
	
	return 0;


}

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

bool odd(int n){
    if(n%2==1) return true;
    else return false;
}

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int sum=a+b+c;
    if((odd(a)&&odd(b)&&!odd(c))||(!odd(a)&&!odd(b)&&odd(c))){
        a++;b++;
    }
    else if((odd(a)&&!odd(b)&&odd(c))||(!odd(a)&&odd(b)&&!odd(c))){
        a++;c++;
    }
    else if((!odd(a)&&odd(b)&&odd(c))||(odd(a)&&!odd(b)&&!odd(c))){
        b++;c++;
    }
    int m=max({a,b,c});
    int ans=(m*3-sum)/2;
  cout<<ans<<endl;
}

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

int n, a, b;
vector <int> h;

bool check(int steps) {
	int c = a - b;
	vector <int> t = h;
	for (int i = 0; i < n; i++) {
		t[i] = max(0LL, t[i] - 1LL * steps * b);
	}
	long long req = 0;
	for (int i = 0; i < n; i++) {
		req += (t[i] + c - 1) / c;
	}
	return req <= steps;
}

int main() {
	cin >> n >> a >> b;
	h.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	int l = 0, r = 1e9;
	while (l + 1 < r) {
		int mid = (l + r) >> 1;
		if (check(mid)) {
			r = mid;
		}
		else {
			l = mid;
		}
	}
	cout << r << endl;
	
  	return 0;
}


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

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
    #include "lib/dump.hpp"
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

signed main() {
    int n,m;cin>>n>>m;
    vi s(m), c(m);
    rep(i, m){
        cin>>s[i]>>c[i];
    }
    dump(s);
    dump(c);

    rep(x, 0, 1000){
        string t = to_string(x);
        dump(x);
        if (sz(t)==n){
            bool ok = true;
            rep(i, m){
                if (t[s[i]-1] != c[i]+'0') ok = false;
            }
            if (ok) {
                cout << x << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;

signed main()
{
  string a, b, c;
  cin >> a >> b >> c;
  printf("%c%c%c\n",
      toupper(a[0]), toupper(b[0]), toupper(c[0]));
  return 0;
}



Measured memory_bytes: 256
from collections import defaultdict, deque
import sys

INF = float('inf')
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


a, b, t = LI()
ans = 0
for i in range(1, t + 1):
    if i % a == 0:
        ans += b
print(ans)


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

int main(){
    bool f1 = false, f2 = false;
    string s; cin >> s;
    map<char,int> mp;

    for(auto c:s){
        mp[c]++;
    }

    if(mp['S'] > 0 && mp['N'] > 0 ||
        mp['S'] == 0 && mp['N'] == 0){
            f1 = true;
    }else{
        f1 = false;
    }
    if(mp['E'] > 0 && mp['W'] > 0 ||
        mp['E'] == 0 && mp['W'] == 0){
            f2 = true;
    }else{
        f2 = false;
    }

    cout << (f1 && f2 ? "Yes" : "No") << endl;
}

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

bool a(int x){
  string s=to_string(x);
  string t=s;
  reverse(t.begin(),t.end());
  if(s==t){
    return true;
  }
  else{
    return false;
  }
}

int main() {
  int n,m,ans=0;
  cin>>n>>m;
  for(int i=n;i<=m;i++){
    if(a(i)==true){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
a = (1..3).map { gets.split.map(&:to_i) }
n = gets.to_i
x = (1..n).map { gets.to_i }
(0...3).each { |i| (0...3).each { |j| a[i][j] = 0 if x.include?(a[i][j]) } }
puts('Yes') + exit if (0...3).any? { |i| (0...3).all? { |j| a[i][j] == 0 } }
puts('Yes') + exit if (0...3).any? { |j| (0...3).all? { |i| a[i][j] == 0 } }
puts('Yes') + exit if (0...3).all? { |i| a[i][i] == 0 }
puts('Yes') + exit if (0...3).all? { |i| a[i][2 - i] == 0 }
puts 'No'


Measured memory_bytes: 14304
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
#define ordered_set     tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> 

const long long INF = (long long) 1e11+1;
const long long mod = (long long) 100000000 ;
const long long hell = (long long) 1000000007;


ll power(ll x,ll y)
{
  ll res=1;
  while(y>0){
    if(y%2) res=(x*res);
    x=(x*x);    
    y=y/2;
  }
  return res;
}

ll modinv(ll x,ll m){
  return power(x,m-2);
}

void solve();


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

ll gcd(ll a,ll b)
{
    while( b != 0)
	{
		ll  t = b;
		b= a %t;
		a = t;
	}
	return a;
}

int main(){
   fastIO();
   int test;
   //cin>>test;
   test=1;

   while(test--)
   solve();
}


void solve(){
    int n;
    cin>>n;
    
    bool dp[n+1]={0};
    for(int i=3;i<=n;i+=3){
        dp[i]=true;
    }
    for(int i=5;i<=n;i+=5){
        dp[i]=true;
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        if(!dp[i])
        ans+=i;
    }
    cout<<ans;
}


///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/

// gcd of strings
/*
string getgcd(string s1,string s2){
    
    while(true){
        if(s1.length()<s2.length()){
            swap(s1,s2);
            continue;
        }
        if(s2.empty())
        return s1;
        
        if(s1.substr(0,s2.length())!=s2)
        return "";
        
        s1=s1.substr(s2.length());
    }
}
*/
/*
// for user defined DS hashmap and set
 
struct hash_pair{
      size_t operator()(const pair<int,pair<int,int>>& p) const{
          auto hash1=hash<int>()(p.F) ;
          auto hash2=hash<int>()(p.S.F) ;
          auto hash3=hash<int>()(p.S.S) ;
          return (hash1^hash2)^hash3;
      }  
};
struct pair_hash
{
	template <class T1, class T2>
	std::size_t operator () (std::pair<T1, T2> const &pair) const
	{
		std::size_t h1 = std::hash<T1>()(pair.first);
		std::size_t h2 = std::hash<T2>()(pair.second);

		return h1 ^ h2;
	}
};
*/



Measured memory_bytes: 4628
N = int(input())
A = list(map(int, input().split()))
S = sum(A)/N
S1 = sum(A)//N
if S - S1 >= 0.5:
  m = S1 + 1
else:
  m = S1
EX = sum((A[i]-m)*(A[i]-m) for i in range(N))
print(EX)

Measured memory_bytes: 3060
//header{{{
#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 setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
 
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(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	bool P = false,W = false,G = false,Y = false;
	rep(i,n){
		char s;
		cin >> s;
		P |= (s == 'P');
		W |= (s == 'W');
		G |= (s == 'G');
		Y |= (s == 'Y');
	}
	cout << (P+W+G+Y == 3 ? "Three\n" : "Four\n");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

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


double a, b,c;
double pi = 3.14159265358979;

int main(){
	cin >> a>> b >>c;
	c /= a;
	double ans = 45.0;
	double cnt = 45.0/2.0;
	if(c > a*b/2){
		for(int i = 0; i < 1000; i++){
			if(a*a*tan(pi * ans/180)/2 < a*b-c){
				ans += cnt;
			}
			else{
				ans -= cnt;
			}
			cnt /= 2.0;
		}
		
		printf("%.10f\n", ans);
	}
	else{
		for(int i = 0; i < 1000; i++){
			if(b*b*tan(pi * ans/180)/2 < c){
				ans += cnt;
			}
			else{
				ans -= cnt;
			}
			cnt /= 2.0;
		}
		
		printf("%.10f\n", 90-ans);
	}
	
	return 0;
}

Measured memory_bytes: 256
input_data = gets.chomp
n = input_data.to_i

while n != 0 do 
    upflug = false
    count = 0
    #初めの状態、両足が地面についている。
    preL = 'ld'
    preR = 'rd'
    #splitは配列になってします。
    g = gets.chomp.split(" ")
    n.times do |i|
        
        if upflug && g[i] == 'ld' && preR == 'rd'
            count += 1
            upflug = false
        end
    
        if upflug  && g[i] == 'rd' && preL == 'ld'
            count += 1
            upflug = false
        end
    
        if !upflug && g[i] == 'lu' && preR == 'ru'
            count += 1
            upflug = true
        end
    
        if !upflug && g[i] == 'ru' && preL == 'lu'
            count += 1
            upflug = true
        end
    
        if g[i] == 'lu' || g[i] == 'ld'
            preL = g[i]
        end
        if g[i] == 'ru' || g[i] == 'rd'
            preR = g[i]
        end
    end
    p count
    input_data = gets.chomp
    n = input_data.to_i 
end



Measured memory_bytes: 6880
#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
struct DATA{

  string name;
  int point;
  int num;
  
  bool operator<(const DATA& another) const{
  
    if(name==another.name){
    
      return point>another.point;
    }
    else return name<another.name;
  }
};
int main(){

  int N;
  cin>>N;
  vector<DATA>data(N);
  for(int i=0;i<=N-1;i++){
  
    cin>>data[i].name>>data[i].point;
    data[i].num=i+1;
  }
  sort(data.begin(),data.end());
  for(int i=0;i<=N-1;i++){
  
    cout<<data[i].num<<endl;
  }
  return 0;
}

Measured memory_bytes: 3596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		ALDS1_4_C();
	}
	public static void ALDS1_4_C() {
		Scanner sc = new Scanner(System.in);
		StringBuilder ans = new StringBuilder();
		HashSet<String> list = new HashSet<String>();
		int n = sc.nextInt();
		for(int i = 0; i < n; i++) {
			String order = sc.next();
			String dic = sc.next();
			if(order.equals("insert")) {
				list.add(dic);
			}else if(order.equals("find") ) {
				if(list.contains(dic)) {
					ans.append("yes\n");
				}else {
					ans.append("no\n");
				}
			}
		}
		System.out.print(ans);
	}

}



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

void add(vector<int> &a, int i, int x) {
    a[i-1] += x;
}

int getSum(vector<int> &a, int s, int t) {
    int sum = 0;
    for(int i=s-1; i<=t-1; ++i) {
        sum += a[i];
    }
    return sum;
}

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n, 0);

    vector<int> com, x, y;
    for(int i=0; i<q; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        com.push_back(a);
        x.push_back(b);
        y.push_back(c);
    }

    for(int i=0; i<q; ++i) {
        if(com[i] == 0) {
            add(a, x[i], y[i]);
        } else if(com[i] == 1) {
            cout << getSum(a, x[i], y[i]) << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 4644
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

map<long long,int> prime_factor(long long n){
	map<long long,int> ret;
	for(long long i = 2; i * i <= n; i++){
		while(n % i == 0){
			ret[i]++;
			n /= i;
		}
	}
	if(n != 1) ret[n]++;
	return ret;
}

int main(){
	ll n,p;
	cin >> n >> p;
	map<ll,int> mp = prime_factor(p);
	ll ans = 1;
	for(auto i : mp){
		int j = i.second / n;
		REP(k,j) ans *= i.first;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  long long n,p;cin>>n>>p;
  if(n==1){
    cout << p << endl;
    return 0;
  }
  long long nw = 0;
  long long ans = 1;
  bool lock = false;
  for(long long i = 2; p >= i*i; i++){
    if(p%i==0){
      nw++;
      if(i*i==p)nw++;
      if(!lock && nw >= n){
        nw = nw%n;
        ans *= i;
      }
      p/=i;
      i--;
    }else{
      lock = false;
      nw = 0;
    }
  }
  cout << ans << endl;
}
      

Measured memory_bytes: 256
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int x;
    cin >> x;
    int ans = 1;
    for(int i = 2; i <= sqrt(x); i++){
        int res = 1;
        while(res <= x){
            if(ans < res) ans = res;
            res*=i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3564
fun main(args:Array<String>){
    val str = readLine()!!
    when {
        str == "RRS" -> {print(2)}
        str == "SRR" -> {print(2)}
        str == "RRR" -> {print(3)}
        str == "SSS" -> {print(0)}
        else -> {print(1)}
    }
}

Measured memory_bytes: 34168
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
using namespace std;
long long MOD = 1e9 + 7;

long long N, A, B;
vector<long long> H;

bool judge(long long K) {
	long long time = 0;
	for (int n = 0; n < N; n++) {
		if (H[n] - B * K <= 0)continue;
		time += ceil((long double)(H[n] - B * K) / (A - B));
		if (time > K)return false;
	}
	return true;
}

long long sum = 0;

int main() {
	cin >> N >> A >> B;
	H.resize(N);
	for (int n = 0; n < N; n++) {
		cin >> H[n];
		sum += H[n];
	}
	long long s = 0, e = sum / B;
	while (e - s > 1) {
		long long m = (e + s) / 2;
		if (judge(m))e = m;
		else s = m;
	}
	cout << e << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>

using namespace std;

bool dp[6][100000 + 100];
int cost[6] = { 100, 101, 102, 103, 104, 105 };

int main() {
	int X;
	cin >> X;
	dp[0][0] = true;
	for (int i = 1; i * cost[0] <= X; i++) {
		dp[0][cost[0] * i] = true;
	}
	for (int i = 1; i < 6; i++) {
		for (int j = 0; j <= X; j++) {
			dp[i][j] = dp[i - 1][j];
			if (j - cost[i] >= 0 && dp[i - 1][j - cost[i]])dp[i][j] = true;
			if (j - cost[i] >= 0 && dp[i][j - cost[i]])dp[i][j] = true;
		}
	}
	cout << dp[5][X] << endl;
	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<queue> 
#include<algorithm>
#include<cmath>
#include<cstring>
#include<ctime>
#include<map>
#define int long long 
using namespace std;
const int maxn=2000006;
int n,m;
char s[maxn],t[maxn];
map<int,char>vis;
inline int gcd(int a,int b)
{
	if (b==0) return a;
	return gcd(b,a%b);
}
signed main()
{
	cin>>n>>m;
	scanf("%s",s+1);
	scanf("%s",t+1);
	int tmp=n*m/gcd(n,m);
	int ns=tmp/n,nt=tmp/m,cnt1=1,cnt2=1;
	for (int i=1;i<=n;i++)
	{
		
		vis[cnt1]=s[i];
		cnt1+=ns;	
	}
	for (int i=1;i<=m;i++)
	{	
		if (vis.count(cnt2)) 
		{
			if (vis[cnt2]!=t[i])
			{
				cout<<"-1"<<endl;
				return 0;
			}
		}
		cnt2+=nt;
	}
	cout<<tmp<<endl;
	return 0;
}

Measured memory_bytes: 6144
from collections import deque
from copy import deepcopy

def parse():
  N, M = map(int, input().split(" "))
  # A, B = [], []
  edges = [[] for n in range(N)]
  for m in range(M):
    a, b = map(int, input().split(" "))
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)
  return N, M, edges

def main():
  N, M, edges = parse()
  # print(N, M, edges)

  # visited = [False for n in range(N)]
  stack = deque([(0, edges[0], [False for n in range(N)])])
  ans = 0
  while len(stack) > 0:
    i, paths, visited = stack.pop()
    visited[i] = True
    for path in paths:
      # print("next_path:", path)
      if not visited[path]:
        stack.append((path, edges[path], deepcopy(visited)))
    
    # print(i, paths, visited)
    if not (False in visited):
      ans += 1

  print(ans)

if __name__ == "__main__":
  main()


Measured memory_bytes: 3436
fun main(args: Array<String>) {
    val (n, k, q) = readLine()!!.split(" ").map { it.toInt() }
    val counts = mutableMapOf<Int, Int>()
    repeat(q) {
        val a = readLine()!!.toInt()
        val cur = counts[a]
        val nex = if (cur != null) cur + 1 else 1
        counts[a] = nex
    }
    repeat(n) {
        var winC = counts[it + 1]
        if (winC == null) winC = 0
        if ((q - winC) >= k) {
            println("No")
        } else {
            println("Yes")
        }
    }
}


Measured memory_bytes: 47108
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

class City {
public:
	int no;
	int no1;
	int no2;
	int ans;
	City(int i, int a, int b) {
		no = i, no1 = a, no2 = b;
	}
};

int main() {
	int n, m;
	cin >> n >> m;
	vector<City> x;
	rep(i, m) {
		int p, y;
		cin >> p >> y;
		auto z = City(i, p, y);
		x.push_back(z);
	}
	sort(x.begin(), x.end(), [](const City &a, const City &b) {
		if (a.no1 != b.no1) {
			return a.no1 < b.no1;
		}
		else {
			return a.no2 < b.no2;
		}
	});
	
	rep(i, m) {
		auto a = x[i];
		if (i == 0) {
			x[i].ans = 1;
		}
		else {
			if (x[i].no1 == x[i - 1].no1) {
				x[i].ans = x[i - 1].ans + 1;
			}
			else {
				x[i].ans = 1;
			}
		}
	}

	sort(x.begin(), x.end(), [](const City &a, const City &b) {
		return a.no < b.no;
	});

	rep(i, m) {
		cout << std::setfill('0') << std::right << std::setw(6)
			<< x[i].no1;
		cout << std::setfill('0') << std::right << std::setw(6)
			<< x[i].ans << endl;
	}

}



Measured memory_bytes: 3184
a,b,c,d=map(int,input().split())
t=0
if a < c:
    t=c-a
else:
    t=a-c
if t<=d:
    print('Yes')
    exit()
if a < b:
    t=b-a
else:
    t=a-b
if t>d:
    print('No')
    exit()
if c < b:
    t=b-c
else:
    t=c-b
if t<=d:
    print('Yes')
else:
    print('No')

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

int luggageNum(std::vector<int> luggages, int trucks_num, int capacity) {
  int head = 0;
  for (int i = 0; i < trucks_num; i++) {
    int cur_load = 0;
    while (cur_load + luggages[head] <= capacity) {
      cur_load += luggages[head];
      head++;
      if (head == luggages.size()) {
        return head;
      }
    }
  }
  return head;
}

int main() {

  int n, k;
  std::cin >> n >> k;

  std::vector<int> luggages(n);

  int tmp;
  for (int i = 0; i < n; i++) {
    std::cin >> tmp;
    luggages[i] = tmp;
  }

  const long long max_p = 1000000000;

  long long left = 0;
  long long right = max_p;
  long long center = (left + right) / 2;

  while (left != center) {

    int v = luggageNum(luggages, k, center);

    if (v < n) {
      left = center;
      center = (left + right) / 2;
    } else {
      right = center;
      center = (left + right) / 2;
    }


  }

  int v = luggageNum(luggages, k, center);
  if (v < n) {
    std::cout << center + 1 << std::endl;
  } else {
    std::cout << center << std::endl;
  }

}



Measured memory_bytes: 3636