akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'


const double PI = 3.141592653589;
const ll MOD = 1e9 + 7;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  int a, b, x;
  cin >> a >> b >> x;
  int vol = a * a * b;
  if (x >= vol / 2) {
    long double y = 2 * (long double)(vol - x) / a / a;
    long double rr = atanl(y / a);
    long double ans = rr * 180 / PI;
    cout << ans << endl;
  } else {
    long double y = 2 * (long double) x / a / b;
    long double rr = atanl(b / y);
    long double ans = rr / PI * 180;
    cout << ans << endl;
  }
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 256
N = int(input())
arm = [list(map(int, input().split())) for _ in range(N)]
dist = [[0 for _ in range(3)] for _ in range(N)]

for i in range(N):
  dist[i][0] = arm[i][0] + arm[i][1]
  dist[i][1] = arm[i][0]
  dist[i][2] = arm[i][1]

dist.sort()

ans = 1
left = dist[0][1] + dist[0][2]
for i in range(1, N):
  if left <= dist[i][1] - dist[i][2]:
    ans += 1
    left = dist[i][1] + dist[i][2]

print(ans)

Measured memory_bytes: 41176
import numpy as np
N, X, Y = [int(_) for _ in input().split()]
X -= 1
Y -= 1
cnt = np.zeros(N, dtype=int)
for i in range(0, (X + Y) // 2):
    #t-i<=abs(i-X)+1+Y-t
    #2*t<=abs(i-X)+1+Y+i
    #t<= tmax = 0 - - (abs(i-X)+1+Y+i)//2
    #tmin=i-X+1
    tmin = abs(i - X) + 1
    tmax = 0 - -(abs(i - X) + 1 + Y + i) // 2
    cnt[1:tmax - i] += 1
    cnt[tmin:tmin + Y - tmax + 1] += 1
    cnt[tmin + 1:tmin + N - Y] += 1
for i in range((X + Y) // 2, N):
    cnt[1:N - i] += 1
print(*cnt[1:], sep='\n')


Measured memory_bytes: 26620
import math
def comb(n, k):
    if n < 0 or k < 0 or n < k: return 0
    return math.factorial(n) // math.factorial(n-k) // math.factorial(k)



n,k = map(int, input().split())
MOD = 10 ** 9 + 7

dp = [[0] * (n+1)] * (k+1)

dp[0][0] = 1
for i in range(1, k+1):
    for j in range(n+1):
        if j >= i: dp[i][j] = (dp[i-1][j] + dp[i][j-i])%MOD
        else: dp[i][j] = dp[i-1][j]

print(dp[k][n])


Measured memory_bytes: 5668
/*
 * Author - Abhas Jain
 * Code is inside the solve function
 */
 
#include <bits/stdc++.h>
 
#define F first
#define S second
#define all(c) c.begin(), c.end()
#define endl '\n'
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
 
const ld PI = 3.141592653589793;
const ll INF = 9223372036854775807ll;
const ll mod = 1e9 + 7;
 
void solve() 
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int i = 0, j = n - 1;
	int ans = 0;
	while (i < j) {
		if (s[i] == 'W' && s[j] == 'R') {
			i++;
			j--;
			ans++;
		}  else if (s[i] == 'R') {
			i++;
		} else j--;
	}
	cout << ans << endl;
}
 
int main( )
{   
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    solve();
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair< ll , string > P;

int main(){
	ll h, n;
	cin >> h >> n;
	
	rep( i , n){
		int a;
		cin >> a;
		h -= a;
		if( h <= 0){
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
}


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

template <typename T>
using lim = numeric_limits<T>;

const int MOD = 1e9+7;
const int MAXN = 1e5+1;

vector<int> prime;
bool is_composite[MAXN];
int mu[MAXN];

void sieve(int n){
	memset(is_composite, 0, sizeof is_composite);
	mu[1] = 1;
	for (int i = 2; i < n; i++){
		if (!is_composite[i]) {
			prime.push_back(i);
			mu[i] = -1;
		}
		for (int j = 0; j < prime.size() and i*prime[j] < n; j++){
			is_composite[i*prime[j]] = true;
			if (i % prime[j] == 0){
				mu[i*prime[j]] = 0;
				break;
			}
			mu[i*prime[j]] = mu[i]*mu[prime[j]];
		}
	}
}

ll modpow(ll b, ll e, int mod){
	ll ans = 1;
	while(e){
		if (e&1) ans = ans*b%mod;
		e >>= 1;
		b = b*b%mod;
	}
	return ans;
}

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

	sieve(MAXN);
	ll n, k;
	cin >> n >> k;
	ll ans = 0;
	for (ll i = 1; i <= k; i++){
		ll innerans = 0;
		for (ll d = 1; d <= k/i; d++){
			innerans = (innerans + mu[d]*modpow(k/(i*d), n, MOD))%MOD;
		}
		ans = (ans+innerans*i%MOD)%MOD;
	}

	cout << ans << "\n";
}

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

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; }
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
using Graph = vector<vector<int>>;
queue<int> quex,quey;

int main(){
    int n;  cin >> n;
    vector<char>s(n);
    vector<char>t(n);
    rep(i,n) cin >> s.at(i) ;
    rep(i,n) cin >> t.at(i);
    rep(i,n){
        cout << s.at(i) << t.at(i);
    }
    cout << endl;
}


Measured memory_bytes: 256
import numpy as np

n = int(input())
a = input().split()
np_a=np.array(a, dtype=int)

sum=np.int(sum(np_a))
count=np.zeros(100001, dtype='int64')
for i in range(0,n):
  count[np_a[i]]+= 1
  
q = int(input())
for i in range(0,q):
  b, c= map(int, input().split())
  sum=sum+(c-b)*count[b]
  count[c]=count[c]+count[b]
  count[b]=0
  
  print (sum)


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

const int INF = 1001001001;
int dist[100005][3];

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> to(n);
  rep(i,m){
    int u,v;
    cin >> u >> v;
    u--; v--;
    to[u].push_back(v);
  }
  int s,t;
  cin >> s >> t;
  s--; t--;
  rep(i,n)rep(j,3)dist[i][j] = INF;
  dist[s][0] = 0;
  queue<P> q;
  q.push(P(s,0));
  while(!q.empty()){
    int a = q.front().first, b = q.front().second;
    q.pop();
    for(auto c:to[a]){
      int nl = (1+b)%3;
      if(dist[c][nl]!=INF)continue;
      dist[c][nl] = dist[a][b] + 1;
      q.push(P(c,nl));
    }
  }
  int ans = dist[t][0];
  if(ans==INF){
    puts("-1");
    return 0;
  }
  cout << ans/3 << endl;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// // assign avl ncm dijkstra geo2 kruskal graph uf lca BIT
// matrix dinic next_combination topcoder lcm vi st gin
// cusum segtree

struct Monoid {
    using T = int;
    T operator()(const T &a, const T& b) { return (a + b); }
    //static const T I = 0;
    const T I = 0;
};
struct SegmentTree {
    using T = Monoid::T;
    Monoid op;
    int n;
    vector<T> d;
    SegmentTree(int m) {
        for (n = 1; n < m; n *= 2);
        d.assign(2 * n - 1, op.I);
    }
    void update(int k, T x) {
        k += n - 1;
        d[k] = x;
        while (k > 0) {
            k = (k - 1) / 2;
            d[k] = op(d[2 * k + 1], d[2 * k + 2]);
        }
    }
    T query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l)return op.I;
        if (a <= l&&r <= b)return d[k];
        T xl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        T xr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return op(xl, xr);
    }
    T query(int a, int b) {
        return query(a, b, 0, 0, n);
    }
};

bool prime[101000];

void init()
{
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1] = false;
    rep(i, 100100) {
        if (prime[i]) {
            for (int j = 2; i * j < 100100; j++) {
                prime[i*j] = false;
            }
        }
    }
}

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

    init();
    SegmentTree funami(100010);
    rep(i, 50010) {
        if (prime[i] && prime[i * 2 - 1]) funami.update(i * 2 - 1, 1);
    }

    Int(q);
    while (q--) {
        int2(a, b);
        cout << funami.query(a, b+1) << endl;
    }
    

    return 0;
}


Measured memory_bytes: 2944
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
4 5
0 0 1 0 0
1 0 0 0 0
0 0 0 1 0
0 0 0 1 0

output:
6
"""

import sys


class Rectangle(object):
    __slots__ = ('pos', 'height')

    def __init__(self, pos=float('inf'), height=-1):
        """
        init a Rectangle
        """
        self.pos = pos
        self.height = height


def gen_rec_info(_carpet_info):
    dp = [[float('inf')] * W for _ in range(H)]

    for i in range(H):
        for j in range(W):
            if int(_carpet_info[i][j]):
                dp[i][j] = 0
            else:
                dp[i][j] = dp[i - 1][j] + 1 if i else 1

    return dp


def get_largest_area(_hi_info):
    hi_max_area = 0
    rec_stack = []
    _hi_info.append(0)

    for i, v in enumerate(_hi_info):
        rect = Rectangle(pos=i, height=int(v))
        if not rec_stack:
            rec_stack.append(rect)
        else:
            last_height = rec_stack[-1].height
            if last_height < rect.height:
                rec_stack.append(rect)
            elif last_height > rect.height:
                target = i
                while rec_stack and rec_stack[-1].height >= rect.height:
                    pre = rec_stack.pop()
                    area = pre.height * (i - pre.pos)
                    hi_max_area = max(hi_max_area, area)
                    target = pre.pos
                rect.pos = target
                rec_stack.append(rect)

    return hi_max_area


def solve(_rec_info):
    overall_max_area = 0
    for hi_info in _rec_info:
        overall_max_area = max(overall_max_area, get_largest_area(hi_info))

    return overall_max_area


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    H, W = map(int, _input[0].split())
    carpet_info = list(map(lambda x: x.split(), _input[1:]))

    rec_info = gen_rec_info(carpet_info)
    # print(rec_info)
    ans = solve(rec_info)
    print(ans)

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

using namespace std;

bool cmp(pair<pair<int,int>,int> a,pair<pair<int,int>,int> b)
{
	if(a.first.first==b.first.first)
	{
		return a.first.second < b.first.second;
	}
	return a.first.first < b.first.first;
}

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

	int n,m,p,y;
	vector <pair<pair<int,int>,int>> v;

	cin >> n >> m;

	vector <string> res(m);

	for(int i=0;i<m;i++)
	{
		cin >> p >> y;
		v.push_back(make_pair(make_pair(p,y),i));
	}

	sort(v.begin(),v.end(),cmp);

	int number = 0;
	int count = 1;

	for(int i=0;i<m;i++)
	{
		if(v[i].first.first!=number)
		{
			number = v[i].first.first;
			count = 1;
		}
		else
		{
			count++;
		}
		int a = number;
		int b = count;
		string s1,s2;

		while(a>0)
		{
			s1 = char(a%10+'0') + s1;
			a/=10;
		}

		while(1)
		{
			if(s1.length()==6)
			{
				break;
			}
			s1 = '0' + s1;
		}

		while(b>0)
		{
			s2 = char(b%10+'0') + s2;
			b/=10;
		}

		while(1)
		{
			if(s2.length()==6)
			{
				break;
			}
			s2 = '0' + s2;
		}		
		res[v[i].second] = s1+s2;
	}

	for(int i=0;i<m;i++)
	{
		cout << res[i] << '\n';
	}

	return 0;
}

Measured memory_bytes: 8180
# include <cstdio>
# include <map>
# include <cmath>

using namespace std;

const int mod = 1e9+7;

int main()
{
    int n;
    int  a[100005];
    map<int,int> m;
    scanf("%d",&n);

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

    int flag = 0; 
    if(n%2) //奇数 
    {
        if(m[0] != 1)
        {
            flag = 1;
        }
        for(int i = 2;i < n;i+=2)
        {
            if(m[i] != 2)
            {
                flag = 1;
            }
        }
    }else{
        for(int i = 1;i < n;i+=2)
        {
            if(m[i] != 2)
            {
                flag = 1;
            }
        }
    }
    long long sum = 1;

    for(int i =0;i < floor(n/2);i++)
    {
        sum = ((sum % mod) * 2)% mod;
    }

    if(n%2)
    {
        if(flag)
        printf("0\n");
        else
        printf("%lld\n",sum);
    }   
    else
    {
        if(flag)
        printf("0\n");
        else
        printf("%lld\n",sum);
    }

    return 0;
 } 


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

int n,ans; 

int main()
{
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++)
		cin >> a[i];
	for(int i=0;i<100;i++)
	{
		int sum=0;
		for(int j=0;j<n;j++)
			sum += (a[j]-i)*(a[j]-i);
		if(!i)
			ans=sum;
		else
			ans=min(sum,ans);
	} 
	cout << ans << endl;
	return 0;
}

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

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

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

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

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

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

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

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

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

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

fn main() {
    input! {
        n: i64,
    }

    let mut ans = 0;

    let mut r = n;
    let lim = (n as f64).sqrt().ceil() as i64;
    for i in 1..lim * 2 {
        let l = n / (i + 1) + 1;

        // dbg!((i, l, r));

        // n / a = i
        // n % a = i

        let rem = n % l;
        if rem >= i && rem % i == 0 {
            // dbg!((l, i, rem, l + (rem / i - 1)));

            ans += l + (rem / i - 1);
        }

        // if rem < i {
        //     break;
        // }

        r = l;
    }

    println!("{}", ans);
}


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

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

    long long m = (n / b) * b - 1;
    if(n < b) m = n;

    long long ans = (a * m) / b - a * (m / b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (s)
{
  const h = Math.floor(s/(60*60));
  const m = s/60;
  const a = Math.floor(m%60);
  const t = (s - (h*60*60)) - (a*60);
  const coron = ':';
  const result = h+coron+a+coron+t
  console.log(result);
});


Measured memory_bytes: 19356
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{


	public static void main(String[] a){

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(is);


        String str = "";
        char[] chr;

		try {
			str = br.readLine();
			chr = new char[str.length()];

			for(int i = 0; i < str.length(); i++) {
				 chr[i] = str.charAt(i);
			}

			String ans = "";

			for(int i = (chr.length - 1); i >= 0; i--) {
				ans += chr[i];
			}
			System.out.println(ans);

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

	}


}

Measured memory_bytes: 24032
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <ctime>
#include <fstream>
#include <cmath>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	long long n, k;
	cin >> n >> k;

	vector<long long> neg;
	vector<long long> pos;
	for (long long i = 0; i < n; i++) {
		long long a;
		cin >> a;
		if (a < 0) {
			neg.push_back(-a);
		}
		else {
			pos.push_back(a);
		}
	}
	reverse(neg.begin(), neg.end());

	const long long INF = 1e14;
	long long mn = INF;
	if (pos.size() >= k) {
		mn = pos[k - 1];
	}
	if (neg.size() >= k) {
		mn = min(mn, neg[k - 1]);
	}

	for (long long i = 0; i < min((long long)pos.size(), k - 1); i++) {
		long long tmp = pos[i] * 2;
		if (k - i - 1 <= neg.size()) {
			tmp += neg[k - i - 2];
			mn = min(tmp, mn);
		}
	}
	for (long long i = 0; i < min((long long)neg.size(), k - 1); i++) {
		long long tmp = neg[i] * 2;
		if (k - i - 2 < pos.size()) {
			tmp += pos[k - i - 2];
			mn = min(tmp, mn);
		}
	}
	cout << mn;
}

Measured memory_bytes: 1656
#include <cstdio>
#include <cmath>

int main(){
	int n=0,psum=0,asum=0,price,amount;
	while(scanf("%d,%d",&price,&amount)!=EOF){
		psum += price*amount;
		asum += amount;
		n++;
	}
	printf("%d\n%.lf\n",psum,round((double)asum/(double)n));
	return 0;
}

Measured memory_bytes: 0
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <numeric>
using namespace std;

int main() {
    int H1,M1,H2,M2;
    int K;
    cin>>H1>>M1>>H2>>M2>>K;
    
    int st =H1*60+M1;
    int en = H2*60+M2;
    
    cout << en - st - K << endl;
    
}


Measured memory_bytes: 3188
#pragma region template
 
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#pragma region random
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T> T randint(T a, T b) {
    return uniform_int_distribution<T>(a, b)(rng);
}
 
#pragma endregion
 
#pragma region debug
string to_string(string s) { return '"' + s + '"'; }
 
string to_string(const char *s) { return to_string((string)s); }
 
string to_string(bool b) { return (b ? "true" : "false"); }
 
template <typename A, typename B> string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A> string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first)
            res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
 
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
 
#pragma endregion
 
#pragma endregion
 
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin>>n;
    ll ans = n-1;
    for(ll i=1LL;i*i<=n;i++)
    {
        if(n%i==0)
        {
        ans = min(ans,i-1+n/i-1);
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
           String x= Console.ReadLine();
            int i = int.Parse(x);
            Console.WriteLine(i*i*i);
        }
    }
}


Measured memory_bytes: 17980
my_input = input

def less_than(a, b):
    return a[0] < b[0] and a[1] < b[1]

n = int(my_input())
a = []
b = []
for _ in range(n):
    ax, ay = my_input().split()
    a.append((int(ax), int(ay)))
for _ in range(n):
    bx, by = my_input().split()
    b.append((int(bx), int(by)))
a = sorted(a, key=lambda x:x[1], reverse=True)
b = sorted(b, key=lambda x:x[0], reverse=False)
ans = 0
ii = set()
for j in range(n):
    for i in range(n):
        if i in ii:
            continue
        if less_than(a[i], b[j]):
            ans += 1
            ii.add(i)
            break
print(ans)

Measured memory_bytes: 3064
#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;
typedef long long ll;

int dp[105][4][2];

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int K;
    cin >> K;

    dp[0][0][0] = 1;
    rep(i, n) rep(j, 4) rep(k, 2) {
        int nd = s[i]-'0';
        rep(d, 10) {
            int ni = i+1, nj = j, nk = k;
            if (d != 0) nj++;
            if (nj > K) continue;
            if (k == 0) {
                if (d > nd) continue;
                if (d < nd) nk = 1;
            }
            dp[ni][nj][nk] += dp[i][j][k];
        } 
    }
    int ans = dp[n][K][0] + dp[n][K][1];
    cout << ans << endl;

    return 0;
}

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

int main(){
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  if(s==u){
    a--;
  }
  else{
    b--;
  }

  cout << a << " " << b << endl;


  return 0;
}

Measured memory_bytes: 3568
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

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

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  cout<<(n/2)*(n/2+n%2)<<endl;

}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int n,a[20],b[20],c[19];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
        cin>>b[i];
    for(int i=0;i<n-1;i++)
        cin>>c[i];
    int ans=0;
    for(int i=0;i<n;i++){
        ans+=b[a[i]-1];
        if(i+1!=n&&a[i]+1==a[i+1])
            ans+=c[a[i]-1];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define vvl vector<vector<ll>>
#define vl  vector<ll>
#define vs  vector<string>
#define rep(i,sta,end) for(ll i=sta;i<end;i++)
//lcm:最小公倍数、gcd:最大公約数
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back 
typedef long long ll;
const ll MOD = 1000000007;
const double PI = acos(-1);  
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||
//map<int,int>mp

//ll n;
//string s;
signed main(){
	acc_io;
	//ll n;
	vs s(3);
	rep(i,0,3) cin>>s[i];
	vector<queue<char>>p(3);
	rep(i,0,3){
		rep(j,0,s[i].size()) p[i].push(s[i][j]);
	}
	char next;
	next=p[0].front();
	p[0].pop();
	while(1){
		int idx=next-'a';
		if(p[idx].empty()){
			cout<<char('A'+idx)<<endl;
			return 0;
		}
		next=p[idx].front();
		p[idx].pop();
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		System.out.printf("%d:%d:%d\n", S / 3600, S % 3600 / 60, S % 3600 % 60);
	}
}



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

using namespace std;

int main(void)
{
    string s;
    cin >> s;
    int cnt=0;
    int n = s.length();
    for (int i = 0; i < n;i++){
        if(i%2==0){
            if(s.at(i)=='0')
                cnt++;
        }
        else{
            if (s.at(i) == '1')
                cnt++;
        }
    }
        cout << min(cnt, n - cnt) << endl;

        return 0;
}

Measured memory_bytes: 512
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
#include <math.h>
#include <vector>
//#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    int n;
    vector<LL> x;
    vector<LL> y;
    vector<LL> h;
    LL tmp_x;
    LL tmp_y;
    LL tmp_h;
    LL ans_x;
    LL ans_y;
    LL ans_h;
    LL tmp_ans_h;
    cin >> n;

    for(int i=0; i<n; i++){
        cin >> tmp_x >> tmp_y >> tmp_h;
        x.push_back(tmp_x);
        y.push_back(tmp_y);
        h.push_back(tmp_h);
    }

    bool cand;
    for(LL i=0; i<=100; i++){
        for(LL j=0; j<=100; j++){
            cand=true;
            int start=0;
            while(true){
                if(h[start]!=0){
                    tmp_ans_h=h[start]+(int)abs(i-x[start])+(int)abs(j-y[start]);
                    break;
                }
                start++;
            }
            for(int k=0; k<n; k++){
                if(h[k]==0 && tmp_ans_h<(int)abs(i-x[k])+(int)abs(j-y[k])){
                    continue;
                }else if(tmp_ans_h!=h[k]+(int)abs(i-x[k])+(int)abs(j-y[k])){
                    cand=false;
                    break;
                }
            }
            if(cand==true){
                ans_x=i;
                ans_y=j;
                ans_h=tmp_ans_h;
                break;
            }
        }
        if(cand==true){
            break;
        }
    }

    cout << ans_x << " " << ans_y << " " << ans_h << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }



void solve(long long N, std::vector<long long> v){
	ASC(v);
	double res = v[0];
	REP(i, N-1) {
		res = (res+v[i+1])/2.0;
	}
	cout << res << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> v(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&v[i]);
    }
    solve(N, std::move(v));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <math.h>
#include <map>
#include <set>
#include <cstdlib>
#define INF 100000000
#define INFLL (long long)1e14
#define Loops(i, n) for(int i = 0; i < (int)n; i++)
#define Loops1(i, n) for(int i = 1; i <= (int)n; i++)
int counter[1001];
int gousei(int x);
int N;
int main(void){
	Loops(i,1001){
		counter[i]=0;
	}
	std::cin>>N;
	for(int i=2;i<=N;i++){
	//	counter[i]=N/i;
		int temp=i;
		for(int j=1;j<100;j++){
			temp=pow(i,j);
			if(temp>N){
				break;
			}
			counter[i]+=int(N/temp);
		}
	}
/*	for(int i=2;i<=N;i++){
		int temp=i;
		for(int j=2;j<=N;j++){
			if(i!=j){
				if(temp==1){
					counter[i]=0;
					break;
				}
				if(temp%j==0){
					temp/=j;
					counter[j]+=counter[i];
					j--;
				}
			}
		}
		for(int k=2;k<6;k++){
			std::cout<<counter[k]<<std::endl;
		}
		std::cout<<std::endl;
	}*/
	long long int ans=1;
/*	for(int i=0;i<101;i++){
		std::cout<<counter[i]<<std::endl;
	}*/
	long long int a=1000000007;
	for(int i=2;i<1001;i++){
		if(counter[i]!=0 && gousei(i)){
			ans*=(counter[i]+1);
			ans%=a;
		}
	}
	std::cout<<ans<<std::endl;
	return 0;
}
int gousei(int x){
	for(int i=2;i<x;i++){
		if(x%i==0){
			return 0;
		}
	}
	return 1;
}

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

template <unsigned mod>
struct RollingHash {
  vector<unsigned> hashed;
  vector<unsigned> power;
  RollingHash(const string &s, unsigned base = 10007) {
    int n = (int) s.size();
    hashed.assign(n + 1, 0);
    power.assign(n + 1, 0);
    power[0] = 1;
    for (int i = 0; i < n; i++) {
      power[i + 1] = (long long) power[i] * base % mod;
      hashed[i + 1] = ((long long) hashed[i] * base + s[i]) % mod;
    }
  }
  unsigned get(int l, int r) const {
    unsigned ret = hashed[r] + mod - ((long long) hashed[l] * power[r - l]) % mod;
    if (ret >= mod) ret -= mod;
    return ret;
  }
};

using RH = RollingHash<1000000007>;

struct UnionFind {
  vector<int> par;
  vector<int> siz;
  UnionFind(int n) {
    par = vector<int>(n);
    siz = vector<int>(n, 1);
    iota(par.begin(), par.end(), 0);
  }
  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    par[x] = y;
    siz[y] += siz[x];
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return siz[root(x)];
  }
};

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size();
  string ss = s;
  while (ss.size() < t.size()) {
    ss += s;
  }
  ss += ss;
  RH sh(ss), th(t);
  auto uf = UnionFind(n);
  for (int i = 0; i < n; i++) {
    if (sh.get(i, i + t.size()) == th.get(0, t.size())) {
      int x = i % n;
      int y = (i + t.size()) % n;
      if (uf.same(x, y)) {
        cout << -1 << endl;
        return 0;
      }
      uf.unite(x, y);
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, uf.size(i) - 1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 31412
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int a, b;
    cin >> a >> b;
    cout << max( a + b, max( a - b, a * b ) ) << endl;

    return 0;
}



Measured memory_bytes: 256
nums = input().split()

if (nums[0].isdigit()==True) and (nums[1].isdigit()==True):
    a=int(nums[0])
    b=int(nums[1]) 
    if (1<=a) and (a<=9) and (1<=b) and (b<=9) :
        if a<=b:
            n_min=a
            n_max=b
        else:
            n_min=b
            n_max=a
        l=str(n_min)*n_max
        print(l)  

Measured memory_bytes: 3064
import itertools

n = int(input())
lst = []
for _ in range(n):
  lst.append(list(map(int, input().split())))
#print(lst)

cases = list(itertools.permutations(list(range(n))))
#print(cases)
length = 0
for case in cases:
  for i in range(n - 1):
    pos_1 = case[i]
    pos_2 = case[i + 1]
    position_1 = lst[pos_1]
    position_2 = lst[pos_2]
    #print(position_1)
    length += ((position_1[0] - position_2[0]) ** 2 + (position_1[1] - position_2[1]) ** 2) ** 0.5
length = length / len(cases)
print(length)

Measured memory_bytes: 13864
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<climits>
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
template<class T> void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }
using namespace std;

int main(void) {
	int n;
	cin >> n;
	
	vector<vector<int> > A(2, vector<int>(n));
	rep(i,n) cin >> A[0][i];
	rep(i, n) cin >> A[1][i];

	int max = 0;
	for (int i = 0; i < n; i++) {
		int tmp = 0;
		int position = 0;

		for (int j = 0; j <= i; j++) {
			tmp += A[0][j];
			position = j;
		}

		for (int k = position; k < n; k++) {
			tmp += A[1][k];
		}

		if (max < tmp) {
			max = tmp;
		}
	}

	cout << max << endl;
} 

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
 
static class Program
{
    static void Main(string[] args)
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        //入力
        long n = long.Parse(Console.ReadLine());
        var dictionary = new Dictionary<string, int>();
        for(var i = 0; i < n; i++){
          var str = Console.ReadLine();
          if(dictionary.ContainsKey(str)){
            dictionary[str]++;
          }else{
            dictionary.Add(str, 1);
          }
        }
        var max = dictionary.Values.Max();

        var list3 = dictionary.Where(v => v.Value == max).Select(e => e.Key).ToList();
        list3.Sort(StringComparer.Ordinal);
      
        foreach(var s in list3){
          Console.WriteLine(s);
        }
        Console.Out.Flush();
    }
}

Measured memory_bytes: 39280
n = int(input())
a = [int(i) for i in input().split(" ")]

a.sort()
dp = [True for i in range(a[-1]+1)]
count=0

for i in range(n):
    if dp[a[i]]:
        count+=1
        for j in range(1,n-i):
            if a[i]!=a[i+j]:
                break
            elif j==1:
                count-=1
            dp[a[i+j]]=False
        for j in range(a[i], a[-1]+1, a[i]):
            dp[j]=False
        # for j in range(i + 1, n):
        #     if not a[j] % a[i]:
        #         dp[j] = False
        #     if a[j] == a[i]:
        #         dp[i] = False

#print(dp.count(True))
print(count)

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

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

   if (a<b)
   {
       cout << "a < b" <<endl;
   }else if(a>b){
       cout << "a > b" << endl;
   }else if(a==b){
       cout << "a == b" <<endl;
   }
return 0;
}   


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

int main(){
    int n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;
    map<char,int> score;
    score['r'] = p;
    score['s'] = r;
    score['p'] = s;
    vector<bool> win(n, false);
    int ans = 0;
    rep(i,n){
        if(i < k){
            ans += score[t[i]];
            win[i] = true;
        }
        else{
            if(t[i-k] == t[i]){
                if(win[i-k]) win[i] = false;
                else{
                    win[i] = true;
                    ans += score[t[i]];
                }
            }
            else{
                ans += score[t[i]];
                win[i] = true;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3764
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<limits>
#include<algorithm>
#include<numeric>
#include<utility>
#include<iomanip>

using ULLI = unsigned long long int;
using LLI = long long int;

using namespace std;

template<class T>
class ModCal{
private:
    const ULLI MAX = 1000000;
    ULLI mod;

    std::vector<T> fac;
    std::vector<T> finv;
    std::vector<T> inv;

    void COMinit() {
        fac.resize(MAX);
        finv.resize(MAX);
        inv.resize(MAX);

        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++){
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod%i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
public:
    ModCal(ULLI _mod){
        this->mod = _mod;
        ModCal<T>::COMinit();
    }
    ModCal(){
        this->mod = 0;
    }

    T add(T a, T b){
        T tmp;
        tmp = a + b;
        if(mod != 0) tmp %= mod;
        return tmp;
    }

    T sub(T a, T b){
        T tmp;
        tmp = a - b;
        if(mod != 0){
            if(tmp < 0) tmp += mod;
            tmp %= mod;
        }
        return tmp;
    }

    T mul(T a, T b){
        T tmp;
        tmp = a * b;
        if(mod != 0) tmp %= mod;
        return tmp;
    }

    T modinv(T a, T m){
        T b = m, u = 1, v = 0;
        while (b) {
            T t = a / b;
            a -= t * b; std::swap(a, b);
            u -= t * v; std::swap(u, v);
        }
        u %= m;
        if (u < 0) u += m;
        return u;
    }

    T div(T a, T b){
        if(mod == 0){
            return a / b;
        }
        a %= mod;
        T tmp = a * ModCal<T>::modinv(b, mod) % mod;
        return tmp;
    }

    T pow(T a, T b){
        T tmp = 1;
        while(b > 0){
            if(mod != 0){
                if(b & 1) tmp = tmp * a % mod;
                a = a * a % mod;
            }else{
                if(b & 1) tmp *= a;
                a *= a;
            }
            b >>= 1;
        }
        return tmp;
    }

    // 以下の関数はMODを設定しない限り使えない
    // 無理やり使う場合は "ModCal<T> cal(Tの最大値)" でオブジェクトを作る
    T com(T n, T k){
        if(n < k) return 0;
        if(n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
    }

    T fact(T n){
        return fac[n];
    }
};

struct S{
    int A;
    int B;
    double v;

    S(int A, int B){
        this->A = A;
        this->B = B;
    }

    bool operator<(const S &l) const{
        return static_cast<double>(B)/A < static_cast<double>(l.B)/l.A;
    };
};

struct P{
    int x;
    int y;

    P(int x, int y){
        this->x = x;
        this->y = y;
    }
};

int main() {
    int N;
    string S;
    int cnt=0;

    cin >> N >> S;

    for(int i=0;i<N;i++){
        if(S[i]=='A'){
            if(i+1<N && S[i+1]=='B'){
                if(i+2<N && S[i+2]=='C'){
                    cnt++;
                }
            }
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#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-1);i>=(b);i--)
#define all(x) (x).begin(), (x).end()
const int INF = 1e18;
const int MOD = 1e9+7;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef string str;
typedef vector<str> vstr;
void print() {cout<<endl;}template<class Head,class...Tail>void print(Head&&head,Tail&&...tail){cout<<head;if(sizeof...(tail)!=0)cout<<" ";print(forward<Tail>(tail)...);}template<class T>void print(vector<T>&vec){for(auto&a:vec){cout<<a;if(&a!=&vec.back())cout<<" ";}cout<<endl;}template<class T>void print(vector<vector<T>>&df){for(auto&vec:df){print(vec);}}
template<class T=int>T in() {T x;cin>>x;return(x);}
template<class T=int>vector<T> input_to_vector(int n) {vector<T>x;rep(i,n){T a;cin>>a;x.push_back(a);}return(x);}

signed main(){
    int s = in();
    map<int, int> mp;
    int i = 1;
    while(true){
        if (mp.count(s) == 0) {
            mp[s] = 1;
        } else {
            break;
        }
        if(s % 2 == 0){
            s = s / 2;
        } else {
            s = 3 * s + 1;
        }
        i++;
    }
    print(i);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    sort(A.begin(), A.end());

    vector<int> x(100000);
    vector<int> y(100000);
    int Ct = 0; int plus = A.at(N-1); int minus = A.at(0);
    for(int i = 1; i < N-1; i++) {
        if(A.at(i) < 0) {
            x.at(Ct) = plus;
            y.at(Ct) = A.at(i);
            plus -= y.at(Ct);
            Ct++;
        }else {
            x.at(Ct) = minus;
            y.at(Ct) = A.at(i);
            minus -= y.at(Ct);
            Ct++;
        }
    }
    x.at(Ct) = plus;
    y.at(Ct) = minus;
    
    cout << plus - minus << endl;
    for(int i = 0; i <= Ct; i++) {
        cout << x.at(i) << " " << y.at(i) << endl;
    }
}

Measured memory_bytes: 3072
from collections import deque
N,Q = map(int,input().split())
edge = [[]for i in range(N)]
for i in range(N-1):
    a,b = map(int,input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
tree = [0]*N
for i in range(Q):
    p,x = map(int,input().split())
    tree[p-1] += x
flag = [0]*N
flag[0] = 1
queue = deque([0])
while queue != deque([]):
    p = queue.popleft()
    for i in edge[p]:
        if flag[i] == 0:
            flag[i] = 1
            tree[i] += tree[p]
            queue.append(i)

for i in tree:
    print(i,end=" ")

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

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

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, K;
  cin >> N >> K;

  vector<int> p(N);
  REP(i, N) cin >> p[i];

  double ans = 0;
  double now = 0;
  for ( int i = 0; i < K; i++ ) {
    now += (double)(1.0 + p[i]) / 2.0;    
  }

  ans = now;

  for ( int i = K; i < N; i++ ) {
    now -= (double)(1.0 + p[i-K]) / 2.0;
    now += (double)(1.0 + p[i]) / 2.0;
    ans = max(ans, now);    
  }

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


Measured memory_bytes: 1792
n,k,*a=map(int,open(0).read().split())
v=[0]+[-1]*n
p=0
for i in range(n):
  t=a[p]-1
  if v[t]>=0: l,r=v[t],i+1; break
  v[t]=i+1; p=t
print(v.index(min(k,l+(k-l)%(r-l)))+1)

Measured memory_bytes: 31728
n, m, x, y = map(int, input().split())
z = x

for i in list(map(int, input().split())):
    z = max(z, i)
z += 1

if z > y:
    print("War")
else:
    for i in list(map(int, input().split())):
        if z > i:
            print("War")
            break
    else:
        print("No War")
        

Measured memory_bytes: 3060