akhauriyash/Code-Regression huggingface dataset:
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

int a[100000];
int s=0;

void push(int x){
	int c=s++, p=(c-1)/2;
	while(c>0 && x>a[p]){
		a[c]=a[p];
		c=p, p=(c-1)/2;
	}
	a[c]=x;
}
int pop(void){
	int t=a[0], x=a[--s];
	int p=0, c=p*2+1;
	while(c<s && a[c=(c+1<s&&a[c+1]>a[c])?c+1:c]>x){
		a[p]=a[c];
		p=c, c=p*2+1;
	}
	a[p]=x;
	return t;
}

uint32_t nextpint(void){ char c=getchar_unlocked(); while(c<'0'||'9'<c) c=getchar_unlocked(); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return x; }
void rsort_u32(void *base, const int count);

uint32_t b[100000][2];
int main(void){
	uint32_t n=nextpint();
	uint32_t m=nextpint();
	for(uint32_t i=0; i<n; i++){
		b[i][0]=nextpint();
		b[i][1]=nextpint();
	}
	rsort_u32(b, n);
	uint32_t ans=0;
	uint32_t p=0;
	for(uint32_t i=1; i<=m; i++){
		for(; p<n&&b[p][0]<=i; p++){
			push(b[p][1]);
		}
		if(s>0) ans+=pop();
	}
	printf("%"PRIu32"\n", ans);
}

void rsort_u32(void *base, const int count){
	uint64_t *a=base;
	uint64_t *b=malloc(count*sizeof(uint64_t));
	int c[0x100];
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(0<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(0<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(1<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(1<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(2<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(2<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(3<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(3<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	free(b);
}


Measured memory_bytes: 1664
using System;
 
public class Program
{
  private static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    
    bool result = false;
    
    for(int i = 1; i <= 9; i++)
    {
      if(N % i == 0 && N / i <= 9)
      {
        Console.WriteLine("Yes");
    	return;
      }
    }
    Console.WriteLine("No");
  }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    a[0]--;
    bool answer=true;
    for(int i=1;i<n;i++){
        if(a[i]>a[i-1]){
            a[i]--;
        }
        else if(a[i]<a[i-1]){
            answer=false;
            break;
        }
    }
    if(answer) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

int main() {
	int K, i=1;
	string s;
	set<string> S;

	cin >> s >> K;

	for (int i = 0; i < s.size(); i++) {
		for (int j = 1; j <= K; j++) {
			S.insert(s.substr(i, j));
		}
	}

	for (set<string>::iterator it = S.begin(); it != S.end(); it++) {
		if(i == K)
			cout << (*it) << " ";
		i++;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 1664
def main():
    N = int(input())
    a = list(map(int, input().split()))
    
    num_remain_blocks = 0
    for ai in a:
        if num_remain_blocks + 1 == ai:
            num_remain_blocks += 1
    if num_remain_blocks == 0:
        print(-1)
    else:
        print(N - num_remain_blocks)


if __name__ == "__main__":
    main()


Measured memory_bytes: 24744
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define PI 3.1415926535897
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


string S;


int solve(){
	int ans = INF;
	rep(i, 0, SIZE(S)-2){
		string s = { S[i], S[i+1], S[i+2] };
		int v = atoi(s.c_str());
		chmin(ans, abs(753-v));
	}
	return ans;
}


signed main(){
	cin >> S;

	cout << solve() << endl;

	return 0;
}

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

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

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

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

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

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

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

def main():
	N = inputInt()
	A = inputList()

	ans = 0
	for i in A:
		tmp = 1/i
		ans += tmp

	print(1/ans)


if __name__ == "__main__":
	main()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d,x;
  long long la,lb;
  double da,db;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  cin >> a;
  
  int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  int result3 = std::max({a, b, c});
//--------------------------------------------------------------------------------
db = a/2 + a%2;
  da = a;
//  if(s == "Sunny") anss = "Cloudy";
//  else anss = "red";

  cout << fixed << setprecision(6) << db / da << endl;

}

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

int main() {
	char a, b;//一文字だからcharだぞ
	cin >> a >> b;
	if (a == 'H') cout << b;
	if (a == 'D'&&b == 'H') cout << 'D';
	if (a == 'D'&&b == 'D') cout << 'H';
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <stack>
#include <utility>
#include <queue>
using namespace std;
typedef long long int lld;
typedef long double llf;
typedef pair<lld, lld> pii;

const int MAXN = 200002;

int n, k;
int arr[MAXN];
int L_min[MAXN], R_min[MAXN];
int L_max[MAXN], R_max[MAXN];

int menor(int i, int j) {
  return min(L_min[j], R_min[i]);
}

int mayor(int i, int j) {
  return max(L_max[j], R_max[i]);
}

int solution() {
  int ans = 0;
  bool oneSorted = false;
  int cnt = 0;
  int i = 0, j;
  for (j = 0; j+1 < k; ++j) {
    if (arr[j] > arr[j+1]) {
      cnt ++;
    }
  }
  for (; j < n; ++j) {
    if (cnt == 0) {
      oneSorted = true;
    } else if (mayor(i, j) != arr[j] || i == 0 || menor(i-1, j-1) != arr[i-1]) {
      ans ++;
    }

    if (arr[i] > arr[i+1]) {
      cnt--;
    }
    i++;
    if (j+1 < n && arr[j] > arr[j+1]) {
      cnt++;
    }
  }
  if (oneSorted) {
    ans++;
  }
  return ans;
}

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }

  for (int i = 1; i < n; ++i) {
    L_min[i] = L_max[i] = arr[i];
    if (i % k) {
      L_min[i] = min(L_min[i], L_min[i-1]);
      L_max[i] = max(L_max[i], L_max[i-1]);
    }
  }

  R_min[n-1] = R_max[n-1] = arr[n-1];
  for (int i = n-2; i >= 0; --i) {
    R_min[i] = R_max[i] = arr[i];
    if ((i+1) % k) {
      R_min[i] = min(R_min[i], R_min[i+1]);
      R_max[i] = max(R_max[i], R_max[i+1]);
    }
  }

  cout << solution() << "\n";
  return 0;
}


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

using namespace std;

typedef long long ll;

int n, u ,v;
vector<vector<int>> g;

void bfs(int start, vector<int> &dis) {
    queue<pair<int, int>> q;
    vector<bool> reached(n, false);
    q.push({start, 0});
    reached[start] = true;
    while (!q.empty()) {
        auto front = q.front();
        int cur = front.first;
        int d = front.second;
        dis[cur] = d;
        q.pop();
        for (int vv : g[cur]) {
            if (!reached[vv]) {
                q.push({vv, d + 1});
                reached[vv] = true;
            }
        }
    }
}

int main() {
    cin >> n >> u >> v;
    u--;
    v--;
    g.resize(n);
    for (int i = 0; i < n - 1; ++i) {
        int a, b; cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> dv(n), du(n);
    bfs(u, du);
    bfs(v, dv);
    int mx = 0;
    for (int i = 0; i < n; ++i) {
        if (dv[i] > du[i]) {
            mx = max(mx, dv[i]);
        }
    }
    cout << mx - 1;
    return 0;
}


Measured memory_bytes: 6784
#include<iostream>
using namespace std;
int main(){
	int S,h,m,s;
	cin>>S;
	
	h=S/3600;
	m=S%3600/60;
	s=S%3600%60;
	
	cout<<h<<":"<<m<<":"<<s<<endl;
	
	return 0;
}

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

int D,T,S;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>D>>T>>S;
	if(D <= S * T) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


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


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

    int candy1[N];
    int candy2[N];

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


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

    int maxCandy = 0;
    for (int i = 0; i < N; i++){
        int getCandy = 0;
        for(int k = 0; k < i+1; k++){
            getCandy += candy1[k];
        }
        for(int l = i; l < N; l++){
            getCandy += candy2[l];
        }
        if (getCandy > maxCandy){
            maxCandy = getCandy;
        }
    }

    cout << maxCandy << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())

for x in range(1,n+1):
    num = x
    if(x % 3 == 0):
        print(" %d" %x, end="")
        continue
        
    while True:
        if(x % 10 == 3): # 一の位が３であるかの判定
            print(" %d" %num, end = "")
            break
        
        x //= 10
        if(x == 0): 
            break

        if(x % 10 == 3):
            print(" %d" %num, end ="")
            break
print()


Measured memory_bytes: 5872
n = gets.to_i
m = gets.split.map(&:to_i)

n.times do |i|
	str = ""
	str += "node #{i+1}: key = #{m[i]}, "
	str += "parent key = #{m[(i+1)/2 - 1 ]}, " if i != 0
	str += "left key = #{m[2*i+1]}, " if  m[2*i + 1]
	str += "right key = #{m[2*i + 2]}, " if  m[2*i + 2]
	puts str
end

Measured memory_bytes: 8816
import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    ab = [list(map(int, input().split())) for i in range(N)]

    ab = sorted(ab, key=lambda x: x[0])

    ans = 0
    rest = M
    for i in range(N):
        a, b = ab[i]
        if b <= rest:
            ans += a * b
            rest -= b
        else:
            ans += a * rest
            break
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 29720
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>


using namespace std;

int main(){
    int n;
    int wk;
    
    cin >> n;
    
    int pre = 0;
    int wkans = 0;
    int ans = 0;
    for(int i = 0; i < n; i ++){
        cin >> wk;
        if(pre < wk){
         
            wkans = 0;
        }else{
         
            wkans++;
            if(wkans > ans)ans = wkans;
            
        }
        
        pre = wk;
    }
  
    cout << ans << endl;
    return 0;  
}

Measured memory_bytes: 384
import sys

X, Y = map(int, input().split())
A, mod = divmod(2*Y-X, 3)
if mod != 0 or A < 0:
	print(0)
	sys.exit()
B, mod = divmod(2*X-Y, 3)
if mod != 0 or B < 0:
	print(0)
	sys.exit()

mod = 10**9 + 7

a = A+B
b = min(A,B)

ans = 1

for i in range(b):
	ans *= a-i
	ans %= mod

	ans *= pow(i+1, mod-2, mod)

ans %= mod

print(ans)

Measured memory_bytes: 3064
def main():
    N, A, B, C = list(map(int, input().split()))
    S = [{'AB':(0, 1), 'BC': (1, 2), 'AC': (0, 2)}[input()] for _ in range(N)]
    ABC = [A, B, C]
    RR = ['A', 'B', 'C']
    R = []
    for i, (s1, s2) in enumerate(S):
        if ABC[s1] == 0 and ABC[s2] == 0:
            return False, None
        if ABC[s1] < ABC[s2]:
            s1, s2 = s2, s1
        if A + B + C == 2 and ABC[s1] == 1 and ABC[s2] == 1 and i < N - 1 and S[i] != S[i + 1]:
            s1n, s2n = S[i + 1]
            if s1 in [s1n, s2n]:
                s1, s2 = s2, s1
        ABC[s1] -= 1
        ABC[s2] += 1
        R.append(RR[s2])
    return True, R

a, s = main()
if not a:
    print('No')
else:
    print('Yes')
    print('\n'.join(s))


Measured memory_bytes: 10716
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  ll a[N];
  for(int i=0;i<N;++i) cin>>a[i];
  int maxabs=-1, maxind;
  for(int i=0;i<N;++i) {
    if(maxabs<abs(a[i])) {
      maxabs = abs(a[i]);
      maxind = i;
    }
  }
  if(maxabs==0) {
    cout<<0<<endl;
    return 0;
  }
  vector<pair<int, int> > ans;
  if(a[maxind]>0) {
    for(int i=0;i<N-1;++i) {
      if(a[i]>a[i+1]) {
        while(a[i]>a[i+1]) {
          a[i+1] += a[maxind];
          ans.push_back(mp(maxind+1, i+2));
          if(abs(a[i+1])>abs(a[maxind])) maxind = i+1;
        }
      }
    }
  }
  else {
    for(int i=N-2;i>=0;--i) {
      if(a[i]>a[i+1]) {
        while(a[i]>a[i+1]) {
          a[i] += a[maxind];
          ans.push_back(mp(maxind+1, i+1));
          if(abs(a[i])>abs(a[maxind])) maxind = i;
        }
      }
    }
  }
  cout<<ans.size()<<endl;
  for(int i=0;i<ans.size();++i) cout<<ans[i].fi<<" "<<ans[i].se<<endl;
}



Measured memory_bytes: 3620
import sys
def input(): return sys.stdin.readline().rstrip()
import math
def is_prime(n):
    if n==1:return False
    for k in range(2,int(math.sqrt(n))+1):
        if n%k==0:
            return False
    return True
def main():
    x=int(input())
    while True:
        if is_prime(x)==True:
            print(x)
            break
        x+=1
if __name__=='__main__':
    main()

Measured memory_bytes: 38384
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            
            var h = cin.nextLong();


            var cc = 1L;
            var ans = 1L;
            while (true)
            {
                if (h == 1) break;
                h /= 2;
                cc *= 2;
                ans += cc;
            }
            
            Console.WriteLine(ans);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


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

int main() {
  string S,T;
  cin >> S >> T;
  int A=1;
  for (int i=0;i<S.size();i++){
    if (S.at(i)!=T.at(i)){
      A--;
      break;
    }
  }
  if(A){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

string remove_zero(string s) {
    int index = s.size() - 1;
    while (true) {
        if (s[index] == '0') index--;
        else break;
    }
    return s.substr(0, index + 1);
}

pii get_25(ll n) {
    int ret2 = 0, ret5 = 0;
    while (n % 10 == 0) n /= 10;
    while (n % 2 == 0) {
        ret2++;
        n /= 2;
    }
    while (n % 5 == 0) {
        ret5++;
        n /= 5;
    }
    return {ret2, ret5};
}

int main() {
    ll N;
    int cnt[13][50][50];
    REP(i, 13) REP(j, 50) REP(k, 50) cnt[i][j][k] = 0;
    cin >> N;
    REP(i, N) {
        string s;
        cin >> s;
        auto it = s.find(".");
        if (it == string::npos) {
            int zeroc = 0;
            RREP(j, s.size()) {
                if (s[j] == '0') zeroc++;
                else break;
            }
            pii ret = get_25(atoll(s.c_str()));
            cnt[3 - zeroc][ret.first][ret.second]++;
        } else {
            bool all_zero = true;
            FOR(j, it + 1, s.size()) {
                if (s[j] != '0') all_zero = false;
            }
            if (all_zero) {
                int zeroc = 0;
                RREP(j, it) {
                    if (s[j] == '0') zeroc++;
                    else break;
                }
                pii ret = get_25(atoll(s.c_str()));
                cnt[3 - zeroc][ret.first][ret.second]++;
            } else {
                s = remove_zero(s);
                pii ret = get_25(atoll(s.erase(it, 1).c_str()));
                cnt[3 + (s.size() - it)][ret.first][ret.second]++;
            }
        }
    }

    ll ans1 = 0, ans2 = 0;
    REP(si, 13) REP(sj, 50) REP(sk, 50) {
        ll sc = cnt[si][sj][sk];
        if (sc == 0) continue;

        REP(di, 13) REP(dj, 50) REP(dk, 50) {
            ll dc = cnt[di][dj][dk];
            if (dc == 0) continue;

            int digit = si + di - 6 - min(sj, dk) - min(sk, dj);
            if (digit <= 0) {
                if (si == di && sj == dj && sk == dk) {
                    ans1 += sc * (sc - 1) / 2;
                } else {
                    ans2 += sc * dc;
                 }
            }
        }
    }
    cout << ans1 + ans2 / 2 << endl;
    return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
 
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
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;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹) */
///////////////////////////////////////////////
const int MAX = 510000;
 
long long fac[MAX], finv[MAX], inv[MAX];
 



int main() {
	int ans = 0;
	int N; cin >> N;
	int A[N];
	for (int i = 0; i < N; i++){cin >> A[i];}
	for (int i = N-1; i > 0; i--)
	{
		if(A[i]-A[i-1] == - 1){A[i-1]--;}
		else if(A[i]-A[i-1] < -1){ans = 2;}
	}
	string S;
	if(ans == 1 || ans == 0){S = "Yes";}
	else{S = "No";}
	
	cout << S << endl;
}


Measured memory_bytes: 640
from collections import deque

K = int(input())

lunlun = deque([i for i in range(1,10)])

for i in range(K):
    x = lunlun.popleft()
    if x % 10 != 0:
        lunlun.append(x * 10 + (x % 10) - 1)
    lunlun.append(x * 10 + (x % 10))
    if x % 10 != 9:
        lunlun.append(x * 10 + (x % 10) + 1)

print(x)

Measured memory_bytes: 18640
S = [input() for _ in range(int(input()))]

end_A = 0
start_B = 0
sB_eA = 0
ans = 0

for s in S:
    ans += s.count('AB')
    if s[0] == 'B' and s[-1] == 'A':
        sB_eA += 1
    elif s[0] == 'B':
        start_B += 1
    elif s[-1] == 'A':
        end_A += 1

ans += min(start_B,end_A)

if start_B == 0 and end_A == 0:
    ans += max(0,sB_eA-1)
else:
    ans += sB_eA
print(ans)

Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
using namespace std;
#define ll long long

int main() {
	int N; cin >> N;
	cout << 180*(N-2) << endl;
	return 0;
}


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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
    
int main(){
    int N,M;
    cin>>N>>M;
    vector<int> d(N);
    REP(i,M){
        int a,b;
        cin>>a>>b;
        a--,b--;
        d[a]++;
        d[b]++;
    }
    REP(i,N)cout<<d[i]<<endl;
    return 0;
}


Measured memory_bytes: 256
K,N = map(int,input().split())
An_list = list(map(int,input().split()))

An_list.append(An_list[0]+K)
#print(An_list)

distance=[0]*N

for i in range(0,N):
    distance[int(i)]=An_list[int(i+1)]-An_list[int(i)]

distance.sort()
del distance[-1]
#print(distance)
print(sum(distance))

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

int main(){
	int n;
	cin >> n;
	double x;
	int sum=0;
	for(int i=1;i<=n;i++){
		if(i&1==1) sum++;
	}
	printf("%0.10f\n" ,sum*1.0/n);		
	return 0;
} 

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    int ans = 1;
    imfor(i, n) {
        if (i == 0) {
            continue;
        }
        if (i * i > n) {
            break;
        }
        ans = i * i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>

#define int long long

template<class T>void fr(T &a) {
    T w=0,s=1;char c=getchar();
    while(c<'0'||c>'9') {if(c=='-')s=-1;c=getchar();}
    while(c>='0'&&c<='9') w=w*10+c-'0',c=getchar();
    a=w*s;
}
template<class T>T fr() {T a;fr(a);return a;}
#define R() fr<int>()

const int p=1e9+7,N=1e6;
int fac[N+10]={1};

int qpow(int a,int b) {
    int ans=1;
    while(b) {
        if(b%2)ans=ans*a%p;
        a=a*a%p,b/=2;  
    }
    return ans;
}

int C(int n,int m) {
    return fac[n]*qpow(fac[n-m],p-2)%p*qpow(fac[m],p-2)%p;
}

signed main() {
    int x=R(),y=R(),z=(x+y)/3,a=y-z,b=x-z;
    if(z*3!=x+y)return !printf("0\n");
    else {
        for(int i=1;i<=N;i++) fac[i]=fac[i-1]*i%p;
        if(a>=0&&a<=z)return !printf("%lld\n",C(z,a));
        return !printf("0\n");
    }
    return 0;
}
/*
(i,j) to (i+1,j+2) = a
(i,j) to (i+2,j+1) = b

a+2b=x
2a+b=y

3a+3b=x+y

a+b=(x+y)/3

a=y-(x+y)/3
b=x-(x+y)/3
*/

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

int main() {
    int n, m; cin >> n >> m;
    int sum = 0;
    vector<int> a(n);
    
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
        sum += a.at(i);
    }
    
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    
    for(int i = 0; i < m; i++){
        if(sum % 4 == 0){
            if(a.at(i) < sum / (4 * m)){
                cout << "No" << endl;
                return 0;
            }
        
        }else{
            if(a.at(i) <= sum / (4 * m)){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    
    cout << "Yes" << endl;
    

}




Measured memory_bytes: 256
/*
        |___Arshit Mangukiya___|
        |___DA-IICT____|
        |___201801173____|
*/
        //__WRITE  YOUR  CODE  HERE___//
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;            
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppl;
typedef vector<pll> vpl;
#define ff first
#define ss second
#define pi acos(-1)
#define mr_ad_0501 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define all(a)      a.begin(),a.end()
#define f(i,a,n) for(ll i=a;i<n;i++)
#define MOD 1000000007
#define MAX 200007
#define LM LLONG_MAX
#define sz size()
#define p(x)        cout<< x << " ";
#define pe(x)       cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
const int N=1e5+5;
        /*  bool fun(pair<int,int>a , pair<int,int>b)
            {
                if(a.ff == b.ff)    return a.ss < b.ss;
                else            return a.ff < b.ff;
            }*/
 /*void bfs(ll x)
 {
    queue<ll> q;
    q.push(x);
    while(!q.empty())
    {
        ll k=q.front();
        q.pop();
        for(auto X:v[k])
        {
            if(!vis[X])
            {
                l[X]=l[k]+1;
                vis[X]=1;
                q.push(X);
            }
        }
    }
 }*/
ll i,j;
void solve()
{
	ll n;
	cin>>n;
	ll a[n+1],c=0;
	f(i,1,n+1)cin>>a[i];
	f(i,1,n+1)
	{
		if(i%2 && a[i]%2)c++;
	}
	cout<<c;
}
    
int32_t main(){
    mr_ad_0501;
    ll t=1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    
}    	

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
const int N = 100001;
const int M = 100001;
int a[M];
//int x[N];
int m;
ll k;
vector<vector<ll>> x(2, vector<ll>(n));
void brute(){
  vector<ll> sx = x[0];
  int c = 1;
  for(int i = 0;i < k;i++){
    for(int j = 0;j < m;j++){
//      cout << a[j] << endl;
      sx[a[j]] = sx[a[j] - 1] + sx[a[j] + 1] - sx[a[j]];
    }
  }
  for(int i = 0;i < n;i++)
    cout << sx[i] << ' ';
  cout << endl;
  return ;
}
int main(){
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
//  srand(time(0));
//  cout << 10 << endl;
//  for(int i = 0;i < 10;i++){
//    cout << rand() % 1000 << ' ';
//  }
//  cout << endl;
//  cout << 10 << ' ' << 10;
//  cout << endl;
//  for(int i = 0;i < 10;i++)
//    cout << rand() % 8 + 2 << ' ';
//  return 0;
  scanf("%d", &n);
  x = vector<vector<ll>>(2, vector<ll>(n));
  for(int i = 0;i < n;i++)
    scanf("%lld", &x[0][i]);
  scanf("%d %lld", &m, &k);
  for(int i = 0;i < m;i++)
    scanf("%d", a + i), a[i]--;
  x[1] = x[0];
  for(int i = 0;i < m;i++){
    x[1][a[i]] = x[1][a[i] - 1] + x[1][a[i] + 1] - x[1][a[i]];
  }
  ll diff[2][n - 1];
  map<ll, vector<int>> mp;
  map<ll, int> mpc;
  vector<vector<int>> cs;
  for(int i = 0;i < n - 1;i++){
    diff[0][i] = x[0][i + 1] - x[0][i];
    diff[1][i] = x[1][i + 1] - x[1][i];
    mp[diff[0][i]].push_back(i);
    mpc[diff[0][i]] = 0;
//    cout << diff[0][i] << ' ';
  }
//  cout << endl;
//  for(int i = 0;i < n - 1;i++)
//    cout << diff[1][i] << ' ';
//  cout << endl;
//  brute();
  int p[n - 1];
  bool vis[n - 1];
  memset(vis, 0, sizeof(vis));
  for(int i = 0;i < n - 1;i++){
    int s = i;
    if(vis[s])continue;
    ll num = diff[1][s];
    int nx = mp[num][(mpc[num]++) % mp[num].size()];
    cs.push_back(vector<int>());
    vector<int>& c = cs[cs.size() - 1];
    c.push_back(s);
    while(nx != s){
      vis[nx] = 1;
      c.push_back(nx);
      ll num = diff[1][nx];
      nx = mp[num][(mpc[num]++) % mp[num].size()];
    }
//    for(auto el : c)
//      cout << el << ' ';
//    cout << endl;
  }
  ll diffr[n - 1];
  for(auto el : cs){
    int sh = k % el.size();
    for(int i = 0;i < el.size();i++){
      diffr[el[i]] = diff[0][el[(i + sh + el.size()) % el.size()]];
    }
  }
  ll res[n];
  res[0] = x[0][0];
  for(int i = 1;i < n;i++)
    res[i] = res[i - 1] + diffr[i - 1];
  for(int i = 0;i < n;i++)
    cout << res[i] << '\n';
//  for(int i = 0;i < n - 1;i++){
//    cout << diff[0][i] << ' ';
//  }
//  cout << endl;
//  for(int i = 0;i < n - 1;i++){
//    cout << diff[1][i] << ' ';
//  }
//  cout << endl;
  return 0;
}


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

using namespace std;

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

    vector<int> l(n);

    for(int i = 0;i < n;i++)    cin >> l[i];

    int d = 0;
    int count = 1;

    for(int i = 0;i < n;i++){
        d += l[i];
        if(d > x){
            break;
        }
        count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits.h>

std::vector< std::vector< std::pair<int, int> > > g(100010);
long long int ans = 0, size[100010] = { 0 };

long long int mmax(long long int a, long long int b)
{
	return a >= b ? a : b;
}

long long int mmin(long long int a, long long int b)
{
	return a >= b ? b : a;
}

void dfs(int n, int parent, int place)
{
	size[place] = 1;
	
	int max = 0;
	for (int i = 0; i < g[place].size(); ++i)
	{
		if (g[place][i].first != parent)
		{
			dfs(n, place, g[place][i].first);
			size[place] += size[g[place][i].first];
		}
	}
	
	for (int i = 0; i < g[place].size(); ++i)
	{
		if (g[place][i].first != parent)
		{
			max = mmax(max, size[g[place][i].first]);
			long long int currentMinimumSize = mmin(n - size[g[place][i].first], size[g[place][i].first]);
					
			ans += currentMinimumSize * g[place][i].second * 2;
			
			if (currentMinimumSize * 2 == n)
				ans -= g[place][i].second;
		}
	}
	
	max = mmax(max, n - size[place]);
	if (max * 2 < n)
	{
		long long int min = LLONG_MAX;
		for (int i = 0; i < g[place].size(); ++i)
		{
			min = mmin(min, g[place][i].second);
		}
		
		ans -= min;
	}
}

int main()
{
	int n;
	std::cin >> n;
	
	for (int i = 0; i < n - 1; ++i)
	{
		int x, y, w;
		std::cin >> x >> y >> w;
		--x;
		--y;
		
		g[x].push_back(std::make_pair(y, w));
		g[y].push_back(std::make_pair(x, w));
	}
	
	dfs(n, -1, 0);
	
	std::cout << ans;
}

Measured memory_bytes: 11904
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

vector<int> as;
int ns[1000001];

vector<int> calc_divs(int n) {
    vector<int> ans;

    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ans.push_back(i);
            if (i * i != n) {
                ans.push_back(n / i);
            }
        }
    }

    sort(ans.begin(), ans.end());
    return ans;
}

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

    as.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> as[i];
        ns[as[i]]++;
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        vector<int> ds = calc_divs(as[i]);

        // cout << "divs: " << endl;
        // for (auto d : ds) {
        //     cout << d << " ";
        // }
        // cout << endl;

        bool ok = true;
        for (auto d : ds) {
            if (ns[d] > 0) {
                if (ns[d] > 1 || d != as[i]) {
                    ok = false;
                    break;
                }
            }
        }

        if (ok) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7880
import fractions

def divcount(a,b,x):
    return b//x - (a-1)//x

a,b,c,d = [int(i) for i in input().split()]
print(b-a+1-(divcount(a,b,c)+divcount(a,b,d)-divcount(a,b,c*d//fractions.gcd(c,d))))

Measured memory_bytes: 5084
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n;
	cin >> n;
	cout << (n-2) * 180 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
	char s[6];
	scanf("%c", s);
	if(s[0]=='S') {
		printf("Cloudy");
	}
	if(s[0]=='C') {
		printf("Rainy");
	}
	if(s[0]=='R') {
		printf("Sunny");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
        cin>>s;
	int freq[26]={0},flag=0;
	for(int i=0;i<s.length();i++)
	{
	freq[s[i]-'a']++;
	if(freq[s[i]-'a']>1)
	{
		flag=1;
		break;
	}
	}
	if(flag==1)
	printf("no");
	else 
	printf("yes");
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long k,g;
	cin >> k;
	queue<long long> a;
	for (int i = 1; i < 10; i++) {
		a.push(i);
	}
	for (int i = 1; i <= k; i++) {
		g = a.front();

		a.pop();
		if (g % 10 != 0)a.push(10 * g + g % 10 - 1);
		a.push(10 * g +g % 10);
		if (g % 10 != 9)a.push(10 * g + g % 10 + 1);
	}
	cout << g << endl;
}


Measured memory_bytes: 1792
n, x, y = map(int, input().split())

graph = [[] for _ in range(n)]
for i in range(n - 1):
    graph[i].append((1, i + 1))
    graph[i + 1].append((1, i))

graph[x - 1].append((1, y - 1))
graph[y - 1].append((1, x - 1))

# Dijikstra with heap 単一最短経路問題
from heapq import heappop, heappush
def dijkstra_with_heap(graph, start, v):
    distance = [float('infinity')] * v
    distance[start] = 0
    stack = [[0, start]] # cost, vertex
    while stack:
        _, vertex = heappop(stack)
        edges = graph[vertex]
        for d, t in edges:
            if d + distance[vertex] < distance[t]:
                distance[t] = d + distance[vertex]
                heappush(stack, (d, t))
    return distance
table = [0] * n
for i in range(n):
    distance = dijkstra_with_heap(graph, i, n)
    for j in range(i, n):
        d = distance[j]
        table[d] += 1

for i in range(1, n):
    print(table[i])




Measured memory_bytes: 108380
n=int(input())
a=[]
for _ in range(n):
    a.append(int(input()))
s=0
for i in range(n):
    if s<=a[i]:
        s=a[i]
t=0
for i in range(n):
    if s==a[i]:
        t+=1
if t>=2:
    for i in range(n):
        print(s)
else:
    u=0
    for i in range(n):
        if u<=a[i] and a[i]!=s:
            u=a[i]
    for i in range(n):
        if a[i]==s:
            print(u)
        else:
            print(s)

Measured memory_bytes: 89588
#include<iostream>
#include <iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,l=0,r=0;
    string s;
    cin>>n>>s;
    rep(i,n){
        if(s[i]=='(') l++;
        else r++;
    }
    // cout<<l<<" "<<r<<endl;
    rep(i,n){
        if(s[i]=='('){
            ll c=1;
            rep2(j,i+1,n){
                if(s[j]=='(')c++;
                else c--;
                if(c==0){
                    ll a=j-(i-1);
                    r-=a/2;
                    l-=a/2;
                    i+=(a-1);
                    break;
                }
            }
        }
    }
    // cout<<l<<" "<<r<<endl;
    rep(i,r){
        cout<<'(';
    }
    cout<<s;
    rep(i,l){
        cout<<')';
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
 
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    int n,ii,a,b;
    cin>>n;
    long long cnt[10][10];
    REP(i,100)cnt[i%10][i/10]=0;
    for(int i=1;i<=n;i++){
        b=i%10;
        a=i;
        while(a>=10){
            a/=10;
        }
        cnt[a][b]++;
    }
    long long ans=0;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            // cout<<i<<" "<<j<<" "<<cnt[i][j]<<" "<<cnt[j][i]<<endl;
            ans+=cnt[i][j]*cnt[j][i];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
int main(){
    int k;
    string p;
    cin >> k>> p;
    if(p.size()>k){
        string s = "";
        fo(i,k){
            s +=p[i];
        }
        cout << s + "...";
    }
    else{
        cout <<p ;
    }
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	int n, a;
	cin >> n >> a;
	print(n*n - a);





	return 0;
}

Measured memory_bytes: 256
from sys import stdin
N = int(stdin.readline().rstrip())
P = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 0
for i in range(1, N-1):
    if P[i-1] < P[i] and P[i] < P[i+1]:
        ans += 1
    elif P[i-1] > P[i] and P[i] > P[i+1]:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int i=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    long long N;
    cin >> N;
    vector<long long> A(N);
    REP(i, N) cin >> A[i];
    long long Q;
    cin >> Q;
    vector<pair<long long, long long>> BC(Q);
    REP(i, Q) cin >> BC[i].first >> BC[i].second;

    map<long long, long long> mp;
    REP(i, N) mp[A[i]]++;
    long long ans = 0;
    for(auto x : mp){
        ans += x.first * x.second;
    }
    REP(i, Q){
        long long B = BC[i].first;
        long long C = BC[i].second;
        ans += C * mp[B];
        ans -= B * mp[B];
        mp[C] += mp[B];
        mp[B] = 0;

        cout << ans << endl;
    }

    return 0;
}

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

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

using namespace std;

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

	int sum=0;
	for(char c:str) 
      sum+=c-'0';
	cout<<max<int>(sum,(str[0]-'1')+9*(str.length()-1))<<'\n';

	return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define rg register
#define maxn 73000
#define ll long long
#define IT set<node>::iterator
#define int ll
#pragma GCC optimize(3)
#pragma -fcrossjumping
#pragma -fdefer-pop
#pragma -fmerge-constans
#pragma -fthread-jumps
#pragma -floop-optimize
#pragma -fif-conversion
#pragma -fif-conversion2
#pragma -fdelayed-branch
#pragma -fguess-branch-probability
#pragma -fcprop-registers
#pragma -fforce-mem
#pragma -foptimize-sibling-calls
#pragma -fstrength-reduce
#pragma -fgcse
#pragma -fcse-follow-jumps
#pragma -frerun-cse-after-loop
#pragma -fdelete-null-pointer-checks
#pragma -fextensive-optimizations
#pragma -fregmove
#pragma -fschedule-insns
#pragma -fsched-interblock
#pragma -fcaller-saves
#pragma -fpeephole2
#pragma -freorder-blocks
#pragma -fstrict-aliasing
#pragma -funit-at-a-time
#pragma -falign-functions
#pragma -fcrossjumping
#pragma -finline-functions
#pragma -fweb
#pragma -fgcse-after-reload
inline int read()
{
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-') f=-1;
        c=getchar();
    }
    while(c<='9'&&c>='0')
    {
        x=(x<<1)+(x<<3)+(c^48);
        c=getchar();
    }
    return x*f;
}
inline int max(int a,int b)
{
	if(a>b) return a;
	return b;
}
int a,b;
signed main()
{
	cin>>a>>b;
	int c=a-b*2;
	if(c<=0) cout<<0;
	else cout<<c;
} 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void bubbleSort(int *,int);

int main(){
	int n;
	cin>>n;
	int *array;
	array=new int [n];
	if (array==NULL) {
		cout<<"Error!"<<endl;
		return -1;
	}
	for (int i=0;i<n;i++){
		cin>>array[i];
	}
	bubbleSort(array,n);
	delete [] array;
	return 0;
}

void bubbleSort(int *a,int n){
	int cnt=0;
	for (int i=0;i<n;i++){
		for (int j=n-1;j>=i+1;j--){
			if (a[j]<a[j-1]){
				int temp;
				temp=a[j];
				a[j]=a[j-1];
				a[j-1]=temp;
				cnt++;
			}
		}
	}
	for (int i=0;i<n;i++){
		cout<<a[i];
		if (i!=n-1){
			cout<<" ";
		}
	}
	cout<<endl;
	cout<<cnt<<endl;
}

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

int main() {
  long a, b;
  long a1, b1;
  long c;
  long dif;
  
  cin >> a >> b;
  
  a1 = a;
  b1 = b;
  
  dif = 1;
  while(true) {
    if (a1 > b1) {
      int tmp = a1;
      a1 = b1;
      b1 = tmp;
    }
    dif = b1 - a1;
    if (dif < 2) break;
    if ((a1 % dif == 0) && (b1 % dif == 0)) {
      break;
    }
    b1 = a1;
    a1 = dif;
  }
  c = a * b / dif;
  cout << c << endl;
}

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

int main() {
    int N, H, M=10000000, a[8]={0},F=0;
    cin >> N;
    H = N;
    for(int i=0; i<8; i++){
        a[i] = N / M;
        N = N - (a[i]*M);
        M /= 10;
        F += a[i];
    }
    if(H % F == 0){
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;
}

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

using namespace std;

typedef long long ll;

int main() {
  ll n,m;
  cin >> n >> m;
  if(n == 1 && m == 1) {
    cout << "1" << endl;
  }
  else if(n == 1 || m == 1) {
    cout << max(n,m) - 2 << endl;
  }
  else {
    cout << n * m - (2 * n + 2 * m - 4) << endl;
  }
}
  


Measured memory_bytes: 256
n = int(input())

ans = 0

for i in range(1,n+1):
    yakusu = []
    for j in range(1,i+1):
        if i % j == 0:
            yakusu.append(i)
    if i % 2 == 1 and len(yakusu) == 8:
        ans +=1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
//#include <set>
//#include <map>
//#include <ctime>
//#include <cmath>
//#include <utility>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define ii InputInteger( );
#define f for(int i=0; i<n; i++)
int InputInteger( ){ int x; cin >> x; return x; }
const int Inf = 2147483647;
const char e = '\n';

void iv( vi& p ){ for( int& x: p ) cin >> x; }
void sa( vi& p ){ sort( p.begin(), p.end() ); }
void sd( vi& p ){ sort( p.begin(), p.end(), [](int a, int b){ return a > b; } ); }
void pv( const vi& p ){ for( int x: p ) cout << x << ' '; cout << e; }

int main()
{
	ios_base::sync_with_stdio( false );
	cin.tie( nullptr );
	int x;
	while( cin >> x )
	{
	    int a = ii;
	    if(x < a) cout << "0";
	    else cout << "10";
	    cout << e;
	}
	return 0;
}

// Kafe's Grandmaster Template 14th


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

int maxy[100000+1];

int main() {

    int w,h,n;

    cin >> w >> h >> n;

    while(n--){
        int x,y;
        cin >> x >> y;
        maxy[x] = max(maxy[x],y);
    }

    int ans=w-1,dp=0;

    for(int x=w-2; x>=0; x--){
        dp = max(dp,maxy[x+1]);
        ans = min(dp+x,ans);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3464