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

template <typename T>
T ipow(T b, long long e) {
    if (e == 0) {
        return 1;
    } else if (e % 2 == 0) {
        return ipow(b * b, e / 2);
    } else {
        return ipow(b * b, e / 2) * b;
    }
}

// aを1番目、zを26番目としてx番目のcharを返す
char get_char(int x) { return 'a' - 1 + x; }

int main() {
    long long N;
    cin >> N;
    int i = 1;
    while (N > ipow<long long>(26, i)) {
        N -= ipow<long long>(26, i);
        i++;
    }
    string ans;
    // i文字の名前のうち、N番目を計算して出力
    for (int j = i; j > 0; j--) {
        int c = 1;
        while (N > ipow<long long>(26, j - 1)) {
            N -= ipow<long long>(26, j - 1);
            c++;
        }
        ans += get_char(c);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612
class RollingHash:
    def __init__(self,S,base,M):
        self.N=len(S)
        self.M=M
        self.H=[0]*(self.N+1)
        self.B=[0]*(self.N+1)
        self.B[0]=1
        for i in range(self.N):
            self.B[i+1]=self.B[i]*base%M
            self.H[i+1]=(self.H[i]*base+(ord(S[i])-96))%M
    def get(self,l,r):
        return (self.H[r]-self.H[l]*self.B[r-l]+self.M)%self.M

def main():
    import random

    N=int(input())
    M=2**61-1
    base=random.randrange(100,M)
    RH,S=[],[]
    RH,S=[None for i in range(N)],[None]*N
    for i in range(N):
        s=input()
        S[i]=s
        RH[i]=RollingHash(s,base,M)

    dic={}
    dic[0]=[0]*26
    for k,s in enumerate(S):
        Set=set()
        l=len(s)
        for j in range(l):
            Hash=RH[k].get(j,l)
            if not Hash in dic:
                dic[Hash]=[0]*26
            for c in Set:
                dic[Hash][ord(c)-97]+=1
            Set.add(s[j])
        for c in Set:
            dic[0][ord(c)-97]+=1
    ans=0
    for i,s in enumerate(S):
        Hash=RH[i].get(1,len(s))
        ans+=dic[Hash][ord(s[0])-97]-1
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 724364
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
    for (T &x : vec)
        is >> x;
    return is;
}

ll gcd(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    while (m != n)
    {
        if (m > n)
            m = m - n;
        else
            n = n - m;
    }
    return m;
}

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

int main(){
    int x;
    cin >> x;
    
    if(x==7 or x==5 or x==3){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  
  sort(A.begin(), A.end());
  
  int ans = 0, num = 0;
  for (int i = N - 1; i >= 0; i--){
    if (num % 2 == 0){
      ans += A.at(i);
    }
    else{
      ans -= A.at(i);
    }
    
    num++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main(){
	int h, w;
	while (1){
		cin >> h >> w;
		if (w == 0 && h == 0) break;
		int d = w*w + h*h; //????§????
		int minH = 151, minW = 151, minD = 100000;

		for (int hi = 1; hi <= 150; hi++){
			for (int wi = hi+1; wi <= 150; wi++){
				if (hi == h && wi == w) continue;
				int thisD = wi*wi + hi*hi;
				int differ = thisD - d;
				if (differ >= 0){
					if (differ == 0 && minD != d && hi > h){
						minD = thisD;
						minH = hi;
						minW = wi;
						break;
					}
					if (minD > thisD && thisD > d){
						minD = thisD;
						minH = hi;
						minW = wi;
					}
				}
			}
		}
		cout << minH << " " << minW << endl;
	}
}

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

using namespace std;

deque<int> Q;

void Push(int x) {
	while(Q.size() && Q.back() > x) Q.pop_back();
	Q.push_back(x);
}
void Pop(int x) {
	if(Q.size() && Q.front() == x)
		Q.pop_front();
}

int A[500005];

int main() {
	int n, x;
	cin >> n >> x;

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

	long long best = 1e18;

	for(int i = 0; i <= n; ++i) {
		long long ans = 1LL * i * x;

		Q.clear();
		for(int pos = 0; pos < i; ++pos)
			Push(A[pos]);

		for(int j = 0; j < n; ++j) {
			Push(A[j + i]);
			ans += Q[0];
			Pop(A[j]);
		} 

		best = min(best, ans);
	}

	cout << best << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  long long D = 0;
  cin>>N>>D;
  
  int sum = 0;
  sum = N/(D*2+1);
  if(N%(D*2+1)!=0) sum++;
    
    cout << sum<< endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
const double PI=3.14159265359;
int main()
{
    int a,b,c;
    double S,L,h;
    scanf("%d%d%d",&a,&b,&c);
    S=a*b*sin((double)c/180*PI)/2;
    L=a+b+sqrt(a*a+b*b-2*a*b*cos((double)c/180*PI));
    h=S*2/a;
    printf("%lf %lf %lf\n",S,L,h);
    return 0;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
typedef long long int ll;

using namespace std;
const double PI = 3.14159265358979323846;

int red_c(vector<vector<int>> A, vector<int> I, vector<int> J, int K)
{

    int count = 0;
    for (int i = 0; i < I.size(); i++)
    {
        for (int j = 0; j < J.size(); j++)
        {

            if ((I[i] + J[j]) > 0)
            {
                A[i][j] = 0;
            }

            count += A[i][j];
        }
    }

    if (K == count)
    {

        return 1;
    }

    return 0;
}

int main()
{
    int H, W, K;

    cin >> H >> W >> K;

    vector<vector<int>> A(H, vector<int>(W, 0));

    for (int i = 0; i < H; i++)
    {

        for (int j = 0; j < W; j++)
        {
            char c;
            cin >> c;

            if (c == '#')
            {
                A[i][j] = 1;

            }
        }
    }

    int count = 0;

    for (int bit_i = 0; bit_i < (1 << H); bit_i++)
    {

        vector<int> color_i(H, 0);
        for (int p = 0; p < H; p++)
        {

            if ((1 << p) & bit_i)
            {

                color_i[p] = 1;
            }
        }

        for (int bit_j = 0; bit_j < (1 << W); bit_j++)
        {

            vector<int> color_j(W, 0);
            for (int q = 0; q < W; q++)
            {

                if ((1 << q) & bit_j)
                {
                    color_j[q] = 1;
                }
            }
            count += red_c(A, color_i, color_j, K);
        }
    }

    cout << count << endl;
    return 0;
}

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

using namespace std;

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

int main() {
    int N; ll K, x = 0LL;
    bool is_lower_than_K = false;// 未満フラグ
    cin >> N >> K;
    vector<ll> a(N);
    for(int i=0;i<N;++i){
        cin >> a[i];
    }
    
    int k_msb = 60;
    if(K) {
        while(!((1LL << k_msb) & K)) --k_msb;
    } else {
        k_msb = 0;
    }
    
    
    for(int i=k_msb;i>=0;--i) {
        int count_one = 0;
        for(int j=0;j<N;++j) {
            if(a[j] & (1LL << i)) ++count_one;
        }

        if(is_lower_than_K || (K & (1LL << i))) {
            if(count_one < N - count_one) {
                x |= (1LL << i);
            } else {
                is_lower_than_K = true;
            }
        }
    }

    ll ans = 0LL;
    for(int i=0;i<N;++i){
        ans += x ^ a[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
	int n;
	while(cin >> n,n){
		int sum = 0,a;
		for(int i = 0; i < n; i+=4){
			cin >> a;
			sum += a;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N = 2e5;
vector<int> adj[N+1];
int p[N+1];
void dfs(int u, int prev)
{
    p[u] = prev;
    for(const int& v : adj[u])
        if(v != prev)
            dfs(v,u);
}
int main()
{
    int n; cin >> n;
    for(int i = 0; i < n-1; i++)
    {
        int u, v; cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dfs(1,-1);
    LL ans = n; // for 1
    for(LL s = 2; s <= n; s++)
        if(p[s] < s)
            ans += (s-p[s])*(n-s+1);
        else
            ans += s*(p[s]-s);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 24612
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  int n;
  cin >> n;
  vi p(n), q(n);
  rep(i, n) cin >> p[i];
  rep(i, n) cin >> q[i];
  vi tmp(n);
  rep(i, n) tmp[i] = i+1;
  
  int cnt=1;
  int ip=0, iq=0;
  do {
    if (p==tmp) ip = cnt;
    if (q==tmp) iq = cnt;
    cnt++;
    } while(next_permutation(tmp.begin(), tmp.end()));

  cout << abs(ip-iq) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
//ミョ(-ω- ?)
int main() {
    ll a,b,x;
    cin >> a >> b >> x;
    ll minv = INF;
    rep(i,21){
        rep(j,41){
            /*if(i*1000 + j*500 == x){
                cout << i*a + j*b << endl;
                return 0;
            }else*/ if(i*1000 + j*500 >= x){
                minv = min(minv,i*a + j*b);
            }
        }
    }
    cout << minv << endl;
    return 0;
}


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

int main(){
    ll a;
    string b;
    cin >> a >> b; 
    long long b100 = (b[0]-'0')*100 + (b[2]-'0')*10 + (b[3]-'0')*1;
    cout << a * b100 / 100 << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>

int main()
{
  long long N, A, B, C;
  std::cin >> N >> A >> B >> C;
  std::vector<long long> ls(N, 0);
  for (int i = 0; i < N; ++i)
    std::cin >> ls[i];

  long long ans = std::numeric_limits<long long>::max();
  auto calc = [A, B, C](const std::vector<long long>& As, const std::vector<long long>& Bs, const std::vector<long long>& Cs)
  {
    long long ans = 0;
    if (As.empty())
      return std::numeric_limits<long long>::max();
    long long accA = std::accumulate(begin(As), end(As), 0LL);
    ans += 10 * (As.size() - 1) + std::abs(A - accA);
    if (Bs.empty())
      return std::numeric_limits<long long>::max();
    long long accB = std::accumulate(begin(Bs), end(Bs), 0LL);
    ans += 10 * (Bs.size() - 1) + std::abs(B - accB);
    if (Cs.empty())
      return std::numeric_limits<long long>::max();
    long long accC = std::accumulate(begin(Cs), end(Cs), 0LL);
    ans += 10 * (Cs.size() - 1) + std::abs(C - accC);
    return ans;
  };
  const unsigned long long limit = std::pow(2ULL, 2 * N);
  std::vector<long long> As{}, Bs{}, Cs{};
  for (auto cnt = 0ULL; cnt < limit; ++cnt)
  {
    As.clear();
    Bs.clear();
    Cs.clear();
    int i = cnt;
    int j = 0;
    while(i)
    {
      int n = i & 3ULL;
      switch(n)
      {
      case 0:
        break;
      case 1:
        As.push_back(ls[j]);
        break;
      case 2:
        Bs.push_back(ls[j]);
        break;
      default:
        Cs.push_back(ls[j]);
        break;
      }
      ++j;
      i >>= 2;
    }
    ans = std::min(ans, calc(As, Bs, Cs));
  }
  std::cout << ans << std::endl;

  return 0;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter

from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
#dequeを使うときはpython3を使う、pypyはダメ
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds

#mod = 10**9+7
#w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

#N = int(input())
#N, K = map(int, input().split())
#L = [int(input()) for i in range(N)]
#A = list(map(int, input().split()))
#S = [list(map(int, input().split())) for i in range(N)]

mod=10**4
def dk(edge,vis):
    q=[vis]
    visited=[False]*N
    heapify(q)
    while len(q):
        e=heappop(q)
        cd,ce=e//mod, e%mod
        
        if visited[ce]:
            continue
        #print(cd,ce)
        visited[ce]=True
        if ce>vis:
            ans[cd]+=1
        for ne in edge[ce]:
            heappush(q,(cd+1)*mod+ne)



N, X, Y = map(int,input().split()) #n:頂点数　w:辺の数
ans=[0]*(N)
edge = [[] for i in range(N)]
    #edge[i] : iから出る道の[重み,行先]の配列
for i in range(N-1):
    x,y=i,i+1
    edge[x].append(y)
    edge[y].append(x)
edge[X-1].append(Y-1)
edge[Y-1].append(X-1)

for vis in range(N-1):
    dk(edge,vis)
    #print(ans)
for a in ans[1:]:
    print(a)

    

Measured memory_bytes: 69084
#include <iostream>

using namespace std;

int main() {
    int n, x;
    cin >> n >> x;

    int m_min = 1000;
    for (int i = 0; i < n; i++) {
        int m;
        cin >> m;

        x -= m;
        if (m_min > m) {
            m_min = m;
        }
    }

    cout << n + x / m_min << endl;
}


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

const int MAXR = 22;
int N, M;
int G[MAXR][MAXR];

int main() {
  while(cin >> N && N) {
    fill(G[0], G[MAXR], 0);
    for(int i = 0; i < N; ++i) {
      int x, y;
      cin >> x >> y;
      G[y][x] += 1;
    }
    cin >> M;
    int num = 0;
    int x, y;
    x = y = 10;
    for(int t = 0; t < M; ++t) {
      char d;
      int l;
      cin >> d >> l;
      int vx, vy;
      if(d == 'N') vx =  0, vy =  1;
      if(d == 'E') vx =  1, vy =  0;
      if(d == 'S') vx =  0, vy = -1;
      if(d == 'W') vx = -1, vy =  0;
      num += G[y][x];
      G[y][x] = 0;
      for(int j = 0; j < l; ++j) {
        x += vx;
        y += vy;
        num += G[y][x];
        G[y][x] = 0;
      }
    }
    if(num == N) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1148
#include<stdio.h>
int main(void)
{
    int i,a,b;
	b=0;
	for(i=0;i<5;i++){
	scanf("%d",&a);
	if(a>=40){
	b+=a;
	}
	else{
	b+=40;
	}
	}
	printf("%d\n",b/5);
	return 0;
	}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define ones(n) __builtin_popcount(n)
#define ONES(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> ii;
typedef pair<long long, pair<int, int>> iii;
typedef pair<ii, ii> iiii;

const double PI = acos(-1.0), EPS = 1e-6;
const int N = 402, M = 100005, mod = 1000000007, mxLog = 20;
long long a[N];
long long memo[N][N];
long long solve(int i, int j) {
    if (i == j)
        return 0;
    long long &ret = memo[i][j];
    if (~ret)
        return ret;
    ret = OO;
    for (int k = i; k < j; ++k) {
        ret = min(ret, a[j] - a[i - 1] + solve(i, k) + solve(k + 1, j));
    }
    return ret;
}



int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        a[i] += a[i - 1];
    }
    memset(memo, -1, sizeof memo);

    cout << solve(1, n) << '\n';

    return 0;
}

Measured memory_bytes: 1536
N = int(input())
S = input()

string = [chr(i) for i in range(65, 65+26)] + [chr(i) for i in range(65, 65+26)]
box = []

for i in S:
    box.append(string.index(i) + N)


for i in box:
    print(string[i], end="")

Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s[0]=='A') cout<<"T";
  if(s[0]=='T') cout<<"A";
  if(s[0]=='C') cout<<"G";
  if(s[0]=='G') cout<<"C";
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int n,k;
    cin >> n >> k;
    if((1+2*(k-1)) <= n) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    ll N, K, Q;
    cin >> N >> K >> Q;
    Vl A(N);
    for (int i = 0; i < Q; i++) {
        ll a;
        cin >> a;
        --a;
        ++A[a];
    }
    for (int i = 0; i < N; i++) {
        if (K - Q + A[i] > 0) {
            cout << "Yes\n";
        }
        else {
            cout << "No\n";
        }
    }

    return 0;
}

Measured memory_bytes: 1408
inp = input().split(" ")

A = int(inp[0]); B = int(inp[1]); C = int(inp[2]); K = int(inp[3]);
point = 0

if (A > 0) & (K > 0):
  itr = min([A,K])
  point += (itr * 1)
  K -= itr

if (B > 0) & (K >0):
  itr = min([B,K])
  point += (itr * 0)
  K -= itr
  
if (C > 0) & (K >0):
  itr = min([C,K])
  point += (itr * -1)
  K -= itr

print(point)

Measured memory_bytes: 9212
#include <stdio.h>

int main()
{
  int x;
  scanf("%d",&x);
  int i = 0;
  float n = 1.08;
  while (n * i < x)
  {
    i++;
    if (n*i >= x+1)
    {
      printf(":(");
      return (0);
    }
  }
  printf("%d",i);
}

Measured memory_bytes: 128
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

r,g,b = I()
if (10*g+b)%4 == 0:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 77184
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl "\n"
using namespace std;
int main()
{
	fast;
	int n,d;
	cin>>n>>d;
	int ans,num=2*d+1;
	if(n%num>0)
	{
		ans=(int)(n/num)+1;
	}
	else
	{
		ans=(int)(n/num);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
from decimal import Decimal as de
n=int(input())
def factorization(n):
    factor=[]
    p=[]
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            factor.append(i)
            p.append(cnt)
    if temp!=1:
        factor.append(temp)
        p.append(1)
    if len(factor)==0:
        factor.append(n)
        p.append(1)
    return factor,p

ans=0
for i in [k for j,k in zip(factorization(n)[0],factorization(n)[1]) if j!=1]:
  ans+=((de(1)+de(8)*de(i))**de('0.5')-de(1))//de(2)
print(int(ans))

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

int main(){
    int N;
    cin >> N;

    string S;
    cin >> S;

    int counter = 0;
    for(int i = 0; i <= N - 3; i++){
        string str = S.substr(i, 3);
        if(str == "ABC")
            counter++;
    }

    cout << counter << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    int L = max(A, B);
    int S = min(A, B);
    if (L == S){
        cout << L + S << endl;
    }else{
        cout << L + L - 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import numpy as np
from itertools import chain,combinations

words = lambda t : list(map(t, input().split()))

n,m = words(int)
ks = []
for i in range(m):
  ks.append(words(int))
  ks[i].pop(0)

ms = words(int)

#print(ks,ms)

def powerset(it):
  s = list(it)
  return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))

ans = 0
for s in powerset([i+1 for i in range(n)]):
  n_on = 0
  for k,mods in zip(ks,ms):
    n_inc = 0
    for ink in k:
      if ink in s:
        n_inc += 1
    if n_inc % 2 == mods:
      n_on += 1
  if n_on == m:
    ans += 1

print(ans)


Measured memory_bytes: 21360
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int X, Y, Z;

int main()
{
	in >> X >> Y >> Z;
	out << (X - Z) / (Y + Z) << std::endl;
	return 0;
}

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

#define rep(i, u) for (int i = 0; i < u; i++)

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a < b && b < c) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 3084
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int M = int.Parse(str[1]);
		int[,]A = new int[N-1,2];
		for(var i=0;i<N-1;i++){
			string[] str2 = Console.ReadLine().Split();
			A[i,0] = int.Parse(str2[0]);
			A[i,1] = int.Parse(str2[1]);
		}
		int[,]B = new int[M,2];
		int[]Q = new int[N];
		for(var i=0;i<M;i++){
			string[] str2 = Console.ReadLine().Split();
			B[i,0] = int.Parse(str2[0]);
			B[i,1] = int.Parse(str2[1]);
			Q[B[i,0]-1] += B[i,1];
		}
		int[]Ans = new int[N];
		var list = new List<int>[N];
		for(var i=0;i<N;i++){
			list[i] = new List<int>();
		}
		for(var i=0;i<N-1;i++){
			list[A[i,0]-1].Add(A[i,1]-1);
			list[A[i,1]-1].Add(A[i,0]-1);
		}
		int[]F = new int[N];
		var listA = new List<int>();
		listA.Add(0);
		while(listA.Count>0){
			var list2 = new List<int>(listA);
			listA.Clear();
			foreach(var i in list2){
				int q1 = Ans[i]+Q[i];
              	Ans[i] = q1;
				F[i] = 1;
				foreach(var j in list[i]){
					if(F[j] == 0){
                      	Ans[j] = q1;
						listA.Add(j);
					}
				}
			}
		}
		Console.Write(Ans[0]);
		for(var i=1;i<N;i++){
			Console.Write(" "+Ans[i]);
		}
	}
}


Measured memory_bytes: 48380
import math

a, b, h, m = map(int, input().split(" "))

mp = 360 * (m / 60)
hp = 30 * h + (mp / 12)

mn = abs(hp - mp)
if mn > 180:
    mn = 360 - mn

a = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(math.radians(mn)))

print(a)

Measured memory_bytes: 9436
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	char s[51];
	for(int i=1;i<=n;i++)
		cin>>s[i];
	s[k]+=32;
	for(int i=1;i<=n;i++)
		cout<<s[i];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp(a,b)   make_pair(a,b)
#define ll        long long
#define mp(a,b)   make_pair(a,b)
#define si(n)     scanf("%d",&n)
#define sl(n)     scanf("%lld",&n)
#define pi(n)     printf("%d\n",n)
#define pl(n)     printf("%lld\n",n)
#define           newline cout << endl;
#define           ff first
#define           ss second
using namespace std;

int main(){
  //clock_t tStart = clock();
  int a,b;
  cin >> a >> b;
  int ans = a-b+1;
  cout << ans << endl;
  //printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cmath>
#include<bitset>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define pii(p)			pair<int,int> p
#define mii(m)			map<int, int> m
#define msi(m)			map<string, int, less<>> m
#define mmsi(m)			multimap<string, int, less<>> m
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
#define PI 3.141592
#define MOD 1e9+7
using namespace std;

void solve() {
	ll n, k, ans = 0;
	cin >> n >> k;
	vector<ll>h(n);
	FOR(n)
		cin >> h[i];
	if (n <= k) {
		cout << 0 << endl;
		return;
	}
	sort(ALL(h));
	for (int i = n-1; i >= n-k; --i)
		h[i] = 0;
	for (int i = 0; i < n; ++i)
		ans += h[i];

	cout << ans << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    vec A(n);
    rep(i,n) cin>>A[i];
    ll sum=0;
    rep(i,n) sum=sum^A[i];
    rep(i,n) cout<<(sum^A[i])<<" ";
}

Measured memory_bytes: 4708
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;

    if(m1 != m2){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main() {
	char num[5];
	int flag = 0;
	bool b = false;
	cin >> num;
	for (int i = 1; i < 4; i++) {
		if (num[i-1] == num[i]) {
			flag++;
			if (flag == 2) {
				b = true;
			}
		}
		else {
			flag = 0;
		}
	}
	if (b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
/*bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}*/

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

const ll mod = 1e9 + 7;
const ll IMF = 1LL<<29;
const double PI = 3.14159265358979323846;


// ******************************CODE**********************************//



int n;
vector<int> a(100001);
int s;

int main()
{

        cin >> n;
        a[0] = 0;
        //全部の差の距離を求める。
        for(int i = 1; i <= n; i++)
        {
                cin >> a[i];
                s += abs(a[i] - a[i-1]);
        }
        a[n+1] = 0;
        s += abs(a[n+1] - a[n]);

        //自分もところを経由しないように旅行をするために、自分を経由したルートの分の距離を消して、そしてその消して行けなかった分を足し合わせている。
        for(int i = 1; i <= n; i++)
        {
                cout << s - abs(a[i] - a[i-1]) - abs(a[i] - a[i+1]) + abs(a[i-1] - a[i+1]) << endl;
        }
       
        return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
const int md=998244353;
int mygcd(int x,int y){return !y?x:mygcd(y,x%y);};
int n;
int a[100010];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	sort(a+1,a+n+1);
	int ans=1;
	for(int i=1;i<=n;i++)ans=1LL*ans*mygcd(a[i],i-1)%md;
	printf("%d",ans);
	return 0;
}

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

using namespace std;

typedef long long ll;

const int MAXW = (int)1e5+1;
const int MAXN = 101;
ll dp[MAXW], N, W;
bool achievable[MAXW];

int main()
{
    cin >> N >> W;
    ll weight, value;
    achievable[0] = true;
    for(int i=0; i<N; i++)
    {
        cin >> weight >> value;
        for(int i=W-1; i>=0; i--)
        {
            if(achievable[i] && i + weight <= W)
            {
                dp[i+weight] = max(dp[i+weight], dp[i] + value);
                achievable[i+weight] = true;
            }
        }
    }

    ll ans = 0;
    for(int i=0; i<=W; i++)
    {
        ans = max(ans, dp[i]);
        //cout << dp[i] << " ";
    }

    cout << ans;


    return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>

typedef struct {
	int id;
	long long key;
} data;

void merge_sort(data x[], int n)
{
	static data y[1001] = {};
	if (n == 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p].key < x[q].key)? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, N, M;
	long long x[1001], y[1001], z[1001];
	scanf("%d %d", &N, &M);
	for (i = 1; i <= N; i++) scanf("%lld %lld %lld", &(x[i]), &(y[i]), &(z[i]));
	
	int sgn[3] = {1, 1, 1};
	long long ans = 0, sum;
	data d[1001];
	while (1) {
		for (i = 0; i < N; i++) d[i].key = x[i+1] * sgn[0] + y[i+1] * sgn[1] + z[i+1] * sgn[2];
		merge_sort(d, N);
		for (i = 0, sum = 0; i < M; i++) sum += d[N-i-1].key;
		if (sum > ans) ans = sum;
		
		for (i = 0; i <= 2 && sgn[i] == -1; i++);
		if (i == 3) break;
		for (sgn[i--] = -1; i >= 0; sgn[i--] = 1);
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1780
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math


N = int(input())
V = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

ans = 0
for i in range(N):
    if V[i] > C[i]:
        ans += V[i]-C[i]

print(ans)


Measured memory_bytes: 7872
def combination(n, k):
    if n < k:
        return 0
    n2, k2 = 1, 1
    for i in range(1, min(k, n - k) + 1):
        n2 *= n
        k2 *= i
        n -= 1
    return n2 // k2
 
mod = 10 ** 9 + 7
N, K = map(int, input().split())
for i in range(1, K+1):
    a = combination(N-K+1, i) * combination(K-1, i-1) % mod
    print(a)

Measured memory_bytes: 45148
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

int main() {
	ll N,M;
	cin >> N >> M;
	ll ans=0;

    ans+=min(M/2,N);
   	M-=2*N;
  	ans += max((ll)0,M/4);
	cout << fixed << ans <<endl;
	return 0;
}

Measured memory_bytes: 256
////
////  main.cpp
////  L2-005
////
//
#include <cstring>
#include <vector>
#include <iostream>
#include <unordered_map>
#include<algorithm>
#include <set>
#include <list>
#include<stdio.h>
#include <cmath>
using namespace std;
using ll=long long;

 long double MySqrt( long double n, long double ep) //用二分法
{
    if(n<0) //小于0的按照你需要的处理
        return n;
     long double mid,last;
     long double low,up;
    low=0,up=n;
    mid=(low+up)/2;
    do
    {
        if(mid*mid>n)
            up=mid;
        else
            low=mid;
        last=mid;
        mid=(up+low)/2;
    }while(abs(mid-last) > ep);//精度控制
    return mid;
}

int main(){
    long double a,b,c;
    cin>>a>>b>>c;
    long double res=a+b+ 2* ( long double) (sqrt(a*b));
    if (res<c) {
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

Vi yakusuu(int n){
    Vi ret;
    for(int i=1 ; i*i<=n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i*i!=n) ret.push_back(n/i);
        }
    }
    sort(ALL(ret));
    return ret;
}

void solve(long long N){
    int ans=INF;
    Vi yak=yakusuu(N);
    REP(i,0,yak.size()){
        int a=yak[i];
        int b=N/yak[i];
        chmin(ans,a+b-2);
    }
    cout<<ans<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

// 連想配列map      　set重複無し集合

int main(void){
    int n;
    cin >> n;
    vector<int> vec(n);
    rep(i,n) cin >> vec.at(i);

    set<int> values;
    rep(i,n){
        values.insert(vec.at(i));
    }
    cout << values.size() << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define max 5005
//#define max1 60000000
#define inf INT_MAX
using namespace std;
typedef  long long int ll;
template<typename T> inline T maxi(T a,T b){return a>b?a:b;}
template<typename T> inline T mini(T a,T b){return a<b?a:b;}
template<typename T> inline T absl(T a){return a>0?a:-a;}
template<typename T> inline T gcd(T a,T b){T t;if(a<b){while(a){t=a;a=b%a;b=t;}return b;}else{while(b){t=b;b=a%b;a=t;}return a;}}
#define mp(a,b) make_pair(a,b)
//###################################################------------------------------------------------------#######################################

void input(){
    int H,W;cin>>H>>W;
    int h,w;cin>>h>>w;
    cout<<(H*W)-((W*h)+(w*(H-h)))<<endl;
}
int main(){
    input();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int h,w;
char field[11][11];
int sang;
int sx,sy;
int leaf;
int rec[1001];
bool fin;

const int dy[]={-1,0,1,0};
const int dx[]={0,1,0,-1};
char chs[1001];
int rev[1001];

void dfs(int cx,int cy,int cang,int cnt){
	if(fin)return;
	if(leaf==cnt){
		fin=true;
		for(int i=0;i<leaf;i++)cout<<chs[rec[i]];
		cout<<endl;
		return;
	}
	for(int i=0;i<4;i++){
		if(i!=(cang+2)%4){
			for(int j=1;;j++){
				int ny=cy+dy[i]*j;
				int nx=cx+dx[i]*j;
				if(ny>=0&&nx>=0&&ny<h&&nx<w){
					if(field[ny][nx]=='o'){
						field[ny][nx]='.';
						rec[cnt]=i;
						dfs(nx,ny,i,cnt+1);
						if(fin)return;
						field[ny][nx]='o';
						break;
					}
				}
				else break;
			}
		}
	}
}

int main(){
	chs[0]='U';
	chs[1]='R';
	chs[2]='D';
	chs[3]='L';
	rev['U']=0;
	rev['R']=1;
	rev['D']=2;
	rev['L']=3;

	cin>>h>>w;
	fin=false;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>field[i][j];
			if(field[i][j]=='o')leaf++;
			else if(field[i][j]!='.'&&field[i][j]!='o'){
				sang=rev[field[i][j]];
				field[i][j]='.';
				sx=j;sy=i;
			}
		}
	}
	dfs(sx,sy,sang,0);

	return 0;
}

Measured memory_bytes: 0
//Author: Abitnav
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
vector<pair<int,int> > v;
int dp[2001][2001];


int solve(int i,int l){
	if(i==v.size()) return 0;
	int r=l+v.size()-i-1,a,b;
	if(dp[i+1][l+1]==-1) dp[i+1][l+1]=solve(i+1,l+1);
	if(dp[i+1][l]==-1)	dp[i+1][l]=solve(i+1,l);
	a=v[i].fi*abs(v[i].se-l)+dp[i+1][l+1];
	b=v[i].fi*abs(v[i].se-r)+dp[i+1][l];
	return max(a,b);	
}

signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	memset(dp,-1,sizeof(dp));	
	int n,x;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x;
		v.pb({x,i});
	}
	sort(all(v));
	reverse(all(v));
	cout<<solve(0,0);
		
	return 0;
}













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

int reverse_int(int n) {
	int logn = log10(n) + 1;
	int ans = 0;
	for (int i = 0; i < logn; i++) {
		ans = ans * 10 + n % 10;
		n /= 10;
	}
	return ans;
}

int main() {
	int A, B;
	cin >> A >> B;
	int logA = log10(A)+1;
	int logB = log10(B)+1;
	int a = A;
	int b = B;
	for (int i = 0; i < logA / 2; i++) a /= 10;
	for (int i = 0; i < logB / 2; i++) b /= 10;
	int aa = a;
	int bb = b;
	for (int i = 0; i < logA / 2; i++) aa *= 10;
	for (int i = 0; i < logB / 2; i++) bb *= 10;
	if (logA % 2 == 0) aa += reverse_int(a);
	else aa += reverse_int(a / 10);
	if (logB % 2 == 0) bb += reverse_int(b);
	else bb += reverse_int(b / 10);
	if (aa < A) a++;
	if (bb > B) b--;
	cout << b - a + 1;

}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DBG(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define DBG(...)
#endif

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, n) for (auto i : (n))
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int N;
int X[100];

int cost(int i, int x) {
  int a = abs(X[i] - x);
  return a * a;
}

int main() {
  cin >> N;
  REP(i, N) cin >> X[i];

  int ans = 1000000000;
  for (int x = 1; x <= 100; ++x) {
    int total = 0;
    REP(i, N) total += cost(i, x);
    ans = min(ans, total);
  }
  cout << ans << endl;
}


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

using namespace std;

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

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

int main() {
  int n;
  cin >> n;
  ll ans = 1;
  REP1(i, n) ans *= i;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define pi 2*asin(1.0)
#define MAX 10000000
#define MOD 1000000007
 
 
vector<long> fac(MAX);
vector<long> finv(MAX);
vector<long> inv(MAX);
 
//template functions
/////////////////////////
void Cominit(){
  fac.at(0)=fac.at(1)=1;
  finv.at(0)=finv.at(1)=1;
  inv.at(1)=1;
  for(long i=2;i<MAX;i++){
      fac.at(i)=(fac.at(i-1)*i)%MOD;
      inv.at(i)=MOD-inv.at(MOD%i)*(MOD/i)%MOD;
      finv.at(i)=finv.at(i-1)*inv.at(i)%MOD;
  }
}

long facComb(long N,long M){// nCm%
if(N<M) return 0;
if(N<0||M<0) return 0;
return fac.at(N)*(finv.at(M)*finv.at(N-M)%MOD)%MOD;
}

long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}

long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}

long GCM(long A,long B){
            long W,r;
    if(A<B){

        W=B;
        B=A;
        A=W;
    }
    while(A%B!=0){
        r=A%B;
        A=B;
        B=r;
    }
    return B;
}
long LCM(long A,long B){
    return (A*B)/GCM(A,B);
}

long upDiv(long a,long b){
  return (a+b-1)/b;
}

/////////////////////////


//Answer


int main() {

long T,S,D;
cin>>D>>T>>S;

if(D>T*S){
    cout<<"No"<<endl;
}else{
    cout<<"Yes"<<endl;
}
}

Measured memory_bytes: 237508
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	std::string s; cin >> s;
	
	int tmp = 0;
	std::vector<int> vec;
	for(int i = 0; i < (int)s.size() - 1; i++) {
		if(s[i] == 'A') tmp++;
		else if(s.substr(i, 2) == "BC") {
			vec.push_back(tmp);
			tmp = 0;
			i++;
		} else {
			vec.push_back(-1);
			tmp = 0;
		}
	}
	
	i64 latte = 0, ans = 0;
	for(int i = 0; i < vec.size(); i++) {
		if(vec[i] == -1) {
			latte = 0;
			continue;
		}
		latte += vec[i];
		ans += latte;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1532
cards = []
suit = ['S', 'H', 'C', 'D']

n = int(input())

for i in range(n):
    s, c = input().split()
    c = int(c)
    if s == 'S':
        cards.append(0 + c)
    elif s == 'H':
        cards.append(13 + c)
    elif s == 'C':
        cards.append(26 + c)
    elif s == 'D':
        cards.append(39 + c)
        
for i in range(1, 53):
    if not i in cards:
        print(suit[(i-1)//13], (i-1)%13+1)
    
    


Measured memory_bytes: 5596
#include <cstdio>
#include <vector>

using namespace std;
class node{
public:
  node()
    :parent(-1)
    ,depth(-1)
    ,c(0)
  {};
  int parent;
  int depth;
  vector<int> c;
};

node nodes[100000];
void setDepth(int index, int depth){
  nodes[index].depth = depth;
  for(int i : nodes[index].c){
    setDepth(i, depth+1);
  }
}

int main(){
  int n;
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    int id;
    scanf("%d", &id);
    int k;
    scanf("%d", &k);
    for(int j = 0; j < k; j++){
      int tmp;
      scanf("%d", &tmp);
      nodes[id].c.push_back(tmp);
      nodes[tmp].parent = id;
    }
  }
  int rootIndex = -1;
  for(int i = 0; i < n; i++){
    if(nodes[i].parent == -1){
      rootIndex = i;
      break;
    }
  }
  setDepth(rootIndex, 0);
  for(int i = 0; i < n; i++){
    printf("node %d: parent = %d, depth = %d, ", i, nodes[i].parent, nodes[i].depth);
    if(nodes[i].parent == -1){
      printf("root");
    } else if((int)nodes[i].c.size() == 0){
      printf("leaf");
    } else {
      printf("internal node");
    }
    printf(", [");
    for(int j = 0; j < (int)nodes[i].c.size(); j++){
      printf("%d", nodes[i].c[j]);
      if(j+1 < (int)nodes[i].c.size()){
	printf(", ");
      }
    }
    printf("]\n");
  }
}

Measured memory_bytes: 4948
#include <stdio.h>

int main(void){
    
    double a,b;
    double result;
    
    scanf("%lf",&a);
    scanf("%lf",&b);
    
    printf("%d\n",(int)a/(int)b);
    
    printf("%d\n",(int)a%(int)b);
    
    result = a/b;
    
    printf("%f\n",result);
    
    
    return 0;
}

Measured memory_bytes: 648
#include <iostream>

using namespace std;

int main(){
	int dataSet, money, year, n, hukuriFlag , charge;
	int money2,risi,answer;
	double nenri;

	//f[^ZbgÌüÍ
	cin >> dataSet;

	//f[^Zbg¾¯üÍ³¹é
	for(int i=0 ; i<dataSet ; i++){
		//ÏÌú»
		answer = 0;

		//money:ú^pàÊ  year:^pN  n:^pû@ÌíÞ
		cin >> money >> year >> n;

		//^pû@ÌíÞ¾¯[v³¹é
		for(int j=0 ; j<n ; j++){
			//hukuriFlag:Por¡  nenri:N¦  chargeNÌè¿  
			cin >> hukuriFlag >> nenri >> charge;

			money2 = money;
			risi = 0;

			if(hukuriFlag==1){//¡¾Á½ç
				//^pN¾¯[v³¹é
				for(int y=0 ; y<year ; y++){
					money2 += money2*nenri;
					money2 -= charge;
				}
				//ÅIàªå«©Á½ç¦Éüêé
				if(answer<money2)answer = money2;
			}
			else{//P¾Á½ç
				//^pN¾¯[v³¹é
				for(int y=0 ; y<year ; y++){
					risi += money2*nenri;
					money2 -= charge;
				}
				//ÅIàªå«©Á½ç¦Éüêé
				if(answer<money2+risi)answer = money2 + risi;
			}
		}

		//¦ÌoÍ
		cout << answer << endl; 
	}

	return 0;
}

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

void print_array(int a[], int n) {
  cout << a[0];
  for (int i = 1; i < n; i++) {
    cout << " " << a[i];
  }
  cout << endl;
}

void insertion_sort(int a[], int n) {
  print_array(a, n);
  for (int i = 1; i < n; i++) {
    int v = a[i];
    int j = i - 1;
    while (j >= 0 && a[j] > v) {
      a[j + 1] = a[j];
      j--;
    }
    a[j + 1] = v;
    print_array(a, n);
  }
}

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

Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i))
#define down(i,b,a) for(int (i) = (b);i>=(a);--i)
#define debug(x) cerr << (x) << '\n';
#define bits(x,i) ((x >> i) & 1)
using namespace std;
const int N = 105;
int n,a,b;
int main(){
	cin >> n;
	cin >> a >> b;
	int v = a/n;
	v = (v + (a % n != 0)) * n;
	if (v >= a && v <= b) cout << "OK";
	else cout << "NG";
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  
  sort(A.begin(),A.end());
  
  vector<int> B;
  for (int i = 1; i * i <= A.at(0); i++) {
    if (A.at(0) % i == 0) {
      B.push_back(i);
      B.push_back(A.at(0) / i);
    }
  }
  
  sort(B.begin(),B.end());
  int M;
  
  for (int i : B) {
    bool can = true;
    for (int j : A) if (j % i != 0) can = false;
    if (can) M = i;
  }
  
  cout << M << endl;
}

Measured memory_bytes: 640