akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
//#define double long double
//#define double float
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 998244353; int MAX = 10000001;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;

long long fac[10000010], finv[10000010], inv[10000010];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}

void solve() {
	int N; cin >> N;
	MAX = N+1;
	COMinit();
	int al = bin_pow(3, N);
	int sb = 0;
	FOR(k, N / 2 + 1, N + 1) {
		int tmp = mult(COM(N, k), bin_pow(2, N - k));
		sb = add(sb, tmp);
	}
	sb = mult(sb, 2);
	al = sub(al, sb);
	print(al);
}

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


Measured memory_bytes: 234624
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int main(){
    int n,k;cin >> n >> k;
    vector<vector<vector<LL>>> dp(n+1,vector<vector<LL>> (n+1,vector<LL> (4*n*n,0)));
    dp[0][0][0]=1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int l = 0; l <= k; l++) {
                dp[i+1][j+1][l+2*(j+1)] = (dp[i+1][j+1][l+2*(j+1)] + dp[i][j][l])%mod;
                dp[i+1][j][l+2*j] = (dp[i+1][j][l+2*j] + (2*j+1)*dp[i][j][l])%mod;
                if(j) dp[i+1][j-1][l+2*(j-1)] = (dp[i+1][j-1][l+2*(j-1)] + j*j*dp[i][j][l])%mod;
            }
        }
    }
    cout << dp[n][0][k] << endl;
    return 0;
}


Measured memory_bytes: 207744
#include <bits/stdc++.h>
#define mdsaqib std::ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long
#define all(c) (c).begin(),(c).end()
#define endl '\n'
using namespace std;

vector <bool> V(1e5+5,false);
vector <vector <int> > A(1e5+5);

void dfs(int x){
    if(V[x])return;
    V[x]=true;
    for(int i=0;i<A[x].size();i++){
        dfs(A[x][i]);
    }
}

signed main(){
    mdsaqib;
    int n,m;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        A[a].push_back(b);
        A[b].push_back(a);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(V[i]==false){
            ans++;
            dfs(i);
        }
    }
    cout << ans-1;
}

Measured memory_bytes: 10064
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    // 参加人数
    int participant = sc.nextInt();
    // 日数と余り
    int date = sc.nextInt();
    int add = sc.nextInt();
    // 食べた数
    int sum = add;
    for(int i = 0; i < participant ; i++){
      int num = sc.nextInt();
      int eat = 0;
      for(int j =0; j < date ; j++){
        if(j * num + 1 <= date){
          eat++;
        }else{
          break;
        }
      }
      sum = sum + eat;
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 22612
<?php
    $n = trim(fgets(STDIN));

    if($n == 0) {
        echo 0;
        return;
    }

    $a = floor($n / 500);

    $n = $n - ($a * 500);

    if($n == 0) {
        echo ($a * 1000);
        return;
    }

    $b = floor($n / 5);

    echo ($a * 1000) + ($b * 5);
?>

Measured memory_bytes: 4984
n=int(input())
a=list(map(int,input().split()))
b=[]
c=[]
ans="DENIED"
for i in range(n):
  if a[i]%2==0:
    b.append(a[i])
for i in range(len(b)):
	if b[i]%3==0 or b[i]%5==0:
		c.append(b[i])  
if len(b)==len(c):
  ans="APPROVED"
print(ans)  

Measured memory_bytes: 3064
listA=[1,3,5,7,8,10,12]
listB=[4,6,9,11]
listC=[2]
x,y=map(int,input().split())
if x in listA and y in listA:
    print('Yes')
elif x in listB and y in listB:
    print('Yes')
elif x in listC and y in listC:
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
int main(){
	char r[128],m,s;
	int i,k=0;
	scanf("%s",r);
	m='A';
	for(i=0;i<strlen(r);i++){
		s=r[i];
		if(s-m<=0){
			k++;
		}
		m=s;
	}
	printf("%d\n",k);
    return 0;
}

Measured memory_bytes: 1844
def solve():
    dxys = [(-1,0), (1,0), (0,-1), (0,1)]

    H, W, K = map(int, input().split())
    Ass = ['#'*(W+2)] + ['#'+input()+'#' for _ in range(H)] + ['#'*(W+2)]

    def find2D(Sss, ch):
        for x, Ss in enumerate(Sss):
            y = Ss.find(ch)
            if y != -1:
                return (x, y)
        return (-1, -1)

    xS, yS = find2D(Ass, 'S')

    usedss = [[False]*(W+2) for _ in range(H+2)]
    usedss[xS][yS] = True
    vs = set([(xS, yS)])
    for _ in range(K):
        v2s = set()
        for x, y in vs:
            for dx, dy in dxys:
                x2, y2 = x+dx, y+dy
                if not usedss[x2][y2] and Ass[x2][y2] == '.':
                    usedss[x2][y2] = True
                    v2s.add((x2, y2))
        vs = v2s

    ans = 10**5
    for x in range(H):
        for y in range(W):
            if usedss[x+1][y+1]:
                dist = min(x, H-1-x, y, W-1-y)
                ans = min(ans, -(-dist//K)+1)
    print(ans)

solve()


Measured memory_bytes: 9076
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ld PI = 2 * acos(0.0);
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
const ll mod=1e9+7;
int MOD(int a)
{
    if(a<0)
        a+=mod;
    if(a>=mod)
        a%=mod;
    return a;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int n;cin>>n;
    int rem=cel(n,1000)*1000-n;
    cout<<rem;
    return 0;
}

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

int sum_digits(int X){
  int sum = 0;
  while (X > 0){
    sum += (X % 10);
    X /= 10;
  }
  return sum;
}

int main(){
  int N, A, B;
  int result = 0;
  cin >> N >> A >> B;

  for (int i = 1; i <= N; i++){
    if (sum_digits(i) >= A && sum_digits(i) <=B){
      result += i;
    }
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
let solve a b = (a + b) / 2 + if (a + b) mod 2 = 0 then 0 else 1

let read_ints () = read_line () |> Str.split (Str.regexp " ") |> List.map int_of_string

let _ =
  match read_ints () with
  | [a; b] -> solve a b |> string_of_int |> print_endline
  | _ -> ()

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int A = 0;
  int B = 0;
  for (int i = 0; i < N; i += 2) {
    A += vec.at(i);
  }
  for (int i = 0; i + 1 < N; i += 2) {
    B += vec.at(i+1);
  }
  cout << A - B << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long int movecheck(int x, int y, int h, int w, int check);

int b[500][500];
long int total=0;
int main(void){
    int h,w,flag=0;
    long int count=0;
    int check;
    char s;
    cin >> h >> w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> s;
            if(s=='.'){
                b[i][j]=1;
            }else{
                b[i][j]=0;
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(b[i][j]==0){
                flag=1;
//                cout << i << " " << j << endl;
                check=1;
//                for(int x=0;x<h;x++){
//                    for(int y=0;y<w;y++){
//                        b[x][y]=board[x][y];
//                    }
//                }
                b[i][j]=2;
                total=0;
                count+=total*movecheck(i,j,h,w,check);
//                cout << total << endl;
            }
        }
    }
    cout << count << endl;
    return 0;
}
//check=1='.' check=0='#'
long int movecheck(int x, int y, int h, int w, int check){
    int flag=0;
    long int answer=0;
    total+=check;
    if(x+1<h && b[x+1][y]==check){
        b[x+1][y]=2;
        answer+=movecheck(x+1,y,h,w,(check+1)%2)+check;
        flag=1;
    }
    if(y+1<w && b[x][y+1]==check){
        b[x][y+1]=2;
        answer+=movecheck(x,y+1,h,w,(check+1)%2)+check;
//        flag=1;
    }
    if(x-1>=0 && b[x-1][y]==check){
        b[x-1][y]=2;
        answer+=movecheck(x-1,y,h,w,(check+1)%2)+check;
//        flag=1;
    }
    if(y-1>=0 && b[x][y-1]==check){
        b[x][y-1]=2;
        answer+=movecheck(x,y-1,h,w,(check+1)%2)+check;
//        flag=1;
    }
//    if(flag) total+=check;
    return answer;
}

Measured memory_bytes: 16000
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N;
   cin >> N;
   int log[26];
   int tmp[26];
   string s;
   for (int i = 0; i < N; i++) {
      cin >> s;
      memset(tmp, 0, sizeof(tmp));
      for (int j = 0; j < s.size(); j++) {
         int id = (char)s[j] - 'a';
         tmp[id]++;
      }
      for (int j = 0; j < 26; j++) {
         if (i == 0) log[j] = tmp[j];
         else chmin(log[j], tmp[j]);
      }
   }
   for (int i = 0; i < 26; i++) {
      char now = 'a' + i;
      for (int j = 0; j < log[i]; j++) {
         cout << now;
      }
   }
   cout << endl;
   return 0;
}


Measured memory_bytes: 256
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

import string

def main():
    x = i_input()
    l = [0]
    for i in range(1,10**6):
        l.append(l[i-1]+i)

    for i,k in enumerate(l):
        if x <= k:
            print(i)
            exit()


if __name__=="__main__":
    main()


Measured memory_bytes: 150852
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int H,W,i,j;
  char a_H_W;
  cin>>H>>W;
  for(i=0;i<W+1;i++){
    cout<<"#";
  }
  cout<<"#"<<endl;
  for(i=0;i<H;i++){
    cout<<"#";
    for(int j=0;j<W;j++){
      cin>>a_H_W;
      cout<<a_H_W;
    }
    cout<<"#"<<endl;
  }
  for(i=0;i<W+1;i++){
    cout<<"#";
  }
  cout<<"#"<<endl;
}
 


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define debug(x) cout<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
const int inf=0x3f3f3f3f;
const int maxn=2e6+10;
ll dp[maxn];
int main()
{
   ll n;
   cin>>n;
    queue<string>que;
    for(int i=1;i<=9;i++)
    {
        string s=to_string(i);
        que.push(s);
    }
    int cnt=0;
    while(!que.empty())
    {
        string cur=que.front();
        que.pop();
        int len=cur.size();
        cnt++;
        if(cnt==n) {
            cout<<cur<<endl;
            return 0;
        }
        int x=cur[len-1]-'0';
        if(x==0) que.push(cur+"0"),que.push(cur+"1");
        else if(x==9) que.push(cur+"8"),que.push(cur+"9");
        else 
        {
            que.push(cur+to_string(x-1));
            que.push(cur+to_string(x));
            que.push(cur+to_string(x+1));
        }
    }
   //system("pause");
   return 0;
}


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

const int MAX_N=2e5+10;

int a[MAX_N],N,K=0,last=0;

int main(){
	scanf("%d",&N);
	for(int i=0;i<N;i++) scanf("%d",&a[i]);
	bool flag=false;
	for(int i=0;i<N;i++) if(a[i]==1) flag=true;
	if(!flag){
		printf("-1\n");
		return 0;
	}
	for(int i=0;i<N;i++) if(a[i]==last+1) K++,last++;
	printf("%d\n",N-K);
	return 0;
}

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

int main()
{
	map <string,long long> p;
	string s;
	long long n,sum = 0;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> s;
		sort(s.begin(),s.end());
		if(p.count(s)) sum += p[s];
		p[s]++;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair < int , int > pii;
#define mpr make_pair
#define FS first
#define SC second
#define PB push_back
template < typename T > T MAX(T a,T b){return (a>b)?a:b;}
template < typename T > T MIN(T a,T b){return (a<b)?a:b;}
template < typename T > void UMAX(T &a,T b){a=(a>b?a:b);}
template < typename T > void UMIN(T &a,T b){a=(a<b?a:b);}
LL readint(){
	char c=getchar();
	LL ret=0ll;
	bool neg=0;
	while(!(c>='0' && c<='9')){
		if(c=='-') neg=1;
		c=getchar();
	}
	while(c>='0' && c<='9'){
		ret=ret*10ll+(LL)(c-'0');
		c=getchar();
	}
	return neg?-ret:ret;
}
void putint(LL v){
	if(v<0){
		putchar('-');
		v=-v;
	}
	if(!v){
		putchar('0');
		return;
	}
	if(v>=10ll) putint(v/10ll);
	putchar('0'+(v%10ll));
}
const int MX=100001;
bool notp[MX+5];
vector < int > prms;
void prec(){
	int i,j,t;
	for(i=2;i<=MX;++i){
		if(!notp[i]){
			prms.push_back(i);
		}
		for(j=0;j<(int)prms.size() && (t=i*prms[j])<=MX;++j){
			notp[t]=1;
			if(!(i%prms[j])) break;
		}
	}
}
int n;
LL a[505][505];
LL gcd(LL a,LL b){
	if(!b) return a;
	return gcd(b,a%b);
}
LL lcm(LL a,LL b){
	return a/gcd(a,b)*b;
}
const int dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
map < LL , bool > mp;
int main(){
	int i,j,k;
	prec();
	n=readint();
	for(i=0;i<n;++i){
		for(j=0;j<n;++j){
			if(!((i+j)&1)) continue;
			int x=(i+j)/2,y=(i-j+n-1)/2;
			a[i][j]=(LL)prms[x]*prms[y+n-1];
		}
	}
	for(i=n-1;i>=0;--i){
		for(j=n-1;j>=0;--j){
			if(a[i][j]) continue;
			a[i][j]=1;
			LL stp=1;
			for(k=0;k<4;++k){
				if(i+dx[k]>=0 && i+dx[k]<n && j+dy[k]>=0 && j+dy[k]<n){
					stp=lcm(stp,a[i+dx[k]][j+dy[k]]);
				}
			}
			a[i][j]+=stp;
			while(mp.count(a[i][j])) a[i][j]+=stp;
			mp[a[i][j]]=1;
		}
	}
	for(i=0;i<n;++i){
		for(j=0;j<n;++j){
			printf("%lld ",a[i][j]);
		}
		printf("\n");
	}
	return 0;
}

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

int main(){
  int N;
    cin >> N;
  vector<char> X(10000);

  for(int i=0;i<10000;i++){
    cin >> X.at(i);
    if(X.at(i) != '\0'){
      cout << char(int('A')+ (int(X.at(i) - 'A') + N)%26);
    }else{
      break;
    }
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 1000000007;
const int MOD = (int)1e9+7;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
int dy[4] = {-2, -1};
int dx[4] = {-1, -2};

int main(void) {
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("in.txt", "r", stdin);
	int q;
	cin >> q;
	priority_queue<ll, vl, less<ll> > maxHeap;
	priority_queue<ll, vl, greater<ll> > minHeap;
	ll maxHeapTotal = 0;
	ll minHeapTotal = 0;
	ll B = 0;
	rep(query, 0, q) {
		int flag;
		cin >> flag;
		if(flag == 2) {
			ll mean = maxHeap.top();
			ll total = (maxHeap.size() * mean) - maxHeapTotal;
			total += minHeapTotal - (minHeap.size() * mean);
			total += B;
			cout << mean << ' ' << total << endl;
			continue;
		}

		ll a, b;
		cin >> a >> b;
		B += b;

		if(minHeap.size() == maxHeap.size()) {
			maxHeap.push(a);
			maxHeapTotal += a;
		} else {
			minHeap.push(a);
			minHeapTotal += a;
		}

		if(!minHeap.empty() && !maxHeap.empty() && minHeap.top() < maxHeap.top()) {
				ll x = maxHeap.top(), y = minHeap.top();
				maxHeap.pop(); minHeap.pop();
				maxHeap.push(y);
				minHeap.push(x);
				maxHeapTotal = maxHeapTotal - x + y;
				minHeapTotal = minHeapTotal - y + x;
		}
	}
	return 0;
}


Measured memory_bytes: 3828
d = tuple([1] + [6**i for i in range(1, 7)] + [9**i for i in range(1, 6)])
M = 10**5+1
B = [float("inf")]*M
B[0] = 0
for i in range(M):
  for j in d:
    if i+j < M:
      B[i+j] = min(B[i+j], B[i]+1)
n = int(input())
print(B[n])

Measured memory_bytes: 3956
def profit(xs, n, F, P):
    return sum([P[i][sum(map(lambda x: x[0]*x[1], zip(xs, F[i])))] for i in range(n)])


def vector(k):
    return [1 if k & 1 << i else 0 for i in range(10)]


def foo(n, F, P):
    return max([profit(vector(pat), n, F, P) for pat in range(1, 1024)])


if __name__ == "__main__":
    n = int(input())
    F = {}
    P = {}
    for i in range(n):
        F[i] = list(map(int, input().split()))
    for i in range(n):
        P[i] = list(map(int, input().split()))
        
    print(foo(n, F, P))

Measured memory_bytes: 3188
#include <cstdio>
#include <set>
using namespace std;
typedef long long ll;
const int N = 505;
int n, tail;
ll ans[N][N];
int pri[N * N];
bool isNot[N * N];
void Sieve() {
	for (int i = 2; i <= 100000; ++i) {
		if (!isNot[i])
			pri[++tail] = i;
		for (int j = 1; j <= tail && pri[j] * i <= n * n; ++j) {
			isNot[pri[j] * i] = 1;
			if (i % pri[j] == 0)
				continue ;
		}
	}
}
ll gcd(ll x, ll y) { return (!x) ? (y) : gcd(y % x, x); }
ll lcm(ll x, ll y) { return (!x || !y) ? (x | y) : (x / gcd(x, y) * y); }
//这个地方需要先除 gcd，在乘 y，否则 x * y会爆 long long 
int PA[N], PB[N];
int main() {
	scanf("%d", &n);
	if (n == 2) {
		printf("4 7\n23 10\n");
		return 0;
	}
	Sieve();
	for (int i = 1; i <= n; ++i) {
		PA[i] = pri[i];
		PB[i] = pri[i + n];
	}
	int cnt = 0;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j)
			if ((i & 1) == (j & 1)) {
				ll tmp = 1ll * PA[(i + j) / 2] * PB[(i - j) / 2 + (n + 1) / 2];
				ans[i][j] = tmp;
			}
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j) {
			if ((i & 1) != (j & 1)) {
				ll tmp = lcm(lcm(ans[i - 1][j], ans[i + 1][j]), lcm(ans[i][j - 1], ans[i][j + 1]));
				ans[i][j] = tmp + 1;
			}
		}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j)
			printf("%lld ", ans[i][j]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <stdio.h>
using namespace std;

bool contains(int v, int S[], int n){
    
    for (int i=0; i<n; i++) {
        if(S[i]==v) return true;
    }
    
    return false;
    
}

int main(int argc, const char * argv[]) {
    
    int n;
    scanf("%d", &n);
    
    int S[n];
    for(int i=0; i<n; i++){
        scanf("%d", &S[i]);
    }
    
    int q;
    scanf("%d", &q);
    
    int T[q];
    for(int i=0; i<q; i++){
        scanf("%d", &T[i]);
    }
    
    //search
    int count = 0;
    for(int i=0; i<q; i++){
        if(contains(T[i], S, n)){
            count++;
        }
    }
    
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 3184
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>
#include <map>

using namespace std;



int main(int argc, const char * argv[]) {
  long n;
  int bi;
  cin >> n;
  vector<int> h(n), x(n), y(n);
  for(int i = 0; i <n; i++){
    cin >> x[i] >> y[i] >> h[i];
    if(h[i] > 0){
      bi = i;
    }
  }

  int ch;
  for(int i = 0; i <= 100; i++){
    for(int j = 0; j <= 100; j++){
      ch = h[bi] + abs(x[bi] - i) + abs(y[bi] - j);
      bool check = true;
      for(int k = 0; k < n; k++){
        if(h[k] > 0 && ch - h[k] != abs(x[k] - i) + abs(y[k] - j)){
          check = false;
        }
        if(h[k] == 0 && ch > abs(x[k] - i) + abs(y[k] - j)){
          check = false;
        }
      }
      if(check){
        cout << i << " " << j << " " << ch << endl;
        return 0;
      }
    }
  }
  return 0;
  
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;
#define debug(x) cerr << #x << ": " << (x) << "\n";

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

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

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

  int k;
  cin >> k;

  string ans;
  int cnt = 0;
  queue<string> q;
  rep(i, 1, 10) {
    char ch = i + '0';
    string s = "";
    s += ch;
    q.push(s);
  }
  while (cnt <= k) {
    string s2 = q.front(); q.pop();
    cnt++;
    if (cnt == k) {
      ans = s2;
      break;
    }
    char last = s2[s2.size()-1];
    int num = last - '0';
    if (num == 0) {
      q.push(s2+'0');
      q.push(s2+'1');
    } else if (num == 9) {
      q.push(s2+'8');
      q.push(s2+'9');
    } else {
      char a = (num-1) + '0';
      char b = (num) + '0';
      char c = (num+1) + '0';
      q.push(s2+a);
      q.push(s2+b);
      q.push(s2+c);
    }
  }

  cout << ans << endl;




  return 0;
};


Measured memory_bytes: 13824
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    n = ini()
    c = 0
    for i in range(n):
        x, y = inl()
        if x == y:
            c += 1
        else:
            c = 0
        if c == 3:
            return True
    return False


print("Yes" if solve() else "No")


Measured memory_bytes: 9196
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		long k = in.nextLong();
		long[] a = new long[n];
		for(int i=0;i<n;i++) {
			a[i] = in.nextLong();
		}
		int digit = 0;
		while((k>>digit)>0) {
			digit++;
		}
		boolean free = false;
		long ans = 0;
		for(int i=digit-1;i>=0;i--) {
			if(free) {
				int count0 = 0;
				int count1 = 0;
				for(int j=0;j<n;j++) {
					if(((a[j]>>i)&1)==0) count0++;
					else count1++;
				}
				ans += Math.max(count0, count1)*(1L<<i);
			}else {
				if(((k>>i)&1)==1) {
					int count0 = 0;
					int count1 = 0;
					for(int j=0;j<n;j++) {
						if(((a[j]>>i)&1)==0) count0++;
						else count1++;
					}
					if(count1>=count0) {
						ans += count1*(1L<<i);
						free = true;
					}else {
						ans += count0*(1L<<i);
					}
				}else {
					int count1 = 0;
					for(int j=0;j<n;j++) {
						if(((a[j]>>i)&1)==1) count1++;
					}
					ans += count1*(1L<<i);
				}
			}
		}
		for(int i=digit;i<64;i++) {
			int count1 = 0;
			for(int j=0;j<n;j++) {
				if(((a[j]>>i)&1)==1) count1++;
			}
			ans += count1*(1L<<i);
		}
		
		System.out.println(ans);
		in.close();
	}

}


Measured memory_bytes: 59304
n,k=map(int,input().split())
sum1=sum(range(k,k+2*n))
sum2=sum(range(k+2*n,k+3*n))
if sum1<=sum2 and k-1<=n//2:
  arr1=set([k+i for i in range(n)])
  arr2=set([k+n+i for i in range(n)])
  ans1=[]
  for i in range(k-1):
    ans1.append([k+i,k+2*n-2-2*i,2*k+2*n-2-i])
    arr1.discard(k+i)
    arr2.discard(k+2*n-2-2*i)
  arr1=list(arr1)
  arr2=list(arr2)
  arr2=sorted(arr2,reverse=True)
  ans2=[]
  for i in range(n-(k-1)):
    ans2.append([arr1[i],arr2[i],arr1[i]+arr2[i]])
  ans2=sorted(ans2,key=lambda x:x[2])
  for i in range(1,n-(k-1)):
    if ans2[i][2]<=ans2[i-1][2]:
      ans2[i][2]=ans2[i-1][2]+1
  ans=ans1+ans2
  for a,b,c in ans:
    print(a,b,c)
else:
  print(-1)

Measured memory_bytes: 28120
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long h,w,i,ans=1e9;
  cin >> h >> w;
  if (h%3==0||w%3==0){
    cout << 0 << endl;
    return 0;
  }
  long a,b,c;
  for (i=1;i<=h/2;i++){
    a=i*w;
    if (((h-i)*w)%2==0) b=c=(h-i)*w/2;
    else if (h-i>w){
      b=w*(h-i-1)/2;
      c=w*(h-i+1)/2;
    }else{
      b=(w-1)*(h-i)/2;
      c=(w+1)*(h-i)/2;
    }
    ans=min(ans,max({a,b,c})-min({a,b,c}));
  }
  for (i=1;i<=w/2;i++){
    a=i*h;
    if ((h*(w-i))%2==0) b=c=h*(w-i)/2;
    else if (w-i>h){
      b=h*(w-i-1)/2;
      c=h*(w-i+1)/2;
    }else{
      b=(h-1)*(w-i)/2;
      c=(h+1)*(w-i)/2;
    }
    ans=min(ans,max({a,b,c})-min({a,b,c}));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		if(a.equals(b)){
			System.out.println("H");
		}else{
			System.out.print("D");
		}
	}
}

Measured memory_bytes: 23888
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip	;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	ll a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	ll t=ceil(d*100./b)+ceil(e*100./c);
	if(t>a)cout<<-1<<endl;
	else cout<<a-t<<endl;
}
 
 

Measured memory_bytes: 1164
#include<stdio.h>
int main(){
    int a,b,c[5],cnt=0,i;
    scanf("%d%d",&a,&b);
    for(i=0;a<=b;a++){
        c[4]=a%10;
        c[3]=(a/10)%10;
        c[2]=(a/100)%10;
        c[1]=(a/1000)%10;
        c[0]=(a/10000)%10;
        if((c[4]==c[0])&&(c[3]==c[1])){
            cnt++;
        }
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;

#define REP(i, n) for (int (i) = 0; (i) < (int)(n); ++(i))
#define ALL(s) (s).begin(),(s).end()
#define EACH(i,s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T> ostream& operator<<(ostream &s, set<T> P) {s<<"{ ";for(__typeof__(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<*it;}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(__typeof__(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}

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



const long long INF = 1LL<<59;
const int MAX = 4010;

int N;
long long w[MAX];
long long sum[MAX];
long long dp[MAX][MAX];
int kdp[MAX][MAX];

int main() {
    while (cin >> N) {
        for (int i = 0; i < N; ++i) cin >> w[i];
        
        sum[0] = 0;
        for (int i = 0; i < N; ++i) sum[i+1] = sum[i] + w[i];
        for (int i = 0; i < MAX; ++i) for (int j = i; j < MAX; ++j) { dp[i][j] = INF; }
        for (int i = 0; i < MAX; ++i) { dp[i][i+1] = w[i]; kdp[i][i+1] = i; }
        
        for (int b = 2; b <= N; ++b) {
            for (int i = 0; i+b <= N; ++i) {
                int j = i + b;

                for (int k = kdp[i][j-1]; k <= kdp[i+1][j]; ++k) {
                    if (chmin(dp[i][j], dp[i][k] + dp[k][j] + sum[j] - sum[i])) 
                        kdp[i][j] = k;
                }
            }
        }

    cout << dp[0][N] - sum[N] << endl;
    }
    
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair< int , int > P;
typedef tuple<int, int, int> T;
    


int main(){
    ll n,q;
    ll sum=0;
    cin>>n;
    vector<ll>a(n);
    map<ll,ll> d;
    rep(i,n){
        cin>>a[i];
        d[a[i]]++;
        sum+=a[i];
    }
    cin>>q;
    vector<ll>b(q);
    vector<ll>c(q);
    rep(i,q){
        cin>>b[i]>>c[i];
    }

    rep(i,q){
        sum-=d[b[i]]*b[i];
        sum+=d[b[i]]*c[i];
        d[c[i]]+=d[b[i]];
        d[b[i]]=0;
        cout<<sum<<endl;
    }
}
 

Measured memory_bytes: 11296
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
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; }
const long long INF = 1LL <<60;
typedef long long ll;
using namespace std;
 
ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
 
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}
 
ll choose2(ll n){
    return n*(n-1)/2;
}
 
int main() {
    ll n;
    cin>>n;
    vector<int> res;
 
    int cnt = 0;
 
    if(n == 1) {
        cout<<0<<endl;
        return 0;
    }
 
    for(ll a = 2; a * a <= n; a++){
        if(n % a != 0) continue;
 
        int ex = 0;
        int tmp = 0;
        while(n % a == 0){
            ex++;
            if(tmp < ex){
                cnt++;
                tmp = ex;
                ex = 0;
            }
            n /= a;
        }
    }
 
    if(n != 1) cnt++;
 
    cout<<cnt<<endl;
 
    return 0;
}

Measured memory_bytes: 3676
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=5000 +117;
const int MM=4000 +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int m,n;
LL s[NN][NN]={};
LL mi[NN]={};
LL fact[NN]={};
LL rev[NN]={};
int mod;
LL comp(LL n,LL m){
	return fact[n]*rev[m]%mod*rev[n-m]%mod;
}
LL ksm(LL a,LL b){
	LL ret=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1)ret=ret*a%mod;
	return ret;
}
void prefact(int n){
	fact[0]=1;
	for(int i=1;i<=n;++i)fact[i]=fact[i-1]*i%mod;
	rev[n]=ksm(fact[n],mod-2);
	for(int i=n;i>=1;--i)
		rev[i-1]=rev[i]*i%mod;
}
LL ding[NN]={};
int main(){
	//open();
	n=read();
	mod=read();
	prefact(n);
	s[0][0]=1;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=i;++j){
			s[i][j]=s[i-1][j-1]+s[i-1][j]*j;
			s[i][j]%=mod;
		}
	}
	mi[0]=1;
	ding[0]=1;
	for(int i=1;i<=n;++i){
		mi[i]=mi[i-1]*2%mod;
		ding[i]=ding[i-1]*2%(mod-1);
	}
	LL ans=0;
	for(int k=0;k<=n;++k){
		LL res=0;
		LL mimi=ksm(2,ding[n-k]);
		for(int j=0;j<=k;++j,mimi=mimi*mi[n-k]%mod){
			res+=(s[k][j+1]*(j+1)+s[k][j])%mod*mimi;
			res%=mod;
		}
		res*=comp(n,k);
		if(k&1)res*=-1;
		res%=mod;
		ans=(ans+res)%mod;
	}
	ans=(ans+mod)%mod;
	printf("%lld\n",ans);
	close();
	return 0;
}

Measured memory_bytes: 119296
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string S;

    cin >> S;
    if(S=="SUN")
    cout << 7;
    else if(S=="SAT")
               cout << 1;
     else if(S=="FRI")
              cout << 2;
     
      else if(S=="THU")
              cout << 3;
       else if(S=="WED")
                cout << 4;
       
        else if(S=="TUE")
              cout << 5;
        
         else if(S=="MON")
              cout << 6;
         
    
}


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

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    ll d=c-a-b;
    if(d*d-4*a*b>0 && d>0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine().trim());
		Job[] jobs = new Job[n];
		for(int i = 0; i < n; i++){
			StringTokenizer st = new StringTokenizer(br.readLine());
			int a = Integer.parseInt(st.nextToken());
			int b = Integer.parseInt(st.nextToken());
			jobs[i] = new Job(a, b);
		}
		Arrays.sort(jobs);
		int curr = Integer.MAX_VALUE;
		for(int i = n-1; i >= 0; i--){
			curr = Integer.min(jobs[i].b, curr) - jobs[i].a;
		}
		if(curr >= 0) System.out.println("Yes");
		else System.out.println("No");
	}
	static class Job implements Comparable<Job>{
		int a, b;
		public Job(int a, int b){
			this.a = a; this.b = b;
		}
		@Override
		public int compareTo(Job p){
			return b - p.b;
		}
		public String toString(){
			return a+" "+b;  
		}
	}
}


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

#define int long long int
#define double long long double
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define endl "\n"

const int N = 2e5 + 5;
int a[N], vis[N];

int32_t main()
{
	IOS;
	int n, k;
	cin >> n >> k;
	int cnt = 0;
	int town = 1;

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

	while (vis[town] == 0)
	{
		vis[town] = ++cnt;
		town = a[town];
		k--;
		if (k == 0)
		{
			cout << town << endl;
			return 0;
		}
	}
	//cout << cnt << " " << vis[town] << endl;
	int rem = cnt - vis[town] + 1;
	//cout << rem << endl;
	k %= rem;
	//cout << k << endl;
	for (int i = 1; i <= k; i++)
		town = a[town];
	cout << town << endl;


	return 0;
}

Measured memory_bytes: 6744
from collections import deque
def resolve():
    N, M = map(int, input().split())
    G = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map(lambda x: int(x) - 1, input().split())
        G[a].append(b)

    shortest = N + 1
    res = []
    for s in range(N):
        dist = [-1] * N
        pre = [-1] * N
        q = deque()
        q.append(s)
        dist[s] = 0
        while q:
            v = q.popleft()
            for to in G[v]:
                if dist[to] == -1:
                    dist[to] = dist[v] + 1
                    pre[to] = v
                    q.append(to)

        for t in range(N):
            if t == s or dist[t] == -1:
                continue
            for to in G[t]:
                if to == s:  # サイクルになっている頂点
                    tmp = [s]
                    cur = t
                    while cur != s:
                        tmp.append(cur)
                        cur = pre[cur]
                    if shortest > len(tmp):
                        shortest = len(tmp)
                        res = tmp

    if shortest == N + 1:
        print(-1)
    else:
        print(len(res))
        res.sort()
        for v in res:
            print(v + 1)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <typename T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const vector<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
void ce(void){cerr << '\n';}
template <typename T>
void ce(const T n){cerr << n << '\n';}
template <typename T>
void cesp(const T n){cerr << n << ' ';}
template <typename T>
void ce(initializer_list<T> v){for(T i : v) cesp(i); ce();}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18L+1;
constexpr ll MOD = 1e9L+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

int main(void){
	string s;
	cin >> s;
	ll n = s.size();

	Vec dp1(13), dp2(13);
	dp1[0] = 1;
	ll pos = 1;
	repr(i, n){
		dp2.assign(13, 0);
		if(s[i] != '?'){
			ll t = s[i] - '0';
			rep(j, 13){
				dp2[(j + pos * t) % 13] += dp1[j];
			}
			rep(j, 13){
				dp2[j] %= MOD;
			}
		}else{
			rep(k, 10){
				rep(j, 13){
					dp2[(j + pos * k) % 13] += dp1[j];
				}
			}
			rep(j, 13){
				dp2[j] %= MOD;
			}
		}
		pos *= 10;
		pos %= 13;
		swap(dp1, dp2);
		// co(dp1[5]);
	}
	co(dp1[5]);

	return 0;
}


Measured memory_bytes: 3728
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int n = scan.nextInt();
        int k = scan.nextInt();
        String s = scan.next();
        for(int i = 1; i < s.length() + 1; i++){
            if(i == k){
                if(s.charAt(k - 1) == 'A'){
                    System.out.print('a');
                }else if(s.charAt(k - 1) == 'B'){
                    System.out.print('b');
                }else{
                    System.out.print('c');
                }
            }else{
                System.out.print(s.charAt(i - 1));
            }
        }
    }
}

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

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

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

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

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

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

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

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

fn main() {
    input! {
        n: usize,
        s: String,
    }

    println!("{}", (0..n - 2).filter(|&i| &s[i..i + 3] == "ABC").count());
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main() {
    long  long int N;cin>>N;
    string S;cin>>S;
    long long int size,ans;
    size=S.length();
    ans=N;
    for(int i=0;i<size;i++){

            if(S[i]==S[i-1]){
                ans=(ans-1);
            }
        ans=ans;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 512
N = gets.to_i
A = N.times.map{ gets.split.map(&:to_i) }.unshift([])
ans = 0
completed = [true] + Array.new(N, false)
current_idx = (1..N).to_a
while completed.any?{|val| !val }
    ans += 1
    matched = Array.new(N+1, false)
    next_idx = []
    current_idx.each do |idx|
        next if completed[idx] || completed[A[idx][0]]
        if (!matched[idx] && !matched[A[idx][0]] && A[A[idx][0]][0] == idx)
            idx2 = A[idx].shift
            A[idx2].shift
            next_idx << idx
            next_idx << idx2
            matched[idx] = true
            matched[idx2] = true
            completed[idx] = true if A[idx].empty?
            completed[idx2] = true if A[idx2].empty?
        end
    end
    if next_idx.empty?
        p -1
        exit
    end
    current_idx = next_idx
end
p ans

Measured memory_bytes: 47836