akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
#define mp make_pair
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
    ch c;
    cin >> c;
    rep(i,26){
        if(abc[i]==c){
            cout << "a" << endl;
            return 0;
        }
    }
    cout << "A" << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
#define mod 1000000000+7
#define rep(i,n) for(int i=0;i<(int) (n);i++)
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
using namespace std;
int main(){
int n,ans=0;
cin>>n;
vector<int>a(n);
rep(i,n)cin>>a[i];
rep(i,n){
  int b;
  cin>>b;
  ans+=b;
}
int z;
z=n-1;
vector<int>c(z);
rep(i,n-1)cin>>c[i];


rep(i,n-1){
  int p,q;
  p=a[i];
  q=a[i+1];
  if(p+1 == q)ans+=c[p-1];
}

cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

const int inf = 1e9 + 10;

int N, M;
int A[100010];
int sum[100010];
map<int, int> m;

signed main()
{
	cin >> N >> M;
	int ans = 0;
	m[0]++;
	rep1(i, N) {
		cin >> A[i];
		sum[i] = A[i] + sum[i - 1];
		sum[i] %= M;
		ans += m[sum[i]];
		m[sum[i]]++;
	}

	cout << ans << endl;
}
// sum[i] = sum[j] (mod M) ( i > j )


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

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

  string s;
  cin >> s;
  string ans;
  for (char &i : s) {
    if (i == '0') {
      ans += '0';
    } else if (i == '1') {
      ans += '1';
    } else if (i == 'B') {
      if (ans != "") {
        ans.pop_back();
      }
    }
  }
  cout << ans << endl;
  return 0;

}

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

const int inf=1000000007;
const int MOD=1000000007;
const long long INF=1000000000000000007;

int n;
string s[100100];
unordered_map<string, int> m;

int main() {
  cin >> n;
  rep(i, n) {
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
  }

  ll ans = 0;
  rep(i, n) {
    ans += m[s[i]];
    m[s[i]]++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 17700
#include<iostream>
using namespace std;
int main(){
    int a,b;
    char op;
    while(1){
        cin>>a>>op>>b;
        if(op=='?')break;
        else if(op=='+')cout<<a+b<<endl;
        else if(op=='-')cout<<a-b<<endl;
        else if(op=='*')cout<<a*b<<endl;
        else if(op=='/')cout<<a/b<<endl;
    }return 0;
}


Measured memory_bytes: 3076
import math

p = math.pi
A, B, H, M = map(int, input().split())
t = H*60+M
ax, ay = A*math.sin((p*t)/360), A*math.cos((p*t)/360)
bx, by = B*math.sin(p*t/30), B*math.cos(p*t/30)
print(math.sqrt((ax-bx)**2+(ay-by)**2))

Measured memory_bytes: 9576
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#define manx 150005
using namespace std;

void trace(int a[],int n)
{
    int i;
    for(i=0; i<n; i++)
    {
        if(i>0)
            printf(" ");
        printf("%d",a[i]);
    }
    printf("\n");
}

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

}

int main()
{
    int n,i,j;
    int a[100];

    scanf("%d",&n);
    for(i=0; i<n; i++)
        scanf("%d",&a[i]);
    trace(a,n);
    insertionSort(a,n);
    return 0;
}



Measured memory_bytes: 3232
N,D = map(int,input().split())
X=[]
ans=0

def cheak_root(n):
    i=0
    while i<n:
        i+=1
        if i*i==n: return i
    return False

for i in range(N):
    X.append(list(map(int,input().split())))

for i in range(N):
    for j in range(i+1,N):
        sums=0
        for d in range(D):
            diff=X[i][d]-X[j][d]
            sums+=diff*diff
        if cheak_root(sums):ans+=1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007;
long long po(long long p,long long n){
    long long x=1;
    for(int i=n;i>0;i/=2){
        if(i%2){
            x*=p;
            x%=mod;
        }
        p*=p;
        p%=mod;
    }
    return x;
}
int main(){
    long long n,k,x=0;
    cin>>n>>k;
    long long g[k+1];
    for(int i=k;i>0;i--){
        g[i]=po(k/i,n);
        for(int j=i*2;j<=k;j+=i)g[i]-=g[j];
        g[i]=(g[i]%mod+mod)%mod;
        x+=g[i]*i;
        x%=mod;
    }
    cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 4376
#include <bits/stdc++.h>
using namespace std;
double INF = 100000000000000;
long long inversion_number(vector<int> p){
  int N = p.size();
  long long ans = 0;
  vector<int> BIT(N + 1, 0);
  for (int i = 0; i < N; i++){
    ans += i;
    int x;
    x = p[i] + 1;
    while (x > 0){
      ans -= BIT[x];
      x -= x & -x;
    }
    x = p[i] + 1;
    while (x <= N){
      BIT[x]++;
      x += x & -x;
    }
  }
  return ans;
}
long long inversion_count(vector<int> A, vector<int> B){
  int N = A.size();
  vector<int> p(N);
  for (int i = 0; i < N; i++){
    p[A[i]] = i;
  }
  for (int i = 0; i < N; i++){
    B[i] = p[B[i]];
  }
  return inversion_number(B);
}
int main(){
  cout << fixed << setprecision(20);
  int N;
  cin >> N;
  vector<double> A(N), B(N), C(N);
  for (int i = 0; i < N; i++){
    cin >> A[i] >> B[i] >> C[i];
  }
  double tx = INF;
  double fx = -INF;
  for (int i = 0; i < 100; i++){
    double mid = (tx + fx) / 2;
    vector<pair<double, int>> L(N);
    for (int j = 0; j < N; j++){
      L[j] = make_pair(A[j] / B[j], j);
    }
    sort(L.begin(), L.end());
    vector<pair<double, int>> M(N);
    for (int j = 0; j < N; j++){
      M[j] = make_pair((C[j] - A[j] * mid) / B[j], j);
    }
    sort(M.begin(), M.end());
    vector<int> A(N);
    for (int j = 0; j < N; j++){
      A[j] = L[j].second;
    }
    vector<int> B(N);
    for (int j = 0; j < N; j++){
      B[j] = M[j].second;
    }
    long long cnt = inversion_count(A, B);
    if (cnt >= ((long long) N * (N - 1) / 2 + 1) / 2){
      tx = mid;
    } else {
      fx = mid;
    }
  }
  double ty = INF;
  double fy = -INF;
  for (int i = 0; i < 100; i++){
    double mid = (ty + fy) / 2;
    vector<pair<double, int>> L(N);
    for (int j = 0; j < N; j++){
      L[j] = make_pair(B[j] / A[j], j);
    }
    sort(L.begin(), L.end());
    vector<pair<double, int>> M(N);
    for (int j = 0; j < N; j++){
      M[j] = make_pair((C[j] - B[j] * mid) / A[j], j);
    }
    sort(M.begin(), M.end());
    vector<int> A(N);
    for (int j = 0; j < N; j++){
      A[j] = L[j].second;
    }
    vector<int> B(N);
    for (int j = 0; j < N; j++){
      B[j] = M[j].second;
    }
    long long cnt = inversion_count(A, B);
    if (cnt >= ((long long) N * (N - 1) / 2 + 1) / 2){
      ty = mid;
    } else {
      fy = mid;
    }
  }
  cout << tx << ' ' << ty << endl;
}

Measured memory_bytes: 6800
#include <iostream>

using namespace std;

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

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

H, W, K = MAP()

s = [input() for _ in range(H)]

tmp = 1
ans = [[0]*W for _ in range(H)]

for i in range(H):
	if not "#" in s[i]:
		if i != 0:
			ans[i] = ans[i-1]
			continue
		else:
			continue

	is_first = True
	for j in range(W):
		if s[i][j] == "#":
			if is_first:
				is_first = False
			else:
				tmp += 1
		ans[i][j] = tmp
	tmp += 1

for i in range(H-2, -1, -1):
	if 0 in ans[i]:
		ans[i] = ans[i+1]

for i in range(H):
	print(*ans[i])


Measured memory_bytes: 14044
import java.util.Scanner
import scala.collection.mutable.Stack 

object Main extends App { 
  val sc = new Scanner(System.in)
  val N, S = sc.nextInt()
  val array = (for (i <- 0 until N) yield sc.nextInt()).toArray

  def solver(l:Int, r:Int, acc:Int, len:Int):Int = {
    if (r >= N && acc < S) if (len < N+1) len else 0
    else if (acc < S) solver(l, r+1, acc+array(r), len)
    else solver(l+1, r, acc-array(l), len min (r-l))
  }

  println(solver(0, 0, 0, N+1))
}


Measured memory_bytes: 131224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(ll i = (ll)a; i <= (ll)b; i++)
#define DEC(i, a, b) for(ll i = (ll)a; i >= (ll)b; i--)
typedef pair<ll, ll> pi;
#define f first
#define s second
typedef vector<ll> vi;
typedef vector<pi> vpi;
#define pb push_back
#define all(v) v.begin(), v.end()
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

pi frac(ll a, ll b) {
	if (b == 0) return pi(a, b);
	ll g = gcd(a, b);
	pi res = pi(a/g, b/g);
	if (res.s < 0) {
		res.f *= -1;
		res.s *= -1;
	}
	return res;
}

pi inv(pi a) {
	return frac(-1 * a.s, a.f);
}

ld a, b;
ll n, ans = 1, two[200005], mod = 1e9+7, a0, b0, ab0;
map<pi, ll> num;
set<pi> s;


int main() {
	fastio; cin >> n;
	FOR(i, 1, n) {
		cin >> a >> b;
		if (a == 0 and b == 0) ab0++;
		else if (a == 0) a0++;
		else if (b == 0) b0++;
		else {
			pi p = frac(a, b);
			num[p]++;
			if (p.f < 0) s.insert(inv(p));
			else s.insert(p);
		}
	}
	two[0] = 1; FOR(i, 1, n) two[i] = (2*two[i-1]) % mod;
	for (auto it:s) {
		ans *= (two[num[it]] + two[num[inv(it)]] - 1) % mod;
		ans %= mod;
		num[it] = 0; num[inv(it)] = 0;
	}
	ans *= (two[a0] + two[b0] - 1) % mod;
	ans += mod + ab0 - 1;
	ans %= mod;
	cout << ans;
}


Measured memory_bytes: 42704
#include<cstdio>
#include<algorithm>
using namespace std;

#define ll long long 
#define debug if (debug_message)

#define file_io 0
#define debug_message 0

ll i,t,j;
ll n,nt,a[100005],b,c,q,cnt[100005],sum;

int main(){
	if (file_io){
		freopen(".in","r",stdin);
		freopen(".out","w",stdout);
	}
	
	scanf("%lld",&n);
	
	for (i=1; i<=n; ++i) {
		scanf("%lld",&a[i]);
		cnt[a[i]]++;
		sum+=a[i];
	}
	
	scanf("%lld",&q);
	
	for (i=1; i<=q; ++i){
		scanf("%lld%lld",&b,&c);
		sum+=(c-b)*cnt[b];
		cnt[c]+=cnt[b];
		cnt[b]=0;
		printf("%lld\n",sum);
	}
	
	return 0;
}
/*

*/

Measured memory_bytes: 3240
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;
 
int main()
{
	int N;
	string S;
	cin >> N >> S;
 
	for(int i=0;i<S.size();i++){
		int tt;
		char t;
		tt=(int)S[i]+N;
		if(tt<=90){
			t = (int)S[i]+N;
			cout << t;
		}
		else{
			t = (int)S[i]+N-26;
			cout << t;
		}
	}
	cout << endl;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
#define downint greater<int>()
#define downchar greater<char>()
#define downstring greater<string>()
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,r=0;
  int a[LIMIT2]={0};
  deque<int> b;
  
  cin >> n;
  rep(i,n) cin >> a[i];
  
  rep(i,n){
    if(r%2 == 0) b.push_back(a[i]);
    else b.push_front(a[i]);
    r++;
    r%=2;
  }
  if(r==0){
    while(!b.empty()){
      cout << b.front() << " ";
      b.pop_front();
    }
  }else{
    while(!b.empty()){
      cout << b.back() << " ";
      b.pop_back();
    }
  }
  
  return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <cstdlib>

bool isStable(char* A, char *B, int N)
{
	for (int i=0; i<N; i++) {
		if (A[i] != B[i]) return false;
	}
	return true;
}

void copy(int *A, int *B, int N)
{
	for (int i=0; i<N; i++) A[i] = B[i];
}

void copy(char *A, char *B, int N)
{
	for (int i=0; i<N; i++) A[i] = B[i];
}

void show(char *suits, int* nums, int N)
{
	std::cout << suits[0] << nums[0];
	for (int i=1; i<N; i++) std::cout << " " << suits[i] << nums[i];
	std::cout << std::endl;
}

void swap(int& a, int& b)
{
	int tmp = a; a = b; b = tmp;
}

void swap(char& a, char& b)
{
	char tmp = a; a = b; b = tmp;
}

void bubbleSort(char* suits, int* nums, int N)
{
	for (int i=0; i<N; i++) {
		for (int j=N-1; j>i; j--) {
			if (nums[j-1] > nums[j]) {
				swap(suits[j-1], suits[j]); 
				swap(nums[j-1], nums[j]);
			}
		}
	}
}

void selectionSort(char* suits, int* nums, int N)
{
	for (int i=0; i<N; i++) {
		int min_i = i;
		for (int j=i; j<N; j++) {
			if (nums[j] < nums[min_i]) min_i = j;
		}
		if (i < min_i) {
			swap(suits[i], suits[min_i]); 
			swap(nums[i], nums[min_i]); 
		}
	}
}

int main()
{
	int N;
	std::cin >> N;
	
	char *suits = new char[N];
	int *nums = new int[N];
	for (int i=0; i<N; i++) {
		std::cin >> suits[i] >> nums[i];
	}
	
	char *suits_cpy = new char[N];
	int *nums_cpy = new int[N];
	copy(suits_cpy, suits, N);
	copy(nums_cpy, nums, N);
	
	bubbleSort(suits, nums, N);
	show(suits, nums, N);
	std::cout << "Stable" << std::endl;
	
	selectionSort(suits_cpy, nums_cpy, N);
	show(suits_cpy, nums_cpy, N);
	if (isStable(suits, suits_cpy, N)) std::cout << "Stable" << std::endl;
	else std::cout << "Not stable" << std::endl;

	delete[] suits;
	delete[] nums;
	delete[] suits_cpy;
	delete[] nums_cpy;
	
	return 0;
}




Measured memory_bytes: 3100
//浣跨敤杩涘埗杞崲

#include <bits/stdc++.h>
using namespace std;

int ans;
int t(int n, int k);
int main()
{
    int x, m;
    cin >> x >> m;
    t(x, m);
    cout << ans << endl;
}
int t(int n, int k)
{
    int r;
    r = n % k;
    n = n / k;
    if (n != 0)
        t(n, k);
    ans++;
}

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

vector<vi> adj;
map<ii, int> mapEdge;
int u[101], v[101], a[101], b[101],c[51], d[51];

ll dp[51][3001];
void solve(int node, int coin) {
	queue<ii> q;
	q.push(ii(node, coin));
	dp[node][coin] = 0;
	while(!q.empty()){
		ii front = q.front(); q.pop();
		node = front.first, coin = front.second;
		// printf("node: %d coin: %d\n",node, coin);
		ll waktu = (ll)inf*(ll)inf;
		for(int i=0;i<adj[node].size();i++){
			int v = adj[node][i];
			int idxEdge = mapEdge[ii(node, v)];
			if(coin >= a[idxEdge]){
				int sisa = coin - a[idxEdge];
				if(dp[v][sisa] > dp[node][coin] + b[idxEdge]) {
					// printf("push v: %d sisaCoin: %d\n",v, coin - a[idxEdge]);
					q.push(ii(v, sisa));
					dp[v][sisa] = dp[node][coin] + b[idxEdge];
					
				}
			}

			ll totCoin = min((ll)coin + c[node], (ll)3000);
			if(dp[node][totCoin] > dp[node][coin] + d[node]) {
				// printf("dorong node: %d totCoin: %lld\n",node, totCoin);
				q.push(ii(node, totCoin));
				dp[node][totCoin] = dp[node][coin] + d[node];		
			}
		}
	}
}

int main(){
	int n,m,s,i,j;
	
	scanf("%d %d %d",&n,&m,&s);
	adj.assign(n+1, vi());
	for(i=0;i<m;i++){
		scanf("%d %d %d %d",&u[i],&v[i],&a[i],&b[i]);
		adj[u[i]].pb(v[i]);
		adj[v[i]].pb(u[i]);
		mapEdge[ii(u[i], v[i])] = i;
		mapEdge[ii(v[i], u[i])] = i;
	}
	for(i=1;i<=n;i++){
		scanf("%d %d",&c[i],&d[i]);
	}
	int maksVal = 3000;
	s = min(s, maksVal);
	for(i=1;i<=n;i++){
		for(j=0;j<=3000;j++){
			dp[i][j] = (ll)inf*(ll)inf;
		}
	}

	dp[1][s] = 0;
	solve(1, s);
	

	for(i=2;i<=n;i++){
		ll ans = (ll)inf*(ll)inf;	
		for(j=0;j<=3000;j++){
			// if(j <= 10){printf("dp[%d][%d]: %lld\n",i,j,dp[i][j]);}
			ans = min(ans, dp[i][j]);
		}
		printf("%lld\n",ans);
	}
	
	return 0;
};

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

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

    priority_queue<ll> que;
    for(int i=0;i<N;i++){
        ll A;
        cin >> A;
        que.push(A);
    }

    for(int i=0;i<M;i++){
        ll now = que.top();
        que.pop();
        que.push(now/2);
    }

    ll ans = 0;
    while(!que.empty()){
        ans += que.top();
        que.pop();
    }

    cout << ans << endl;
}

Measured memory_bytes: 1400
import queue

N = int(input())

pos = []
for _ in range(N):
    a, b = map(int, input().split())
    pos.append((a, b))

visited = {v: False for v in pos}
edges = {v: [] for v in pos}
x_sorted = sorted([(p[0], i) for i, p in enumerate(pos)])
for i in range(len(x_sorted) - 1):
    j = x_sorted[i][1]
    l = x_sorted[i+1][1]
    edges[pos[j]].append((pos[l], abs(pos[l][0] - pos[j][0])))
    edges[pos[l]].append((pos[j], abs(pos[l][0] - pos[j][0])))
y_sorted = sorted([(p[1], i) for i, p in enumerate(pos)])
for i in range(len(y_sorted) - 1):
    j = y_sorted[i][1]
    l = y_sorted[i+1][1]
    edges[pos[j]].append((pos[l], abs(pos[l][1] - pos[j][1])))
    edges[pos[l]].append((pos[j], abs(pos[l][1] - pos[j][1])))

que = queue.PriorityQueue()
que.put((0, pos[0]))

res = 0
while not que.empty():
    cost, vertex = que.get()
    if visited[vertex]:
        continue
    visited[vertex] = True
    res += cost

    for to, next_cost in edges[vertex]:
        if not visited[to]:
            que.put((next_cost, to))

print(res)


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

using namespace std;


struct edge{
    long from;
    long to;
    long cost;
};

long dist[2500];

//return
//true:if nagetive loop does not exist
//false:if negative loop exists
//d:result
bool bellmanford(edge es[],long d[], long start, long num_v, long num_e){
    //init
    for(long i = 0; i < num_v; i++){
        d[i] = __LONG_MAX__;
    }
    d[start] = 0;
    int cnt_loop = 0;
    while(true){
        cnt_loop++;
        bool update = false;
        bool update_end;
        if(cnt_loop == num_v) update_end = false;
        for(int i = 0; i < num_e; i++){
            edge e = es[i];
            if(d[e.from] != __LONG_MAX__ && d[e.from]+e.cost < d[e.to]){
                //cout << "update " << e.to << endl;
                d[e.to] = d[e.from]+e.cost;
                update = true;
                //cout << num_v-1 << endl;
                if(e.to == (num_v-1)) update_end = true;
            }
        }
        if(!update) return true;
        else if(cnt_loop >= 2*num_v) return !update_end;
    }
}

//vector<int> G[2500];
edge es[5000];


int main(){
    int N, M, P;
    cin >> N >> M >> P;
    for(int i = 0; i < M; i++){
        int A, B, C;
        cin >> A >> B >> C;
        A--;
        B--;
        es[i] = (edge){A, B, P-C};
        //cout << P-C <<  endl;
    }
    if(!bellmanford(es, dist, 0, N, M)){
        cout << -1 << endl;
        //cout << "H" << endl;
    }else{
        cout << max((long)0, -dist[N-1]) << endl;
    }
}

Measured memory_bytes: 384
import java.io.*;
public class Main {
    private static MyScanner scanner;

    public static void main (String[] args){
        Main instance = new Main();
        scanner = instance.new MyScanner();
        instance.solve();
    }

    private void solve() {
        try {
            long min_point = scanner.nextLong();
            long mod_min_point = min_point % 11;
            if ( 6 < mod_min_point) {
                System.out.println(2*(min_point/11) + 2);
            } else if (0 < mod_min_point){
                System.out.println(2*(min_point/11) + 1);
            } else if (mod_min_point == 0){
                System.out.println(2*(min_point/11));
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String line = br.readLine();
            while (line.equals("")) {
                line = br.readLine();
            }
            s = line.split(reg, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }

        public long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 8272
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int maxn=1000+10,maxd=5000+10,inf=1000000000;
int f[maxn][2],g[maxn][maxd][2],a[maxn];
int X[maxn],h[maxn],go[maxn],nxt[maxn];
int i,j,k,l,t,n,m,tot,top;
bool czy;
void add(int x,int y){
	go[++tot]=y;
	nxt[tot]=h[x];
	h[x]=tot;
}
void dfs(int x){
	int t=h[x];
	while (t){
		dfs(go[t]);
		t=nxt[t];
	}
	if (!czy) return;
	top=0;
	t=h[x];
	while (t){
		a[++top]=go[t];
		t=nxt[t];
	}
	int i,j,k,l,r;
	fo(i,0,top)
		fo(j,0,X[x])
			g[i][j][0]=g[i][j][1]=inf;
	g[0][0][0]=g[0][0][1]=0;
	fo(i,0,top-1)
		fo(j,0,X[x])
			fo(k,0,1){
				if (g[i][j][k]==inf) continue;
				fo(l,0,1){
					if (k==l) t=X[a[i+1]];else t=f[a[i+1]][l]-X[a[i+1]];
					if (k==l) r=0;else r=X[a[i+1]];
					if (j+t<=X[x]) g[i+1][j+t][k]=min(g[i+1][j+t][k],g[i][j][k]+r);
				}
			}
	f[x][0]=f[x][1]=inf;
	fo(k,0,1)
		fo(j,0,X[x])
			f[x][k]=min(f[x][k],g[top][j][k]);
	f[x][0]=min(f[x][0]+X[x],inf);f[x][1]=min(f[x][1]+X[x],inf);
	if (f[x][0]>=inf&&f[x][1]>=inf) czy=0;
}
int main(){
	scanf("%d",&n);
	fo(i,2,n){
		scanf("%d",&j);
		add(j,i);
	}
	fo(i,1,n) scanf("%d",&X[i]);
	czy=1;
	dfs(1);
	if (czy) printf("POSSIBLE\n");else printf("IMPOSSIBLE\n");
}

Measured memory_bytes: 37248
import java.io.*;
import java.math.*;
import java.util.*;





public class Main {

    static MyScanner in = new MyScanner();
    static   PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    int N;
    static int max = 200001;
    static int [] dr = {1,-1,0,0};
    static int [] dc={0,0,-1,1};
    public static void main(String args[]) throws IOException {
            int R = in.nextInt();
            out.println(Math.PI*R*2);
            out.flush();
        }
       static boolean isEven(long a){
            return (a&1)==0;
        }
       static  void swap (int a, int b){

        int temmp = b;
        b=a;
        a = temmp;
        }
        static boolean same(int [] arr,int [] temp){
            Arrays.sort(arr);
           Arrays.sort(temp);
            for(int i=0;i<arr.length;i++){
                if(temp[i]!=arr[i])
                return false;
            }
            return true;
        }

 
  


    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
   
        public MyScanner() {
           br = new BufferedReader(new InputStreamReader(System.in));
        }
   
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
   
        int nextInt() {
            return Integer.parseInt(next());
        }
   
        long nextLong() {
            return Long.parseLong(next());
        }
   
        double nextDouble() {
            return Double.parseDouble(next());
        }
   
        String nextLine(){
            String str = "";
        try {
           str = br.readLine();
        } catch (IOException e) {
           e.printStackTrace();
        }
        return str;
        }
  
     }
}

Measured memory_bytes: 33248
#include<stdio.h>
#include<algorithm>
int main() {
	
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int N, M;
	scanf("%d", &N);
	printf("Christmas ");
	for (int i = N; i < 25; i++) {
		printf("Eve ");
	}
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        int m, f, r;
        Scanner sc = new Scanner(System.in);
        m = sc.nextInt();
        f = sc.nextInt();
        r = sc.nextInt();
        while (m != -1 || f != -1 || r != -1) {
            if (m == -1 || f == -1) {
                System.out.println("F");
            } else if (m + f >= 80) {
                System.out.println("A");
            } else if (m + f >= 65) {
                System.out.println("B");
            } else if (m + f >= 50) {
                System.out.println("C");
            } else if (m + f >= 30) {
                if (r >= 50) {
                    System.out.println("C");
                } else {
                    System.out.println("D");
                }
            } else {
                System.out.println("F");
            }
            m = sc.nextInt();
            f = sc.nextInt();
            r = sc.nextInt();
        }
    }
}


Measured memory_bytes: 26144
N = int(input())
A = list(map(int, input().split()))

d = dict()

for a in A:
    d[a] = d.get(a, 0) + 1

ans = 0
for k, v in d.items():
    if k == v:
        continue
    if k > v:
        ans += v
    if k < v:
        ans += v - k

print(ans)


Measured memory_bytes: 17780
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static ArrayList<Integer> ps;

	static boolean solve() {
		int n = in.nextInt();
		if (n == 0) return false;

		long ans = 0;
		for (int i=0; i<n; i++) {
			ans += ps.get(i);
		}
		out.println(ans);

		return true;
	}

	static ArrayList<Integer> createPrimeList(int n) {
		if (n < 2) return null;
		ArrayList<Integer> res = new ArrayList<Integer>();
		BitSet isPrimeBit = createIsPrimeBit(n);
		int p = 1;
		while ((p = isPrimeBit.nextSetBit(p+1)) >= 0) {
			res.add(p);
		}
		return res;
	}

	static BitSet createIsPrimeBit(int n) {
		if (n < 2) return null;
		BitSet res = new BitSet();
		res.set(2,n,true);
		for (int i=2; i*i<n; i=res.nextSetBit(i+1)) {
			for (int j=i+i; j<n; j+=i) res.set(j,false);
		}
		return res;
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		ps = createPrimeList(10000000);

		while(solve());
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

Measured memory_bytes: 48492
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    cin.sync_with_stdio(0);
    
    int n;
    string s;
    cin >> n >> s;

    int sumE = 0;
    for (int i = 0; i < n; i++) if (s[i] == 'E') sumE++;
    int sumW = n - sumE;

    int e = 0, w = 0;
    int sum, mini = n;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'E') {
            e++;
            sum = sumE - e + w;
        } else {
            w++;
            sum = sumE - e + w - 1;
        }

        mini = min(sum, mini);
    }

    cout << mini << endl;
}

Measured memory_bytes: 3476
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define F first
#define S second
#define pi acos(-1)
using ll = long long;
using namespace std;
using namespace __gnu_pbds;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
const ll mod = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;


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

void solve(){
    int n,cnt = 0;
    cin>>n;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        if(x % 2 == 1&& i%2 == 1 ){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  //  int n; cin>>n; for (int i = 0; i < n; ++i)
    solve();
    return 0;
}


Measured memory_bytes: 3644
#include<stdio.h>
#include<string.h>
 
int main(){
  int i, len, h0, h1, h2, h3, in;
  char str[20];
   
  h0 = h1 = h2 = h3 = 0;
 
  scanf("%s", str);
 
  len = strlen(str);
 
  if(len >= 6) h0 = 1;
 
  for(i=0; i<len; i++){
    in = str[i];
    if(in >= 48 && in <=57) h1 = 1;
    else if(in <= 90 && in >=65) h2 = 1;
    else if(in >= 97 && in <=122) h3 = 1;
  }
   
  if(h0==1 && h1==1 && h2==1 && h3==1) printf("VALID\n");
  else printf("INVALID\n");
 
  return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  map<int, int> a;
  REP(i, n) {
    int aa;
    cin >> aa;
    a[aa] = i + 1;
  }
  for (auto& it : a) {
    cout << it.second << endl;
  }
  return 0;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using  namespace  std;
using ll=long long;
int main(){
int n;
cin>>n;
vector<int> a(n);
for(int i=0;i<n;i++)cin>>a.at(i);
int alice=0,bob=0;
sort(a.begin(),a.end(),greater<int>());
for(int i=0;i<n;i++){
if(i%2==0)alice+=a.at(i);
else bob+=a.at(i);
}
cout<<alice-bob<<endl;
}


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

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

#define RFOR(i, b, a) for(int(i)=(b); (i)>=(a); (i)--)
#define RREP(i, n) FOR((i), (n), 0)

#define pb push_back
#define mp make_pair 

using namespace std;

const int INF=INT_MAX/4;
const int MOD=1000000007;
const double EPS=1e-14;

const bool debug_flag=true;

void debug(string str){
	if(debug_flag){
		cout<<str<<endl;
	}
}

void debugs(string str){
	if(debug_flag){
		cout<<str;
	}
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout.precision(10);

	int n, m;
	cin>>n>>m;
	vector<string> a(n), b(m);
	REP(i, n){
		cin>>a[i];
	}
	REP(i, m){
		cin>>b[i];
	}
	
	REP(c, n-m+1){
		REP(d, n-m+1){
			bool flag=true;
			REP(i, m){
				if(flag){
					REP(j, m){
						if(a[c+i][d+j]!=b[i][j]){
							flag=false;
							break;
						}
					}
				}
			}
			if(flag){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}

	cout<<"No"<<endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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; }

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  string s;
  cin >> s;

  string ans;

  for(int i=1; i<s.size(); i++){
    if((s.size()-i)%2 != 0) continue;
    ans = s.substr(0,s.size()-i);
    bool ok=true;
    rep(j,ans.size()/2){
      if(ans[j] != ans[j + ans.size() / 2]) ok=false;
    }
    if(ok){
      cout << ans.size() << endl;
      return 0;
    }
  }

  return 0;
} 

Measured memory_bytes: 3604
#include <iostream>
using namespace std;
int main()
{
    long long n,m,ans;
    cin>>n>>m;
    if(m - 2*n >= 0) {
        ans += n;
        ans += (m-2*n)/4;
    } else {
        ans = m/2;
    }
    cout << ans;
    return 0;
}

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

using namespace std;

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

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

ll n;

int main(){
  cin>>n;
  vl factors;
  for(ll x=2;x*x<=n;x++)if(n%x==0){
    factors.push_back(x);
    if(n/x != x)factors.push_back(n/x);
  }
  vl primes;
  ll t = n;
  for(ll x=2;x*x<=t;x++)if(t%x==0){
    primes.push_back(x);
    while(t%x==0)t/=x;
  }
  if(t>1 && t<n)primes.push_back(t);
  int mn = primes.size();
  if(mn==0)mn=1;
  int mx = factors.size() + 1;
  printf("%d %d\n",mn, mx);
  return 0;
}



Measured memory_bytes: 3272
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String word = sc.next();
		for(int i = word.length(); i >=0;) {
			if(i - 5 < 0) {
				System.out.println("NO");
				return;
			}
			if(word.substring(i-5,i).equals("dream") || word.substring(i-5,i).equals("erase")) {
				i -= 5;
				if(i == 0) {
					System.out.println("YES");
					return;
				}else {
					continue;
				}
			}
			if(i - 6 < 0) {
				System.out.println("NO");
				return;
			}
			if(word.substring(i-6,i).equals("eraser")) {
				i -= 6;
				if(i == 0) {
					System.out.println("YES");
					return;
				}else {
					continue;
				}
			}
			if(i - 7 < 0) {
				System.out.println("NO");
				return;
			}
			if(word.substring(i-7,i).equals("dreamer")) {
				i -= 7;
				if(i == 0) {
					System.out.println("YES");
					return;
				}else {
					continue;
				}
			}else {
				System.out.println("NO");
				return;
			}
		}
	}
}

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

int main(){
  int n;
  cin >> n;
  if(n%1111==0)
    cout << "Yes" << endl;
  else if((n/10)%111==0)
    cout << "Yes" << endl;
  else if((n%1000)%111==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  long ans = 0;
  rep (i, N) {
    long a;
    cin >> a;
    while (a % 2 == 0) {
      a /= 2;
      ans++;
    }
  }
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	int n;
	cin >> n;
	
	vector<int> v(n), pos(n, -1);
	
	for(int i = 0; i < n; i++)
		cin >> v[i];
	
	pos[n - 1] = 1;
	int ans = 1;
	for(int i = n - 2; i >= 0; i--){
		if(v[i + 1] <= v[i])
			pos[i] = 1 + pos[i + 1];
		else
			pos[i] = 1;
		ans = max(ans, pos[i]);
	}
	
	cout << ans - 1 << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll ceil(ll a, ll b) {  // a÷b以上の最小の整数
    if(b == 0) {
        return 0;
    }
    return (a+b-1)/b;
}

int main() {
    ll h, w;
    cin >> h >> w;
    if(h == 1 || w == 1) {
        out(1);
        re0;
    }
    out(ceil(h*w, 2));
    re0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
int p[25];
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> p[i];
	int cnt = 0;
	rep(i, n - 2) {
		if (p[i] < p[i + 1] && p[i + 1] < p[i + 2])cnt++;
		if (p[i] > p[i + 1] && p[i + 1] > p[i + 2])cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
M, D = gets.chomp.split(' ').map(&:to_i)

output = 0

max = D/10
maxLast = D%10
(4..M).each do |i|
  (2..(max-1)).each do |j|
    next if i%j != 0
    r = i/j
    output += 1 if r < 10 && r > 1
  end
  output += 1 if max > 1 && i % max == 0 && i/max <= maxLast && i/max > 1
end

puts output


Measured memory_bytes: 1788
#include <iostream>
#include <cmath>
#define INF 10000000

using namespace std;

int main(int argc, char const* argv[])
{
	int n, m;
	cin >> n >> m;
	int *c = new int[m];
	int **dp = new int*[m];
	for(int i = 0; i < m; i++){
			cin >> c[i];
			dp[i] = new int[n + 1];
			for(int j = 0; j <= n; j++){
					if(j == 0){
							dp[i][j] = 0;
					}else{
							dp[i][j] = INF;
					}
			}
	}
	for(int i = 0; i <= n / c[0]; i++){
			dp[0][i * c[0]] = i;
	}
	for(int i = 0; i < m - 1; i++){
			for(int j = 0; j <= n; j++){
					dp[i + 1][j] = dp[i][j];
					if(j - c[i + 1] >= 0){
							dp[i+1][j] = min(dp[i + 1][j], dp[i + 1][j - c[i + 1]] + 1);
					}
			}
	}
	cout << dp[m - 1][n] << endl;
	return 0;
}



Measured memory_bytes: 6988
import math

a,b,x = map(int,input().split())


if a*a*b>2*x:
	print(90- math.atan2(2*x, a*b*b) *360/(2*math.pi))
else:
	print(90- math.atan2(a**3, 2*(a*a*b-x)) *360/(2*math.pi))

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

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

  int n,t,a;
  cin >> n >> t >> a;
  
  vector<double> v;
  int m;
  double temp;
  for(int i = 0; i < n; i++){
    cin >> m;
    temp = t - m * 0.006 - a;
    v.push_back(fabs(temp));
  }
  
  auto iter = min_element(v.begin(), v.end());
  size_t index = distance(v.begin(), iter);

  cout << index + 1 << endl;
}


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

typedef long long ll;
typedef long double ld;

#define pb push_back

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

void solve()
{
				
	
		int x;
		cin>>x;
		if(!x)cout<<1;
		else
		cout<<0;	
			
		
	
}

int main()
{
	
solve();
		
	
	
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <math.h>

int main(){
	
	int i,n,s;
	int a[52];
	char m;

	for (i = 0; i < 52; i++){
		a[i] = 0;
	}

	scanf("%d", &n);

	for (i = 0; i < n; i++){
		//scanf("%c %d",&m, &s);
		scanf(" %c", &m);
		scanf("%d",&s);
		if (m == 'S'){
			a[s - 1] = 1;
		}else if(m=='H'){
			a[s + 12] = 1;
		}else if (m=='C'){
			a[s + 25] = 1;
		}else if(m=='D'){
			a[s + 38] = 1;
		}
	}

	for (i = 0; i < 52; i++){
		if (a[i] == 0){
			if (i < 13){
				printf("S %d\n",i+1);
			}else if (i < 26){
				printf("H %d\n",i-12);
			}else if (i < 39){
				printf("C %d\n",i-25);
			}else if(i <52){
				printf("D %d\n",i -38);
			}
		}
		
	}
	return 0;
}

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

int main(){
    int a = 0;int ans = 0;int min_one = 10;
    for(int i=0;i<5;i++){
        cin>>a;
        int one_d = a%10;
        if(one_d>0) a += (10-one_d);
        ans += a;
        if(one_d==0) continue;
        min_one = min(one_d, min_one);
    }
    ans -= (10-min_one);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

int main() {
	// 小数点以下12ケタを表示させるためのおまじない
	cout << fixed << setprecision(12);

	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	double x = x2 - x1;
	double y = y2 - y1;
	cout << fixed << sqrt(x * x + y * y) << endl;
	return 0;
}



Measured memory_bytes: 3256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <string>
     
using namespace std;
     
      
         
int main(){
  int N, L;
  cin >> N >> L;
  vector<string> vec(N, "");
  string ans = "";
  for(int i = 0; i < N; i++) cin >> vec[i];
      
  sort(vec.begin(), vec.end());
  for(int i = 0;i < N; i++) ans += vec[i];
  cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define ll long long
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int read()
{
    char ch = getchar();
	int x = 0, f = 1;
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
int main()
{
	ll n,d;
	cin>>n>>d;
	ll ans=n/(2*d+1)+(n%(2*d+1)==0?0:1);
	cout<<ans;
}


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



int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll i = 0; i < n; i++) cin >> a[i];

    ll k;
    ll search = 1;
    for(ll i = 0; i < n; i++){
        if(search == a[i]) search++;
    }
    search--;
    ll ans;
    if(search == 0) ans = -1;
    else ans = n - search;
    cout << ans << endl;



}

Measured memory_bytes: 1792