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

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

    int count_1=0,count_2=0;
    //10101...
    for(int i=0; i<s.size(); i++){
        if(i%2==0){
            if(s[i]=='0'){
                count_1++;
            }
        }else{
            if(s[i]=='1'){
                count_1++;
            }
        }
    }
    //01010...
    for(int i=0; i<s.size(); i++){
        if(i%2==0){
            if(s[i]=='1'){
                count_2++;
            }
        }else{
            if(s[i]=='0'){
                count_2++;
            }
        }
    }

    cout<<min(count_1,count_2)<<endl;
}

Measured memory_bytes: 512
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

void solve(){
	while(true){
		int n;
		cin >> n;
		if (n == 0) return;
		vector<pair<string, string>> inputs;
		REP(i, n) {
			string a, b;
			cin >> a >> b;
			inputs.push_back(mp(a, b));
		}
		string a, c;
		cin >> a >> c;
		map<string, int> gogo;
		gogo[a] = 1;
		queue<string> next;
		next.push(a);
		while (next.empty() == false) {
			string now = next.front();
			next.pop();
			REP(i, n) {
				string b;
				for (int q = 0; q < now.length(); ++q) {
					if (q + inputs[i].first.length() - 1 < now.length()) {
						int ok = 1;
						for (int j = 0; j < inputs[i].first.length(); ++j) {
							if (inputs[i].first[j] != now[q+j]) {
								ok = 0;
								break;
							}
						}
						if (ok == 1) {
							b += inputs[i].second;
							q += inputs[i].first.length() - 1;
							continue;
						}
					}
					b.push_back(now[q]);
				}
				if (b.length() > c.length()) continue;
				if (gogo[b] == 0) {
					gogo[b] = gogo[now] + 1;
					next.push(b);
				}
			}
		}
		cout << gogo[c] - 1 << endl;
	}
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define vec vector
#define vi vec<int>
#define vvi vec<vec<int>>
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(ALL(a))
#define RSORT(a) stable_sort(RALL(a))
#define REV(a) reverse(ALL(a))
#define UNIQUE(a) a.erase(unique(ALL(a)), end(a))
#define lambda(i) [=](auto i)
#define compare(i, j) [=](auto i, auto j)
#define min_of(a) *min_element(ALL(a))
#define max_of(a) *max_element(ALL(a))
#define sum(a) accumulate(ALL(a), 0)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(a) (int)(a).size()
#define REP(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define RREP(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (auto i = b - 1; i != a; i--)
#define EACH(i, a) for (auto&& i: (a))
using namespace std;

const int INF = 1e18;
const int MOD = 1e9 + 7;

int ceil_div(int X, int Y) {
  return (X - 1) / Y + 1;
}

struct union_find {
  vi data;
  union_find(int size) : data(size, -1) { }
  bool union_set(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find_set(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

vi cum(vi V) {
  vi U(SZ(V));
  partial_sum(ALL(V), begin(U));
  return U;
}

void solve() {
  int n;
  int ans = 0;

  cin >> n;
  string s = to_string(n);

  cout << (s[0] == '7' || s[1] == '7' || s[2] == '7' ? "Yes" : "No") << endl;
  // REP(i, n) {
  //   cout << v[i];
  // }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  solve();
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}



int main() {
  i64 N, K;
  cin >> N >> K;
  vector<i64> A(N);
  rep(i,0,N) cin >> A[i];
  i64 mi = 0;
  i64 ze = 0;
  i64 pl = 0;
  rep(i,0,N) {
    if(A[i] < 0) mi++;
    if(A[i] == 0) ze++;
    if(A[i] > 0) pl++;
  }
  if(K <= mi * pl) {
    i64 ok = 1e18 + 10;
    i64 ng = 0;
    vector<i64> X;
    vector<i64> Y;
    rep(i,0,N) {
      if(A[i] < 0) X.push_back(-A[i]);
      else if(A[i] > 0) Y.push_back(A[i]);
    }
    sort(all(X));
    sort(all(Y));
    while(ok - ng > 1) {
      i64 mid = (ok + ng) / 2;
      i64 j = Y.size();
      i64 ans = 0;
      for(i64 i = 0;i < X.size(); i++) {
        while(j > 0 && Y[j - 1] * X[i] > mid) {
          j--;
        }
        ans += j;
      }
      ans = mi * pl - ans;
      //cout << mid << " = " << ans << endl;
      if(ans < K) ok = mid;
      else ng = mid;
    }
    cout << -ok << endl;
    return 0;
  }
  else if(K <= mi * pl + ze * (mi + pl) + ze * (ze - 1) / 2) {
    cout << 0 << endl;
    return 0;
  }
  else {
    K -= mi * pl + ze * (mi + pl) + ze * (ze - 1) / 2;
    i64 ng = 1e18 + 10;
    i64 ok = 0;
    vector<i64> X;
    vector<i64> Y;
    rep(i,0,N) {
      if(A[i] < 0) X.push_back(-A[i]);
      else if(A[i] > 0) Y.push_back(A[i]);
    }
    sort(all(X));
    sort(all(Y));
    while(ng - ok > 1) {
      i64 mid = (ok + ng) / 2;
      i64 j = X.size();
      i64 ans = 0;
      for(i64 i = 0;i < X.size(); i++) {
        while(j > 0 && X[j - 1] * X[i] > mid) {
          j--;
        }
        if(j <= i) break;
        ans += j - i - 1;
      }
      j = Y.size();
      for(i64 i = 0;i < Y.size(); i++) {
        while(j > 0 && Y[j - 1] * Y[i] > mid) {
          j--;
        }
        if(j <= i) break;
        ans += j - i - 1;
      }
      //cout << mid << " = " << ans << endl;
      if(ans < K) ok = mid;
      else ng = mid;
    }
    cout << ok + 1 << endl;
    return 0;
  }
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define maxs 2020202
#define pb(u)  push_back(u)
#define mme(i,j) memset(i,j,sizeof(i))
using namespace std;
vector<int>ed[maxs];
int n,m;

bool dfs(int u,int p,int k)
{
    if(k==0&&u==n)
        return 1;
    if(!k) return 0;
    int sz =ed[u].size();
    for(int i=0;i<sz;i++)
    {
        int j = ed[u][i];
        if(j == p ) continue;
        
        if(dfs(j,u,k-1)) return 1;
    }
    return 0;
}

int main()
{
    while(~scanf("%d%d",&n,&m))
    {
        for(int i=0;i<=n;i++) ed[i].clear();

        int u,v;
        for(int i=0;i<m;i++)
        {
            scanf("%d%d",&u,&v);
            ed[u].push_back(v);
            ed[v].push_back(u);
        }
        if(dfs(1,0,2))
            puts("POSSIBLE");
        else puts("IMPOSSIBLE");
    }
    return 0;
}

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

int main(){
  int d, e;
  while(cin >> d >> e, d || e){
    double ans = 1e9;
    double money;
    int path;
    for(int i = 0; i <= 100; i++){
      path = d - i;
      if(path < 0)break;
      money = sqrt(i * i + path * path) - e;
      if(money < 0)money = -money;
      ans = min(ans, money);
    }
    cout << fixed << setprecision(10) << ans << endl;
  }
}

Measured memory_bytes: 3140
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=1e5;

int main(){
	int N;
	cin>>N;
	lli A[MAX];
	lli sum=0;
	rep(i,N){
		cin>>A[i];
		sum+=A[i];
	}
	sort(A,A+N,greater<int>());

	int ans=1;
	rep1(i,N-1){
		sum-=A[i-1];
		if(2*sum<A[i-1])break;
		ans++;
	}
	cout<<ans;
}

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

using namespace std;

int cnt = 0;

bool Op(int id) {
  ++cnt;
  assert(cnt <= 20);
  cout << id << endl;
  string res;
  cin >> res;
  if (res == "Vacant") {
    exit(0);
  }
  return (res == "Male");
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<bool> a(n);
  a[0] = Op(0);
  int low = 0, high = n;
  while (high - low > 1) {
    int mid = (low + high) / 2;
    a[mid] = Op(mid);
    if ((a[mid] == a[low]) != (mid % 2 == low % 2)) {
      high = mid;
    } else {
      low = mid;
    }
  }
  Op(low);
  throw;
}


Measured memory_bytes: 3856
n = int(input())
heights = [int(x) for x in input().split()]

dp = [float("inf")] * n
dp[0] = 0
for i in range(1, n):
    if i - 2 >= 0:
        val1 = abs(heights[i] - heights[i - 1]) + dp[i - 1]
        val2 = abs(heights[i] - heights[i - 2]) + dp[i - 2]
        dp[i] = min(val1, val2)
    else:
        dp[i] = abs(heights[i] - heights[i - 1]) + dp[i - 1]
print(dp[-1])

Measured memory_bytes: 20408
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MOD = 1e9+7;
const ll LINF = 1e18;
const int INF = 1e9;
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

int main()
{
    cin >> X;

    for (ll i = 1; i < 100000; i++)
    {
        if(X%i == 0) 
        {
            Y = X / i;
                // cout << Y << endl;
            for (ll j=0; j <= Y/2; j++)
            {

                A = j;
                B = j-i;
                ll A2 = A*A;
                ll B2 = B*B;
                D = A * B;
                E = (A*A)+(A*B)+(A*A);
                if(Y == A2*A2+B2*B2+D*(A2+D+B2))
                {
                    cout<< A << " " << B;
                    return 0;
                }

            }
            
        } 
    }
    
    
    return 0;
}

Measured memory_bytes: 3636
N, K = map(int, input().split())
*A, = map(int, input().split())
mod = 10**9+7
v1, v2 = 0, 0

for i in range(N):
    p, q = 0, 0
    for j in range(i+1, N):
        if A[i]>A[j]:
            p += 1
    
    for j in range(N):
        if i==j:continue
        if A[i]>A[j]:
            q += 1
    
    v1 += p
    v2 += q

print((v1*K+v2*(K*(K-1)//2))%mod)

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

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

  int64_t M=N+1;
  int64_t count=0;
  for(int i=0;i<N;++i){
    if(M>=P[i]){
      M=P[i];
      ++count;
    }
  }

  cout<<count<<endl;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PAIR;
map<LL,LL>w;
int cmp(const PAIR a,const PAIR b)
{
    return a.first>b.first;
}
int main(void)
{
    LL n;
    while(cin>>n)
    {
        w.clear();
        for(LL i=0;i<n;i++)
        {
            LL c;
            cin>>c;
            if(!w.count(c)) w[c]=0;
            w[c]++;
        }
        vector<PAIR>x;
        for(map<LL,LL>::iterator it=w.begin();it!=w.end();it++)
             x.push_back(make_pair(it->first,it->second));
        sort(x.begin(),x.end(),cmp);
        LL flag=0,cc=0,num=0,xx=0,sum=1;
        for(LL i=0;i<x.size();i++)
        {
            if(num==2) break;
            if(x[i].second<2)
                continue;
            else
            {
                flag=1;
                if(x[i].second>=4&&cc==0)
                {
                    cout<<x[i].first*x[i].first<<endl;
                    xx=1;
                    break;
                }
                else
                {
                    sum*=x[i].first;
                    cc=1;
                    num++;
                }
            }
        }
        if(flag==0||num==1)
        {
            cout<<0<<endl;
            continue;
        }
        if(xx==0)
        {
            cout<<sum<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 8696
from itertools import product
n,k = map(int, input().split())
d = list(map(int, input().split()))

nums = []
for i in range(10):
  if i not in d: nums.append(i)

m = len(str(n))
for i in range(m, m+2):
  for j in product(nums, repeat=i):
    ans = ""
    for k in j: ans += str(k)
    if int(ans) >= n:
      print(ans)
      exit()

Measured memory_bytes: 9064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n, m, a, ans = 0;

    cin >> n >> m;
    for(int i = 0; i < m; i++)
    {
        cin >> a;
        ans += a;
    }

    if(n - ans < 0)
    {
        cout << "-1" << endl;
    }
    else
    {
        cout << n - ans << endl;
    }
    
}

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

bool counter(int _i,int _j,int _k,int _y){
  if(10000*_i + 5000*_j + 1000*_k == _y){
    return true;
  }
  else{
    return false;
  }
}
  

int main(){
  
  int n,y;
  cin >>n >>y;
  
  vector<int> answer(3);
  
  for(int i=0; i<=n; i++){
    for(int j=0; j<=n-i; j++){
      for(int k=0; k<=n-i-j; k++){
        if(counter(i,j,k,y) && i+j+k == n){
          answer.at(0) = i;
          answer.at(1) = j;
          answer.at(2) = k;
          break;
        }
        else{
          continue;
        }
      }
    }
  }
  
  if(answer.at(0)==0 && answer.at(1)==0 && answer.at(2)==0){
    for(int i=0; i<3; i++){
      cout << -1 << " ";
    }
  }
  else{
    for(int i=0; i<3; i++){
      cout << answer.at(i) << " ";
    }
  }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for( int i=a; i<b; i++)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<pii>vpi;
void solve(){
    ll n,k;
    cin>>n>>k;
    vll h(n);
    vll dp(n);
    for(ll i=0;i<n;i++){
        cin>>h[i];
    }
    dp[n-1] = 0;
    ll mn;
    for(ll i = n-2; i>=0; i--){
        mn = INT_MAX;
        for(ll j = 1; i+j<=n-1 && j<=k;j++){
            mn = min( mn, dp[i+j]+abs(h[i]-h[i+j]) );
        }
        dp[i] = mn;
    }
    cout<<dp[0]<<"\n";
    // for(ll i =0;i<n;i++){
    //     cout<<dp[i]<<" ";
    // }
    // cout<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t;
    // cin>>t;
    t =1;
    while(t--){
        solve();
    }
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll, int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const int N = 100005;

struct query{
	int i, l, r, ans;
};

void solve(){
	int n,qq;
	cin >> n >> qq;
	vector<int> a(n), see(n+1);
	vector<query> q(qq);
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i = 0; i < qq; i++){
		cin >> q[i].l >> q[i].r;
		q[i].i = i;
		q[i].l--, q[i].r--;
	}
	int len = sqrt(n) + 1;
	sort(q.begin(), q.end(), [&len](query &a, query &b){ // sqrt decomp. trick (mo's)
		if(a.l/len != b.l/len)
			return a.l/len < b.l/len;
		return a.r < b.r;
	});
	int l = 0, r = -1, cnt = 0;
	for(auto &q:q){
		while(l < q.l){
			see[a[l]]--;
			if(see[a[l]] == 0)cnt--;
			l++;
		}
		while(l > q.l){
			l--;
			if(see[a[l]] == 0)cnt++;
			see[a[l]]++;
		}
		while(r < q.r){
			r++;
			if(see[a[r]] == 0)cnt++;
			see[a[r]]++;
		}
		while(r > q.r){
			see[a[r]]--;
			if(see[a[r]] == 0)cnt--;
			r--;
		}
		q.ans = cnt;
	}
	sort(q.begin(), q.end(), [](query &a, query &b){
		return a.i < b.i;
	});
	for(int i = 0; i < qq; i++)
		cout << q[i].ans << '\n';
}

int main(){
	fastio;
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 15400
-- うおおおおお競プロでHaskell勉強してやるううううううう

import Data.Char
import Data.List
import System.IO
import Control.Applicative
import Control.Monad
-- https://hoogle.haskell.org で関数検索

{- お客様の中でHaskellを書ける方はいらっしゃいますか？
    と、Haskellの例がなくて困っていたところを @tanakh さんに助けて頂きました。本当にありがとうございました。-}
main :: IO ()
main = do
    a <- getChar
    putStrLn [chr$(ord a)+1]
    



  -- print
pr [] = putStrLn ""
pr (x:xs) = do
    putStr $ (show x) ++ " "
    pr xs

or2 c1 c2 x 
    | c1 x ==True    = True
    | c2 x ==True    = True
    | otherwise        = False

same3 [a,b,c]
    | a==b && b==c = True
    | otherwise         = False       
      
diff3 [a,b,c] 
    | a==b = False
    | b==c = False
    | c==a = False
    | otherwise = True

yesno cond
    | cond         = putStrLn "Yes"
    | otherwise = putStrLn "No"
    
    
    
{-

ord 'a' --> 97
chr 97 --> 'a'

main = do 
    [a,b] <- getDoubleList
    print $ ceiling $  a / b
  


 「/」はdouble同士でしか使えない

main = readLn >>= print . ceiling . (/2) 


(+) 3 $ (*) 4 4
-> 19
pure (+) <*> (Just 1) <*> ( Just 3)
-> Just 4

main = do 
    [a,b] <- getIntegerList 
    print $ (a*(a-1)+b*(b-1)) `div` 2
    -- / じゃなくて'div' ！！！！！

main = do
    s <- getLine    
    samecoffee s

samecoffee [x,y,a,b,c,d] 
    | a==b && c==d = do putStrLn "Yes"
    | otherwise         = do putStrLn "No"
samecoffee s = do putStrLn ""
         
putStrLn $ (show c) ++ " " ++ (show a) ++ " " ++ (show b)


main :: IO ()
main = do
    -- 整数の入力
    a <- readLn
    -- スペース区切り整数の入力
    [b, c] <- getIntegerList

    --[b, c] <- map read . words <$> getLine
    -- 文字列の入力
    s <- getLine
    -- 出力
    putStrLn $ show (a + b + c) ++ " " ++ s
-}

-- レイアウト規則

fac 0 = 1
fac n = n * fac (n-1)

-- FileName   : 164a
-- CreatedDate: 2020-04-26 20:56:13

--------------------------------------------  https://atcoder.jp/contests/abc164/submissions/12342628

getIntList        = map (read :: String -> Int) . words <$> getLine
getIntegerList    = map (read :: String -> Integer) . words <$> getLine
getIntegerListN m = map (read :: String -> Integer) <$> replicateM m getLine

getStringList    = words <$> getLine
getDoubleList    = map (read :: String -> Double) . words <$> getLine

base :: Integer
base = 1000000007

plus :: Integer -> Integer -> Integer
plus a b = (a+b) `mod` base

times :: Integer -> Integer -> Integer
times a b = a * b `mod` base

minus :: Integer -> Integer -> Integer
minus a b
   | a < b     = a-b + base
   | otherwise = a-b

power :: Integer -> Integer -> Integer
power n k
   | k == 0         = 1
   | k `mod` 2 == 0 = power (times n n) (k`div`2)
   | otherwise      = times n $! power n (k-1)

inv :: Integer -> Integer
inv n = power n $ base - 2

binom :: Integer -> Integer -> Integer
binom n m
   | (n-m) < m = times (foldr times 1 [m+1..n]) $ inv $ foldr times 1 [1..n-m]
   | otherwise = times (foldr times 1 [n-m+1..n]) $ inv $ foldr times 1 [1..m]



















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

typedef long long ll;

int N;
ll A[200010],X[200010];
ll mem[200010];
ll MAX[200010];
ll aa[200010],bb[200010];
ll ans = 0;

int main()
{
    scanf("%d",&N);
    for(int i = 1; i <= N; i++)
    {
        scanf("%lld%lld",X + i,A + i);
        A[i] += A[i - 1];
    }
    for(int i = 1; i <= N; i++)aa[i] = A[i] - X[i];
    for(int i = 1; i <= N; i++)bb[i] = A[i - 1] - X[i];

    ll mm = -1001001001001001001;
    for(int i = N; i > 0; i--)
    {
        mm = max(mm,aa[i]);
        MAX[i] = mm;
    }

    for(int i = 1; i <= N; i++)
    {
        ans = max(ans,MAX[i] - bb[i]);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
int n,m,q;
int dp[502][502];
int main() {
    int a,b;
    scanf("%d%d%d",&n,&m,&q);
    for(int i = 0;i < m;i ++) {
        scanf("%d%d",&a,&b);
        dp[a][b] ++;
    }
    for(int j = 1;j < n;j ++) {
        for(int i = 1;i + j <= n;i ++) {
            int k = i + j;
            dp[i][k] += dp[i + 1][k] + dp[i][k - 1];
            if(j > 1)dp[i][k] -= dp[i + 1][k - 1];
        }
    }
    for(int i = 0;i < q;i ++)
 {
        scanf("%d%d",&a,&b);
        printf("%d\n",dp[a][b]);
    }
    return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int a,n,m;
	cin>>a>>n>>m;
	int sum;
	int gk;
	int gk2;
	int y=1;
	int cnt=0;
	while(1){
		sum=a+y;
		gk=1;
		
		for(int i=0;i<n;i++){
			gk*=sum;
		}
	
		if(gk>m)	break;
		gk2=0;
		while(gk>0){
			gk2+=gk%10;
			gk=gk/10;
		}
		
		if(gk2==y)	cnt++;
		y++;
	}
	cout<<cnt<<endl;
	return 0;
}
		


Measured memory_bytes: 3136
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#define ll long long
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> a(m);
    for(int i=0;i<m;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    vector<int> dif(m-1);
    for(int i=0;i<m-1;i++){
        dif[i]=a[i+1]-a[i];
    }
    sort(dif.begin(),dif.end());
    int ans=0;
    for(int i=0;i<m-n;i++){
        ans+=dif[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int N;
	while(~scanf("%d", &N)) {
		vector<int> A(N);
		for(int i = 0; i < N; ++ i)
			scanf("%d", &A[i]);
		vector<vector<ll>> dp(N + 1, vector<ll>(2, -1));
		dp[0][0] = 0;
		rep(i, N) rep(j, 2) {
			ll x = dp[i][j];
			if(x == -1) continue;
			rep(a, 2) rep(b, 2) {
				if(a + b > A[i]) continue;
				amax(dp[i + 1][b], x + (j + a) / 2 + (A[i] - a - b) / 2);
			}
		}
		ll ans = max(dp[N][0], dp[N][1]);
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 6144
#include <iostream>
#include <string.h>
#include <map>
#include <utility>
#include <algorithm>
using namespace std;

#define ll long long

int main () {
  ll n;
  cin >> n;
  pair<ll, ll> sum[n];
  ll x[n], y[n];
  for (ll i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    sum[i] = make_pair(x[i] + y[i], i);    
  }
  sort(sum, sum + n);
  ll takahasi, aoki;
  takahasi = 0;
  aoki = 0;
  for (ll i = 0; i < n; i++) {
    ll j = n - i - 1;
    if (i % 2 == 0) {
      takahasi += x[sum[j].second];  
    }  
    else {
      aoki += y[sum[j].second];  
    }
  }
  cout << takahasi - aoki << endl;
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        String al = "abcdefghijklmnopqrstuvwxyz";
        String[] alp = al.split("");
        int cou[] = new int[26];

        while(scn.hasNextLine()) {
            String s ="";
            s = scn.nextLine();
            String[] str = s.split("");

            for (int i = 0; i < al.length(); i++) {
                 cou[i] += count(str, alp[i]);
            }

        }


        for (int i = 0; i < al.length(); i++) {
            System.out.printf("%s : %d%n",alp[i],cou[i]);
        }

        scn.close();


    }

    static int count(String[] S, String M) {
        int c = 0;
        for (int i = 0; i < S.length; i++) {
            if (S[i].equalsIgnoreCase(M)) {
                c += 1;
            }
        }
        return c;
    }


}


Measured memory_bytes: 28576
package main

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

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	turn := true
	for a > 0 && c > 0 {
		if turn {
			c -= b
			turn = false
		} else {
			a -= d
			turn = true
		}
	}
	if a <= 0 {
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")
}

// =================================
// I/O util
// =================================

var sc = bufio.NewScanner(os.Stdin)


func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

Measured memory_bytes: 1820
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cctype>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int a,b,c;
	cin>>a>>b>>c;
	cout<<(a-b)%c;
	return 0;
}


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

int64_t Q=1000000007;

int64_t jyo(int64_t x,int64_t y,int64_t z){
  int64_t H=y; //ここから
       int64_t a=1,b=0,c=1;
       while(H>0){
         a*=2;
         if(H%a!=0){
           H-=a/2;
           int64_t d=x;
           for(int j=0;j<b;j++){
            d=d*d;
             d=d%z;
          }
           c=c*d;
          c=c%z;
         }
        b++;
      } //ここまで
  return c;
}

int main() {
  int64_t N;
  cin>>N;
  cout<<(Q+Q+jyo(10,N,Q)+jyo(8,N,Q)-2*jyo(9,N,Q))%Q;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main() {
  int A, P;
  scanf("%d %d", &A, &P);

  int ApplePie = A*3 + P;
  if(ApplePie % 2 == 0) {
    printf("%d", ApplePie / 2);
  }
  else if(ApplePie < 2) {
    printf("0");
  }
  else {
    printf("%d", (ApplePie - 1) / 2);
  }
  return 0;
}

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        n: usize,
    }
    let mut p = vec![];
    for x in vec![6, 9] {
        let mut d = x;
        while d <= n {
            p.push(d);
            d *= x;
        }
    }
    p.sort();
    let mut x = vec![0; n + 1];
    for i in 1..n + 1 {
        x[i] = i;
    }
    for pi in p {
        for i in pi..n + 1 {
            let y = x[i - pi] + 1;
            if y < x[i] {
                x[i] = y;
            }
        }
    }
    println!("{}", x[n]);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

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


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

int main() {
int N, Y;
cin >> N >> Y;
int count = 0;
int x, y, z;
for(int a = 0; a <= N; a++){
for(int b = 0; b <= N; b++){
if((10000*a + 5000*b + 1000*(N - a - b)) == Y){
count++;
x = a;
y = b;
z = (N - a - b) ;}}}
if(count >= 1 && z >= 0){
cout << x << " " << y << " " << z << endl;}
else cout << "-1 -1 -1" << endl;}


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

void swap(int *, int *);

int main(){

  int *A, i, j, n, flag, count=0;

  scanf("%d",&n);

  A = (int *)malloc( sizeof(int) * n);

  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
  }

  flag = 1;

  while(flag){
    flag = 0;
    for(j=0; j<n-1; j++){
      for(i=n-1; i>0; i--){
	if(A[i] < A[i-1]){
	  swap(&A[i], &A[i-1]);
	  flag = 1;
	  count++;
	}
      }
    }
  }
    
  for(i=0; i<n-1; i++){
    printf("%d ", A[i]);
  }

  printf("%d\n",A[i]);
  printf("%d\n",count); 

  return 0;
}

void swap(int *a, int *b){
  int c;

  c = *a;
  *a = *b;
  *b = c;

}

Measured memory_bytes: 600
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

def main():
    n = I()

    return pow(n,3)


print(main())



Measured memory_bytes: 5712
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
using namespace std;
int sum(int k){
    int d;
    int s=0;
    while(k){
        d=k%10;
        s+=d;
        k/=10;
    }
    return s;
}
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    long long int ans=0;
    for(int i=1;i<=n;i++){
        if((a<=sum(i))&&(b>=sum(i))){
            ans+=i;
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include  <stdio.h>
#define N 100
int main(){
    int i,j,k;
    int A[1000],v,num;
    
    scanf("%d",&num);
    for(i=0;i<num;i++) scanf("%d",&A[i]);
    
    for(i=0;i<num;i++){
        v = A[i];
        j = i - 1;
        while(j>=0 && A[j]>v){
            A[j+1] = A[j];
            j--;
            A[j+1] = v;
        }
	printf("%d",A[0]);
         for(k=1;k<num;k++) printf(" %d",A[k]);
         printf("\n");
    }
    return 0;
}


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

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

  vector<string> s(n);
  rep(i, n) cin >> s.at(i);

  int ac = 0, wa = 0, tle = 0, re = 0;
  rep(i, n) {
    string r = s.at(i);
    if (r == "AC") {
      ac++;
    } else if (r == "WA") {
      wa++;
    } else if (r == "TLE") {
      tle++;
    } else {
      re++;
    }
  }

  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
  return 0;
}

Measured memory_bytes: 6424
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
void maxii(P &a, const P &b) {
    if (a.first < b.first){
        a.second = max(a.first, b.second);
        a.first = b.first;
    }
    else{
        a.second = max(a.second, b.first);
    }
}
//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    
    vector<ll> A(1<<N);
    vector<P> dp;
    rep(i,1<<N) cin>>A[i], dp.emplace_back(A[i],-INF2);

    rep(i,N) rep(j,1<<N) if (j&(1<<i)) maxii(dp[j],dp[j xor (1<<i)]);

    ll ans=0;

    reps(i,1,1<<N){
        maxi(ans,dp[i].first+dp[i].second);
        cout<< ans <<"\n";
    }
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 9324
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
//ll MOD = 1000000007;
ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
vector<pair<ll, pii> > data;
int dp[214514][4]={0};
int main(){
	string str;
	cin>>str;
	int n=str.size();
	rep(i,n+1)rep(j,5)dp[i][j]=-n-1;
	dp[1][1]=1;
	dp[2][2]=1;
	dp[3][3]=1;
	for(int i=0;i<str.size();i++){
		if(i>=1&&(str[i]!=str[i-1]))dp[i+1][1]=max(dp[i+1][1],dp[i][1]+1);
		if(i>=2)dp[i+1][1]=max(dp[i+1][1],dp[i][2]+1);
		if(i>=3)dp[i+1][1]=max(dp[i+1][1],dp[i][3]+1);
		
		if(i>=2)dp[i+1][2]=max(dp[i+1][2],dp[i-1][1]+1);
		if(i>=3&&(str[i]!=str[i-2]||str[i-1]!=str[i-3]))dp[i+1][2]=max(dp[i+1][2],dp[i-1][2]+1);
		if(i>=4)dp[i+1][2]=max(dp[i+1][2],dp[i-1][3]+1);
		
		if(i>=3)dp[i+1][3]=max(dp[i+1][3],dp[i-2][1]+1);
		if(i>=4)dp[i+1][3]=max(dp[i+1][3],dp[i-2][2]+1);
		if(i>=5&&(str[i]!=str[i-3]||str[i-1]!=str[i-4]||str[i-2]!=str[i-5]))dp[i+1][3]=max(dp[i+1][3],dp[i-2][3]+1);
	}
	cout<<max(dp[n][1],max(dp[n][2],dp[n][3]))<<endl;
}

Measured memory_bytes: 3716
c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())

diff1 = c21 - c11
diff2 = c31 - c21
if diff1 == (c22-c12) and diff2 == (c32-c22) and diff1 == (c23-c13) and diff2 == (c33-c23):
    print("Yes")
else:
    print("No")
    


Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#define maxn 110
#define ll long long
using namespace std;
ll n,i,p=1e9,q,t;
double ans[maxn],x,y,z;
struct type
{
	ll x,y,id;
}a[maxn],s[maxn];
ll mul(ll a,ll b,ll c,ll d)
{
	return a*d-b*c;
}
bool cmp1(type x,type y)
{
	return x.y<y.y||x.y==y.y&&x.x<y.x;
}
bool cmp2(type x,type y)
{
	ll ans=mul(x.x-a[1].x,x.y-a[1].y,y.x-a[1].x,y.y-a[1].y);
	if(ans!=0)return ans>0;
	return(x.x-a[1].x)*(x.x-a[1].x)<(y.x-a[1].x)*(y.x-a[1].x);
}
int main()
{
	scanf("%lld",&n);
	if(n==2)
	{
		puts("0.5");
		puts("0.5");
		return 0;
	}
	for(i=1;i<=n;i++)
	{
		scanf("%lld%lld",&a[i].x,&a[i].y);
		a[i].id=i;
	}
	sort(a+1,a+n+1,cmp1);
	t=1;
	s[1]=a[1];
	sort(a+2,a+n+1,cmp2);
	for(i=2;i<=n;i++)
	{
		while(t>1&&mul(s[t].x-s[t-1].x,s[t].y-s[t-1].y,a[i].x-s[t].x,a[i].y-s[t].y)<=0)t--;
		s[++t]=a[i];
	}
	s[t+1]=s[1];
	s[t+2]=s[2];
	for(i=2;i<=t+1;i++)
	{
		x=sqrt((s[i-1].x-s[i].x)*(s[i-1].x-s[i].x)+(s[i-1].y-s[i].y)*(s[i-1].y-s[i].y));
		y=sqrt((s[i-1].x-s[i+1].x)*(s[i-1].x-s[i+1].x)+(s[i-1].y-s[i+1].y)*(s[i-1].y-s[i+1].y));
		z=sqrt((s[i+1].x-s[i].x)*(s[i+1].x-s[i].x)+(s[i+1].y-s[i].y)*(s[i+1].y-s[i].y));
		ans[s[i].id]=0.5-(acos((x*x+z*z-y*y)/2/x/z)/acos(-1)/2);
	}
	for(i=1;i<=n;i++)
		printf("%.10lf\n",ans[i]);
}

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

using namespace std;

const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int qn;
  cin >> qn;

  vector<set<int>> v(26);
  for (int i = 0; i < n; ++i) {
    v[(s[i]-'a')].insert(i);
  }

  vector<int> ans;
  for (int i = 0; i < qn; ++i) {
    int type;
    cin >> type;
    if (type == 1) {
      int a; char b;
      cin >> a >> b;
      a--;
      v[(s[a]-'a')].erase(a);
      s[a] = b;
      v[(s[a]-'a')].insert(a);
    } else {
      int l, r;
      cin >> l >> r;
      l--;
      int cnt = 0;
      for (int i = 0; i < 26; ++i) {
        auto it = v[i].lower_bound(l);
        if (it != v[i].end() && *it < r) cnt++;
      }
      printf("%d\n", cnt);
    }
  }

  return 0;
}

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

struct change {
  int b;
  long long c;
};
bool operator < (const change &l, const change &r) { return l.c < r.c; }
bool operator > (const change &l, const change &r) { return l.c > r.c; }
 
int main() {
  int n, m;
  cin >> n >> m;
  long long a[n];
  change st[m];
  for ( int i = 0; i < n; i++ ) { cin >> a[i]; }
  for ( int i = 0; i < m; i++ ) { cin >> st[i].b >> st[i].c; }
  sort(a, a+n);
  sort(st, st+m, greater<change>());
  
  long long ans = 0;
  int cur = 0;
  for ( int k = 0; k < m && cur < n; k++ ) {
    if ( cur+st[k].b-1 >= n && a[n-1] < st[k].c ) {
      ans += st[k].c * (n-cur);
      cur = n;
    } else if ( cur+st[k].b-1 < n && a[cur+st[k].b-1] < st[k].c ) {
      ans += st[k].c * st[k].b;
      cur += st[k].b;
    } else if ( a[cur] < st[k].c ) {
      while ( a[cur] < st[k].c && st[k].b > 0 ) {
        ans += st[k].c;
        cur++;
        st[k].b--;
        if ( cur >= n ) { break; }
      }
    } else {
      break;
    }
  }
  for ( int i = cur; i < n; i++ ) { ans += a[i]; }

  cout << ans << endl;
  return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

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

	ll n; cin >> n;
	map<pll,ll> cnt;
	FOR(i,0,n) {
		ll x = -9, y = -9;
		
		double a; cin >> a;
		ll b = llround(a*1e9);
		
		while (b%2 == 0) b /= 2, x++;
		while (b%5 == 0) b /= 5, y++;
		
//		cout << x << " " << y << endl;
		cnt[mp(x,y)]++;
	}
	
	ll res = 0;
	for (auto p: cnt) for (auto q: cnt) if (p < q) {
		if (p.xx.xx+q.xx.xx >= 0 && p.xx.yy+q.xx.yy >= 0) res += p.yy*q.yy;
	}
	for (auto p: cnt) if (p.xx.xx >= 0 && p.xx.yy >= 0) res += p.yy*(p.yy-1)/2;
	
	cout << res << endl;


}



Measured memory_bytes: 3744
#include <iostream>
using namespace std;
 
int main(){
    //入力を受け取る
    int N, X, T;
    cin >> N >> X >> T;
 
    //たこ焼きを焼く回数を求める
    int times = (N + X - 1) / X;
 
    //答えを求める
    int ans = times * T;
 
    //答えを出力する
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
using namespace std;
static const int MAX = 100001;

struct task {
  char name[10];
  int time;
};

struct task que[MAX];
int head = 0;
int tail = 0;

int increment(int p) { return (p + 1) % MAX; }

void enqueue(struct task t) {
  que[tail] = t;
  tail = increment(tail);
}

struct task dequeue() {
  int pre = head;
  head = increment(head);
  return que[pre];
}

bool isEmpty() { return tail == head; }

int main() {
  int n, q;
  cin >> n;
  cin >> q;
  struct task t;
  for (int i = 0; i < n; i++) {
    cin >> t.name;
    cin >> t.time;
    enqueue(t);
  }

  int elaps;
  int total = 0;
  while (!isEmpty()) {
    t = dequeue();
    elaps = min(t.time, q);
    t.time -= elaps;
    total += elaps;
    if (t.time > 0) {
      enqueue(t);
    } else {
      cout << t.name << " ";
      cout << total << endl;
    }
  }
}

Measured memory_bytes: 4552
#include<stdio.h>
#include <algorithm>
#include<iostream>
#include<string.h>
#include<vector>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<deque>
#include<ctype.h>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<algorithm>
#define INF 0x3f3f3f3f
#define FAST_IO ios::sync_with_stdio(false)
const double PI = acos(-1.0);
const double eps = 1e-6;
const int MAX=1e5+10;
const int mod=1e9+7;
typedef long long ll;
using namespace std;
#define gcd(a,b) __gcd(a,b)
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll qpow(ll a,ll b){ll r=1,t=a; while(b){if(b&1)r=(r*t)%mod;b>>=1;t=(t*t)%mod;}return r;}
inline ll inv1(ll b){return qpow(b,mod-2);}
inline ll exgcd(ll a,ll b,ll &x,ll &y){if(!b){x=1;y=0;return a;}ll r=exgcd(b,a%b,y,x);y-=(a/b)*x;return r;}
inline ll read(){ll x=0,f=1;char c=getchar();for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;for(;isdigit(c);c=getchar()) x=x*10+c-'0';return x*f;}
//freopen( "in.txt" , "r" , stdin );
//freopen( "data.txt" , "w" , stdout );

ll a[MAX*2];
int main()
{
    ll n,x,y;
    ll sum=0;
    scanf("%lld",&n);

    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        sum+=a[i];
    }
    x=a[1],y=sum-a[1];
    ll ans=abs(x-y);
    for(int i=2;i<=n-1;i++)
    {
        y-=a[i];
        x+=a[i];
        ans=min(ans,abs(x-y));
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1792
/*input
5
24 11 8 3 16
*/
/*

**************************
*						 *
* AUTHOR :: knight_coder *
*						 *
**************************

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rrep(i,m,n)	for(lld i=m;i>=n;i--)
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; 
//change null_type to get ordered_map
#define N  1000005
lld cnt[N];
bool vis[N];
void solve()
{
	lld n;
	cin >> n;
	lld g=0;
	vi v;
	rep(i,0,n){
		lld x;
		cin >> x;
		cnt[x]++;
	} 
	lld ans=0;
	rep(i,1,N){
		if(cnt[i]){
			bool f=1;
			for(lld j=2*i;j<N;j+=i){
				vis[j]=true;
			}
		}
	}
	rep(i,1,N){
		if(cnt[i]==1 && vis[i]==false){
			ans++;
		}
	}
	cout << ans << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

Measured memory_bytes: 12412
#include<iostream>
int main()
{
  unsigned long N,H,W;
  unsigned long output{};
  std::cin>>N>>H>>W;
  for (int i{};i<N;++i)
    {
      unsigned long height,width;
      std::cin>>height>>width;
      if (H<=height&&W<=width)
	++output;
    }
  std::cout<<output;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n;
	int w[100];
	int i, sum = 0, t, h = 0;
	int minsum=0, maxsum=0;
	int temp[100];

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &w[i]);
	}
	t = n / 2;
	if (!(n % 2 == 0)) {
		t += 1;
	}
	while (t>0) {
		minsum = maxsum = 0;
		for (i = 0; i < t; i++) {
			minsum += w[i];
		}
		for (i = t; i < n; i++) {
			maxsum += w[i];
		}
		sum = minsum - maxsum;
		if (sum < 0) {
			sum *= -1;
		}
		temp[h++] = sum;
		for (i = 0; i < h; i++) {
			if (sum < temp[i]) {
				temp[i] = sum;
			}
		}
		t--;
	}
	t = n / 2;
	if (!(n % 2 == 0)) {
		t += 1;
	}
	while (t < n) {
		minsum = maxsum = 0;
		for (i = 0; i < t; i++) {
			minsum += w[i];
		}
		for (i = t; i < n; i++) {
			maxsum += w[i];
		}
		sum = minsum - maxsum;
		if (sum < 0) {
			sum *= -1;
		}
		temp[h++] = sum;
		for (i = 0; i < h; i++) {
			if (sum < temp[i]) {
				temp[i] = sum;
			}
		}
		t++;
	}
	for (i = 0; i < h; i++) {
		if (sum > temp[i]) {
			sum = temp[i];
		}
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 128