akhauriyash/Code-Regression huggingface dataset:
/*2019/07/29 */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
typedef long long int ll;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}
/*
int asc_t(const void *a,const void *b){return ((user_t*)a)->score - ((user_t*)b)->score;}
int desc_t(const void *a,const void *b){return ((user_t*)b)->score - ((user_t*)a)->score;}
*/

int main(){
    int n;
    char str[2000];

    scanf("%d",&n);
    scanf("%s",str);

    int x=0;
    int max=-1;
    for(int i=0;i<n;i++){
        if(str[i]=='I'){
            x++;
        }else{
            x--;
        }

        if(x>max){
            max=x;
        }
    }

    if(max<0){
        max=0;
    }
    printf("%d\n",max);

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main(){
	int a,b,c;
	scanf("%d",&a);
	b=1;
	while(1){
		if (b*b>a)
		{
			break;
		}else{
			b=b+1;
		}
	}
	printf("%d\n",(b-1)*(b-1));


}

Measured memory_bytes: 128
n = int(input())
c = [list(map(int, input().split())) for _ in range(n)]

d = [[x[0], 0] for x in c] + [[y[1], 1] for y in c]
d.sort()
r = 0
p = 0
for z in d:
  if z[1] == 0:
    r += 1
    p = max(r, p)
  else:
    r -= 1

print(p)


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

#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    while(cin >> n){
        ll ans = 0;
        int a[n+5] = {},b[n+5] = {};
        f1(n+1){
            cin >> b[i];
        }
        f1(n){
            cin >> a[i];
        }
        f1(n){
            int ff = min(a[i],b[i]);
            b[i] -= ff;
            a[i] -= ff;
            ans += ff;
            ff = min(a[i],b[i+1]);
            a[i] -= ff;
            b[i+1] -= ff;
            ans += ff;
        }
        cout << ans << endl;
    }

}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main(){
	char s[1010],k1[]="apple",k2[]="peach";
	int i,j,f1,f2;
	fgets(s,1010,stdin);
	for(i=0;i<strlen(s)-5;i++){
		f1=f2=0;
		for(j=0;j<5;j++){
			if(s[i+j]==k1[j])f1++;
			else if(s[i+j]==k2[j])f2++;
			else break;
		}
		if(f1==5){
			for(j=0;j<5;j++)s[i+j]=k2[j];
		}
		if(f2==5){
			for(j=0;j<5;j++)s[i+j]=k1[j];
		}
	}
	printf("%s",s);
	return 0;
}

Measured memory_bytes: 0
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine(Buttons());
    }

    private static int Buttons()
    {
        int A = 0, B = 0;

        readData(ref A, ref B);

        int[] pushResult = new int[3];
        pushResult[0] = 2*A - 1;
        pushResult[1] = 2 * B - 1;
        pushResult[2] = A +B;

        return pushResult.Max();
    }

    /// <summary>
    /// データを読み込む
    /// </summary>
    private static void readData(ref int A, ref int B)
    {
        int[] line = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

        A = line[0];
        B = line[1];
    }
}




Measured memory_bytes: 13268
import Control.Applicative

type Row = [Int]

type Matrix = [Row]

type Problem = (Matrix, Matrix)

type Result = Matrix

access :: Matrix -> Int -> Int -> Int

access matrix row col
    = matrix !! row !! col
    
calcElement :: Matrix -> Matrix -> Int -> Int -> Int

calcElement mat1 mat2 row col
    = sum [access mat1 row x * access mat2 x col | x <- xs] where
        m = length mat2
        xs = [0..(m - 1)]

solve :: Problem -> Result

solve (mat1, mat2)
    = [[calcElement mat1 mat2 row col | col <- cols] | row <- rows] where
        n = length mat1
        l = length $ head mat2
        rows = [0..(n - 1)]
        cols = [0..(l - 1)]

output :: Result -> String

output matrix
    = init.concat $ [outputRow row ++ "\n" | row <- matrix]
    
outputRow :: Row -> String

outputRow row
    = init.concat $ [show x ++ " " | x <- row]
    
input :: IO Problem

input
    = do
        [n, m, _] <- map read.words <$> getLine
        mat1 <- inputMatrix n []
        mat2 <- inputMatrix m []
        return (mat1, mat2)
        
inputMatrix :: Int -> Matrix -> IO Matrix

inputMatrix 0 matrix
    = return matrix
    
inputMatrix rows matrix
    = do
        row <- map read.words <$> getLine
        inputMatrix (rows - 1) $ matrix ++ [row]
    
main :: IO ()

main
    = putStrLn.output =<< solve <$> input

Measured memory_bytes: 12348
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    return gcd(b, a%b)

def gcd_l(A):
    if len(A) == 1:
        return A[0]
    x = gcd(A[0], A[1])
    if len(A) == 2:
        return x
    for i in range(2, len(A)):
        x = gcd(x, A[i])
    return x

def lcm(a, b):
    if a < b:
        a, b = b, a
    return a * b // gcd(a, b)

def lcm_l(A):
    A.sort()
    if len(A) == 1:
        return A[0]
    x = lcm(A[0], A[1])
    if len(A) == 2:
        return x
    for i in range(2, len(A)):
        x = lcm(x, A[i])
    return x


N = int(input())
T = [int(input()) for _ in range(N)]
T = list(set(T))
T.sort()
N = len(T)
L = []
'''
for i in range(N):
    flag = 1
    for j in range(N-1, i, -1):
        if T[j] % T[i] == 0:
            flag = 0
            break
    if flag:
        L.append(T[i])

GCD = gcd_l(L)
ans = 1
for i in range(len(L)):
    ans *= L[i] // GCD
ans *= GCD
if len(L) == 1:
    ans = L[0]
'''
ans = lcm_l(T)
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int cnt=0;
	bool flag=0;
	int maxx=0;
	for(int i=0;i<3;i++){
		if(flag==0&&s[i]=='R'){
			cnt=1;
			flag=1;
			maxx=max(maxx,cnt);
			continue;
		}
		if(flag==1&&s[i]=='R'){
			cnt++;
			maxx=max(maxx,cnt);
			continue;
		}
		if(flag==0&&s[i]=='S') continue;
		if(flag==1&&s[i]=='S') flag=0,cnt=0;
	}
	printf("%d",maxx);
	return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;
const ll mod = 1e9 + 7;
int main() {
  int n, m;
  cin >> n >> m;
  vector <vector <int> > edge(n + 1);
  REP(i, m) {
	int a, b;
	cin >> a >> b;
	edge[a].push_back(b);
	edge[b].push_back(a);
  }
  vector <int> ans(n + 1, 0);
  vector <bool> flg(n + 1, false);
  queue <int> que;
  que.push(1);
  flg[1] = true;
  while (!que.empty()) {
	  int u = que.front();
	  que.pop();
	  REP(i, SZ(edge[u])) {
		int v = edge[u][i];
		if (!flg[v]) {
			ans[v] = u;
			que.push(v);
			flg[v] = true;
		  }
	  }
	}
  if (1) {
	  cout << "Yes" << endl;
	  for (int i = 2; i <= n; i++) {
		  cout << ans[i] << endl;
		}
	}
  return 0;
}

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

using namespace std;

#define int long long
#define x first
#define y second
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define sz(a) (int)(a.size())

typedef long long ll;typedef vector<int> vi;
typedef pair<int,int> ii;typedef vector<ii> vii;
typedef vector<vi> vvi;

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

void sorted(vii& v,int dir){
	if(dir==0){
		sort(all(v),[](ii&a,ii&b){
			return a.x>b.x;
		});
	}
	else if(dir==1){
		sort(all(v),[](ii&a,ii&b){
			return a.x<b.x;
		});
	}
	else if(dir==2){
		sort(all(v),[](ii&a,ii&b){
			return a.y>b.y;
		});
	}
	else{
		sort(all(v),[](ii&a,ii&b){
			return a.y<b.y;
		});
	}
}

signed main(){
	IOS
	int n,m,k;cin>>n>>m>>k;
	int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
	x1--,x2--,y1--,y2--;
	vvi good(n,vi(m));
	vvi dis(n,vi(m,INT_MAX));
	vector<vector<array<int,4>>> vis(n,vector<array<int,4>>(m,{0,0,0,0}));
	forn(i,n){
		forn(j,m){
			char c;cin>>c;
			if(c=='.')
				good[i][j]=1;
			else
				good[i][j]=0;
		}
	}
	forn(d,4)
		vis[x1][y1][d]=0;
	dis[x1][y1] = 0;
	vector<ii> q1,q2;
	q1.push_back({x1,y1});
	while(!q1.empty()){
		q2.clear();
		for(int d=0;d<4;d++){
			sorted(q1,d);
			for(auto& u:q1){
				for(int a=1;a<=k;a++){
					int nx = u.x+a*dx[d],ny = u.y+a*dy[d];
					// cout<<"nb "<<nx<<" "<<ny<<endl;
					if(nx<0||nx>=n || ny<0 || ny>=m || vis[nx][ny][d] || !good[nx][ny])
						break;
					vis[nx][ny][d] = 1;
					if(dis[nx][ny] > 1+dis[u.x][u.y]){
						q2.push_back({nx,ny});
						dis[nx][ny] = 1+dis[u.x][u.y];
					}
				}
			}
		}
		swap(q1,q2);
	}
	if(dis[x2][y2]==INT_MAX)
		dis[x2][y2] = -1;
	cout<<dis[x2][y2];
}

Measured memory_bytes: 88992
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  string ss,t;
  cin >> ss;
  cin >> t;
  for(int i = sz(ss)-sz(t);i>=0;i--) {
    int j = 0;
    bool ok = true;
    if(ss[i+j] != '?'&&ss[i]!=t[j]) continue;
    for(;j<sz(t);j++) {
      if(ss[i+j] != '?' && ss[i+j] != t[j]) {
        ok = false;
        break;
      }
    }
    if(!ok) continue;
    rep(k,i) {
      if(ss[k] == '?') {
        cout << 'a';
      } else {
        cout << ss[k];
      }
    }
    cout << t;
    srep(k,i+sz(t),sz(ss)) {
      if(ss[k] == '?') {
        cout << 'a';
      } else {
        cout << ss[k];
      }
    }
    cout << endl;
    return 0;
  }
  cout << "UNRESTORABLE" << endl;
  return 0;
}

Measured memory_bytes: 256
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
v = [0] * (n + 1)
for i in a:
    v[i-1] += 1

ans = 100000000000
now = 0
for i in range(0, x):
    now += v[i]
ans = min(ans, now)

now = 0
for i in range(x, n):
    now += v[i]
ans = min(ans, now)

print(ans)


Measured memory_bytes: 3316
n,k = map(int, input().split())
mod = 10**9 + 7

starts=list(range(n+1))
ends=list(reversed(list(range(n+1))))

init_starts=sum(starts[0:k-1])
init_ends=sum(ends[0:k-1])

sums=0
for i in range(k-1,n+1):
    init_starts+=starts[i]
    init_ends+=ends[i]
    sums+=init_ends-init_starts+1
    sums%=mod
print(sums)

Measured memory_bytes: 79524
using System;

class Program
{
    class DICE {
        public int top = 0;
        public int right = 0;
        int left = 0;
        int front = 0;
        int back = 0;
        int bottom = 0;

        public DICE(string[] no) {
            top = int.Parse(no[0]);
            back = int.Parse(no[1]);
            right = int.Parse(no[2]);
            left = int.Parse(no[3]);
            front = int.Parse(no[4]);
            bottom = int.Parse(no[5]);
        }

        public void Move(string mv) {
            for (int i = 0; i < mv.Length; i++) {
                string ch = mv.Substring(i, 1);
                if (ch == "N") {
                    MOVE_N();
                }
                else if (ch == "E") {
                    MOVE_E();
                }
                else if (ch == "W") {
                    MOVE_W();
                }
                else if (ch == "S") {
                    MOVE_S();
                }
            }
        }

        public void Move(int setTop, int setBack) {
            if (setTop == right) { MOVE_W(); }
            if (setTop == left) { MOVE_E(); }
            if (setTop == front) { MOVE_S(); }
            if (setTop == back) { MOVE_N(); }
            if (setTop == bottom) { MOVE_N(); MOVE_N(); }

            if (setBack == right) { TURN_RIGHT(); }
            if (setBack == left) { TURN_LEFT(); }
            if (setBack == front) { TURN_RIGHT(); TURN_RIGHT(); }
        }

        private void TURN_RIGHT() {
            int wk = front;
            front = left;
            left = back;
            back = right;
            right = wk;
        }

        private void TURN_LEFT() {
            int wk = front;
            front = right;
            right = back;
            back = left;
            left = wk;
        }

        private void MOVE_N() {
            int wk = top;
            top = back;
            back = bottom;
            bottom = front;
            front = wk;
        }

        private void MOVE_E() {
            int wk = top;
            top = left;
            left = bottom;
            bottom = right;
            right = wk;
        }

        private void MOVE_W() {
            int wk = top;
            top = right;
            right = bottom;
            bottom = left;
            left = wk;
        }

        private void MOVE_S() {
            int wk = top;
            top = front;
            front = bottom;
            bottom = back;
            back = wk;
        }
    }

    static void Main(string[] args) {
        string[] x = Console.ReadLine().Split(' ');
        int q = int.Parse(Console.ReadLine());

        for (int i = 0; i < q; i++) {
            string[] z = Console.ReadLine().Split(' ');

            DICE d = new DICE(x);
            d.Move(int.Parse(z[0]), int.Parse(z[1]));
            Console.WriteLine(d.right);
        }
    }
}


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

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

    vector<ll> to(m);
    rep(i, m) {
        to[i] = ((ll)i * i) % m;
    }
    deque<ll> a; // 繰り返しの部分
    vector<bool> seen(m, false); // 一度見たかどうか
    ll k = n;
    ll cur = x;
    ll lead = 0;
    ll leadnum = 0;
    ll period = 0;
    while (true) {
        // 一度通った頂点を見つけたときの処理
        if (seen[cur]) {
            while (a[0] != cur) {
                // 最初の余計な数手分を除去する
                --k;
                lead += a[0];
                leadnum++;
                a.pop_front();
                // 繰り返す前に K が限界になったらリターン
                if (k == 0) {
                    cout << lead << endl;
                    return 0;
                }
            }
            break;
        }
        // 最初は愚直にシミュレーションしつつ、履歴をメモしていく
        a.push_back(cur);
        seen[cur] = true;
        cur = to[cur];
        period++;
    }
    k = period - leadnum;
    ll sum1 = 0;
    for (auto t: a) {
        sum1 += t;
    }
    ll last = 0;
    ll cnt = (n-leadnum) % k;
    rep(i, cnt) {
        last += a[i];
    }
    cout << lead + (n-leadnum)/k * sum1 + last << endl;
    return 0;
}
/*
g++ -std=c++17 -Wall -Wextra -g -O0 -fsanitize=undefined,address main.cpp && oj t
*/

Measured memory_bytes: 4484
// Contest: AtCoder Beginner Contest 166 (https://atcoder.jp/contests/abc166)
// Problem: B: Trick or Treat (https://atcoder.jp/contests/abc166/tasks/abc166_b)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion }}}

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

    int n, k; cin >> n >> k;
    set<int> s;
    rep(i, n) s.emplace(i);
    rep(_, k) {
        int d, ai; cin >> d;
        while (d--)
            cin >> ai, --ai, s.erase(ai);
    }
    cout << sz(s) << '\n';

    return 0;
}

Measured memory_bytes: 3660
#include <stdio.h>
#include <string.h>
#include<iostream>
#include<stack>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int n,a[3002]= {0};
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    long long  Max=0;
    for(int i=0; i<n; i++)
    {
        Max+=a[i];
    }
    cout<<Max-n<<endl;
}


Measured memory_bytes: 256
// abc051_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int a = tx - sx;
    int b = ty - sy;

    char r = a > 0 ? 'R' : 'L';
    char l = a > 0 ? 'L' : 'R';
    char u = b > 0 ? 'U' : 'D';
    char d = b > 0 ? 'D' : 'U';

    string ans;

    // 1st
    REP(i, a) ans += r;
    REP(i, b) ans += u;

    // 1ts
    REP(i, a) ans += l;
    REP(i, b) ans += d;

    // 2st
    ans += l;
    REP(i, b+1) ans += u;
    REP(i, a+1) ans += r;
    ans += d;

    // 2st
    ans += r;
    REP(i, b+1) ans += d;
    REP(i, a+1) ans += l;
    ans += u;

    print(ans);

    return 0;
}


Measured memory_bytes: 256
use maplit::hashmap;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        r#as: [i64; n],
        bcs: [(i64, i64)],
    }

    let mut s = r#as.iter().sum::<i64>();

    let mut counts = hashmap!();
    for a in r#as {
        *counts.entry(a).or_insert(0) += 1;
    }

    for (b, c) in bcs {
        if let Some(n1) = counts.remove(&b) {
            let n2 = *counts.get(&c).unwrap_or(&0);
            counts.insert(c, n1 + n2);
            s += n1 as i64 * (c - b);
        }
        println!("{}", s);
    }
}


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

bool isOK(string s) {
    for (int i = 0; i < s.size() / 2; i++) {
        if (s[i] != s[s.size() - 1 - i]) {
            return false;
        }
    }
    return true;
}

int main() {
    int A, B;
    cin >> A >> B;
    int ans = 0;
    for (int i = A; i <= B; i++) {
        if (isOK(to_string(i))) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
 
// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
 
using namespace std;
using namespace __gnu_pbds;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define endl "\n"
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
 
const int INF = 1e16;
const double PI = acos(-1);
const int N = 1e6 + 7;
int mod = 1e9 + 7;

const int maxn = 1e3 + 7;
int dp[maxn][maxn];

int32_t main()
{
    IOS;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n, m;
    cin >> n >> m;
    vector<string> s(n);
    for(int i = 0; i < n; i++)
        cin >> s[i];
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
        {
            if(i == 0 && j == 0)
            {
                dp[i][j] = 1;
                continue;
            }
            if(s[i][j] == '#')
                continue;
            dp[i][j] = (i > 0 ? dp[i-1][j] : 0) + (j > 0 ? dp[i][j-1] : 0);
            if(dp[i][j] >= mod)
                dp[i][j] -= mod;
        }
    cout << dp[n-1][m-1] << endl;
    return 0;
}

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

int main() {
  int N , A;
  cin >> N >> A;
  
  if (N % 500 <= A) {
    cout << "Yes" << endl;
  }
  else if (N % 500 > A) {
    cout << "No" << endl;
  }
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define len length
#define mp make_pair
#define pq priority_queue
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define forn(i,n) for (int i = 0; i < int(n); ++i)
#define take(v) for(int i=0;i<(int)v.size();i++){cin>>v[i];}
#define printvec(v) for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define printds(x) while(!x.empty()){cout<<x.top()<<" ";x.pop();}
#define input(n) int n;cin>>n;
#define PI 3.141592653589793238463
#define lnput(n) long long int n;cin>>n;
#define fr(i,s,e) for(int i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;
int main()
{
  speed;
  int n;
  cin>>n;
  int v[n][3];
  int dp[n][3];
  for(int i = 0;i<n;i++) {
    for(int j = 0;j<3;j++) {
      cin>>v[i][j];
    }
  }
  dp[0][0] = v[0][0];
  dp[0][1] = v[0][1];
  dp[0][2] = v[0][2];
  for(int i = 1;i<n;i++) {
    dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + v[i][0];
    dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + v[i][1];
    dp[i][2] = max(dp[i-1][1],dp[i-1][0]) + v[i][2];
  }
  cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
  return 0;
}


Measured memory_bytes: 5920
import java.util.Scanner;

public class Main{
  static int n;
  static char[] s1, s2;
  static final long MOD = 1000000007;

  static final boolean DEBUG = false;

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    n = sc.nextInt();
    s1 = sc.next().toCharArray();
    s2 = sc.next().toCharArray();

    long[] dp = new long[n + 1];
    int s = -1;
    if(s1[0] == s2[0]){
      s = 2;
      dp[1] = 3;
    }
    else{
      s = 3;
      dp[2] = 6;
    }

    for(int i = s; i <= n; i++){
      if(s1[i - 1] == s2[i - 1]){
        if(s1[i - 2] == s2[i - 2]){
          dp[i] = (2L * dp[i - 1]) % MOD;
        }
        else{
          dp[i] = dp[i - 1];
        }
      }
      else if(s1[i - 1] == s1[i - 2]){
        if(i - 3 >= 0 && s1[i - 3] == s2[i - 3]){
          dp[i] = (2L * dp[i - 2]) % MOD;
        }
        else{
          dp[i] = (3L * dp[i - 2]) % MOD;
        }
      }
      if(DEBUG){
        System.out.println(i + " " + dp[i]);
      }
    }

    System.out.println(dp[n]);
  }
}


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

#define ll long long int
#define inv(name,Type,size) vector<Type> name(size);for(int index=0;index<size;index++) cin>>name[index];
#define F(a,n,i) for(int i=a;i<n;i++)
#define FLL(a,n,i) for(long long int i=a;i<n;i++)
#define pb push_back
#define endl "\n"
#define mod 1000000007
#define modpro 99824435
#define all(x) (x).begin(),(x).end()
const int d8i[8]={-1,0,1,0,-1,1,1,-1},d8j[8]={0,1,0,-1,1,1,-1,-1};


void solve(){
	ll n,d;
	cin>>n>>d;
	int count=0;
	F(0,n,i){
		double x,y;
		cin>>x>>y;
		//cout<<sqrt(pow(2,x)+pow(2,y))<<endl;
		if(sqrt(pow(x,2)+pow(y,2))<=d){
			count++;
		}
	}
	cout<<count;
}

int main()
{
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
  //int t;cin>>t;while(t--) solve(),cout<<endl;
  solve();
}



Measured memory_bytes: 3860
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    ll N; cin>>N;
    vector<ll> D(N+1,0);
    vector<ll> d(N);
    for (ll i = 0; i < N; ++i) {
        d[i]; cin>>d[i];
        D[d[i]]++;
    }

    if(D[0]!=1 || d[0]!=0){
        cout<<0<<endl;
        return 0;
    }

    ll ans = 1;
    for (ll i = 1; i < N; ++i) {
        for (int j = 0; j < D[i]; ++j) {
            ans *= D[i-1];
            ans %= 998244353;
        }
    }

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


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

const int maxn = 1e5+5;

int n, i, da[maxn], db[maxn], dc[maxn], a, b, c;

int main()
{
    cin >> n;
    cin >> da[1] >> db[1] >> dc[1];
    for(i = 2; i <= n; i ++) {
        cin >> a >> b >> c;
        da[i] = max(db[i-1] + a, dc[i-1] + a);
        db[i] = max(da[i-1] + b, dc[i-1] + b);
        dc[i] = max(db[i-1] + c, da[i-1] + c);
    }
    cout << max(max(da[n], db[n]), dc[n]);
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b;
  in2(a, b);
  out((a - 1) * (b - 1));
  memi;
}

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

using namespace std;

int main(){
    int x;
    cin >> x;
    string result = "";
    if(x >= 400 && x <= 599){
        result = "8";
    }
    if(x >= 600 && x <= 799){
        result = "7";
    }
    if(x >= 800 && x <= 999){
        result = "6";
    }
    if(x >= 1000 && x <= 1199){
        result = "5";
    }
    if(x >= 1200 && x <= 1399){
        result = "4";
    }
    if(x >= 1400 && x <= 1599){
        result = "3";
    }
    if(x >= 1600 && x <= 1799){
        result = "2";
    }
    if(x >= 1800 && x <= 1999){
        result = "1";
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, a, b, p;
	cin >> n >> a >> b;

	vector<int> freq(22);
	for (int i = 0; i < n; ++i) {
		cin >> p;
		++freq[p];
	}

	for (int i = 2; i <= 20; ++i)
		freq[i] += freq[i-1];

	int ans = min(freq[a], freq[b] - freq[a]);
	ans = min(ans, freq[20] - freq[b]);
	
	cout << ans << endl;
	return 0;
}

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

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


int main()
{
    int N;
    cin >> N;
    vector<long long> A(N);
    REP(i, N) cin >> A[i];

    REP(i, N-1) A[i+1] += A[i];
    long long ans = 1e+18;
    REP(i, N-1) ans = min(ans, abs(2*A[i]-A.back()));
    cout << ans << endl;

    return 0;
}

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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT64_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

class dsu {
private:
	int *id;
	int* sz;

	int root(int i) {
		while (i != id[i]) {
			id[i] = id[id[i]];
			i = id[i];
		}
		return i;
	}
public:
	int n;
	dsu(int v) {
		n = v;
		id = new int[n];
		sz = new int[n];

		for (int i = 0; i < n; i++) {
			id[i] = i;
			sz[i] = 0;
		}
	}

	bool find(int p , int q) {
		return root(p) == root(q);
	}

	void join(int p , int q) {
		int i = root(p);
		int j = root(q);
		if (i == j) {
			return;
		}
		if (sz[i] < sz[j]) {
			id[i] = j ;
			sz[j] += sz[i];
		}
		else {
			id[j] = i;
			sz[i] += sz[j];
		}
	}
};

class BIT {
private:
	int* FT;
	int n;
public:
	void updateBIT(int index , int val) {
		index += 1;
		while (index <= n) {
			FT[index] += val;
			index += (index & (-index));
		}
	}

	int getSum(int index) {
		index += 1;
		int sum = 0 ;
		while (index > 0) {
			sum += FT[index];
			index -= (index & (-index));
		}
		return sum;
	}


	BIT(int* a , int v) {
		n = v ;
		FT = new int[n + 1];
		for (int i = 1 ; i <= n ; i++) {
			FT[i] = 0 ;
		}
		for (int i = 0 ; i < n ; i++) {
			updateBIT(i, a[i]);
		}
	}
};

int nCr(int n , int r ) {
	int p = 1, k = 1;

	if (n - r < r ) {
		r = n - r;
	}
	if (r != 0) {
		while (r != 0) {
			p *= n ;
			k *= r ;
			int m = __gcd(p, k);
			p /= m;
			k /= m;
			n--;
			r--;
		}
	}
	else {
		p = 1;
	}
	return p ;
}

int modPower(int x, int y , int p) {
	//Used to calculate (x^y)%p
	int res = 1;
	if (y == 0) {
		return 1;
	}

	x = x % p;
	if (x == 0) {
		return 0  ;
	}

	while (y > 0) {
		if (y & 1) {
			res = (res * x) % p;
		}

		y >>= 1;
		x = (x * x) % p;
	}
	return res ;

}

int32_t main() {
	FIO;


	int n ;
	cin >> n;

	vi a(n);
	int f = 0 ;
	for (int i = 0 ; i < n ; i++) {
		cin >> a[i];
		a[i]--;
		f += a[i];
	}
	cout << f;




	return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>

int main()
{
	int i;
	int seed,max = 0;
	int data[100] = { 0 };
	int maxnum[100];
	while ((scanf("%d", &seed)) != EOF)
	{
		data[seed-1] += 1;
	}
	for (i = 0; i < 100; i++)
	{
		if (data[i] > max) max = data[i];
	}
	for (i = 0; i < 100; i++)
	{
		if (data[i] == max) printf("%d\n", i + 1);
	}
	return 0;
}

Measured memory_bytes: 2596
S = input()
T = input()

res = []
for i in range(len(S) - len(T) + 1):
    flag = True
    for j in range(len(T)):
        if S[i + j] != T[j] and S[i + j] != "?":
            flag = False
    if flag:
        U = S.replace("?", "a")
        U = U[:i] + T + U[i + len(T) :]
        res.append(U)

if res:
    print(res[-1])
else:
    print("UNRESTORABLE")


Measured memory_bytes: 3060
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int time = sc.nextInt();
        int hour = time / 3600;
        int minute = time / 60 % 60;
        int second = time % 60 % 60;
        System.out.println(hour+":"+minute+":"+second);
    }
}


Measured memory_bytes: 26296
#include<bits/stdc++.h>
using namespace std;
inline char nchar() {
	static const int bufl=1<<20;
	static char buf[bufl],*a=NULL,*b=NULL;
	return a==b && (b=(a=buf)+fread(buf,1,bufl,stdin),a==b)?EOF:*a++;
}
inline int read() {
	int x=0,f=1;
	char c=nchar();
	for (;!isdigit(c);c=nchar()) if (c=='-') f=-1;
	for (;isdigit(c);c=nchar()) x=x*10+c-'0';
	return x*f;
}
const int maxn=1e5+1;
int n,a[maxn];
bool f() {
	int odd=0,even=0,id=0;
	for (int i=1;i<=n;++i) {
		odd+=(a[i]&1);
		even+=(~a[i]&1);
		if (a[i]&1) id=i;
	}
	if (even&1) return true;
	if (odd>1) return false;
	if (a[id]==1) return false;
	--a[id];
	int g=a[1];
	for (int i=2;i<=n;++i) g=__gcd(g,a[i]);
	for (int i=1;i<=n;++i) a[i]/=g;
	return f()^true;
}
int main() {
	n=read(),generate_n(a+1,n,read);
	puts(f()?"First":"Second");
	return 0;
}


Measured memory_bytes: 1664
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#include "atcoder/all"
using namespace atcoder;

using mint = modint998244353;
const mint inv9 = mint(1)/9;

struct S {mint x, w; S(mint x=0, mint w=1):x(x), w(w){}};
S op(S a, S b){return S(a.x * b.w + b.x, a.w * b.w);}
S e(){return S();}
S mapping(int f, S a){return (f==0 ? a : S((a.w-1)*inv9 * f, a.w));}
int composition(int f, int g){return (f==0 ? g : f);}
int id(){return 0;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q;
	cin >> n >> q;
	lazy_segtree<S, op, e, int, mapping, composition, id> ls(n);
	rep(i,n) ls.set(i, S(1, 10));
	rep(qi,q){
		int l, r, d;
		cin >> l >> r >> d;
		--l;
		ls.apply(l, r, d);
		S ans = ls.prod(0, n);
		cout << ans.x.val() << endl;
	}
	return 0;
}

Measured memory_bytes: 9832
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long
#define ull unsigned long long
#define EPS 1e-8
using namespace std;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
const double pi = acos(-1.0);
int read()
{
	int ret=0;char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	for(;ch>='0'&&ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret;
}
const int MAX_N=1e5+5;
ll h[MAX_N],a,b;
int n;
bool jud(ll t)
{
	ll sum=0;
	for(int i=0;i<n;i++)
	{
		ll temp=h[i]-t*b;
		if(temp>0)
		{
			sum+=(temp+(a-b)-1)/(a-b);
			if(sum>t)
			return false;
		}
	}
	return true;
}
int main()
{
 	#ifdef TEST
	 	freopen("input.txt","r",stdin);
	#endif
	scanf("%d %lld %lld",&n,&a,&b);
	ll m=0;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",h+i);
		m=max(m,h[i]);
	}
	ll l=0,r=(m+b-1)/b;
	while(l<=r)
	{
		ll mid=(l+r)>>1;
		if(!jud(mid))
		{
			l=mid+1;
		}
		else
		{
			r=mid-1;
		}
	}
	printf("%lld\n",l);
	return 0;
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int M;
  int C;
  cin >> N >> M >> C;
  int B[M];
  for(int i=0;i<M;i++){
    cin >> B[i];
  }
  int count = 0;
  for(int i=0;i<N;i++){
    int sum = 0;
    int A[M];
    for(int j=0;j<M;j++){
      cin >> A[j];
    }
    for(int k=0;k<M;k++){
      sum += B[k]*A[k];
    }
    if(sum + C > 0)
      count++;
  }
  cout << count;
}

Measured memory_bytes: 256
int main()
{
    int i,j,k,N,m;
    int A[100];
    
    scanf("%d",&N);
    for (i=0; i<N; i++)scanf("%d",&A[i]);
       
    for(i=1;i<N+1;i++){
        m=A[i];
        j=i-1;

        for(k=0;k<N;k++){
            printf("%d",A[k]);
            if(k<N-1)printf(" ");
            else printf("\n");
            }
     
        while(A[j]>m){
            A[j+1]=A[j];
            j--;
            A[j+1]=m;
            }
        }
    
 return 0;
}

Measured memory_bytes: 604
//in the name of god
#include <bits/stdc++.h>
using namespace std;
#define MAX_N (int)2e5+20
#define INF 2e9+20
#define pb push_back
#define F first
#define S second
typedef long long LL;
#define int LL
typedef pair<int,int> pii;
const int delta=(int)1e9+7;
int  n,y,a,b,c,m;
void out(){
	if(10*a+5*b+c!=y) cout<<"?\n";
	cout<<a<<" "<<b<<" "<<c<<endl;
	exit(0);
}
main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin>>n>>y;
	if(y%1000!=0) return cout<<"-1 -1 -1\n",0;
	y/=1000;
	c=y;
	m=y-n;
	if(m==0) out();
	for(int i=0;i*9<=m;++i){
		int x=m-(i*9);
		if(x%4==0){
			a=i; b=x/4;
			c-=5*b+10*a;
			if(a+c+b==n && c>=0) out();
			c+=5*b+10*a;
			a=b=0;
		}
	}
	return cout<<"-1 -1 -1\n",0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define pb push_back
#define sz(X) ((int)(X).size())
#define all(X) (X).begin(),(X).end()
#define ll long long
#define pi pair<int,int>
const int N=3e5+5,MOD=1e9+7;
 
using namespace std;
int n,q;
string a;
int pref[N];
int main()
{
	//freopen("tst.txt","r",stdin);
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin>>n>>q>>a;
	a = '#' + a ;
	for(int i=1;i<sz(a);i++){
		pref[i]=(a[i]=='C' && a[i-1]=='A');
	}

	for(int i=1;i<=n;i++)pref[i]+=pref[i-1];

	while(q--){
		int l,r;
		cin>>l>>r;
		if(a[l]=='C')l++;
		cout<<pref[r]-pref[l-1]<<"\n";
	}	
}

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

struct edge{
  ll to,cost;
};

ll n,a,b,c;
vector< edge > G[MAX];
ll dist[MAX];

void dfs(int pos,int prev=-1){
  for(int i=0;i<(int)G[pos].size();i++){
    edge e=G[pos][i];
    if(e.to==prev)continue;
    dist[e.to]=dist[pos]+e.cost;

    dfs(e.to,pos);
  }
}

int main(){
  cin>>n;
  for(int i=0;i<n-1;i++){
    cin>>a>>b>>c;
    a--,b--;
    G[a].push_back((edge){b,c});
    G[b].push_back((edge){a,c});
  }
  ll q,K;
  cin>>q>>K;
  K--;
  dfs(K);
  while(q--){
    cin>>a>>b;
    a--,b--;
    cout<<dist[a]+dist[b]<<endl;
  }
  return 0;
}


Measured memory_bytes: 19712
# -*- coding: utf-8 -*-
from collections import Counter, defaultdict, deque
import math
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def eratosthenes(n):
    p = []
    t = [True] * n

    for i in range(2, int(math.ceil(math.sqrt(n)))):
        if t[i]:
            p.append(i)
            for j in range(2*i, n, i):
                t[j] = False

    for j in range(i+1, n):
        if t[j]:
            p.append(j)

    return p

P = eratosthenes(10**6+1)


class Bisect:
    def __init__(self, func):
        self.__func = func

    def bisect_left(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if self.__func(mid) < x:
                lo = mid+1
            else:
                hi = mid
        return lo

    def bisect_right(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if x < self.__func(mid):
                hi = mid
            else:
                lo = mid+1
        return lo

def f(n):
    return (n**2 + n) // 2

@mt
def slv(N):
    if N == 1:
        return 0

    d = Counter()
    for p in P:
        n = 0
        while N % p == 0:
            n += 1
            N //= p
        if n != 0:
            d[p] = n
        if N == 1:
            break
    if N != 1:
        d[N] = 1
    ans = 0
    for p, n in d.items():
        i = Bisect(f).bisect_left(n+1, 0, 10**18)-1
        ans += i

    return ans


def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 80660
#include<iostream>
#include <cstdio>
#include<cstring>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility>
#define LEN 100005
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
ll LGCD(ll x, ll y) {if (x % y == 0) return y;else return LGCD(y, x % y);}
ll LLCM(ll x, ll y) {return x * y / LGCD(x, y);}

int GCD(int x, int y) {if (x % y == 0) return y;else return GCD(y, x % y);}
int LCM(int x, int y) {return x * y / GCD(x, y);}
ll dp[10000][10000];
ll combination(ll n, ll r) {
         if (n == r){dp[n][n] = 1;}
	else if (r == 0) {return dp[n][0] = 1;}
	else if (r == 1) {return dp[n][1]=n;}
	else {dp[n][r]=dp[n - 1][r - 1] % 1000000007 + dp[n - 1][r] % 1000000007;
	return dp[n][r]=combination(n - 1, r - 1) % 1000000007 + combination(n - 1, r) % 1000000007;}
}
int main() {
	string S;
	cin >> S;
	int n;
	n = S.length();
	for (int i = 0;i < n;i++) { cout << "x"; }
	cout << endl;
	return 0;
}

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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
 ll gcd(ll a,ll b){
 if(b == 0) return a;
 return gcd(b,a%b);
 }

//最小公倍数
 ll lcm(ll a,ll b){
 ll g = gcd(a,b);
 return a / g * b; // Be careful not to overflow  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 




int main() {
int a, b;
cin >> a >> b;

int ans = a + b;

if(ans >= 24) ans -= 24;

print (ans);

}

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

ll n,k,s;

template<typename int_t>
void readx(int_t &x)
{
	x=0; int_t k=1; char ch=0;
	while (ch<'0' || ch>'9') { ch=getchar(); if (ch=='-') k=-1; }
	while (ch>='0' && ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	x*=k;
}



int main()
{
	readx(n); readx(k); readx(s);
	
	for (int i=1;i<=k;i++) 
		printf("%lld ",s);
	if (s==1000000000) 
	{
		for (int i=k+1;i<=n;i++)
			printf("1 ");
	}
	else
	{
		for (int i=k+1;i<=n;i++)
			printf("1000000000 ");
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 3684
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll N, Q;
string S;

void solve() {

	vector<ll> pf(S.size());
	ll tmp = 0;
	for (ll i = N - 1; i >= 0; i--) {
		if (i == N - 1) {
			pf[i] = 0;
			continue;
		}
		if (S[i] == 'A' && S[i + 1] == 'C') {
			tmp++;
		}
		pf[i] = tmp;
	}

	rep(i, Q) {
		ll L, R;
		cin >> L >> R;

		cout << pf[L - 1] - pf[R - 1] << endl;

	}

	return;
}

int main() {

	cin >> N >> Q >> S;

	solve();
	cout << endl;
	return 0;
}

Measured memory_bytes: 1792
n = int(input())
a = [int(x) for x in input().split()]
a.sort()
m = max(a) // 2
res = 0
c = max(a)
for i in range(n-1):
  if abs(m - a[i]) <= c:
    res = a[i]
    c = abs(m - a[i])
print(max(a),res)

Measured memory_bytes: 20136
//07
#include<iostream>
#include<complex>
#include<set>

using namespace std;

typedef complex<double> P;

struct cmp{
  bool operator()(P a,P b)const{
    if(a.real()!=b.real()){
      return a.real()<b.real();
    }else{
      return a.imag()<b.imag();
    }
  }
};

int main(){
  for(int x,y;cin>>x>>y,x|y;){
    int n;
    cin>>n;
    P sp[10];
    for(int i=0;i<n;i++){
      int x,y;
      cin>>x>>y;
      sp[i]=P(x,y);
    }
    set<P,cmp> s[11];
    s[0].insert(P(x,y));
    for(int i=0;i<n;i++){
      for(set<P,cmp>::iterator it=s[i].begin();it!=s[i].end();it++){
	P p=*it;
	for(int j=0;j<4;j++){
	  for(int k=-1;k<=1;k++){
	    P n=p+P(2,k)*pow(P(0,1),j);
	    if(abs(n-sp[i])<2){
	      s[i+1].insert(n);
	    }
	  }
	}
      }
    }
    cout<<(s[n].empty()?"NA":"OK")<<endl;
  }
  return 0;
}

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

using namespace std;
using ll = long long;
const ll mod = 1000000007;

vector<vector<int>> DP(500, vector<int>(500, 1e8));

int main()
{
    int n, MA, MB;
    cin >> n >> MA >> MB;
    DP[0][0] = 0;
    
    for(int i = 0; i < n; i++){
        int a, b, c;
        cin >> a >> b >> c;
        vector<vector<int>> dp = DP;

        for(int i = 0; i < 400; i++){
            for(int j = 0; j < 400; j++){
                DP[i + a][j + b] = min(dp[i + a][j + b],dp[i][j] + c);
            }
        }
    }
    int ans = 10000000;
    for(int cef = 1; cef < 500; cef++){
        if(MA * cef > 450 || MB * cef > 450)continue;
        ans = min(DP[cef * MA][cef * MB], ans);
    }
    cout << (ans == 10000000 ? -1 : ans) << endl;

}


Measured memory_bytes: 2272
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 200000

int n;
int a[MAXN], b[MAXN];

int input() {
	if (scanf("%d", &n) < 0) return 0;
	for (int i=0; i<n; i++) scanf("%d %d", &a[i], &b[i]);
	return 1;
}

void init() {
}

long solve() {
	long s = 0;
	for (int i=0; i<n; i++) s+= a[i];
	int m = INT_MAX;
	for (int i=0; i<n; i++)
		if (b[i] < a[i])
			m = min(m, b[i]);
	if (m==INT_MAX) return 0;
	return s - m;
}

void output(long ans) {
	printf("%ld\n", ans);
}

void cleanup() {
}

int main() {
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





Measured memory_bytes: 384