akhauriyash/Code-Regression huggingface dataset:
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll ans[Max];
ll me[Max];
ll p[Max];
void make(int x)//建立
{
    me[x]=x;
}
int find(int x)//寻找根节点
{
    if(me[x]==x)return x;//自己就是根节点
    else find(me[x]);//不是，找爸爸的爸爸
}
int join(int x,int y)//合并
{
    int x1=find(x);
    int y1=find(y);
    if(x1<y1)//根节点不是一个
    {
        me[x1]=y1;
    }else{
    	me[y1]=x1;
	}
}

void solve(){
	ll n,m,k;
	cin>>n>>m>>k;
	vector<set<int>> block(n+1);
	vector<set<int>> f(n+1);
	rep(i,1,n+1)make(i);
	rep(i,0,m){
		int x,y;
		cin>>x>>y;
		if(x>y)swap(x,y);
		join(x,y);
		f[x].insert(y);
		f[y].insert(x);
	}
	rep(i,0,k){
		int x,y;
		cin>>x>>y;
		block[x].insert(y);
		block[y].insert(x);
	}
	int cnt=0;
	
	rep(i,1,n+1){
		p[find(i)]++;
	}
//	rep(i,1,n+1){
//		cout<<"i=="<<i<<" ";
//		cout<<p[find(i)]<<" ";
//		cout<<me[i]<<" \n";
//	}cout<<endl;
	rep(i,1,n+1){
		ll best = p[find(i)]-1;
	//	cout<<"i=="<<i<<" ";cout<<i<<" "<<best<<endl; 
		for(auto num:(block[i])){
			if(find(num)==find(i))best--;
		}
		for(auto num:(f[i])){
			if(find(num)==find(i))best--;
		}
		ans[i]=best;
	}
	rep(i,1,n+1)cout<<ans[i]<<" ";
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

  vector<ll> a(n);
  for (ll i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<ll> b(n);
  for (ll i = 0; i < n; ++i) {
    cin >> b[i];
  }
  vector<ll> c(n);
  for (ll i = 0; i < n; ++i) {
    cin >> c[i];
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());

  vector<ll> bsum(n+1);
  for (ll i = 1; i <= n; ++i) {
    auto itr = upper_bound(c.begin(), c.end(), b[i-1]);
    bsum[i] = c.end()-itr + bsum[i-1];
  }

  ll ans = 0;
  for (ll i = 0; i < n; ++i) {
    auto itr = upper_bound(b.begin(), b.end(), a[i]);
    ll bi = itr - b.begin();
    if (bi == n) continue;
    ans += bsum[n] - bsum[bi];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  fspcnt = 0;
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/
struct position{
  int x;
  int y;
};

int main(){
  int n;
  cin >> n;
  cout << n/3 << endl;
      
  
}

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



int main(){
    
    int n;cin>>n;
    vv faclist(19, vi (19, 0));
    
    rep(i,n){
        double a;cin>>a;
        ll anum = a*1e9+0.5;
        
        //llとして読み込み, 2と5の冪を計算
        int fac2 = -9, fac5 = -9;
        
        while( anum%2 == 0 ){
            fac2++;
            anum /= 2;
        }
        
        while( anum%5 == 0 ){
            fac5++;
            anum /= 5;
        }
        
        faclist[min(18,fac2+9)][min(18,fac5+9)]++;
    }
    
    //個数累積のリストを作る
    vv acclist = faclist;
    
    
    rep(i,19){
        for(int j=17; j>=0; j--){
            acclist[i][j] += acclist[i][j+1];
        }
    }
    rep(j,19){
        for(int i=17; i>=0; i--){
            acclist[i][j] += acclist[i+1][j];
        }
    }
    
    ll ans = 0;
    
    rep(i,19)rep(j,19){
        if(!faclist[i][j])continue;
        
        if(i>8 && j>8)ans += faclist[i][j] * (acclist[18-i][18-j]-1);
        else ans += faclist[i][j] * acclist[18-i][18-j];
    }
    
    cout << ans/2 << endl;
    return 0;
}

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

int main() {
	// your code goes here
	int a,b,d,r;
	cin>>a;
	cin>>b;
	d=a/b;
	r=a%b;
	double f;
	f=1.0*a/b;
	cout<<d<<" "<<r<<" ";
	printf("%.5lf\n",f);
	return 0;
}

Measured memory_bytes: 3252
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

const int mod=1e9+7;

int fact(int N){
    int res=1;
    for(int i=1;i<=N;i++) res=res*i%mod;
    return res;
}

signed main()
{
    int N,M; cin>>N>>M;
    int ans;
    if(N+1==M or M+1==N) ans=fact(N)*fact(M)%mod;
    if(N==M) ans=fact(N)*fact(M)*2%mod;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import qualified Data.Vector.Unboxed as V
import Data.Array.IArray (listArray, accumArray, (!))
import Data.Array.MArray
import Data.Array.ST (STUArray, runSTUArray)
import Data.Array.Unboxed (UArray)
import Data.List (sortOn, sortBy, unfoldr, partition)
import Data.Char (isSpace)
import Control.Monad.ST (ST)
import Control.Monad.Trans.State (StateT(..))
import qualified Data.ByteString.Char8 as B

-- utility functions

--   Input functions
readInt = B.readInt . B.dropWhile isSpace

readInts :: Int -> B.ByteString -> [Int]
readInts n = take n . unfoldr readInt

readIntsV :: Int -> B.ByteString -> V.Vector Int
readIntsV n = V.unfoldrN n readInt

readIntsA :: Int -> B.ByteString -> UArray Int Int
readIntsA n bs = runSTUArray $ do
  arr <- newArray_ (0,n-1)
  go arr 0 bs
  return arr
  where
    go :: STUArray s Int Int -> Int -> B.ByteString -> ST s ()
    go arr i bs
      | i==n = return ()
      | otherwise = do
        let Just (x,bs') = readInt bs
        writeArray arr i x
        go arr (i+1) bs'

readTsV :: Int -> B.ByteString -> V.Vector (Int,Int)
readTsV n = V.unfoldrN n $ runStateT ((,) <$> StateT readInt <*> StateT readInt)

readTs :: Int -> B.ByteString -> [(Int,Int)]
readTs n = take n . unfoldr readT where
  readT = runStateT ((,) <$> StateT readInt <*> StateT readInt)

-- main

pad x
  | x `mod` 10 == 0 = x
  | otherwise = x + 10 - (x`mod`10)

f x y
  | (x-1)`mod`10 < (y-1)`mod`10 = LT
  | (x-1)`mod`10 == (y-1)`mod`10 = EQ
  | otherwise = GT

main = do
  (least:xs) <- sortBy f . map read . words <$> getContents
  print $ sum (map pad xs) + least




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

int main() {
  int n;
  cin>>n;
  int d[n];
  int sum = 0;
  int max = 0;
  for(int i = 0; i < n; i++) {
    cin>>d[i];
    sum += d[i];
    if(d[i] > max) max = d[i];
  }
  
  if(max < sum - max) cout<<"Yes"<<"\n";
  else cout<<"No"<<"\n";
  
}
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  long long H,W;
  cin >> H >> W;
  
  long long Ans = 0;
  if(H == 1 || W ==1) Ans = 1;
  else{
  
  	if(H%2 == 0) Ans = (H/2)*W;
 	else if(W%2 == 0) Ans = ((H/2)+(H/2+1))*(W/2);
 	else if(W%2 == 1) Ans = ((H/2)+(H/2+1))*(W/2) + H/2 + 1;
  
  }
  cout << Ans << endl;
  
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int n,m,k,sx,sy,he,ta,qx[1000000],qy[1000000],d[1000][1000],nx,ny,qs[1000000],ans;
char s[1000][1000];
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,1,-1};
bool vis[1000][1000];
int main(){
	scanf("%d%d%d",&n,&m,&k);
	fo(i,1,n){
		scanf("%s",s[i]+1);
		fo(j,1,m)
			if (s[i][j]=='S'){
				sx=i;
				sy=j;
			}
	}
	he=ta=1;
	qx[1]=sx;qy[1]=sy;vis[sx][sy]=1;
	while (he<=ta){
		if (qs[he]>=k) break;
		fo(i,0,3){
			nx=qx[he]+dx[i];
			ny=qy[he]+dy[i];
			if (nx<1||ny<1||nx>n||ny>m||vis[nx][ny]||s[nx][ny]=='#') continue;
			//printf("vis %d %d\n",nx,ny);
			vis[nx][ny]=1;
			qx[++ta]=nx;
			qy[ta]=ny;
			qs[ta]=qs[he]+1;
			if (nx==1||ny==1||nx==n||ny==m){
				printf("1\n");
				return 0;
			}
		}
		he++;//!!!
	}
	
	he=1;
	while (he<=ta){
		fo(i,0,3){
			nx=qx[he]+dx[i];
			ny=qy[he]+dy[i];
			if (nx<1||ny<1||nx>n||ny>m||vis[nx][ny]) continue;
			vis[nx][ny]=1;
			d[nx][ny]=d[qx[he]][qy[he]]+1;
			qx[++ta]=nx;
			qy[ta]=ny;		
		}
		he++;
	}
	ans=n+m;
	fo(i,1,n){
		if (d[i][1]<ans) ans=d[i][1];
		if (d[i][m]<ans) ans=d[i][m];
	}
	fo(i,1,m){
		if (d[1][i]<ans) ans=d[1][i];
		if (d[n][i]<ans) ans=d[n][i];
	}
	ans=(ans-1)/k+2;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 16128
from itertools import accumulate
n, k = map(int, input().split())
p = list(map(int, input().split()))
p_acc = list(accumulate(p))
ans_max = p_acc[k-1]
ans = 0
if n > k:
    for i in range(n-k):
        ans_max = max(ans_max, p_acc[i+k] - p_acc[i])
        if p_acc[i+k] - p_acc[i] == ans_max:
            ans = i
    print((p_acc[ans+k] - p_acc[ans] + k) / 2)
else:
    print((sum(p) + n) / 2)



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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
const double PI=3.1415926535897932;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll a,b,x;

int main(){
    cin >> a >> b >> x;
    if(a <= x && x <= a+b){
        cout << "YES\n";
    }
    else{
        cout << "NO\n";
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,d,e,f;
	cin>>a>>b>>c;
	if (a==5&&b==5&&c==7||a==7&&b==5&&c==5||a==5&&b==7&&c==5)
	{
		cout<<"YES"<<endl;
	}
	else
	{
		cout<<"NO"<<endl;
	}
	return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)

using ll = long long;
using namespace std;

constexpr int INF = 2147483647;			  // 2 * 1e9
constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int d, n;
	cin >> d >> n;
	int ans = 1;
	REP(i, d)
	ans *= 100;
	ans *= (n == 100 ? 101 : n);
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	H,N = inputMap()
	A = inputList()

	tmp = 0
	for i in A:
		tmp += i

	if tmp >= H:
		print("Yes")
	else:
		print("No")


if __name__ == "__main__":
	main()


Measured memory_bytes: 55152
S=input()
T=input()

dicS={};dicT={}

f=True

for i in range(len(S)):
    c=S[i];d=T[i]
    
    if c in dicS and d!=dicS[c]:
        f=False
        break
    elif c not in dicS:
        dicS[c]=d
    
    if d in dicT and c!=dicT[d]:
        f=False
        break
    elif d not in dicT:
        dicT[d]=c 

print('Yes' if f else 'No')

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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

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

const ll SIZE = 1e5+10;

char c;

int main(){
    cin >> c;
    cout << static_cast<char>(c+1) << endl;
}

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

int n;
int a[2000005];
int c[20005];
int b[2000005];

int main()
{
    cin>>n;
    int i,j;
    memset(c,0,sizeof(c));
    for(i=0;i<n;i++){cin>>a[i];c[a[i]+10000]++;}
    for(i=1;i<=20001;i++){c[i]+=c[i-1];}
    for(i=n-1;i>=0;i--){
        b[c[a[i]+10000]]=a[i];
        c[a[i]+10000]--;
    }
    for(i=1;i<=n;i++){
        cout<<b[i];
        if(i!=n)cout<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 18824
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC

bool cube(int x) {
    int t = pow(x, 1.0/3);
    for (int i = t - 3; i <= t + 3; ++i) {
        if (i * i * i == x) 
            return 1;
    }   
    return 0;
}   
int kv(int x) {
    int t = sqrt(x);
    for (int i = t - 3; i <= t + 3; ++i)
        if (i * i == x)
            return i;
    return -1;             
}   

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n;
    cin >> n;

    map <int, int> d;

    bool have_cube = 0;
    vector <ii> a;
    while (n--) {
        int x;
        cin >> x;
        if (cube(x)) {
            have_cube = 1;
            continue;
        }   

        //cout << "read " << x << endl;

        int m1 = 1, m2 = 1;
        for (int i = 2; i * i * i <= x; ++i) {
            if (x % i == 0) {
                int pw = 0;
                while (x % i == 0) {
                    x /= i;
                    ++pw;
                }   
                pw %= 3;
                for (int j = 0; j < pw; ++j)
                    m1 *= i;  
                if (pw)
                    pw = 3 - pw;   
                for (int j = 0; j < pw; ++j)
                    m2 *= i;
            }   
        }   
        m1 *= x;

        //cout << "m1 : " << m1 << endl;

        ++d[m1];
        int t = kv(x);
        if (t != -1) {
            m2 *= t;
        }   
        else {
            m2 *= x * x;
        }   
        a.app(mp(m1, m2));
    }   

    int ans = 0;
    for (auto e : a) {
        ans += max(d[e.f], d[e.s]);

        //cout << e.f << ' ' << e.s << " : " << d[e.f] << ' ' << d[e.s] << endl;

        d.erase(e.f);
        d.erase(e.s);
    }   

    ans += have_cube;

    //cout << "have " << have_cube << endl;

    cout << ans << endl;
}

Measured memory_bytes: 8432
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;

int main() {
	string str1, str2, str3;
	int a = 0;
	cin >> str1 >> str2;
	str3 = str1 + str1;
	int n = str3.size();
	int l = str2.size();
	int k = 0;
	while (k<n && a == 0){
		if (str3[k] == str2[0]) {
			for (int i = 0; i < l ; ++i) {
				if (str3[(k + i) % n] != str2[i]) {
					a = 0;
					break;
				}
				else {
					a = 1;
					
				}

			}
		}
		++k;
	}
	if (a == 1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3216
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}

	int N;
	std::cin >> N;
	
	std::vector<int> vals = { 105, 135, 165, 189, 195 };

	auto it = std::upper_bound(vals.begin(), vals.end(), N);
	std::cout << it-vals.begin() << "\n";
}


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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    string ref1, ref2;
    int ans1 = 0, ans2 = 0;
    REP(i, n) {
        if(i % 2 == 0)
            ref1.push_back('1');
        else
            ref1.push_back('0');
        if(s[i] != ref1[i]) ans1++;
    }
    REP(i, n) {
        if(i % 2 != 0)
            ref2.push_back('1');
        else
            ref2.push_back('0');
        if(s[i] != ref2[i]) ans2++;
    }
    cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <queue>

using namespace std;

int main() {
	int n;
	cin >> n;
	
	int arr[n];
	for (int i = 0; i < n; ++i) {
		cin >> arr[i];
	}
	deque<int> result;
	for (int i = 0; i < n; ++i) {
		if (i % 2 != n % 2) {
			result.push_front(arr[i]);
		} else {
			result.push_back(arr[i]);
		}
	}
	
	for (int i = 0; i < n; ++i) {
		cout << result[i] << " ";
	}
	return 0;
}

Measured memory_bytes: 3840
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

using vi = vector<int>;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define show(x) cout << #x << " = " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()
#define YesNo {cout<<"Yes";}else{cout<<"No";}
#define YESNO {cout<<"YES";}else{cout<<"NO";}
#define v(T) vector<T>

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; }
template<class T> bool lcmp(const pair<T, T>& l, const pair<T, T>& r) {
  return l.first < r.first;
}
template<class T> istream& operator>>(istream& i, v(T)& v) {
  F0R(j, sz(v)) i >> v[j];
  return i;
}
template<class A, class B> istream& operator>>(istream& i, pair<A, B>& p) {
  return i >> p.first >> p.second;
}
template<class A, class B, class C> istream& operator>>(istream& i, tuple<A, B, C>& t) {
  return i >> get<0>(t) >> get<1>(t) >> get<2>(t);
}
template<class T> ostream& operator<<(ostream& o, const vector<T>& v) {
  F0R(i, v.size()) {
    o << v[i] << ' ';
  }
  o << newl;
  return o;
}
template<class T1, class T2> ostream& operator<<(ostream& o, const map<T1, T2>& m) {
  for (auto& p : m) {
    o << p.first << ": " << p.second << newl;
  }
  o << newl;
  return o;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  unordered_map<char, char> a, b;
  char c = 'a', d = 'a';
  string e, f;
  cin >> e >> f;
  auto f1 = [](auto& a, auto c, auto& e) {
    F0R(i, sz(e)) {
      if (a.find(e[i]) == a.end()) {
        a[e[i]] = c;
        c++;
      }
      e[i] = a[e[i]];
    }
  };
  f1(a, c, e);
  f1(b, d, f);
  if (e == f) YesNo;
}
#endif


Measured memory_bytes: 3892
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int map[][] = new int[N * 2][N * 2];
		int tmpx = 0;
		int tmpy = 0;
		for (int i = 0; i < N; i++) {
			tmpx = sc.nextInt();
			tmpy = sc.nextInt();
			map[tmpx][tmpy] = -1;
		}
		for (int i = 0; i < N; i++) {
			tmpx = sc.nextInt();
			tmpy = sc.nextInt();
			map[tmpx][tmpy] = 1;
		}
		int ans = 0;
		int tmp = 0;
		int diff = 0;
		int tmpk = 0;
		int tmpl = 0;

		for (int i = 0; i < 2 * N; i++) {
			for (int j = 0; j < 2 * N; j++) {
				if (map[i][j] != 1) {
					continue;
				}
				diff = 40000;
				tmp = 0;
				for (int k = i - 1; k > -1; k--) {
					for (int l = j - 1; l > -1; l--) {
						if (map[k][l] == -1) {
							if (diff > j - l) {
								diff = j - l;
								tmpk = k;
								tmpl = l;
								tmp = 1;
							}
						}
					}
				}
				if (tmp == 1) {
					ans += 1;
					map[tmpk][tmpl] = 0;
				}
			}
		}

		System.out.println(ans);
	}
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (int &x : a)
    cin >> x;

  bool ans = true;
  for (int &x : a)
  {
    if (x % 2 == 0)
    {
      if (x % 3 == 0 || x % 5 == 0)
        continue;
      else
        ans = false;
    }
  }
  cout << (ans ? "APPROVED" : "DENIED") << endl;
}

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

const int N = 1010;
const int M = 2010;
const int mod = 1e9 + 7;

struct edge {
    int to, next, w;
} e[N * 2];

int head[N], ecnt;

inline void adde(int from, int to, int w) {
    e[++ecnt] = (edge){to, head[from], w}, head[from] = ecnt;
    e[++ecnt] = (edge){from, head[to], w}, head[to] = ecnt;
}

int fa[N][11], mx[N][11], dep[N];

void dfs(int u, int f, int w) {
    fa[u][0] = f, dep[u] = dep[f] + 1, mx[u][0] = w;
    for (int i = 1; i <= 10; i++) {
        fa[u][i] = fa[fa[u][i - 1]][i - 1];
        mx[u][i] = max(mx[u][i - 1], mx[fa[u][i - 1]][i - 1]);
    }
    for (int i = head[u]; i; i = e[i].next)
        if (e[i].to != f) dfs(e[i].to, u, e[i].w);
}

inline int get(int a, int b) {
    if (dep[a] < dep[b]) swap(a, b);
    int res = 0;
    for (int i = 10; i >= 0; i--) if (dep[fa[a][i]] >= dep[b]) 
        res = max(res, mx[a][i]), a = fa[a][i];
    if (a == b) return res;
    for (int i = 10; i >= 0; i--) if (fa[a][i] != fa[b][i]) {
        res = max(res, mx[a][i]), a = fa[a][i];
        res = max(res, mx[b][i]), b = fa[b][i];
    }
    return max(res, max(mx[a][0], mx[b][0]));
}

int from[M], to[M], t[M], w[M], id[M], F[N], pw2[N];

int find(int x) {
    return x == F[x] ? x : F[x] = find(F[x]);
}

typedef long long LL;

int main() {
    int n, m; LL X; scanf("%d%d%lld", &n, &m, &X); 
    for (int i = 1; i <= n; i++) F[i] = i;
    for (int i = 1; i <= m; i++) 
        scanf("%d%d%d", &from[i], &to[i], &w[i]), id[i] = i;
    sort(id + 1, id + m + 1, [](int a, int b) {
        return w[a] < w[b];
    });
    LL mn = 0;
    for (int i = 1; i <= m; i++) {
        int a = from[id[i]], b = to[id[i]];
        if (find(a) != find(b)) 
            t[id[i]] = 1, adde(a, b, w[id[i]]), F[find(a)] = find(b), mn += w[id[i]];
    }
    if (X < mn) return puts("0"), 0;
    dfs(1, 0, 0), pw2[0] = 1;
    for (int i = 1; i <= m; i++) pw2[i] = pw2[i - 1] * 2 % mod;
    if (X == mn) {
        int a = 0, b = 0;
        for (int i = 1; i <= m; i++) if (!t[i]) {
            if (w[i] == get(from[i], to[i])) a++;
            else b++;
        }
        int res = (LL)(pw2[n - 1] - 2) * pw2[m - (n - 1)] % mod;
        res = (res + (LL)2 * (pw2[a] - 1) * pw2[b]) % mod;
        printf("%d\n", res);
    } else {
        int a = 0, b = 0;
        for (int i = 1; i <= m; i++) if (!t[i]) {
            int diff = w[i] - get(from[i], to[i]);
            if (diff == X - mn) a++;
            else if (diff > X - mn) b++;
        }
        printf("%lld\n", (LL)2 * (pw2[a] - 1) * pw2[b] % mod);
    }
    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#include "debug.cpp"
#endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  long double r; cin >> r;
  long double pi = 3.1415926535;
  long double ans = 2*pi*r;
  cout << fixed << setprecision(12) << ans << '\n';

  

  return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    for(i = 0;i <= n-1;++i){
        j = n-1 - i;
        ll tmin = i*c - j*d;
        ll tmax = i*d - j*c;
        if(tmin <= b-a && b-a <= tmax){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> dice = {{0, 3, 5, 2, 4, 0}, {4, 0, 1, 6, 0, 3}, {2, 6, 0, 0, 1, 5}, {5, 1, 0, 0, 6, 2}, {3, 0, 6, 1, 0, 4}, {0, 4, 2, 5, 3, 0}};
int main(){
  while (1){
    int n;
    cin >> n;
    if (n == 0){
      break;
    }
    vector<vector<int>> top(201, vector<int>(201, -1));
    vector<vector<int>> cnt(201, vector<int>(201, -1));
    for (int i = 0; i < n; i++){
      int t, f;
      cin >> t >> f;
      int y = 100, x = 100;
      int U = t;
      int F = f;
      int R = dice[t - 1][f - 1];
      int D = 7 - U;
      int L = 7 - R;
      int B = 7 - F;
      while (1){
        char c = '.';
        int mx = 0;
        if (F >= mx && cnt[y][x] > cnt[y - 1][x]){
          mx = F;
          c = 'F';
        }
        if (B >= mx && cnt[y][x] > cnt[y + 1][x]){
          mx = B;
          c = 'B';
        }
        if (L >= mx && cnt[y][x] > cnt[y][x - 1]){
          mx = L;
          c = 'L';
        }
        if (R >= mx && cnt[y][x] > cnt[y][x + 1]){
          mx = R;
          c = 'R';
        }
        if (mx >= 4){
          if (c == 'F'){
            tie(U, F, D, B) = make_tuple(B, U, F, D);
            y--;
          }
          if (c == 'B'){
            tie(U, F, D, B) = make_tuple(F, D, B, U);
            y++;
          }
          if (c == 'L'){
            tie(U, L, D, R) = make_tuple(R, U, L, D);
            x--;
          }
          if (c == 'R'){
            tie(U, L, D, R) = make_tuple(L, D, R, U);
            x++;
          }
        } else {
          break;
        }
      }
      cnt[y][x]++;
      top[y][x] = U;
    }
    vector<int> ans(6, 0);
    for (int i = 0; i <= 200; i++){
      for (int j = 0; j <= 200; j++){
        if (top[i][j] != -1){
          ans[top[i][j] - 1]++;
        }
      }
    }
    for (int i = 0; i < 6; i++){
      cout << ans[i];
      if (i < 5){
        cout << ' ';
      }
    }
    cout << endl;
  }
}


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

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

	std::string ans = "No";

	for (int i = 1; i < 10; i++){
		if (N % i == 0){
			A = i;
			B = N / i;

			if (B < 10){
				ans = "Yes";
				break;
			}
		}
	}


	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mod int(1e9+7)
#define N int(2e5+100)
#define ll long long int
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define si second
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(10);
   int k,a,b;
   cin>>k>>a>>b;
   if((b/k)-(a-1)/k){
      cout<<"OK\n";
   }else{
      cout<<"NG\n";
   }
   return 0;
}


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

int main() {
	int A, B, C, K;
	cin >> A >> B >> C >> K;

	bool flag = false;
	for (int i=0;i<=K;i++) {
		long B_tmp = B;
		long C_tmp = C;
		for (int j=0;j<i;j++) {
			B_tmp = 2*B_tmp;
		}
		for (int j=0;j<K-i;j++) {
			C_tmp = 2*C_tmp;
		}
		if ((A < B_tmp) && (B_tmp < C_tmp)) {
			flag = true;
		}
	}
	if (flag) {
		cout << "Yes" << endl;
	} else { // !flag
		cout << "No" << endl;
	}
}

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

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;

const char nl = '\n' ;
const ll MOD = 1e9 + 7;


int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   int x, y , z; cin >> x >> y >> z;

   int ans = 0;
   x = x - z;
   cout << x/(y+z) << nl;

   return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define int        long long
#define MOD        1000000007
#define MAX        100005
#define pb         push_back
#define mp         make_pair
#define pii        pair<int,int>
#define mii        map<int,int>
#define vi         vector<int>
#define ff         first
#define ss         second
#define T          int t;cin>>t;while(t--)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define umi        unordered_map<int,int>
#define maxheap    priority_queue<int>
#define minheap    priority_queue<int,vector<int>,greater<int> >
#define inp(n)     for(int i=0;i<n;i++)
#define N          200005
#define mxN		   2000005
#define all(v)		v.begin(),v.end()
#define lb(v,val)  (int)(lower_bound(v.begin(),v.end(),val)-v.begin())
#define ub(v,val)  (int)(upper_bound(v.begin(),v.end(),val)-v.begin())
using namespace std;
using namespace std::chrono;

int v[N];

void solve(){
	int k,n;
	cin >> k >> n;
	inp(n)cin>>v[i];
	sort(v,v+n);
	int ans = v[n-1]-v[0];
	for(int i=0;i<n-1;i++){
		ans = min(ans,k-v[i+1]+v[i]);
	}
	cout << ans;
}

signed main(){
/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif   */
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int t = 1,tt=0; 
	//cin >> t;
	while(t--){
	tt++;
	//cout << "Case #" <<tt<<": ";
	solve(); 
	cout << "\n";
	}
}




Measured memory_bytes: 1792
// Author : Nachiket Kanore
// Institute : PICT, Pune

#include <stdexcept>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cassert>
#include <cstring>
#include <cstdarg>
#include <cstdio>
#include <memory>
#include <random>
#include <cmath>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <complex>
#include <numeric>
#include <limits>
#include <bitset>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <array>
#include <list>
#include <map>
#include <set>

using namespace std;

#define int long long
#define endl '\n'
#define null nullptr
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
 
 
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
 
const int mod = 1e9+7;
const int inf = 1e18;

int32_t main(){
    FAST;

    string s;   cin >> s;

    if(s == "Sunny")
        cout << "Cloudy";
    else if(s == "Cloudy")
        cout << "Rainy";
    else 
        cout << "Sunny";

    return 0;
}

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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

template <unsigned long long mod> class modint {
public:
	unsigned long long v;
	modint(const long long x = 0) : v(x % mod) {}
	modint operator+(const modint rhs) { return modint(*this) += rhs; }
	modint operator-(const modint rhs) { return modint(*this) -= rhs; }
	modint operator*(const modint rhs) { return modint(*this) *= rhs; }
	modint operator/(const modint rhs) { return modint(*this) /= rhs; }
	modint operator-() { return modint(mod - this->v); }
	modint& operator+=(const modint rhs) {
		v += rhs.v;
		if (v >= mod) v -= mod;
		return *this;
	}
	modint& operator-=(const modint rhs) {
		if (v < rhs.v) v += mod;
		v -= rhs.v;
		return *this;
	}
	modint& operator*=(const modint rhs) {
		v = v * rhs.v % mod;
		return *this;
	}
	modint inverse(modint a) {
		unsigned long long exp = mod - 2;
		modint ret(1ULL);
		while (exp) {
			if (exp % 2) { ret *= a; }
			a *= a;
			exp >>= 1;
		}
		return ret;
	}
	modint& operator/=(modint rhs) {
		(*this) *= inverse(rhs);
		return *this;
	}
	friend ostream& operator<<(ostream& os, modint& u) {
		os << u.v;
		return (os);
	}
	friend istream& operator>>(istream& is, modint& u) {
		is >> u.v;
		return (is);
	}
};

const int MOD = 1000000007;
using mint = modint<MOD>;

class Solution {
public:
	void solve() {
		int n, x, y, z;
		cin >> n >> x >> y >> z;
		int m = 1 << (x+y+z);
		int mask = m-1;
		vector<vector<mint>> dp(n+2, vector<mint>(m, 0));
		dp[0][0] = 1;
		for(int i=0; i <= n; i++){
			for(int j=0; j < m; j++){
				if(dp[i][j].v == 0)continue;
				for(int k=1; k <= 10; k++){
					int t_mask = (((j << 1)|1) << (k-1)) & mask;
					int n_mask = 0;
					if(k != 1){
						n_mask |= ((1 << (k-1)) - 1) << (x);
						n_mask |= ((1 << (k-1)) - 1) << (y+x);
					}
					n_mask = ~n_mask;
					t_mask &= n_mask;
					if(t_mask & (m >> 1))continue;
					dp[i+1][t_mask] += dp[i][j];
				}
			}
		}
		mint ans = 1;
		for(int i=0; i < n; i++)ans *= 10;
		for(int i=0; i < m; i++)ans -= dp[n][i];
		cout << ans << "\n";
		
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 44416
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){
   int n,k;
   cin >> n >> k;
   int h[100010] = {0};
   rep(i,n) cin >> h[i];

   sort(h,h+n,greater<int>());

   int cnt = 0;
   rep(i,n){
      if(k <= h[i]) cnt++;
   }

   cout << cnt << endl;

   return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

const int MOD = 998244353;
ll modpow(ll x, ll n) {
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        ll h = modpow(x, n / 2);
        return h * h % MOD;
    } else {
        return x * modpow(x, n - 1) % MOD;
    }
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> a(N);
    int s = 0;
    REP(i, N) {
        cin >> a[i];
        s += a[i];
    }
    vector<vector<ll>> dp1(N + 1, vector<ll>(s + 1, 0));
    auto dp2 = dp1;
    dp1[0][0] = 1, dp2[0][0] = 1;
    REP(i, N) {
        REP(j, s + 1) {
            dp1[i + 1][j] += dp1[i][j] * 2;
            dp1[i + 1][j] %= MOD;
            dp2[i + 1][j] += dp2[i][j];
            dp2[i + 1][j] %= MOD;
            if (j - a[i] >= 0) {
                dp1[i + 1][j] += dp1[i][j - a[i]];
                dp1[i + 1][j] %= MOD;
                dp2[i + 1][j] += dp2[i][j - a[i]];
                dp2[i + 1][j] %= MOD;
            }
        }
    }
    ll res = modpow(3, N);
    REP(j, s + 1) {
        if (2 * j >= s) {
            res -= (dp1[N][j] * 3) % MOD;
            if (res < 0) {
                res += MOD;
            }
        }
    }
    if (s % 2 == 0) {
        res += dp2[N][s / 2] * 3;
        res %= MOD;
    }
    cout << res << endl;
    return 0;
}


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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;
#define pi 3.14159

typedef long long int ll;

int main() {

	IOS

	int r;
	cin >> r;

	cout << 2 * pi * r << endl;
	return 0;
}

Measured memory_bytes: 3804
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

int gcd(int x, int y) {
	return y ? gcd(y, x%y) : x;
}

signed main() {
	int A, B, C;
	cin >> A >> B >> C;

	
	cout << (((C % gcd(A, B) == 0) && C < B) ? "YES" : "NO") << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;

int main(){
  int s, w;
  cin >> s >> w;
  
  if (s > w)
    cout << "safe" << endl;
  else
    cout << "unsafe" << endl;
  
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(int, k);
	
	string s;
	int c = -1;
	function<void(int, int)> dfs = [&](int d, int p) {
		if(d == 0) { c++; return; }
		
		incID(i, -1, 10) {
			if(p == -1 && i ==  0) { continue; }
			if(p != -1 && i == -1) { continue; }
			
			if(p == -1 || abs(i - p) <= 1) {
				s += (i == -1 ? '-' : '0' + i);
				dfs(d - 1, i);
				if(c == k) { break; }
				s.pop_back();
			}
		}
	};
	dfs(10, -1);
	int x = 0;
	while(s[x] == '-') { x++; }
	OUT(s.substr(x));
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val S = readLine()!!.toString();
    val array = S.split(" ")
    var a = array[0].toLong()
    var b = array[1].toLong()
    var c = array[2].toLong()
    var d = array[3].toLong()

////    a = BigDecimal.TEN.pow(9).toLong()
////    b = BigDecimal.TEN.pow(9).toLong()
////    c = BigDecimal.TEN.pow(9).toLong()
////    d = BigDecimal.TEN.pow(9).toLong()
//
//    // 正負の場合分け
//    val ab = a * b
//    val cd = c * d
//
//    var aMinus = false
//    if (ab < 0) {
//        // a < 0, 0 < b
//        aMinus = true
//    } else {
//        // a , b < 0, 0 < a,b
//    }
//    if (b == 0L && a < 0) {
//        aMinus = true
//    }
//
//    var cMinus = false
//    if (cd < 0) {
//        cMinus = true
//    }
//    if (d == 0L && c < 0) {
//        cMinus = true
//    }
//
//    // a, c ともにマイナスのとき、
//    if (aMinus && cMinus) {
//        // ABS (a+c) と ABS (b+d)を比較して、大きな方のペアを採用する。
//        val absAplusC = abs(a) + abs(c)
//        val absBplusD = abs(b) + abs(d)
//
//        if (b == 0L) {
//            println(a * c)
//            return
//        }
//        if (d == 0L) {
//            println(a * c)
//            return
//        }
//
//        if (absAplusC < absBplusD) {
//            println(b * d)
//        } else {
//            println(a * c)
//        }
//        return
//    }

    // (a,b)および(b,d)がともに、正のセットか、負のセットであるとき
    // 単純に、a*c vs a*d vs b*c vs b*d
    val ac = a * c
    val ad = a * d
    val bc = b * c
    val bd = b * d

    val ints = mutableListOf<Long>(ac, ad, bc, bd)
    ints.sort()

    println(ints.last())
}

Measured memory_bytes: 36436
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */



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

    int n; cin >> n;
    cout << (n+1) / 2 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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() {
	ll a, b, c;
	cin >> a >> b >> c;

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

Measured memory_bytes: 256