akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()

	a := 26
	c := 1
	for n-a > 0 {
		n -= a
		a *= 26
		c++
	}
	a /= 26

	n--
	ans := make([]rune, c)
	for i := 0; i < c; i++ {
		ans[c-1-i] = rune('a' + n%26)
		n /= 26
	}
	fmt.Fprintln(wr, string(ans))
}


Measured memory_bytes: 1780
#include <cstdio>
#include <cmath>
#define buf 10000
using namespace std;
int k=0;
int B[buf];
void Answer(int n);
int PrimeNumber(int n);

int main(void){
  int i,n;
  char str[buf];

  for(i=2;i<buf;i++)
    PrimeNumber(i);
  for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
    sscanf(str,"%d",&n);
    if(n==0) break;
    Answer(n);
  }
  return 0;
}

void Answer(int n){
  int i,j;
  for(i=0;i<k;i++){
    if(B[i]>n)
        break;
  }
  for(j=i-1;j>=0;j--){
    if(B[j]-B[j-1]==2){
      printf("%d %d\n",B[j-1],B[j]);
      break;
    }
  }
}

int PrimeNumber(int n){
  int i,c;
  if(n==2){
    B[k]=n;
    k++; return 0;
  }
  if(n<2 || n%2==0)
    return 0;
  c=sqrt(n);
  for(i=3;i<=c;i+=2){
    if(n%i==0)
      return 0;
  }
  B[k]=n;
  k++; return 0;
}

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

int main(){
	int b=0;
	for(int i=0;i<4;i++){
		char a[4];
		cin>>a[i];
		if(a[i]=='+'){
			b++;
		}
		else {
			b--;
		}
	}
	cout<<b<<endl;
}


Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,string
from collections import defaultdict as D
from functools import reduce
import numpy as np
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353    

s = _S()
t = _S()

ans = False
if s == t[:-1]:
    ans = True

if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 26816
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * Weather Forecaster
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		line = br.readLine();
		int H, W;
		H = parseInt(line.substring(0, line.indexOf(' ')));
		W = parseInt(line.substring(line.indexOf(' ') + 1));

		int[][] forecast = new int[H][W];
		StringBuilder sb = new StringBuilder();

		for (int i = 0; i < H; i++) {
			line = br.readLine();
			for (int j = 0; j < W; j++) {
				if (line.charAt(j) == 'c') {
					forecast[i][j] = 0;
				} else {
					if (j == 0) {
						forecast[i][j] = -1;
					} else {
						if (forecast[i][j - 1] == -1) {
							forecast[i][j] = -1;
						} else {
							forecast[i][j] = forecast[i][j - 1] + 1;
						}
					}
				}
				if (j == 0) {
					sb.append(forecast[i][j]);
				} else {
					sb.append(" " + forecast[i][j]);
				}
			}
			sb.append("\n");
		}
		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 27132
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
const ll MAX_N=2e5;
ll N,ans[MAX_N];
int main(){
	cin.tie(0);
	cin.sync_with_stdio(false);
	cin>>N;
	REP(i,N-1){
		ll a;
		cin>>a;
		++ans[a-1];
	}
	REP(i,N){
		cout<<ans[i]<<endl;
	}

}


Measured memory_bytes: 5016
#include<stdio.h>
#include<limits.h>

int main(void){
	int n;
	long a;
	long min = LONG_MAX, max = LONG_MIN, sum = 0;
	int i;
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%ld", &a);
		if(a < min) min = a;
		if(max < a) max = a;
		sum += a;
	}
	printf("%ld %ld %ld\n", min, max, sum);
	return 0;
}


Measured memory_bytes: 2104
package main

import (
        "fmt"
        "math"
)

func main() {
        var a, b, c, d int
        fmt.Scan(&a, &b, &c, &d)
        fmt.Printf("%d\n", overwrapLength(a, b, c, d))
}

func overwrapLength(a, b, c, d int) int {
        min := math.MaxInt32
        for _, l := range []int{d - a, b - c, b - a, d - c} {
                if l < min {
                        min = l
                }
        }
        if min < 0 {
                return 0
        }
        return min
}

Measured memory_bytes: 512
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

int
main(void){  
  ios_base::sync_with_stdio(false);

  int n, a, b;
  string s;
  cin >> n;

  if(n == 3 || n == 5 || n == 7) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
def main():
    k, n = list(map(int, input().split()))
    a = list(map(int, input().split()))
    
    d = []
    for i in range(len(a)):
        try:
            d.append(abs(a[i] - a[i+1]))
        except:
            break
    
    d_max = max(d)
    d_max2 = a[0] + (k-a[-1])
    print(k - max(d_max, d_max2))

if __name__ == '__main__':
    main()

Measured memory_bytes: 26444
#include <stdio.h>

#define N 100

int main() {

  int m[N][N];
  int i, j, n, u, k, v;

  scanf("%d", &n);

  for( i=0; i<n; i++ ) {
    for( j=0; j<n; j++ ) {
      m[i][j] = 0;
    }
  }

  for( i=0; i<n; i++ ) {
    scanf("%d %d", &u, &k);
    u--;
    for( j=0; j<k; j++ ) {
      scanf("%d", &v);
      v--;
      m[u][v] = 1;
    }
  }

  for( i=0; i<n; i++ ) {
    for ( j=0; j<n; j++ ) {
      if(j) {
	printf(" ");
      }
      printf("%d", m[i][j]);
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;
const int INF = LLONG_MAX;

signed main(){
    
    int k, a, b; cin >> k >> a >> b;
    if(b - a <= 2 || a - 1 >= k) cout << k + 1 << endl;
    else{

        int num = 1;
        // ビスケットを A 枚まで増やす
        k -= (a - 1);
        num += a - 1;
        num += (k / 2) * (b - a);
        k %= 2;
        num += k;
        cout << num << endl;
    }

    return 0;
}

Measured memory_bytes: 256
a = int(input())
b = list(input())

def caesar(s, n):
    ns = []
    for ch in s:
        # A - Z
        if ('A' <= ch and ch <= 'Z'):
            ns.append(chr((ord(ch) - ord('A') + n) % 26 + ord('A')))
    return "".join(ns)

result = caesar(b, a)
print(result)


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


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

ll gcd(ll a, ll b) {
	return (b == 0 ? a : gcd(b, a % b));
}

ll ans = 1;
int main() {
	ll a, b;
	cin >> a >> b;
	ll c = gcd(a, b);
	for (int i = 2; i <= sqrt(c); i++)
	{
		if (c % i == 0) {
			ans++;
			while (c % i == 0)c /= i;
		}
	}
	if (c != 1)ans++;
	cout << ans << endl;
}


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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/

int main(void){
  int N,C[500],S[500],F[500];
  scanf("%d",&N); 
  for(int i=0;i<N-1;i++)scanf("%d%d%d",&C[i],&S[i],&F[i]); 
  
  for(int i=0;i<N;i++) { 
    int t=0; 
    for(int j=i;j<N-1;j++) 
    { if(t<S[j])t=S[j]; 
     else if(t%F[j]==0); 
     else t=t+F[j]-t%F[j];
     t+=C[j]; } 
    printf("%d\n",t); 
  }

}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <iomanip>
using namespace std;

int main(void)
{
	int i, n, s[1000], sum_s;
	double m, sum_v, sigma;

	while (1) {

		sum_s = 0;
		sum_v = 0;

		cin >> n;

		if (n == 0) break;

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

		m = (double)sum_s / (double)n;

		for (i = 0; i < n; i++) {
			sum_v += pow(((double)s[i] - m), 2);
		}

		sigma = sqrt(sum_v / (double)n);

		cout << sigma << endl;
	}
}


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

int main(){
    int X,N;
    cin >> X >> N;
    vector<int> p(N);
    for(int i=0;i<N;i++){
        cin >> p[i];
    }

    sort(p.begin(),p.end());

    
    
    int a=1000;
    int b=1000;
    int c=1000;
    int d=1000;


    for(int j=0;j<100;j++){
      bool anss=true;
        for(int i=N-1;i>=0;i--){
        if(X+j==p[i]){
            anss=false;
        }
    }
    if(anss==true){
        a=X+j;
        b=j;
        break;
    }
    }
  
    for(int j=0;j<100;j++){
      bool anss=true;
        for(int i=0;i<N;i++){
        if(X-j==p[i]){
            anss=false;
        }
    }
    if(anss==true){
        c=X-j;
        d=j;
        break;
    }
    }
  
  int e=min(b,d);

    
    if(e==d){
        cout << c << endl;
    }
    else if(e==b){
        cout << a << endl;
    }

 


}


    


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <queue>
#define pb push_back
#define ll long long

using namespace std;
bool is_prime(int a){
    if(a==1) return 0;
    if(a==2||a==3) return 1;
    if(a%6!=1&&a%6!=5) return 0;
    int temp=sqrt(a);
    for(int i=5;i<=temp;i+=6)
    {
        if(a%i==0||a%(i+2)==0) return 0;
    }
    return 1;
}

int main()
{
    ll a, b; cin >> a >> b;
    ll c = __gcd(a, b);
    int sum = 0;
    for(ll i = 2; i <= sqrt(c); i++) {
        if(c%i==0) {
            sum++;
            while(c%i==0) c/=i;
        }
        if(c < i) break;
    }
    if(c > 1) sum++;
    cout << sum+1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

template <typename T>
struct UnionFind {
  vector<int> par, rank;
  vector<T> wSum;

  UnionFind(int n = 1, T init = 0) : par(n), rank(n, 0), wSum(n, init) {
    iota(begin(par), end(par), 0);
  }
  int root(int x) {
    if (par[x] == x) {
      return x;
    } else {
      int r = root(par[x]);
      wSum[x] += wSum[par[x]];
      return par[x] = r;
    }
  }
  T weight(int x) {
    root(x);
    return wSum[x];
  }
  bool isSame(int x, int y) { return root(x) == root(y); }
  void unite(int x, int y, T w = 0) {
    w += weight(x) - weight(y);
    x = root(x);
    y = root(y);
    if (x == y) return;

    if (rank[x] < rank[y]) swap(x, y), w = negate<T>()(w);
    rank[x] += rank[y];
    par[y] = x;
    wSum[y] = w;
  }
  T getDiff(int x, int y) { return weight(y) - weight(x); }
};

int main() {
  int n, k, l;
  cin >> n >> k >> l;
  UnionFind<int> ufk(n), ufl(n);
  for (int i = 0; i < k; i++) {
    int p, q;
    cin >> p >> q, p--, q--;
    ufk.unite(p, q);
  }
  for (int i = 0; i < l; i++) {
    int r, s;
    cin >> r >> s, r--, s--;
    ufl.unite(r, s);
  }
  map<P, int> mp;
  for (int i = 0; i < n; i++) {
    int a = ufk.root(i);
    int b = ufl.root(i);
    mp[{a, b}]++;
  }
  for (int i = 0; i < n; i++) {
    if (i > 0) cout << " ";
    int a = ufk.root(i);
    int b = ufl.root(i);
    cout << mp[{a, b}];
  }
  cout << endl;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
typedef pair<ll,ll> Pair;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }

const ll INF=99999999999999;
const ll MOD=1000000007;
 
int main() {
  ll n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  vl nums;
  for(ll i=0; i<n;){
    ll j=i;
    while(j < n && s[j] == s[i]) ++j;
    nums.push_back(j-i);
    i = j;
  }
  if(k>=nums.size()/2){
    cout << n-1;
    return 0;
  }
  ll cnt = 0;
  ll x;
  rep(i,2*k+1){
    cnt += nums[i];
  }
  ll ans = cnt-1;
  for(ll i = 2*k+1; i<nums.size(); i++){
    ans += (nums[i]-1);
  }
  cout << ans;
  
 return 0;
}

Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	ll x;
	cin >> x;
	ll ans = x / 11 * 2;
	if (x % 11 != 0) {
		if (x % 11 <= 6) ans++;
		else ans += 2;
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
#define int long long
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int h, add = 1, ans = 0;
    cin >> h;
    while(h) {
        h >>= 1;
        ans += add;
        add <<= 1;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

const int NS = (int)1e5 + 4;
int N, M;
struct data{
    int A, B;
    bool operator<(const data&r)const{
        return A < r.A;
    }
}arr[NS];
priority_queue < int > pq;

int main(){
    scanf("%d %d", &N, &M);
    for(int i = 1; i <= N; ++i){
        scanf("%d %d", &arr[i].A, &arr[i].B);
    }
    sort(arr + 1, arr + N + 1);
    int ans = 0, j = 1;
    for(int i = 1; i <= M; ++i){
        while(j <= N && arr[j].A <= i){
            pq.push(arr[j].B);
            ++j;
        }
        if(!pq.empty()){
            ans += pq.top();
            pq.pop();
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1660
n = int(input())
l = []
for i in range(n):
    l += [list(map(int,input().split()))]
l = sorted(l,key=lambda x:x[1])
t = 0
for i in range(n):
    t += l[i][0]
    if t > l[i][1]:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 55256
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

int t[100000];
signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int(n);
    ll sum = 0;
    rep(i, n){
      scanf("%d", t+i);
      sum += (ll)t[i];
    }
    int(m);
    rep(i, m){
      int2(p, x);
      --p;
      pri(sum - (ll)t[p] + (ll)x);
    }

/*/

//*/ break;
  }
  return 0;
}


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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;


#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;



int main() {ll n;
    ci(n);
  vll A(8);
  ll now=0;
  
  FOR(i,0,8){
    if(n>99){
      now=n%1000;
      A[i]=max(753-now,now-753);
      n/=10;
    }
    else{
      A[i]=1000;
    }
  }
  SORT(A);
    co(A[0])
}

Measured memory_bytes: 256
($H,$W,$A,$B)=glob<>;
@o=map[('.')x$W],1..$H;
if($H%2){
	for($x=0;$x+1<$W;$x+=2){
		if($A){
			$o[-1][$x]='<';
			$o[-1][$x+1]='>';
			--$A
		}
	}
}
if($W%2){
	for($y=0;$y+1<$H;$y+=2){
		if($B){
			$o[$y][-1]='^';
			$o[$y+1][-1]='v';
			--$B
		}
	}
}
for($y=0;$y+1<$H;$y+=2){
	for($x=0;$x+1<$W;$x+=2){
		if($A>=2){
			$o[$y][$x]='<';
			$o[$y][$x+1]='>';
			$o[$y+1][$x]='<';
			$o[$y+1][$x+1]='>';
			$A-=2
		}elsif($B>=2){
			$o[$y][$x]='^';
			$o[$y+1][$x]='v';
			$o[$y][$x+1]='^';
			$o[$y+1][$x+1]='v';
			$B-=2
		}elsif($A){
			$o[$y][$x]='<';
			$o[$y][$x+1]='>';
			--$A
		}elsif($B){
			$o[$y][$x]='^';
			$o[$y+1][$x]='v';
			--$B
		}
	}
}
if($H>=3&&$H%2 && $W>=3&&$W%2 && $A==0 && $B==1){
	if($o[-2][-2]eq'.'){
		$o[-2][-3]='^';
		$o[-1][-3]='v';$o[-1][-2]='<';$o[-1][-1]='>';
		--$B
	}
}
if($A==0 && $B==0){
	print"YES\n";
	print@$_,$/for@o
}else{
	print"NO\n"
}


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

int main(){
  string s;
  cin >> s;
  int n = s.size();
  int cnt = 0;
  bool flag = false;

  for(int i=0; i<n; ++i){
    cnt = 0;
    string ns = s.erase(n-i-1);
    int nns = ns.size();
    if(nns%2==1) continue;
    for(int j=0; j<nns/2; ++j){
      if(ns[j]==ns[nns/2 + j]) ++cnt;
      if(cnt == nns/2) flag = true;
    }
    if(flag){
      cout << ns.size() << endl;
      return 0;
    }
  }

  return 0;
}


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

int main(){
    int N,ans=0;
    cin >> N;
    ll L[N];
    if(N<3){
        cout << ans << endl;
        return 0;
    }
    for(int i=0;i<N;i++)cin >> L[i];
    for(int p=0;p<N-2;p++){
        for(int q=p+1;q<N-1;q++){
            for(int r=q+1;r<N;r++){
                if(L[p]!=L[q] && L[q]!=L[r] && L[r]!=L[p] ){
                    if(L[p]+L[q]>L[r] && L[q]+L[r]>L[p] && L[r]+L[p]>L[q])ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3556
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
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)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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


int a;

int main() {

	cin >> a;

	cout << a + a * a + a * a * a << endl;

	return 0;
}



Measured memory_bytes: 3628
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline.rstrip()
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return tuple(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplt(n): return [tuple(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
P = inpl()
Q = inpl()

i = 0
a = 0
b = 0
for p in permutations(range(1,n+1)):
    i += 1
    if p == P:
        a = i
    if p == Q:
        b = i

print(abs(a-b))

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

#define NAME "A - Frog 1"
#define show(x) cout << (#x) << " is " << (x) << endl
#define ll long long
#define ms(arr,val) memset(arr,val,sizeof(arr))
#define len length()

const int maxn = 2e5;

int main(){
    //ifstream cin(NAME".inp");
    //ofstream cout(NAME".out");
    int n;
    cin>>n;
    //show(n);
    vector<int> h(n);
    vector<int> dp(n,INT_MAX);
    dp[0]=0;
    for(int i=0;i<n;i++){
        cin>>h[i];
        if (i-1>=0 && dp[i-1] + abs(h[i]-h[i-1]) < dp[i] ) dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
        if (i-2>=0 && dp[i-2] + abs(h[i]-h[i-2]) < dp[i] ) dp[i] = dp[i-2] + abs(h[i]-h[i-2]);
    }
    cout<<dp[n-1];

}


Measured memory_bytes: 4004
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    ll ans = 0;
    for(long long  i=0;i<s.size();i++){
        for(ll j=i;j<s.size();j++){
            string tmp = s.substr(i,j-i+1);
            ll k = (ll)stoll(tmp);
            if(i == 0 ||j == s.size()-1){
                ans += k*pow((ll)2,llabs((ll)s.size()-1-(j-i+1)));
            }
            else{
                ans += k*pow((ll)2,llabs((ll)s.size()-1-(j-i+2)));
            }
           // cout << "i=" << i << "ans =" << ans << endl;
        }
    }
    ans -= stoll(s);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n, r;
   cin >> n >> r;
   int ans = r + (n >= 10 ? 0 : (100 * (10 - n)));
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val S = readLine()!!.map { (it - '0').toLong() }
    var answer = 0L
    for (i in 0 until 1.shl(S.size - 1)) {
        val bits = (0 until S.size - 1).map { i.shr(it).and(1) == 1 }

        var localSum = 0L
        var current = 0L
        for (j in 0 until S.size) {
            current = current * 10L + S[j]
            if (bits.getOrElse(j , { false })) {
                localSum += current
                current = 0L
            } else {
            }
        }
        if (current > 0) {
            localSum += current
        }
        answer += localSum
    }
    println(answer)
}

Measured memory_bytes: 33732
#include <bits/stdc++.h>
using namespace std;
 
int main() {

    int N;
    cin >> N;
    vector<int> a(N);
    int two = 0, four = 0, one = 0;

    for(int i = 0; i < N; i++){
        cin >> a.at(i);
        if(a.at(i) % 4 == 0){
            four++;
        }else if(a.at(i) % 2 == 0){
            two++;
        }else{
            one++;
        }
    }

    if(four >= one){
        cout << "Yes" << endl;
    }else if(four == one - 1 && two == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3708
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string>
#include <string.h>
#include <math.h>
#include <iomanip>
#include <stdio.h>
using namespace std;

#define int64 long long
#define pii pair <int64, int64>
#define fr first
#define sc second
#define heap priority_queue
struct piii{
    int64 fr, sc, th;
    bool operator < (const piii &b){
        if (fr != b.fr) return fr < b.fr;
        if (sc != b.sc) return sc < b.sc;
        return th < b.th;
    }
};
///////////////////////////////////////////////
///////////////////////////////////////////////

int main(){
    cout << setprecision(2) << fixed;
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n, m, val;
    cin >> n >> m;
    for (int i = 0; i < m; i++){
        cin >> val;
        n -= val;
    }
    if (n < 0) cout << -1;
    else cout << n;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> ans(N, 0);
  for (int i = 0; i < N-1; i++) {
    int A;
    cin >> A;
    --A;
    ans[A]++;
  }
  for (int i = 0; i < N; i++) {
    cout << ans[i] << endl;
  }
}

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

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#define endl "\n"
#define all(V) V.begin( ), V.end( )
#define Unique(V) sort( all( V ) ), V.erase( unique( all( V ) ), V.end() )
#define Check( N , p ) ( !( ( N & ( 1LL << p ) ) == 0 ) )
#define ON( N , p ) ( N = N | ( 1LL << p ) )
#define OFF( N , p ) ( N = N & ~( 1LL << p ) )
std::mt19937 rng( chrono::steady_clock::now().time_since_epoch().count() );
#define rnd(a, b) ((((rand() << 15) ^ rand()) % ((b) - (a) + 1)) + (a))
#define ran(a, b) rng() % ( (b) - (a) + 1 ) + (a)
#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template < typename Arg1 >
void __f( const char* name , Arg1&& arg1 ) { cerr << name << " : " << arg1 << "\n"; }
template < typename Arg1 , typename... Args >
void __f( const char* names , Arg1&& arg1 , Args&&... args ) {
const char* comma = strchr( names + 1 , ',' );
cerr.write( names , comma - names ) << " : " << arg1 << " , " ; __f( comma + 1 , args... ); }
typedef long long int LL;
typedef pair <int,int> pii;
typedef pair <long long,long long> pll;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
const int N = 1e5 + 5;
const int inf = 1e9;
const long long INF = 1e18;


int main( int argc , char const *argv[] ) {
        ios_base::sync_with_stdio( false ); cin.tie( nullptr );
        int a , b , c;
        cin >> a >> b >> c;
        cout << min( b/a , c ) << endl;
        return 0;
}














Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define CB(X) \
  ( (X) * (X) * (X) )

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int i, j;

  for ( ; ; )
  {
    int res = 2;
    int z;

    scanf ( "%d", &z );
    if ( z == 0 ) break ;

    for ( i = 1; i < z; ++i )
    for ( j = 1; ; ++j )
    {
      const int tmp = CB( i ) + CB( j );

      if ( tmp > CB( z ) ) break ;
      if ( tmp > res )
        res = tmp;
    }

    printf ( "%d\n", CB( z ) - res );
  }

  return ( EXIT_SUCCESS );
}

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

using namespace std;

const int MOD = 1e9 + 7;


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

    unsigned long long n, m;
    cin >> n >> m;

    if (2 * n >= m)
        cout << m / 2;
    else {
        cout << n + (m - 2 * n) / 4;
    }

    return 0;
}


Measured memory_bytes: 256
def main():
    S = input()
    n = len(S) - 1

    ans = 0

    for i in range(2 ** n):
        ops = [""] * (n + 1)
        for j in range(n):
            if (i >> j) & 1:
                ops[j] = "+"

        fomula = ""
        for k in range(n + 1):
            fomula += S[k] + ops[k]

        ans += eval(fomula)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import sys

read = sys.stdin.read

N, *x = map(int, read().split())
mod = 10 ** 9 + 7
'''
x_(i+1)が選ばれる前にx_iが選ばれれば, x_(i+1)-x_iを加算
(N-1)!通りの中でこのような状況はsum (N-i)! i=2toN-1

x_(i+n)が選ばれる前、かつx_(i+1)からx_(i+n-1)が選ばれた後にx_iが選ばれれば, x_(i+n)-x_iを加算

'''
inv = [0] * N
for i in range(1, N):
    inv[i] = pow(i, mod - 2, mod)

for i in range(2, N):
    inv[i] = (inv[i] + inv[i - 1]) % mod

fact = 1
for i in range(1, N):
    fact *= i
    fact %= mod

answer = 0
for i, j, k in zip(inv[1:], x, x[1:]):
    tmp = (i * fact) % mod
    answer += tmp * (k - j) % mod
    answer %= mod

print(answer)


Measured memory_bytes: 14052
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	
	//文字列から10進数に変換するときはparseIntを使います
    var a = input[0];
    
    var b = "abcdefghijklmnopqrstuvwxyz";
    
    var c = b.indexOf(a);

    var d = b.substr(c+1,1);
	//出力
    console.log('%s',d);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

class Point{
    public:
        int t, x, y;
};

int main(){
    int n;
    cin >> n;
    vector<Point> p(n + 1);
    p[0].t = 0;
    p[0].x = 0;
    p[0].y = 0;
    rep(i, n){
        cin >> p[i + 1].t >> p[i + 1].x >> p[i + 1].y;
    }
    /*
    repi(i, p){
        cout << (*i).t << " " << (*i).x << " " << (*i).y << endl;
    }
    */
    rep(i, n){
        int t, x, y;
        t = p[i + 1].t - p[i].t;
        x = abs(p[i + 1].x - p[i].x);
        y = abs(p[i + 1].y - p[i].y);
        if(t < x + y){
            cout << "No" << endl;
            return 0;
        }
        if(t % 2 != (x + y) % 2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<malloc.h>
#include<math.h>
#include<x86intrin.h>


int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

void InputIntAry(int *a,int nDigit,int N){      //nDigitは想定される最大桁数
    char *buf,*ptr;

    buf=(char*)malloc( (N*(nDigit+2)) * sizeof(char) );
    my_gets(buf,N*(nDigit+2),stdin);

    ptr=strtok(buf," ");
    while(ptr!=NULL && N-->0){
        *(a++)=atoi(ptr);
        ptr=strtok(NULL," ");
    }
    free(buf);
}

int CmpInt(const void *a, const void *b){        //b-aを返す(qsortなら4321)
    return *((int*)b)- *((int*)a);
}

int main(){
    int N,H[100000];
    int Coh[100000],tmp=0;

    scanf("%d%*c",&N);
    InputIntAry(H,12,N);

    for(int i=N-1; i>=0; i--){
        Coh[i] = tmp++;
        if(i>0 && H[i]>H[i-1]){
            tmp=0;
        }
    }
    qsort(Coh, N, sizeof(int), CmpInt);

    printf("%d\n",Coh[0]);

    return 0;
} 

Measured memory_bytes: 1664
import math

s = list(map(int, input().split()))
rad = math.pi * 2 * (s[2] / 12.0 + (s[3] / 60.0) / 12.0 - s[3] / 60.0)
rsq = (s[0] * s[0] + s[1] * s[1]) - (2 * s[0] * s[1]) * math.cos(rad)
print(math.sqrt(rsq))

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

// @author: pashka

vector<vector<int>> g;
vector<int> comp;

void dfs(int x, int c) {
    if (comp[x] != -1) return;
    comp[x] = c;
    for (int y : g[x]) dfs(y, c);
}

int main() {
    ios::sync_with_stdio(false);

    int n, m, k;
    cin >> n >> m >> k;

    g.resize(n);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    comp.assign(n, -1);
    int cc = 0;
    for (int i = 0; i < n; i++) {
        if (comp[i] == -1) {
            dfs(i, cc++);
        }
    }
    vector<int> num(cc);
    for (int x : comp) num[x]++;

    vector<int> res(n);
    for (int i = 0; i < n; i++) {
        res[i] = num[comp[i]] - 1 - g[i].size();
    }

    for (int i = 0; i < k; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        if (comp[x] == comp[y]) {
            res[x]--;
            res[y]--;
        }
    }
    for (int x : res) cout << x << " ";

    return 0;
}

Measured memory_bytes: 7552
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <map>

using namespace std;

int main(){
    long mod = 1000000007;

    int n = 0, m = 0;
    cin >> n; cin >> m;

    int mm = m;

    vector<pair<int, int>> vec;
    for(int i=2; i*i<=mm; i++)
    {
        int cnt = 0;
        while(mm % i == 0)
        {
            cnt++;
            mm /= i;
        }
        if(cnt > 0)
        {
            vec.emplace_back(make_pair(i, cnt));
            //cout << i << " " << cnt << endl;
        }
    }
    if(mm > 1)
    {
        vec.emplace_back(make_pair(mm, 1));
        //cout << mm << " " << 1 << endl;
    }

    long ans = 1;
    for(auto p : vec)
    {
        long dp[2][p.second+1];
        for(int i=0; i<=p.second; i++){ dp[0][i] = 0; dp[1][i] = 0; }
        dp[0][0] = 1;

        for(int i=1; i<=n; i++)
        {
            for(int j=0; j<=p.second; j++)
            {
                for(int k=0; k<=j; k++)
                {
                    dp[i % 2][j] += dp[1 - (i % 2)][k];
                    dp[i % 2][j] %= mod;
                }
            }
            for(int j=0; j<=p.second; j++) dp[1 - (i % 2)][j] = 0;
        }
        //cout << dp[n % 2][p.second] << endl;
        ans = ans * dp[n % 2][p.second] % mod;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    int N, X;
    cin >> N >> X;
    int D;
    for (int i = 0; i < N; ++i) {
        int x;
        cin >> x;
        if (i) {
            D = __gcd(D, abs(X - x));
        } else {
            D = abs(X - x);
        }
    }

    cout << D << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iso646.h>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
    ll N, M;
    cin >> N >> M;
    priority_queue<ll> A;
    ll i;
    for(i = 0; i < N; i++) {
        ll a;
        cin >> a;
        A.push(a);
    }
    for(i = 0; i < M; i++) {
        ll a = A.top();
        A.pop();
        A.push(a / 2);
    }
    ll ans = 0;
    for(i = 0; i < N; i++) {
        ans += A.top();
        A.pop();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <math.h>
#include <list>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <string.h>

using namespace std;

#define endl '\n'
#define int long long
#define mod 1000000007

#define forn(i,n) for(int i=0;i<n;i++)

int32_t main() {
	string s,t; cin>>s>>t;
 
	int lenS = s.length();
	int lenT = t.length();
 
	int dp[lenS+1][lenT+1];
 		
 	memset(dp, 0, sizeof dp);

	for(int i=1;i<=lenS;i++) {
		for(int j=1;j<=lenT;j++) {
			dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			
			if(s[i-1] == t[j-1]) {
				dp[i][j] = max(dp[i-1][j-1] + 1, dp[i][j]);
			}
		}
	}

	string ans = "";

	int i = lenS, j = lenT;

	while(i && j) {
		if(s[i-1] == t[j-1]) {
			ans = s[i-1] + ans;
			i--;
			j--;
		} else if(dp[i][j-1]>dp[i-1][j]) {
			j--;
		} else {
			i--;
		}
	}
 
	cout<<ans;
		
	return 0;
}

Measured memory_bytes: 73952
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define sd(t)       scanf("%d",&(t))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define hii         cout << "hii" << endl
#define okay        cout << "okay" << endl
#define hey         cout << "hey" << endl
const int INF = 1e12;
const int MOD = 1e9+7;
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.x << ' ' << v.y; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.x << "=>" << i.y << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
clock_t time_p=clock();
void starboy1299()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
 
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("jjj.txt", "w", stdout);
    #endif
}

void solve(){


    int n, d;
    cin >> n >> d;

    int val = d*d;
    int ans = 0;

    rep(i, 0, n){
        int a, b;
        cin >> a >> b;
        if(a*a + b*b <= val) ans++;
    }

    cout << ans << endl;

}         

int32_t main(){
    fast();
    int t = 1;
    // cin>> t;
    for(int i=1; i<=t; i++){
        // cout << "Case #" << i << ": ";
        solve();
    }
    starboy1299();
}

Measured memory_bytes: 3804
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>

using namespace std;

int main(void) {
    int n;
    while (cin>>n && n) {
        vector<vector<string> > s;
        set<string> se;
        
        for (int i = 0; i < n; i++) {
            string t;
            vector<string> u;
            cin >> t;
            int l = 0, r = 0;
            while (t[r] != ':') r++;
            u.push_back(t.substr(l,r-l));
            r++;
            
            while (1) {
                l = r;
                while (t[r] != '.' && t[r] != ',') r++;
                u.push_back(t.substr(l,r-l));
                if (t[r] == '.') break;
                r++;
            }
            s.push_back(u);
        }
        
        for (int i = 0; i < s[0].size(); i++) se.insert(s[0][i]);
        s.erase(s.begin());
        bool f = true;
        int cnt = 1;
        
        while (f) {
            f = false;
            for (int i = 0; i < s.size(); i++) {
                set<string>::iterator it = se.find(s[i][0]);
                if (it != se.end()) {
                    for (int j = 1; j < s[i].size(); j++) se.insert(s[i][j]);
                    s.erase(s.begin()+i);
                    cnt++;
                    f = true;
                }
            }
        }
        cout << se.size()-cnt << endl;
    }
}

Measured memory_bytes: 3280
#include <string>
#include <iostream>
using namespace std;
const int mod = 1000000007;
int n, m, dp[1009][1009]; string s, t;
int main() {
	cin >> s >> t;
	n = s.size();
	m = t.size();
	dp[0][0] = 1;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j <= m; ++j) {
			dp[i + 1][j] = dp[i][j];
			if (j != 0 && s[i] == t[j - 1]) {
				dp[i + 1][j] += dp[i][j - 1];
				if (dp[i + 1][j] >= mod) dp[i + 1][j] -= mod;
			}
		}
	}
	cout << dp[n][m] << endl;
	return 0;
}


Measured memory_bytes: 7152
list = list(map(int, input().split()))
original = list[0]
n = list[1]
x = 0
ans = 0

if original//n != 0:
  x = original//n
  ans += 2
  while x//n != 0:
    x = x // n
    ans += 1
  print(ans)
else:
  print(1)




Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
const double PI=3.14159265358979323846;
const long long INF = 1LL << 60;

int main() {
	int H1, M1, H2, M2, K;
	cin >> H1 >> M1 >> H2 >> M2 >> K;
	int a=0, b=0, c=0, x, y, z;
	x = H2 - H1;
	y = M2 - M1;
	std::cout << x*60 + y - K << '\n';
}


Measured memory_bytes: 3636
#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>
#include<cstdio>
#include<cstring>
#include<map>
#include<set>
#include<fstream>
#include<sstream>
#include<queue>
#include<iterator>
#include<stack>

using namespace std;

#define st first
#define nd second
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REV(a) reverse(a.begin(),a.end())
#define SORT(a) sort(a.begin(),a.end())
#define inf (int)1e9
#define linf (long long)1e18

typedef long long ll;
typedef short int si;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;


int n,m;
string s[100];
int cnt[26];

int main() {
		cin>>n>>m;
		FOR(i,0,n)cin>>s[i];
		FOR(i,0,n){
				FOR(j,0,m){
						cnt[s[i][j]-'a']++;
				}
		}
		int haha=0;
		FOR(i,0,26)if(cnt[i]%2==1)haha++;
		if(haha>1){
				cout<<"No\n";
				return 0;
		}
		if(haha==1&&(n%2==0||m%2==0)){
				cout<<"No\n";
				return 0;
		}
		haha=0;
		if(n%2==1){
				haha+=m/2;
		}
		if(m%2==1){
				haha+=n/2;
		}
		FOR(i,0,26){
				if(cnt[i]%4==2)haha--;
		}
		if(haha>=0){
				cout<<"Yes\n";
		}
		else cout<<"No\n";


		return 0;
}


Measured memory_bytes: 256