akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
INF = float("inf")


B = 10**7+7
MOD = 10**9+7

# https://tjkendev.github.io/procon-library/python/string/rolling_hash.html


class RollingHash():
    def __init__(self, s, base, mod):
        self.mod = mod
        self.pw = pw = [1]*(len(s)+1)

        l = len(s)
        self.h = h = [0]*(l+1)

        v = 0
        for i in range(l):
            h[i+1] = v = (v * base + s[i]) % mod
        v = 1
        for i in range(l):
            pw[i+1] = v = v * base % mod

    def get(self, l, r):
        return (self.h[r] - self.h[l] * self.pw[r-l]) % self.mod


def z_algorithm(S):
    """Zアルゴリズム
    https://snuke.hatenablog.com/entry/2014/12/03/214243 の二番目のコード
    """
    N = len(S)
    Z = [0]*N

    c = 0
    for i in range(1, N):
        if i+Z[i-c] < c+Z[c]:
            Z[i] = Z[i-c]
        else:
            j = max(0, c+Z[c]-i)
            while i+j < N and S[j] == S[i+j]:
                j += 1
            Z[i] = j
            c = i
    Z[0] = len(S)
    return Z


def zfindall(text, pattern, separator="$"):
    """テキストからパターンと一致する部分文字列を探す。
    開始インデックスを返す
    Zアルゴリズムを利用する
    """
    N = len(pattern)
    conc = pattern+separator+text
    Z = z_algorithm(conc)
    return {i-N-1 for i in range(len(conc)) if Z[i] == N}


def solve(N: int, a: "List[int]", b: "List[int]"):

    c = [a[i] ^ a[(i+1) % N]for i in range(N)]
    d = [b[i] ^ b[(i+1) % N]for i in range(N)]*2
    i = -1
    a1 = [0]*N
    a2 = [0]*N
    b1 = [0]*(2*N)
    k_cand = [True]*N
    for keta in range(30):
        mask = 1 << keta
        for i, aa in enumerate(a):
            a1[i] = (aa & mask) >> keta
            a2[i] = (~aa & mask) >> keta
        for i, bb in enumerate(b):
            b1[i] = (bb & mask) >> keta
            b1[i+N] = (bb & mask) >> keta
        P = RollingHash(a1, 97, MOD)
        Q = RollingHash(a2, 97, MOD)
        R = RollingHash(b1, 97, MOD)
        for i in range(N):
            if k_cand[i]:
                if not ((P.get(0, N) == R.get(i, i+N)) or
                        (Q.get(0, N) == R.get(i, i+N))):
                    k_cand[i] = False
        # k_cand1 = zfindall(b1, a1, separator=[-1])
        # k_cand2 = zfindall(b1, a2, separator=[-1])
        # for i in range(N):
        #     k_cand[i] = k_cand[i] & ((i in k_cand1) or (i in k_cand2))

    ans = []
    if len(k_cand) == 0:
        return
    if k_cand[0] == True:
        print(0, b[0] ^ a[0])
        for i, k in enumerate(k_cand[:0:-1], start=1):
            if k:
                print(i, b[0] ^ a[i])
    else:
        for i, k in enumerate(k_cand[::-1], start=1):
            if k:
                print(i, b[0] ^ a[i])
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N - 1 - 0 + 1)]  # type: "List[int]"
    b = [int(next(tokens)) for _ in range(N - 1 - 0 + 1)]  # type: "List[int]"
    solve(N, a, b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 148564
fn main() {
    let mut sc = Scanner::new();
    let s: Vec<char> = sc.read::<String>().chars().collect();
    let mut count = vec![0; 26];
    for &c in &s {
        let t = (c as u8) - ('a' as u8);
        count[t as usize] += 1;
    }

    let n = s.len();
    let mut ans = n * (n - 1) / 2;
    for &c in &count {
        if c == 0 {
            continue;
        }
        ans -= c * (c - 1) / 2;
    }
    println!("{}", ans + 1);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


Measured memory_bytes: 4352
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>

using namespace std;

template<typename T>
T absi(T x) {
    if (x < static_cast<T>(0)) {
        x *= static_cast<T>(-1);
    }
    return x;
}

int main()
{
    int64_t N, T;
    std::cin >> N >> T;

    std::vector<int64_t> A;
    for (size_t i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        A.push_back(t);
    }

    std::vector<int64_t> costs;
    int64_t min = INT64_MAX;
    for (int64_t i = 0; i < N; ++i) {
        if (min < A[i]) {
            costs.push_back(A[i] - min);
        }
        min = std::min(min, A[i]);
    }
    #if 0
    for (int64_t i = 0; i < N-1; ++i) {
        for (int64_t j = i+1; j < N; ++j) {
            if (A[i] < A[j]) {
                costs.push_back(A[j] - A[i]);
            }
        }
    }
    #endif

    std::sort(std::begin(costs), std::end(costs),
              [](const auto& a, const auto& b) {
                  return a > b;
              });

    size_t count = 0;
    for (auto&& c: costs) {
        if (c != costs[0]) {
            break;
        }
        count++;
    }

    std::cout << count << std::endl;

    return 0;
}


Measured memory_bytes: 2548
import bisect
N = int(input())

seisu = []

for i in range(10):
    for j in range(i,10):
        seisu.append(i*j)

#含まれるかどうかだけなら 以下の文で判定可能

if N in seisu:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,string> tp;
//typedef vector<tp> vt;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
//http://tsutaj.hatenablog.com/entry/2017/03/30/224339
typedef ll SegT;
const SegT defvalue=0;
struct LSTree{
public:
	int n;
	vector<SegT>node,lazy;
	SegT combine(SegT a,SegT b){return a+b;}
	LSTree(const vector<SegT> &v) {
		n=1;
		while(n<v.size())n<<=1;
		node=vector<SegT>(2*n,defvalue);
		lazy=vector<SegT>(2*n,defvalue);
		for(int i=n-1+v.size()-1;i>=0;i--){
			if(n-1<=i)node[i]=v[i-(n-1)];
			else node[i]=combine(node[i*2+1],node[i*2+2]);
		}
	}
	void eval(int k,int l,int r) {
		if(lazy[k]!= 0){
			node[k]+=lazy[k];
			if(r-l>1) {
				lazy[2*k+1]+=lazy[k]/2;
				lazy[2*k+2]+=lazy[k]/2;
			}
			lazy[k]=0;
		}
	}
	void update(int a,int b,SegT x,int k=0,int l=0,int r=-1){
		if(r<0)r=n;
		eval(k,l,r);
		if(b<=l||r<=a)return;
		if(a<=l&&r<=b){
			lazy[k]+=(r-l)*x;
			eval(k,l,r);
		}else{
			update(a,b,x,2*k+1,l,(l+r)/2);
			update(a,b,x,2*k+2,(l+r)/2,r);
			node[k]=combine(node[2*k+1],node[2*k+2]);
		}
	}
	SegT query(int a,int b,int k=0,int l=0,int r=-1){
		if(r<0)r=n;
		eval(k,l,r);
		if(b<=l||r<=a)return 0;
		if(a<=l&&r<=b)return node[k];
		else return combine(query(a,b,2*k+1,l,(l+r)/2),query(a,b,2*k+2,(l+r)/2,r));
	}
	void tmp(){
		rep(i,node.size())cout<<" "<<node[i];cout<<endl;
		rep(i,node.size())cout<<" "<<lazy[i];cout<<endl;
		cout<<endl;
	}
};
int main() {
	int n,q;
	cin>>n>>q;
    LSTree st(vector<ll>(n,0));
	while(q--){
		int a,s,t,x;
		cin>>a>>s>>t;
		if(!a)cin>>x;
		if(!a)st.update(s-1,t,x);
		else cout<<st.query(s-1,t)<<endl;
	}
}

Measured memory_bytes: 9804
#include <iostream>
#include <cstdlib> 
using namespace std;
int main(){
	int n, count = 0;
	cin >> n;
	int A[n];
	for(int i = 0; i < n; i++) cin >> A[i];
	for(int i = 0; i < n; i++){
		int min = i;
		for(int j = i; j < n; j++) if(A[j] < A[min]) min = j;
		int tmp = A[min];
		A[min] = A[i];
		A[i] = tmp;
		if(min != i) count ++;
	}
	for(int i = 0; i < n; i++){
		cout << A[i];
		if(i != n - 1) cout << ' ';
	}
	cout << '\n' << count << endl;
}



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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

ll N;
vector<ll> a;
ll dp[3001][3001];

ll rec(int l, int r){
    if(dp[l][r] != -1) return dp[l][r];
    if(r-l == 1 && N%2 == 1) return dp[l][r] = a[l];
    else if(r-l == 1 && N%2 == 0) return dp[l][r] = -a[l];

    ll res = 0;
    if((r-l)%2 == N%2){
        res = max(rec(l+1,r)+a[l], rec(l,r-1)+a[r-1]);
    }
    else{
        res = min(rec(l+1,r)-a[l], rec(l,r-1)-a[r-1]);
    }
    return dp[l][r] = res;
}

int main(void){
    cin >> N;
    a.resize(N); REP(i,N) cin >> a[i];
    REP(i,N+1)REP(j,N+1) dp[i][j] = -1;
    ll ans = rec(0,N);
    cout << ans << en;
    return 0;
}

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

class Program
{
    void Run()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int m = sc.NextInt();
        int[] a = new int[n];
        var da = new SortedDictionary<long, long>();
        for (int i = 0; i < n; i++)
        {
            a[i] = sc.NextInt();
            if (!da.ContainsKey(a[i])) da.Add(a[i], 0);
            da[a[i]]++;
        }
        var db = new SortedDictionary<long, long>();
        for (int i = 0; i < m; i++)
        {
            long b = sc.NextInt();
            long c = sc.NextInt();
            if (!db.ContainsKey(c)) db.Add(c, 0);
            db[c] += b;
        }
        long sum = 0;
        foreach (var kb in db.Keys.Reverse())
        {
            if (da.Keys.Count == 0) break;
            long k = da.Keys.First();
            long count = 0;
            while (k < kb && count < db[kb])
            {
                long cc = Math.Min(db[kb] - count, da[k]);
                sum += cc * kb;
                count += cc;
                da[k] -= cc;
                if (da[k] == 0) da.Remove(k);
                if (da.Keys.Count == 0) break;
                k = da.Keys.First();
            }
        }
        foreach (long k in da.Keys)
        {
            sum += k * da[k];
        }

        Console.WriteLine(sum);
    }

    static void Main(string[] args)
    {
        new Program().Run();
    }

    static long Gcd(long a, long b)

    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 34520
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, i, q=1, j, Max=0;
    string x;
    cin >> n;
    string a[n];
    vector< pair<string, int> >v;
    for(i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a, a+n);
    for(i=0; i<n;){
        j = i + 1;
        while(a[i]==a[j])q++, j++;
        v.push_back(make_pair(a[i], q));
        if(q>Max)Max=q;
        i=j, q=1;
    }
    sort(v.begin(), v.end());
    for(i=0; i<v.size(); i++)
        if(v[i].second==Max)cout<<v[i].first<<endl;

    return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define PB push_back

using namespace std;
typedef long long ll;

const long long max_n = 1000011, inf = 1000111222;

char s[max_n], cc[] = {'D', 'M', 'C'};
int n, k, m;
long long curr[2][2];

void add(char c) {
	if (c == cc[1]) {
		curr[0][1] += curr[0][0];
		++curr[1][1];
	}
	if (c == cc[0]) {
		++curr[0][0];
	}
}

void rem(char c) {
	if (c == cc[0]) {
		curr[0][1] -= curr[1][1];
		--curr[0][0];
	}
	if (c == cc[1]) {
		--curr[1][1];
	}
}

string write() {
	stringstream iss;
	iss << "(" << curr[0][0] << "," << curr[0][1] << "," << curr[1][1] << ")";
	string s;
	iss >> s;
	return s;
}

long long get_ans(int k) {
	memset(curr, 0, sizeof(curr));
	ll ans = 0;
	for (int i = 0; i < min(n, k); ++i) {
		add(s[i]);
		if (s[i] == cc[2]) {
			ans += curr[0][1];
		}
		// if (s[i] == 'D' || s[i] == 'M' || s[i] == 'C')
		// 	cout << i << " " << write() << " " << s[i] << endl;
	}
	for (int i = k; i < n; ++i) {
		add(s[i]);
		rem(s[i - k]);
		if (s[i] == cc[2]) {
			ans += curr[0][1];
		}
		// if (s[i] == 'D' || s[i] == 'M' || s[i] == 'C' ||
		// 	s[i - k] == 'D' || s[i - k] == 'M')
		// 	cout << i << " " << write() << " " << s[i] << endl;
	}
	return ans;
}

int main() {
	cin >> n;
	scanf("%s", s);
	cin >> m;
	for (int i = 0; i < m; ++i) {
		cin >> k;
		cout << get_ans(k) << endl;
	}
	return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>

int main(){
    int n,a;
    scanf("%d",&n);
    int p[20];
    for (int i = 0; i < n; i++){
        scanf("%d",&p[i]);
    }
    for (int i = 1; i < n - 1; i++){
        if(p[i-1]<p[i]&&p[i]<p[i+1]||p[i-1]>p[i]&&p[i]>p[i+1]){
            a++;
        }
    }
    printf("%d",a);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

std::pair<bool, long long int> do_m(const std::vector<long long int>& happiness, const std::vector<long long int>& sum, const int min, const long long int m) {
	long long int count = 0, count_just = 0;
	long long int sum_upper = 0;
	for (const auto a : happiness) {
		auto lower = std::lower_bound(happiness.begin(), happiness.end(), min - a);
		auto upper = std::upper_bound(happiness.begin(), happiness.end(), min - a);
		count_just += std::distance(lower, upper);
		count += std::distance(upper, happiness.end());
		sum_upper += (sum.back() - sum[std::distance(happiness.begin(), upper)]) + std::distance(upper, happiness.end()) * a;
	}
	return std::make_pair((count + count_just) >= m, sum_upper + (m - count + 0LL) * min);
}
int main() {
	int n; long long int m; std::cin >> n >> m;
	std::vector<long long int> happiness(n), sum{ 0LL }; for (auto& a : happiness) std::cin >> a;
	std::sort(happiness.begin(), happiness.end());
	for (auto a : happiness) sum.push_back(sum.back() + a);
	long long int min = 0;
	long long int max = happiness.back() * 2 + 1;
	while (min < max) {
		const auto mid = (min + max) / 2;
		auto pair = do_m(happiness, sum, mid, m);
		if (pair.first) {
			min = mid + 1;
		}
		else {
			max = mid;
		}
	}
	auto pair = do_m(happiness, sum, max - 1, m);
	std::cout << pair.second << std::endl;
}

Measured memory_bytes: 2168
#include<stdio.h>
int main(){
  char a;
  int c[26];
  for (int i=0 ; i<26 ; i++) {
    c[i]=0;
  }

  while (scanf("%c",&a)!=EOF) {

    if (a>='A'&&a<='Z')
      a+=32;

    if (a >= 'a' && a <= 'z') {
      int num = a - 'a';
      c[num]++;
    }
  }
  for(int i = 0 ; i<26 ; i++) {
    printf("%c : %d\n",i+'a',c[i]);
  }
  return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
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;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if(A * C < B) {
    cout << C << endl;
  } else {
    cout << B / A << endl;
  }
  return 0;
}

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


int main(){

string s;
cin >> s;
int count = 0;
for (int i = 0; i < s.size(); i++)
{
    if(s.at(i) == '1'){
        count++;
    }
}
cout << count << endl;


}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  long long x,d,k;
  cin>>x>>k>>d;
  
  if(x<0)
    x*=-1;
  
  //x%d-d
  if( (x-x%d)/d+1 <= k ){
    
    if((k-((x-x%d)/d+1))%2==0){
      cout<<-1*(x%d-d)<<endl;
      return 0;
    }
    
    else{
      cout<<x%d<<endl;
      return 0;
    }
    
  }
  
  else{
    cout<<x-(k*d)<<endl;
  }
}

Measured memory_bytes: 3604
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var strings = new string[3];
            for(var i = 0; i < 3; i++)
            {
                strings[i] = Console.ReadLine();
            }
            var count = 0;
            for(var i = 0; i < n; i++)
            {
                if (strings[0][i] != strings[1][i]
                    && strings[0][i] != strings[2][i]
                    && strings[2][i] != strings[1][i])
                {
                    count += 2;
                }else if(strings[0][i] != strings[1][i]
                    || strings[0][i] != strings[2][i]
                    || strings[2][i] != strings[1][i])
                {
                    count++;
                }
            }
            Console.WriteLine(count);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13140
#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, m;
	cin >> n >> m;
	vector<vector<int>> g(n, vector<int>(0));
	vector<vector<int>> gr(n, vector<int>(0));
	vector<int> in(n);
	vector<int> ans(n);
	rep(i, n-1+m){
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		gr[b].push_back(a);
		in[b]++;
	}
	int o = 0;
	rep(i, n) if(in[i] == 0) o = i;
	queue<int> q;
	q.push(o);
	ans[o] = 0;
	int cou = 0;
	while(!q.empty()){
		int x = q.front();
		rep(i, g[x].size()){
			int xn = g[x][i];
			in[xn]--;
			if(in[xn] == 0){
				q.push(xn);
				cou++;
				ans[xn] = cou;
			}
		}
		q.pop();
	}
	rep(i, n){
		int ma = -1;
		int oy = 0;
		rep(j, gr[i].size()) if(ma < ans[gr[i][j]]){ ma = ans[gr[i][j]]; oy = gr[i][j];}
		if(ma != -1){
			cout << oy+1 << endl;
		}else{
			cout << 0 << endl;
		}
	}
	return 0;
}

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

static int M=100;

int main(){
  int i,j,r,k,n,h[M+1],o[M+1][M+1];
  scanf("%d",&n);
  for(i=1;i<n+1;i++){
    scanf("%d",&h[i-1]);
    scanf("%d",&h[i]);
  }

  i=1;
  while(i<=n){
    o[i][i]=0;
    i++;
  }
  for(r=2;r<=n;r++){
    for(i=1;i<=n-r+1;i++){
      j=i+r-1;
      o[i][j]=1<<21;
      for(k=i;k<=j-1;k++){
	o[i][j]=fmin(o[i][j],o[i][k]+o[k+1][j]+h[i-1]*h[k]*h[j]);
      }
    }
  }

  printf("%d",o[1][n]);
  printf("\n");
  return 0;
}



Measured memory_bytes: 2112
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

int i, j, n, tab[200005];
LL res;

int main() {
scanf("%d", &n);
for (i=0;i<n;i++) scanf("%d", &tab[i]);
for (i=1;i<n;i++) if (tab[i] > tab[i - 1] + 1) {
	printf("-1\n");
	return 0;
}
if (tab[0] > 0) {
	printf("-1\n");
	return 0;
}
res = 0;
i = n - 1;
while (i > 0) {
	j = i;
	while (j - 1 >= 0 && tab[j-1] == tab[j] - 1) j--;
	res += tab[i];
	i = j - 1;
}
printf("%lld\n", res);
return 0;
}



Measured memory_bytes: 1152
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define mp make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1<<60)
#define MOD 1000000007
#define rep(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(a, max(b, c)) * 9 + a + b + c;
    return 0;
}


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

class Doubling:
    def __init__(self, A, K_max, decrement=True):
        """
        :param A: リスト。i から A[i] へと移動する
        :param K_max: K_max = 2**(k_max) まで参照する可能性がある
        :param decrement: True = A の要素の decrement が必要
        """
        N = len(A)
        k_max = K_max.bit_length()
        self.N = N
        self.doubling = [[None] * N for _ in range(k_max + 1)]
        self.decrement = decrement
        for i, a in enumerate(A):
            self.doubling[0][i] = a - self.decrement

        for i in range(1, k_max):
            for j in range(N):
                if self.doubling[i - 1][j] is None:
                    self.doubling[i][j] = None
                else:
                    self.doubling[i][j] = self.doubling[i - 1][self.doubling[i - 1][j]]

    def apply(self, start, K):
        """
        :param start: スタート地点
        :param K: K回進む
        :return:
        """
        i = start - self.decrement
        for k in range(K.bit_length()):
            m = 1 << k
            if m & K:
                i = self.doubling[k][i]
            if i is None:
                break
        return i + self.decrement


######################################################################################


N, K = map(int, input().split())
A = list(map(int, input().split()))
doubling = Doubling(A, 10**18 + 1, decrement=True)
print(doubling.apply(1, K))

Measured memory_bytes: 184652
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define M 998244353
#define fi first
#define se second
#define endl '\n'
#define INF 1e18
#define PI 3.14159265358979323846
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);

   freopen("output.txt", "w", stdout);
    #endif

    ll n,i,j;
    cin>>n;
    if(n>=30)
    {
        cout<<"Yes";
    }
    else 
    {
        cout<<"No";
    }
}

Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int n;
    cin >> n;
    vi a(3), b(3);
    cin >> a[0] >> a[1] >> a[2] >> b[0] >> b[1] >> b[2];
    vi costs;
    vi values;
    for (int i = 0; i < 3; ++i) {
        if (b[i] - a[i] > 0) {
            costs.push_back(a[i]);
            values.push_back(b[i] - a[i]);
        }
    }
    vl dp(n + 1, 0);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < costs.size(); ++j) {
            if (i + costs[j] <= n) {
                chmax(dp[i + costs[j]], dp[i] + values[j]);
            }
        }
    }
    n += dp[n];
    costs.clear();
    values.clear();
    for (int i = 0; i < 3; ++i) {
        if (a[i] - b[i] > 0) {
            costs.push_back(b[i]);
            values.push_back(a[i] - b[i]);
        }
    }
    dp.clear();
    dp.resize(n + 1, 0);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < costs.size(); ++j) {
            if (i + costs[j] <= n) {
                chmax(dp[i + costs[j]], dp[i] + values[j]);
            }
        }
    }
    cout << n + dp[n] << "\n";
    return 0;
}

Measured memory_bytes: 195584
#include<stdio.h>
int main(void){
  int y,x;

  while(1){
    scanf("%d %d",&x,&y);
    if(x==0 && y==0){
      break;
    }else if(x<y){
      printf("%d %d\n",x,y);
    }else{
      printf("%d %d\n",y,x);
    }
  }
}



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

public class Main {

    static Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws Exception {

        String str = sc.next();
        String t = sc.next();

        if(str.equals(t))
            out.println("0");
        else {

            List<Character> hash1 = new ArrayList<>();
            //Set<Character> hash2 = new HashSet<>();

            for(int i = 0;i < str.length(); ++i){

                if(str.charAt(i) != t.charAt(i))
                    hash1.add(str.charAt(i));

            }


            out.println(hash1.size());
        }

        out.flush();
        out.close();
        sc.close();
    }

    static final int MOD = (int) 1e9 + 7;
    static final double PI = 3.14159265358979323846;

    // takes array input
    public static int[] init(int n) {

        int[] arr = new int[n];

        for (int i = 0; i < n; ++i)
            arr[i] = sc.nextInt();

        return arr;
    }

    // finds GCD of two number
    public static int gcd(int a, int b) {

        if (a == 0) {
            return b;
        }

        return gcd(b % a, a);
    }

    // checks whether a number is prime or not
    public static boolean prime(int n) {

        if (n < 2)
            return false;

        for (int i = 2; i * i <= n; ++i)
            if (n % i == 0)
                return false;

        return true;
    }
}


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

int lcm(int a, int b);
int gcd(int a, int b);

int main(void){
    int n, m;
    while(cin >> n >> m){
        cout << gcd(n, m) << " " << lcm(n, m) << endl;
    }
}

int lcm(int a, int b){
    int sum_a = a;
    int sum_b = b;
    while(true){
        if(sum_a < sum_b){
            sum_a += a;
        } else if(sum_a > sum_b){
            sum_b += b;
        } else {
            return sum_a;
        }
    }
}

int gcd(int a, int b){
    int smaller = a < b ? a : b;
    int bigger = a > b ? a : b;
    int end_point = smaller / 2 + 1;
    int counter = 0;
    int answer = 0;
    while(counter <= end_point){
        counter++;
        if(a % counter == 0 && b % counter == 0){
            answer = counter;
        }
    }
    if(bigger % smaller == 0){                                    
        answer = smaller;                                         
    } 
    return answer;
}

Measured memory_bytes: 3052
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

bool check(string s){
    bool ans = true;
    rep(i, (s.size()+1)/2 )if(s[i] != s[s.size()-1-i])ans = false;
    return ans;
}
int main() {
    string s, a;
    cin >> s;
    int n = s.size();
    bool x = check(s);
    bool y = check(s.substr(0, (n-1)/2));
    for(int i = (n+3)/2; i <= n; i++)a += s[i-1];
    bool z = check(a);
    if(x && y && z)cout << "Yes";
    else cout << "No";
}      

Measured memory_bytes: 256
use std::io::{stdin, BufRead};

const MOD: i64 = 1000000007;

fn dfs(tree: &[Vec<usize>], color: i64, visited: &mut [bool], root: usize, mut dist1: i64, dist2: i64) -> i64 {
    let rest = color - dist1 - dist2;
    if rest <= 0 {
        return 0;
    }
    let mut ret = rest;
    for &nex in tree[root].iter() {
        if visited[nex] {
            continue;
        }
        visited[nex] = true;
        let r = dfs(tree, color, visited, nex, 1, dist1);
        if r == 0 {
            return 0;
        }
        ret = (ret * r) % MOD;
        dist1 += 1;
    }
    ret
}

fn main() {
    let stdin = stdin();
    let cin = stdin.lock();
    let mut lines = cin.lines();
    let (n, k) = {
        let line = lines.next().unwrap().unwrap();
        let mut words = line.split(' ');
        (
            words.next().unwrap().parse::<usize>().unwrap(),
            words.next().unwrap().parse::<usize>().unwrap(),
        )
    };

    let mut g = Vec::with_capacity(n);
    for _ in 0..n {
        g.push(Vec::new());
    }
    for _ in 0..n-1 {
        let (u, v) = {
            let line = lines.next().unwrap().unwrap();
            let mut words = line.split(' ');
            (
                words.next().unwrap().parse::<usize>().unwrap() - 1,
                words.next().unwrap().parse::<usize>().unwrap() - 1,
            )
        };
        g[u].push(v);
        g[v].push(u);
    }
    let mut visited = vec![false; n];
    visited[0] = true;
    println!("{}", dfs(&g, k as i64, &mut visited, 0, 0, 0));
}


Measured memory_bytes: 17532
package main

import (
    "fmt"
)

func main() {
    S := scanString()
    max_substr_len := 0
    for i := 0; i <= len(S) - 1; i++ {
        for j := i; j <= len(S); j++ {
            substr := S[i:j]
            is_acgt := true
            for k := 0; k < len(substr); k++ {
                if substr[k] != 'A' && substr[k] != 'C' && substr[k] != 'G' && substr[k] != 'T' {
                    is_acgt = false
                    break
                }
            }
            if is_acgt {
                if max_substr_len < len(substr) {
                    max_substr_len = len(substr)
                }
            }
        }
    }
    fmt.Println(max_substr_len)
}

func scanInt() (num int) {
    fmt.Scan(&num)
    return
}

func scanInts(len int) (nums []int) {
    var num int
    for i := 0; i < len; i++ {
        fmt.Scan(&num)
        nums = append(nums, num)
    }
    return
}

func scanString() (str string) {
    fmt.Scan(&str)
    return
}

func scanStrings(len int) (strs []string) {
    var str string
    for i := 0; i < len; i++ {
        fmt.Scan(&str)
        strs = append(strs, str)
    }
    return
}

Measured memory_bytes: 512
/*          (: -_-_-_- IN THE NAME OF ALLAH -_-_-_- :)          */
/*                    | S e y e d |                             */
/*                    |    3 7    |                             */
/*                   HASHEMESHOON hastam ;)                     */
/*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*/
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <map>
#include <string>
#include <set>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <ctime>
#include <list>
#include <iterator>
#define ll long long
#define ss second
#define ff first
#define pb push_back
using namespace std;
ll n,m,x,y,z,w,t,d,b[200100],a[200100];
string s;
int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='9')cout<<'1';
        else cout<<'9';
    }
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<long long> A(N+1),B(N);
    for(int i = 0;i < N+1;++i){
        cin >> A[i];
    }
    for(int i = 0;i < N;++i){
        cin >> B[i];
    }
    long long ans = 0;
    for(int i = 0;i < N;++i){
        if(A[i] >= B[i]){
            ans += B[i];
        }else{
            if(A[i]+A[i+1]-B[i] > 0){
                ans += B[i];
                A[i+1] = A[i]+A[i+1]-B[i];
            }else{
                ans += A[i] + A[i+1];
                A[i+1] = 0;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include<functional>
#include<map>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const int max_v = 1003;
int main() {
	string s;
	while (cin >> s) {
		int len = s.size();
		int ans = 0;
		int flag;
		for (int i = 1; i < len; i++) {
			flag = 1;
			ans++;
			if ((len - i) % 2 == 1)
				continue;
			int mid = (len - i)/2;
			for (int j = 0; j < mid; j++) {
				//cout<<j<<" "<<j + mid<< endl;
				if (s[j] != s[j + mid]) {
					flag = 0;
					break;
				}
			}
			if (flag == 1)
				break;
		}
		cout << len - ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func valid(n, p int) bool {
	if p < 357 {
		return false
	}
	if p > n {
		return false
	}
	var exists [10]bool
	for p > 0 {
		exists[p%10] = true
		p /= 10
	}
	if !(exists[3] && exists[5] && exists[7]) {
		return false
	}
	return true
}

func rec(n, p, a, len int) int {
	var count int
	if a < len {
		count += rec(n, p*10+3, a+1, len)
		count += rec(n, p*10+5, a+1, len)
		count += rec(n, p*10+7, a+1, len)
	}
	if valid(n, p) {
		count++
	}
	return count
}

func target(n int) int {
	if n < 357 {
		return 0
	}

	var ns []int
	tmp := n
	for tmp != 0 {
		ns = append(ns, tmp%10)
		tmp /= 10
	}
	count := rec(n, 0, 0, len(ns))
	return count
}

func main() {
	var in int
	fmt.Scan(&in)
	fmt.Println(target(in))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
#define int long long
#define itn int
signed main(void){
    int n; cin>>n; 
    vector <int> h(n); 
    rep(i, n) cin>>h[i];
    rep(i, n){
        if(i == 0) h[i]--;
        else if(h[i-1] < h[i]) h[i]--;
    }
    int ok = true;
    for(int i=1;i<n;i++){
        //cout<<h[i-1]<<h[i]<<endl;
        if(h[i]< h[i-1]) ok = false;
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<iostream>
#define ll long long int
#define pb push_back
#define mk make_pair
#define mt make_tuple
#define ff first
#define ss second
#define mod 1000000007
using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
   int n,k;
   cin>>n>>k;
   int a[n];
   for(int i=0;i<n;i++) cin>>a[i];
   n=n-k;
   k=k-1;
   cout<<1+ceil((double)n/k)<<endl;

}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <utility>
 
using namespace std;


int main() {

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

int A;

int mi;//Ai=1となるi

for(int i=0;i<N; i++){
cin >>A;
if(A==1){mi=i; break;}
}

int le;
le=mi/(K-1);
int ri;
ri=(N-1-mi)/(K-1);

int nokori;
nokori=N-(le+ri)*(K-1);

int cent;
if(nokori==1){cent=0;}
else if(nokori<=K){cent=1;}
else{cent=2;}

cout <<le+ri+cent;

}



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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define int long long int
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

typedef std::pair<int, int> P;

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b) { return a / gcd(a, b) * b; }

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0) {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) //bit計算
{
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i - 1);
            if (i * i != n) {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

signed main() {
    int N, X, Y;
    cin >> N >> X >> Y;
    vector<int> ans(N);
    X--;
    Y--;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            int L = min({abs(j - i), abs(X - i) + 1 + abs(Y - j), abs(Y - i) + 1 + abs(j - X)});
            ans[L]++;
        }
    }
    rep(i, N - 1) {
        cout << ans[i + 1] << endl;
    }
}


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

int main()
{
  int N;
  string S;
  ll res = 0;
  cin >> N >> S;

  ll r=0, g=0, b=0;
  rep(i,N) {
    if(S[i]=='R') r++;
    if(S[i]=='G') g++;
    if(S[i]=='B') b++;
  }
  res = r * g * b;

  for(int i=0; i<N; i++) {
    for(int j=1; i+j*2<N; j++) {
      int pos1 = i;
      int pos2 = i + j;
      int pos3 = pos2 + j;
      if(S[pos1] != S[pos2] && S[pos2] != S[pos3] && S[pos3] != S[pos1]){
        res--;
      }
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 3624
using System;
using System.Collections.Generic;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)

        {
            var b = Console.ReadLine().Split();
            int N;
            Int32.TryParse(b[0], out N);
            var a = Console.ReadLine().Split();

            int[] P = new int[N];
            for (int i = 0; i < N; i++)
            {
                Int32.TryParse(a[i], out P[i]);
            }

            int cnt = 0;
            int min = P[0];
            for (int i = 0; i<N; i++)
            {
                if (P[i] <= min)
                {
                    cnt++;
                    min = P[i];
                }
            }
            Console.WriteLine(cnt);
        }
    }
}


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

#define o(output) cout << output << endl

using namespace std;

string s,t,u;
int a,b,c,d;
int l[13]={0,1,3,1,2,1,2,1,1,2,1,2,1};
char A,B,C;
priority_queue<int,vector<int>,greater<int> >small;

int main(){
  cin >>s>>t>>u;
  A=s[0]-32;
  B=t[0]-32;
  C=u[0]-32;
  cout << A<< B << C;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
//int divr[maxn];
/*ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 














const int N=405;
int n;
int main()
{
     cin>>n;
     int a[n+1];
     for(int i=1;i<=n;i++)cin>>a[i];
     ll pre[n+2]={0};
     for(int i=1;i<=n;i++)pre[i]=pre[i-1]+a[i];
     ll dp[n+2][n+2];
     memset(dp,0,sizeof(dp));
     for(int i=1;i<=n;i++)dp[i][i]=0;
     for(int len=2;len<=n;len++)
     {
          for(int i=1;i<=n-len+1;i++)
          {
               int j=i+len-1;
               dp[i][j]=1LL<<62;
               for(int k=i;k<j;k++)
               {
                    dp[i][j]=min(dp[i][k]+dp[k+1][j]+pre[j]-pre[i-1],dp[i][j]);
               }
          }
     }
     cout<<dp[1][n];
     
     

}























 

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

#define MAXN 100005
#define int long long
#define LL long long
#define pii pair<int, int>
#define fi first
#define se second
#define fastio ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

using namespace std;

int N, K;
int a[105];
int dp[MAXN];

signed main() {
    cin >> K >> N;
    for (int i = 1; i <= K; i++) cin >> a[i];
    dp[0] = 2;
    for (int i = 1; i <= N; i++) {
        int c1 = 0, c2 = 0;
        for (int j = 1; j <= K; j++) {
            if (i - a[j] >= 0) {
                if (dp[i-a[j]] == 1) c1++;
                else c2++;
            }
        }
        if (c2) dp[i] = 1;
        else dp[i] = 2;
    }
    if (dp[N] == 1) cout << "First" << endl;
    else cout << "Second" << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define P pair<ll,ll> 
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b,c;cin>>a>>b>>c;
  if(c-a-b>=0&&4*a*b<(c-a-b)*(c-a-b)) puts("Yes");else puts("No");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <queue>
#include <deque>
#include <vector>
#define maxc 100010
#define inf 0x3f3f3f3f
#define ll long long
using namespace std;
int main(){
   int a,b,c,x,y;
   cin>>a>>b>>c>>x>>y;
   if(c*2<=a+b){
        if(x>y){
            if(a>c*2)
                cout<<c*x*2<<endl;
            else
                cout<<c*y*2+(x-y)*a<<endl;
        }
        else{
            if(b>c*2)
                cout<<c*y*2<<endl;
            else
                cout<<c*x*2+(y-x)*b<<endl;
        }
   }
   else{
        if(a>c*2)
            cout<<c*2*x+b*y<<endl;
        else if(b>c*2)
            cout<<c*2*y+a*x<<endl;
        else
            cout<<a*x+b*y<<endl;
   }
   return 0;
}


Measured memory_bytes: 256
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(x):
	lvls = floor(log(x,2)) + 1
	ans = ((2**lvls - 1))
	return int(ans)
	

N = int(stdin.readline())
ans = solve(N)
print(ans)


Measured memory_bytes: 4932