akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    string S;
    cin >> N >> S;

    map<char,int> m;
    rep(i,N){
        m[S[i]]++;
    }
    long long ans=1;
    for(auto p:m){
        ans=ans*(p.second+1)%MOD;
    }
    ans--;
    cout << ans << endl;



}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

bool prime[1000010];

void set_prime() {
	prime[0] = 1;
	prime[1] = 1;
	for (int i = 2; i < 2000; i++) {
		int j = 2;
		while (i * j <= 1000000) {
			prime[i*j] = 1;
			j++;
		}
	}
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int Q; cin >> Q;
    set_prime();
    int sum[100010] = {};
    for(int i = 3; i <= 100000; i += 2) {
        if (prime[i] == 0 && prime[(i + 1)/ 2] == 0) sum[i]++;
    }
    rep(i, 100001) sum[i + 1] += sum[i];
    while(Q--) {
        int l, r;
        cin >> l >> r;
        cout << sum[r] - sum[l - 1] << endl;
    }

    return 0;
}


Measured memory_bytes: 2048
N = input()
x = list(map(int, input().split()))
start = min(x)
fin = max(x)
res = 0
for j in range(len(x)):
        res = res + (x[j]-start)*(x[j]-start)
        
for i in range(start,fin):
    sum = 0
    for j in range(len(x)):
        sum = sum + (x[j]-i)*(x[j]-i)
    if(sum < res):
        res = sum

print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 2e18;
const ll fact_table = 1200008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define endl "\n"
#ifdef ENJAPMA
    #undef endl
#endif
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
const ll mod = 998244353ll;
// const ll mod = 1000000007ll;
  
ll mypow(ll number1,ll number2, ll mod){
    if(number2 == 0){
        return 1ll;
    }else{
        ll number3 = mypow(number1,number2 / 2, mod);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

/*
ll fact[fact_table + 5],rfact[fact_table + 5]; 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table],mod - 2, mod);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    assert(n >= r);
    assert(n >= 0);
    assert(r >= 0);
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
bool multicase = false;

ll n,m,num,a,b,c,d,e,q;

ll x[100005], y[100005], z[100005];
ll k, ans;

void solve(){
    bool dame = false;
    string s, t;
    cin >> s >> t;
    n = s.size(), m = t.size();
    if(m != n + 1)dame = true;
    if(!dame){
        for(int i=0;i<n;i++){
            if(s[i] != t[i])dame = true;
        }
    }
    Yes(!dame);
    return;
}

int main(){
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;
    if(multicase){
        cin >> q;
    }else{
        q = 1; 
    }
    while(q--){
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    // solve();
    return 0;
}
















Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.ST << ", " << p.ND << ")";
}

template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out) {
	out << '{';
	for(auto &e : x)
        	out << e << (&e == &*--x.end() ? "" : ", ");
	return out << '}';
}

template<class... Args> void dump(Args&&... args) {
	((cerr << args << ";  "), ...);
}
 
#ifdef DEBUG
#  define debug(x...) cerr << "[" #x "]: ", dump(x), cerr << "\n"
#else
#  define debug(...) false
#endif
 
template<class T> int size(T && a) { return (int) a.size(); }
 
using LL = long long;
using PII = pair<int, int>;

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

	int n;
	cin >> n;
	int q = n * n;
	vector<int> p(q);
	REP(i, q) cin >> p[i], p[i]--;

	int inf = 1e9;
	vector<int> dst(q + 1, inf), w(q, 1);
	priority_queue<PII> Q;

	auto is_edge = [&](int i) {
		return (i < n || i % n == 0 || i % n == (n - 1) || q - n <= i);
	};

	REP(i, q) {
		if(is_edge(i)) {
			dst[i] = 1;
			Q.emplace(-dst[i], i);
		}
	}

	auto bfs = [&]() {
		while(!Q.empty()) {
			int v = Q.top().ND;
			Q.pop();

			for(int d : {-1, +1, -n, +n}) {
				int u = v + d;
				if(0 <= u && u < q) {
					if(dst[u] > dst[v] + w[u]) {
						dst[u] = dst[v] + w[u];
						Q.emplace(-dst[u], u);
					}
				}
			}
		}
	};

	bfs();

	LL ans = 0;
	REP(i, q) {
		if(is_edge(p[i])) {
			dst[p[i]] = 0;
			Q.emplace(0, p[i]);
		}
		else for(int d : {-1, +1, -n, +n}) {
			int u = p[i] + d;
			if(0 <= u && u < q)
				Q.emplace(-dst[u], u);
		}

		w[p[i]] = 0;	
		bfs();
		ans += dst[p[i]];	
	}

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


Measured memory_bytes: 6464
n = int(input())
a = list(map(int,input().split()))

a_sum = sum(a)//2
a_odd = 0

for i in range((n-1)//2):
    a_odd += a[i*2+1]

a_back = a_sum-a_odd
print(2*a_back)

for i in range(n-1):
    a_back = a[i]-a_back
    print(2*a_back)


Measured memory_bytes: 14092
import heapq

n = int(input())
a = [0] + [int(input())-1 for i in range(n-1)]
child = [[] for i in range(n)]
for i in range(1,n):
    child[a[i]].append(i)

hq = []

dep = [0 for i in range(n)]
last = [len(child[0])]
for i in range(1, n):
    last.append(len(child[i]))
    if last[i] == 0:
        heapq.heappush(hq, (0, i))

while hq:
    d, i = heapq.heappop(hq)
    if last[i] > 0:
        continue
    dep[a[i]] = max(d, dep[a[i]]) + 1
    # if dep[a[i]] >= d:
    #     dep[a[i]] += 1
    # else:
    #     dep[a[i]] = d+1
    last[a[i]] -= 1
    if last[a[i]] == 0:
        heapq.heappush(hq, (dep[a[i]], a[i]))
print(dep[0]-1)


Measured memory_bytes: 31164
import sys
from collections import deque

def solve():
    input = sys.stdin.readline
    H, W = map(int, input().split())
    A = [input().strip("\n") for _ in range(H)]
    q = deque()
    q.append((0, 0))
    visited = [[False] * W for _ in range(H)]
    possible = True
    while q:
        nh, nw = q.popleft()
        if not visited[nh][nw]:
            visited[nh][nw] = True
            count = 0
            if 0 <= nh + 1 < H and A[nh + 1][nw] == "#":
                if 0 <= nw - 1 and A[nh+1][nw-1] == "#":
                    possible = False
                    break
                q.append((nh+1, nw))
                count += 1
            if 0 <= nw + 1 < W and A[nh][nw+1] == "#":
                if 0 <= nh - 1 and A[nh-1][nw+1] == "#":
                    possible = False
                    break
                q.append((nh, nw+1))
                count += 1
            if count == 2:
                possible = False
                break
    else:
        if not visited[H-1][W-1]: possible = False
    print("Possible" if possible else "Impossible")

    return 0

if __name__ =="__main__":
    solve()

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main(){
  int t;
  t=1;
  while(t--){
   string s,t;
   cin>>s>>t;
   int count=0;
   for(int i=0;i<s.size();i++){
   	if(s[i]!=t[i])
   	count++;
   }
   cout<<count<<"\n";
  }
 
   return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll A, B;
    cin >> A >> B;
    if(A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}


Measured memory_bytes: 256
K,N = map(int,input().split())
if K % 2 == 0:
    ans = [K//2]
    for i in range(N-1):
        ans.append(K)
else:
    back = N//2
    mid = K//2 + 1
    ans = [mid for i in range(N)]
    for i in range(back):
        if ans[-1] == 1:
            ans.pop()
        else:
            ans[-1] -= 1
            while len(ans) < N:
                ans.append(K)
print(' '.join(map(str,ans)))


Measured memory_bytes: 26520
import sys

# import math
# import bisect

# import copy
# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
# INF = sys.maxsize
# MOD = 10 ** 9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()


# ===CODE===
def main():
    class UnionFind():
        def __init__(self, n):
            self.n = n
            self.parents = [-1] * n

        def find(self, x):
            if self.parents[x] < 0:
                return x
            else:
                self.parents[x] = self.find(self.parents[x])
                return self.parents[x]

        def union(self, x, y):
            x = self.find(x)
            y = self.find(y)

            if x == y:
                return

            if self.parents[x] > self.parents[y]:
                x, y = y, x

            self.parents[x] += self.parents[y]
            self.parents[y] = x

        def size(self, x):
            return -self.parents[self.find(x)]

        def same(self, x, y):
            return self.find(x) == self.find(y)

        def members(self, x):
            root = self.find(x)
            return [i for i in range(self.n) if self.find(i) == root]

        def roots(self):
            return [i for i, x in enumerate(self.parents) if x < 0]

        def group_count(self):
            return len(self.roots())

        def all_group_members(self):
            return {r: self.members(r) for r in self.roots()}

        def __str__(self):
            return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    n, m = map(int, input().split())

    d = []
    for i in range(m):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        d.append((a, b))

    d.reverse()
    ans = []
    a = n*(n-1)//2
    que = UnionFind(n)

    for i in range(m):
        ans.append(a)
        x,y = d[i]
        if not que.same(x,y):
            a -= que.size(x)*que.size(y)
            que.union(x,y)

    ans.reverse()
    for tmp_a in ans:
        print(tmp_a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 22520
#include<iostream>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int N;
    cin >> N;
    int tmp;
    int maxa=0, mina=1100;
    for(int i=0; i<N; i++){
        cin >> tmp;
        if(maxa<tmp){
            maxa=tmp;
        }
        if(tmp<mina){
            mina=tmp;
        }
    }
    cout << maxa - mina << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int out;
    out = r % 10;
    
    string read;

    switch (out)
    {
    case 3:
        read = "bon";
        break;
    case 0:
        read = "pon";
        break;
    case 1:
        read = "pon";
        break;
    case 6:
        read = "pon";
        break;
    case 8:
        read = "pon";
        break;
    default:
        read = "hon";
        break;
    }

    cout << read << endl;
    return 0;
}

Measured memory_bytes: 3592
using System;

class E
{
	static void Main()
	{
		Func<int[]> read = () => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		var h = read();
		var s = read();
		var t = read();
		int n = h[0], m = h[1];

		var dp = new int[n + 1, m + 1];
		for (int i = 0; i <= n; i++) dp[i, 0] = 1;
		for (int j = 0; j <= m; j++) dp[0, j] = 1;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				dp[i + 1, j + 1] = MInt(dp[i, j + 1] + dp[i + 1, j] - (s[i] == t[j] ? 0 : dp[i, j]));
		Console.WriteLine(dp[n, m]);
	}

	const int M = 1000000007;
	static int MInt(int x) => (x %= M) < 0 ? x + M : x;
}


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

int main()
{
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  for (int i = 0; i < n; i++)
  {
    int X;
    cin >> X;
    x = max(x, X);
  }
  for (int i = 0; i < m; i++)
  {
    int Y;
    cin >> Y;
    y = min(y, Y);
  }

  if (y <= x)
  {
    cout << "War" << endl;
  }
  else
  {
    cout << "No War" << endl;
  }
}


Measured memory_bytes: 3640
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

const NIL = -1

type Node struct {
	id     int
	weight int
}

func init() {
	sc.Split(bufio.ScanWords)
}

type NodeHeap []Node

func (h NodeHeap) Len() int           { return len(h) }
func (h NodeHeap) Less(i, j int) bool { return h[i].weight < h[j].weight }
func (h NodeHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *NodeHeap) Push(x interface{}) {
	*h = append(*h, x.(Node))
}

func (h *NodeHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

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

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()

	route := make([][]Node, n)
	weight := make([]int, n)
	for i := 0; i < n; i++ {
		weight[i] = NIL
	}

	for i := 0; i < n; i++ {
		u := scanInt()
		k := scanInt()
		route[i] = make([]Node, k)
		for j := 0; j < k; j++ {
			route[u][j] = Node{id: scanInt(), weight: scanInt()}
		}
	}

	start := Node{id: 0, weight: 0}
	h := &NodeHeap{start}
	heap.Init(h)

	for h.Len() > 0 {
		node := heap.Pop(h).(Node)
		if weight[node.id] != NIL {
			continue
		}
		weight[node.id] = node.weight

		for _, nextNode := range route[node.id] {
			if weight[nextNode.id] != NIL {
				continue
			}
			nextNode.weight += node.weight
			heap.Push(h, nextNode)
		}
	}

	for i, w := range weight {
		fmt.Println(i, w)
	}
}



Measured memory_bytes: 32596
#include "bits/stdc++.h"
using namespace std;
long long a[100000];
long long min(long long i, long long j)
{
    return i < j ? i : j;
}
long long max(long long i, long long j)
{
    return i > j ? i : j;
}
int main()
{
    int n, k;
    long long mi = 1ll << 60;
    scanf("%d%d", &n, &k);
    for(int i = 0; i < n; ++i)
    {
        scanf("%lld", &a[i]);
    }
    for(int i = 0; i + k <= n; ++i)
    {
        if(a[i] < 0 && 0 < a[i + k - 1])
        {
            mi = min(mi, min(0 - a[i], a[i + k - 1]) * 2 + max(0 - a[i], a[i + k - 1]));
        }
        else if(a[i] < 0 && a[i + k - 1] <= 0)
        {
            mi = min(mi, 0 - a[i]);
        }
        else
        {
            mi = min(mi, a[i + k - 1]);
        }
    }
    printf("%lld\n", mi);
}


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

int main(){
	int N, M, X;
	cin >> N >> M >> X;
	int C[N], A[N][M];
	for(int i=0;i<N;i++){
		cin >> C[i];
		for(int j=0;j<M;j++){
			cin >> A[i][j];
		}
	}
	int ans = 100000000;
	for(int l = 0;l<(1 << N);l++){
		int lc = l;
		int B[M];
		for(int i=0;i<M;i++){
			B[i] = 0;
		}
		int V = 0;
		for(int i=0;i<N;i++){
			if (lc % 2){
				V += C[i];
				for(int j=0;j<M;j++){
					B[j] += A[i][j];
				}
			}
			lc /= 2;
		}
		bool chk = true;
		for(int j = 0;j<M;j++){
			if(B[j] < X){
				chk = false;
				break;
			}
		}
		if(chk){
			ans = min(ans, V);
			//cout << l << ":" <<  V << endl;
		}
	}
	if(ans == 100000000) ans = -1;
	cout << ans << endl;
}

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

using namespace std;
using ll = long long;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int N;
    cin >> N;
    int sum = 0;
    vector<int> a(N);
    for (int &x : a) cin >> x, sum += x;
    sum /= N;
    int nin = 1e9;
    for (int k : {0, 1}) {
        int cost = 0;
        for (int x : a) {
            cost += (x - sum - k) * (x - sum - k);
        }
        nin = min(nin, cost);
    }
    cout << nin << "\n";
    return 0;   
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include<string>
#include<cmath>
#include<vector>
#include<set>
typedef long long ll;
#define ss ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
using namespace std;

int main()
{
ss
    ll n;
    cin>>n;
    if(n>=30)
        cout<<"Yes";
    else
        cout<<"No";

	return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main(void)
{
	char crypt[512];
	char dec[512];
	int a, b;
	int n, i;
	int ci;
	int len;

	fgets(crypt, sizeof(crypt), stdin);
	n = atoi(crypt);
	for (i = 0; i < n; i++){
		fgets(crypt, sizeof(crypt), stdin);
		len = strlen(crypt);
		for (a = 3; a < 52; a += 2){
			if (a == 13) continue;
			for (b = 0; b < 26; b++){
				for (ci = 0; ci <= len; ci++){
					if (islower(crypt[ci])){
						dec[ci] = (((crypt[ci] - 'a') * a + b) % 26) + 'a';
					}
					else {
						dec[ci] = crypt[ci];
					}
				}
				if (strstr(dec, "this") != NULL || strstr(dec, "that") != NULL) goto end;
			}
		}
		end:;
		printf("%s", dec);
	}
	return (0);
}

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

int main() {
	int N, A, B, P, x[3] = { 0 };
	cin >> N >> A >> B;
	for (int i = 0; i < N; i++) {
		cin >> P;
		if (P <= A) x[0]++;
		else if (P <= B) x[1]++;
		else x[2]++;
	}
	sort(x, x + 3);
	cout << x[0] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
int cnt = 0;
ll N;
map<ll, int>mp;
ll dfs(int idx, ll num){
    //cout << idx << " " << num << endl;
    if(idx == cnt){
        ll ans = 0;
        if(num == 1)return 0;

        //cout << N / (num-1) << " " << N % (num-1) << endl;
        if(N / (num-1) == N % (num-1))ans = num-1;
        return ans;
    }
    ll ans = 0;
    auto itr = mp.begin();
    for(int i = 0;i < idx;i++,itr++){}
    ll power = 1;
    rep(i,0,itr->second +1){
        
        ans += dfs(idx+1, num * power);
        power *= itr->first;
    }
    return ans;
}
main(){
    cin >> N;
    /*
    rep(i,1,N+1){
        printf("%3d : %3lld : %3lld",i ,N/i ,N%i);
        //cout << i << ":" << N / i << " " << N % i;
        if(N / i == N % i)cout << " o";
        else cout << "  ";
        cout << endl;
    }*/
    ll num = N;
    for(ll i = 2;i * i <= N;i++){
        while(num % i == 0){
            mp[i]++;
            num /= i;
        }
    }
    if(num != 1)mp[num]++;
    ll sum = 1;
    for(auto p:mp){
        cnt++;
        sum *= p.second + 1;
        //cout << p.first << "," << p.second << endl;
    }
    //cout << sum << endl;

    cout << dfs(0,1) << endl;
}

Measured memory_bytes: 256
def C():
    nk=list(map(int,input().split()))
    
    abs_val=abs(nk[0]-nk[1])
    
    while True:
        if abs_val>nk[1]:
            abs_val=abs_val%nk[1]
        elif abs_val<nk[1]:
            abs_val=min(abs_val,abs(abs_val-nk[1]))
            break
        else :
            # 0
            abs_val=abs_val-nk[1]
            break
    
    print(min(abs_val,nk[0]))
    
    
    
if __name__=='__main__':
    C()


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

int main() {
  int A, B;
  cin >> A >> B;
  if((A+B)%3 != 0 && A%3 != 0 && B%3 != 0){
    cout << "Impossible" << endl;
  }
  else {
    cout << "Possible" << endl;
  }
}


Measured memory_bytes: 256
n = int(input())
a = [0]+list(map(int,input().split()))
x = [0]*(n+1)
for i in range(n,0,-1):
    buf = 0
    for j in range(1,n//i+1):
        buf += x[i*j]
    if buf%2!=a[i]:x[i]=1
x = x[1:]
m = 0
b = []
for i in range(n):
    if x[i]==1:
        b.append(i+1)
        m+=1
print(m)
print(*b)



Measured memory_bytes: 14132
q,h,s,d = map(int,input().split())
n = int(input())

d1 = min([8*q,4*h,2*s,d])
s1 = min([4*q,2*h,s])

ans = 0
if n >= 2:
    ans += n//2*d1
    n = n%2
    if n == 1:
        ans += s1
elif n == 1:
    ans = s1
    
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

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


		while (true){
		int x = sc.nextInt();
		int y = sc.nextInt();
 
			if (x == 0 && y == 0)break;
		if (x < y) {
			System.out.println(x + " " + y);
		} else {
			System.out.println(y + " " + x);
		}
	}
}
}


Measured memory_bytes: 34588
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i = 0;i < (n); ++i)
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> d(k);
    int a[100][100];
    map<int, int> m;
    rep(i,k){
        cin >> d[i];
        rep(j,d[i]){
            cin >> a[i][j];
            m[a[i][j]] = 1;
        }
    }
    vector<int> b;
    for(auto x:m){
        b.pb(x.first);
    }
    cout << n - b.size() << endl;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define ll long long
#define _ ios::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
using namespace std;

int main() { _
    ll n, m, k, sum = 0, ans = 0, max1 = 0, l = 0, r = 0; cin >> n >> m >> k;
    deque <ll> dq1, dq2;
    for(ll i = 0; i < n; i++){
        ll x; cin >> x;
        dq1.push_back(x);
    }
    for(ll i = 0; i < m; i++){
        ll x; cin >> x;
        dq2.push_back(x);
    }
    while(l < n){
        if(sum + dq1[l] <= k){
            sum += dq1[l];
            ans++;
            l++;
        }else{
            l--;
            break;
        }
    }
    if(l == n) l--;
    max1 = max(max1, ans);
    while(l >= -1 && r < m){
        if(sum + dq2[r] <= k){
            sum += dq2[r];
            ans++;
            r++;
        }else{
            if(l < 0) break;
            sum -= dq1[l];
            l--;
            ans--;
        }
        max1 = max(ans, max1);
    }
    max1 = max(ans, max1);
    cout << max1 << endl;
}

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

int main() {
	
	int a, b, c; cin >> a >> b >> c;
	if (a + b == c || b + c == a || c + a == b) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3604
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		Sushi[] sushies = new Sushi[n];
		for (int i = 0; i < n; i++) {
		    sushies[i] = new Sushi(sc.nextInt(), sc.nextInt());
		}
		Arrays.sort(sushies);
		boolean[] used = new boolean[n + 1];
		PriorityQueue<Sushi> stock = new PriorityQueue<>();
		long max = 0;
		long total = 0;
		long count = 0;
		for (int i = 0; i < n; i++) {
		    Sushi s = sushies[n - i - 1];
		    if (i < k) {
		        total += s.value;
		        if (used[s.type]) {
		            stock.add(s);
		        } else {
		            used[s.type] = true;
		            count++;
		        }
		        max = total + count * count;
		    } else {
		        if (stock.size() == 0) {
		            break;
		        }
		        if (used[s.type]) {
		            continue;
		        }
		        used[s.type] = true;
		        count++;
	            total -= stock.poll().value;
		        total += s.value;
		        max = Math.max(max, total + count * count);
		    }
		}
		System.out.println(max);
    }
    
    static class Sushi implements Comparable<Sushi> {
        int type;
        int value;
        
        public Sushi(int type, int value) {
            this.type = type;
            this.value = value;
        }
        
        public int compareTo(Sushi another) {
            return value - another.value;
        }
    }
}



Measured memory_bytes: 94176
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
template<int mod>
struct ModInt{
    int x;
    ModInt():x(0){}
    ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
    ModInt &operator+=(const ModInt &p){
        if((x+=p.x)>=mod)x-=mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p){
        if((x+=mod-p.x)>=mod)x-=mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p){
        x=(int)(1LL*x*p.x%mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p){
        *this*=p.inverse();
        return *this;
    }
    ModInt operator-()const{return ModInt(-x);}
    ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
    ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
    ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
    ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
    bool operator==(const ModInt &p)const{return x==p.x;}
    bool operator!=(const ModInt &p)const{return x!=p.x;}
    ModInt inverse()const{
        int a=x,b=mod,u=1,v=0,t;
        while(b>0){
            t=a/b;
            a-=t*b;
            swap(a,b);
            u-=t*v;
            swap(u,v);
        }
        return ModInt(u);
    }
    friend ostream &operator<<(ostream &os,const ModInt<mod> &p){
        return os<<p.x;
    }
    friend istream &operator>>(istream &is,ModInt<mod> &a){
        long long x;
        is>>x;
        a=ModInt<mod>(x);
        return (is);
    }
};

const int mod=1e9+7;
using mint=ModInt<mod>;
int main(){
    int n,x;
    cin>>n>>x;
    vi vec(n);
    cin>>vec;
    sort(all(vec),greater<>());
    vector<vector<mint>> dp(n+1,vector<mint>(x+1));
    dp[0][x]=1;
    REP(i,n){
        REP(j,x+1){
            dp[i+1][j]+=dp[i][j]*(n-1-i);
            dp[i+1][j%vec[i]]+=dp[i][j];
        }
    }
    mint ans=0;
    REP(i,x+1){
        ans+=dp[n][i]*(i%vec.back());
    }
    cout<<ans<<endl;
    return 0;
}

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

typedef long long lli;
typedef pair<lli,lli> pll;
typedef vector<lli> vcL;

lli ST[ 20 ][ (int)1E5+5 ];

bool cmp(lli x, lli y) {
	return x > y;
}

int lg(int n) {
	return (int)(log10(n)/.331);
}

lli STab(int l, int r) {
	if ( l > r ) return 0;
	
	int rng = r-l+1;
	int lev = lg(rng);
	
//	printf("gcd from token %lld to %lld is %lld.\n", l, r, __gcd( ST[lev][l], ST[lev][ r-(1<<lev)+1 ] ) );
	return __gcd( ST[lev][l], ST[lev][ r-(1<<lev)+1 ] );
}

lli Get_GCD(int place, int n) {
	return __gcd( STab( 0, place-1 ), STab( place+1, n-1 ) );
}

void solve() {
	memset( ST, 0, sizeof (ST) );
	
	int n = 1;
	cin >> n;
//	lli s[ n+5 ];
	for (int i = 0; i < n; ++i) cin >> ST[0][i];
	
//	printf("lg %d = %d.\n", n, lg(n) );
	
	for (int i = 1; i <= lg(n); ++i) {
		for (int j = 0; j < n-(1<<i)+1; ++j) {
			ST[i][j] = __gcd( ST[ i-1 ][j], ST[ i-1 ][ j+(1<<i-1) ] );
		}
	}
	
	lli _gcd = 0;
	
	for (int i = 0; i < n; ++i) {
		lli get_gcd = Get_GCD( i, n );
		
		if ( get_gcd >= _gcd ) {
			_gcd = get_gcd;
		}
	}
	
	cout << _gcd << '\n';
}

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

Measured memory_bytes: 16256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
const int N =1e3;
int x;
void solve ()
{
    int i,j=0;
    for( i=-N;i<=N;i++)
    {
        for(j=-N;j<=N;j++)
            if((pow(i,5)-pow(j,5))==x)
            {   
                printf("%d %d\n",i,j);
                return ;
            }
    }
}
int main()
{
    scanf("%d",&x);
    solve();
}


Measured memory_bytes: 3640
#import <Foundation/Foundation.h>
#import <stdarg.h>

@interface StdIO : NSObject
+(NSMutableString*)stringFromStdIn; // 標準入力から NSString を得る
+(void)printf:(NSString*)format, ...; // 標準出力へ出力
@end

@implementation StdIO
+(NSMutableString*)stringFromStdIn
{
    NSFileHandle *handle = [NSFileHandle fileHandleWithStandardInput];
    NSMutableString *result = [NSMutableString string];
    NSData *data = [handle availableData];
    while ([data length] > 0) {
        [result appendString:[[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]];
        data = [handle availableData];
    }
    NSUInteger length = [result length];
    if (length >= 1 && [result characterAtIndex:length-1] == '\n') { // 入力末尾に改行文字があれば削除
        [result deleteCharactersInRange:NSMakeRange(length-1,1)];
    }
    return result;
}
+(void)printf:(NSString*)format, ...
{
    va_list arguments;
    va_start(arguments, format);
    NSString *string = [[[NSString alloc] initWithFormat:format arguments:arguments] autorelease];
    NSFileHandle *fileHandle = [NSFileHandle fileHandleWithStandardOutput];
    [fileHandle writeData:[string dataUsingEncoding:NSUTF8StringEncoding]];
    va_end(arguments);
}
@end
  
int main() {
    @autoreleasepool {
        NSArray *numbers = [[StdIO stringFromStdIn] componentsSeparatedByString:@"\n"];
        NSInteger A = [[numbers objectAtIndex:0] integerValue];
        NSInteger B = [[numbers objectAtIndex:1] integerValue];
        NSInteger C = [[numbers objectAtIndex:2] integerValue];
        NSInteger X = [[numbers objectAtIndex:3] integerValue] / 50;
        NSInteger count = 0;
        for (NSInteger x=0; x <= MIN(A,X/10); x++) {
            NSInteger Y = X-10*x;
            for (NSInteger y=0; y <= MIN(B,Y/2); y++) {
                NSInteger z = Y-2*y;
                if (z <= C) {
                    count++;
                }
            }
        }
        [StdIO printf:@"%ld", count];
    }
    return 0;
}

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

#define int long long
#define inf 1e11

int n, m, a[1<<18], t[1<<20] ;

void build(int v, int l, int r){

    if(l==r){
        t[v]=a[l];
    }

    else {

        int mid = (l+r)/2;
        build(2*v, l , mid);
        build(2*v+1, mid+1, r);
        t[v] = min(t[2*v] , t[2*v+1]);

    }


}


int mn(int v, int tl, int tr, int l, int r){

    if(l>r) return inf;

    if(l == tl && r == tr){
        return t[v];
    }

    int tm = (tl+tr)/2;

    return  min(mn(2*v, tl, tm, l, min(r,tm)) ,mn(2*v+1, tm+1, tr, max(tm+1, l), r));


}


void update(int v, int tl, int tr, int pos, int val){


    if(tl==tr){
        t[v]=val;
    }

    else {
    int tm = (tl+tr)/2;

    if(tm<pos){
        update(2*v+1, tm+1, tr, pos, val);
    }
    else update(2*v, tl, tm, pos, val);

    t[v] = min( t[2*v] , t[2*v+1] );

    }

}



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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);



cin >> n  >> m;
int y = 1;
for(int i=0; i<= n-1; i++){
a[i] = (y<<31) - 1;
}

build(1, 0 ,n-1);

while(m--){

int l, r, up, val, x;
cin >> x >> l >> r  ;

if(x==1){
int ans = mn(1, 0, n-1, l, r);
cout << ans << endl;
}
else {
    update(1, 0, n-1, l, r);
}
//cout << m << endl;
}


return 0;}



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

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

	cout << a / b << ' ' << a % b << ' ';
	cout << fixed << setprecision(5) << (double)a / (double)b << endl;

	return 0;
}


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

import sys
if sys.version_info.minor >= 5:
    from math import gcd
else:
    from fractions import gcd

left = [a[0]]
right = [a[-1]]

for i in range(1, n):
    left.append(gcd(left[i-1], a[i]))
    right.append(gcd(right[i-1], a[n-i-1]))

ans = 0
for i in range(n):
    if i == 0:
        num = right[n-i-2]
    elif i == n - 1:
        num = left[i-1]
    else:
        num = gcd(left[i-1], right[n-i-2])
    if num > ans:
        ans = num

print(ans)

Measured memory_bytes: 93792
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int N;
  cin >> N;

  string S;
  cin >> S;

  int answer = 0;

  for (int i = 0; i < N - 2; i++) {
    string s_ = S.substr(i,3);
    if (s_ == "ABC") {
      answer++;
    }
  }

  cout << answer << endl;

}

Measured memory_bytes: 256
N,M = map(int,input().split())

INF = 100000000

g = [ [INF] * N for _ in range(N) ]

for _ in range(M):
  a,b,c = map(int,input().split())
  a-=1
  b-=1
  g[a][b] = c
  g[b][a] = c

t = [ [INF] * N for _ in range(N) ]
for i in range(N):
  for j in range(N):
    t[i][j] = g[i][j]

for k in range(N):
  for i in range(N):
    for j in range(N):
      t[i][j] = min(t[i][j], t[i][k] + t[k][j])

ans = 0
for i in range(N):
  for j in range(i):
    if g[i][j] != INF:
      if t[i][j] != g[i][j]:
        ans += 1
print(ans)

Measured memory_bytes: 3444
#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()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    int N;
    ll  ans = 0;
    cin >> N;
    vector <string> str(N);

    rep(i, N) {
        cin >> str.at(i);
        sort(str.at(i).begin(), str.at(i).end());
    }
    sort(str.begin(), str.end());
    int start = 0;
    rep(i, N) {
        if (str.at(start) != str.at(i)) {
            ll diff = (i - start);
            ans  += diff * (diff - 1) / 2;
            start = i;
        }
    }
    ll diff = N - start;
    ans += diff * (diff - 1) / 2;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
	int n = 0, p[25],count = 0,tmp[3];
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
	}
	for (int i = 0; i < n - 2; i++)
	{
		tmp[0] = p[i]; tmp[1] = p[i + 1]; tmp[2] = p[i + 2];
		sort(tmp, tmp + 3);
		if (tmp[1] == p[i + 1]) { count++; }
	}
	cout << count << endl;
	return 0;
}

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

int main() {
  char a;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a == 'Y') {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
}

Measured memory_bytes: 256
N, M = tuple(map(int, input().split()))


class StudentCoord:

    def __init__(self, x, y):
        self.x = x
        self.y = y

    def distance(self, x, y):
        return abs(x - self.x) + abs(y - self.y)

    def nearest_checkpoint_idx(self, checkpoints):
        min_idx = -1
        min_distance = float('inf')
        for idx, checkpoint in enumerate(checkpoints):
            d = self.distance(checkpoint[0], checkpoint[1])
            if d < min_distance:
                min_idx = idx
                min_distance = d
        return min_idx+1


students = []
for _ in range(N):
    x, y = tuple(map(int, input().split()))
    student = StudentCoord(x, y)
    students.append(student)

checkpoints = []
for _ in range(M):
    checkpoint = tuple(map(int, input().split()))
    checkpoints.append(checkpoint)

for student in students:
    idx = student.nearest_checkpoint_idx(checkpoints)
    print(idx)



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

int main(){
  int N;
  int F;
  int fx=0;
  
  cin >> N;
 
  F= N;

  while (N  > 0){
    fx += N %10;
    N /= 10;
  }
  

  if(F % fx == 0){
    cout <<"Yes"<<endl;
  }else{
    cout <<"No"<<endl;
  }

}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iomanip>
#include<string>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if ((a*b) % 2 != 0 && (c + d) % 2 != 0) { cout << "No" << endl; }
	else { cout << "Yes" << endl; }
	}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
int main() {
  string co;
  cin >> co;
  if((co.at(2) == co.at(3)) && (co.at(4) == co.at(5))) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef vector<lld> vi;
typedef pair<lld,lld> pi;
#define F first
#define S second
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (lld i = a; i < b; i++)
lld r,j,l,x,y,m,b,n,s,f,q,i,z,p,c,k,d,t,u,e,g;string s1,s2,s3,s4;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);lld a;
  cin>>n>>a;
  rep(i,0,1000)
  {
    p=n-(500*i);
    if(p<=a&&p>=0)
    {
      cout<<"Yes";return 0;
    }
  }
    cout<<"No";
} 

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import deque, defaultdict, Counter

S = input().rstrip()
L = len(S)

c = Counter(S)
if sum((x&1 for x in c.values())) >= 2:
    print(-1)
    exit()

alphabet_to_pos = defaultdict(deque)

for i,x in enumerate(S,1):
    alphabet_to_pos[x].append(i)

after = [None] * len(S)
n = 0
for i,x in enumerate(S,1):
    p = alphabet_to_pos[x]
    if not p:
        continue
    if len(p) == 1:
        p.pop()
        after[L//2] = i
        continue
    p.popleft()
    j = p.pop()
    after[n] = i
    after[L - n - 1] = j
    n += 1

def BIT_update(tree,x):
    while x <= L:
        tree[x] += 1
        x += x & (-x)

def BIT_sum(tree,x):
    s = 0
    while x:
        s += tree[x]
        x -= x & (-x)
    return s

answer = 0
tree = [0] * (L+1)
for i,x in enumerate(after):
    answer += i - BIT_sum(tree,x)
    BIT_update(tree,x)

print(answer)

Measured memory_bytes: 16732
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <iostream>
#define maxn 1000009
using namespace std;
const int MOD = 1e9 + 7;
long long dp[maxn],s[maxn];
int main(){
 long long n;
 scanf("%lld", &n);
 dp[0] = 1;
 s[0]=1;
 for(int i = 1; i <= n; i++){
   dp[i]=(dp[i]+MOD+s[i-1]-dp[i-2])%MOD;
   s[i]=(s[i-1]+dp[i])%MOD;

 }
long long ans=dp[n]+dp[n-1]*(n-1)%MOD;
 for(int i =0; i <= n-2; i++){
  ans += dp[i] * ((i + 1)+(n-1)*(n-1)%MOD)% MOD;
  ans %= MOD;
 }

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

Measured memory_bytes: 15872
#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;

#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using multiInt = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
//constexpr ll MOD = 1;
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr double PI = acos(-1.0);
constexpr double EPS = 1e-10;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
template <typename T, typename U>
constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept
{
  os << p.first << " " << p.second;
  return os;
}
#pragma endregion

void solve()
{
  ll a;
  cin >> a;
  double b;
  cin >> b;
  ll c = (ll)round(b * 100.0);
  cout << a * c / 100 << endl;
}

int main()
{
  init_main();

  solve();

  return 0;
}

Measured memory_bytes: 3792
import math
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N, K = list(map(int, sys.stdin.buffer.readline().split()))

# 全部 K の倍数
ans = (N // K) ** 3
# 偶数ならKの半分でもOK
if K % 2 == 0:
    ans += math.ceil((N // (K // 2)) / 2) ** 3
print(int(ans))


Measured memory_bytes: 3060
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
//#include <unordered_map>
//#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()

//typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18; // segment tree size
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f; // memset(dp, 0x3f, sizeof(dp)), 2*INF < INT_MAX
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10; // double EPS

int in1[200050];
int in2[200050];

int N;
int u1[200050];
int u2[200050];
ll getcnt(int mx) {
	int p2 = N;

	ll rv = 0;
	for (int i = 1; i <= N; i++) {
		while (p2) {
			if (u1[i] + u2[p2] < mx) break;
			p2--;
		}
		rv += p2;
	}
	return rv;
}
int main() {
	int i, j, k;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &in1[i]);
	for (i = 1; i <= N; i++) scanf("%d", &in2[i]);

	int ans = 0;
	for (i = 0; i < 29; i++) {
		for (j = 1; j <= N; j++) u1[j] = in1[j] & ((1 << (i + 1)) - 1);
		for (j = 1; j <= N; j++) u2[j] = in2[j] & ((1 << (i + 1)) - 1);

		sort(u1 + 1, u1 + N + 1);
		sort(u2 + 1, u2 + N + 1);

		ll c = getcnt(4 << i) - getcnt(3 << i) + getcnt(2 << i) - getcnt(1 << i);
		if (c % 2 == 1) ans += 1 << i;
	}
	return !printf("%d\n", ans);
}

Measured memory_bytes: 3328
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <numeric>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>
#include <cctype>
#include <string>

int main() {
	int n; std::cin >> n;
	std::vector<std::vector<std::pair<int, int>>> nodes(n);
	for (auto i = 1; i < n; ++i) {
		int u, v, w; std::cin >> u >> v >> w; --u; --v;
		nodes[u].emplace_back(v, w);
		nodes[v].emplace_back(u, w);
	}
	std::vector<int> color(n, -1); color[0] = 0;
	std::stack<int> stack; stack.push(0);
	while (!stack.empty()) {
		const auto top = stack.top(); stack.pop();
		for (const auto pair : nodes[top]) if (color[pair.first] == -1) {
			color[pair.first] = (pair.second & 1) == 0 ? color[top] : 1 - color[top];
			stack.push(pair.first);
		}
	}
	for (const auto c : color) std::cout << c << '\n';
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,W;
    cin >> n >> W;
    vector<ll> v(n);
    vector<ll> w(n);
    for(i = 0;i < n;++i){
        cin >> v.at(i) >> w.at(i);
    }
    ll INF = 1e14;
    ll V_MAX = 1e4;
    vector<vector<ll>> dp(n+1,vector<ll>(V_MAX+1,INF));
    dp.at(0).at(0) = 0;
    for(i = 1;i <= n;++i){
        rep(j, V_MAX+1){
            if(j < v.at(i-1)) dp.at(i).at(j) = dp.at(i-1).at(j);
            else dp.at(i).at(j) = min(dp.at(i-1).at(j), dp.at(i-1).at(j - v.at(i-1)) + w.at(i-1));
        }
    }
    for(i = V_MAX;i >= 0;--i){
        if(dp.at(n).at(i) <= W){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 10816