akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>
#include <string.h>
#include <cctype>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

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

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long gcd(long long a, long long b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	return a.second < b.second;
}
vector<vector<int>> dd;

int main()
{
	int a, p;
	cin >> a >> p;
	cout << ((3 * a + p) / 2);
}



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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

using namespace std;

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

    int temp, counter = 0;
    while(cin >> temp){
    	if(temp != 0)
    		counter++;
    	else{
    		cout << counter + 1;
    		return 0;
    	}
    }
    
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  int n, m;
  map<string, int> map;
  cin >> n;
  REP(i, n)
  {
    string s;
    cin >> s;
    map[s]++;
  }
  cin >> m;
  REP(i, m)
  {
    string s;
    cin >> s;
    map[s]--;
  }

  int ans = 0;
  for (auto v : map)
  {
    ans = max(ans, v.second);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
  int n;
  cin >> n;
  cout << 800 * n - n / 15 * 200 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;

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


int main() {
	int n;
	cin >> n;
	int a[n], b[n], c[n];

	

	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
	}
	rep(i, n) {
		cin >> c[i];
	}


	sort(&a[0], &a[n]);
	sort(&b[0], &b[n]);
	sort(&c[0], &c[n]);

	int ca = 0;
	int cc = 0;
	ll total = 0;
	rep(i, n) {
		auto ca = lower_bound(&a[0], &a[n], b[i]);
		auto cc = upper_bound(&c[0], &c[n], b[i]);
		total += (ll) (ca - &a[0]) * (ll) (n - (cc - &c[0])); 
		//cout << "i:" << i << " ca:" << ca << " cc:" << cc << endl; 
	}


	cout << total << endl;

	return 0;
}

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

vector<pair<ll, int>> factorize(ll n) {
    vector<pair<ll, int>> res;
    for(ll i = 2; i*i <= n; i++) {
        if (n%i != 0) continue;
        res.emplace_back(i,0);
        while (n%i == 0) {
            n/=i;
            res.back().second++;
        }
    }
    if (n!=1) res.emplace_back(n,1);
    return res;
}

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

    map<ll, int> mp;
    for (int i=1; i<=n; i++) {
        auto fact  =factorize(i);
        for (auto p : fact) {
            mp[p.first] += p.second;
        }
    }

    int over3 = 0;
    int over5 = 0;
    int over15 = 0;
    int over25 = 0;
    int over75 = 0;

    for(auto v : mp) {
        int x = v.second+1;
        if (x>=3) over3++;
        if (x>=5) over5++;
        if (x>=15) over15++;
        if (x>=25) over25++;
        if (x>=75) over75++;        
    }

    ll ans = 0;
    // 75
    ans += over75;
    // 25 * 3
    ans += over25 * max(0, (over3-1));
    // 15 * 5
    ans += over15 * max(0, (over5-1));
    // 5 * 5 * 3
    ans += over5*(over5-1)/2 * max(0, (over3-2));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;

int main(){
  int k;
  cin >> k;
  int a,b;
  cin >> a >> b;
  int A,B;
  A=a%k;
  B=b%k;
  a/=k;
  b/=k;
  
  if(A==0 || B==0 || b-a>=1) cout << "OK" << endl;
  else cout << "NG" << endl;
  
}
  
  


Measured memory_bytes: 3632
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		new Main().run();
	}

	private void run() throws NumberFormatException, IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		Node[] nodes = new Node[n];
		for (int i = 0; i < n; i++) {
			nodes[i] = new Node();
		}
		for (int i = 0; i < n; i++) {
			int v = scanner.nextInt();
			int l = scanner.nextInt();
			int r = scanner.nextInt();
			nodes[v].left = l;
			nodes[v].right = r;
			if (l != -1)
				nodes[l].parent = v;
			if (r != -1)
				nodes[r].parent = v;
		}
		int root = 0;
		for (int i = 0; i < n; i++) {
			if (nodes[i].parent == -1) {
				root = i;
				break;
			}
		}
		setDepth(root, 0, nodes);
		setHeight(root, nodes);
		for (int i = 0; i < n; i++) {
			print(i, nodes);
		}
	}

	private void print(int u, Node[] nodes) {
		System.out.printf("node %d: parent = %d, sibling = %d, ", u,
				nodes[u].parent, getSibling(u, nodes));
		int deg = 0;
		if (nodes[u].left != -1)
			deg++;
		if (nodes[u].right != -1)
			deg++;
		System.out.printf("degree = %d, depth = %d, height = %d, ", deg,
				nodes[u].d, nodes[u].h);
		if (nodes[u].parent == -1)
			System.out.println("root");
		else if (nodes[u].left == -1 && nodes[u].right == -1)
			System.out.println("leaf");
		else
			System.out.println("internal node");
	}

	private int getSibling(int u, Node[] nodes) {
		int p = nodes[u].parent;
		if (nodes[u].parent == -1)
			return -1;
		if (nodes[p].left != u && nodes[p].left != -1)
			return nodes[p].left;
		if (nodes[p].right != u && nodes[p].right != -1)
			return nodes[p].right;
		return -1;
	}

	private void setHeight(int u, Node[] nodes) {
		Deque<Integer> deque = new ArrayDeque<Integer>();
		deque.push(u);
		while (!deque.isEmpty()) {

			int c = deque.peek();
			int l = nodes[c].left;
			int r = nodes[c].right;
			if (l != -1 && nodes[l].h == -1) {
				deque.push(l);
				continue;
			}
			if (r != -1 && nodes[r].h == -1) {
				deque.push(r);
				continue;
			}
			int h1 = 0;
			int h2 = 0;
			if (l != -1)
				h1 = nodes[l].h + 1;
			if (r != -1)
				h2 = nodes[r].h + 1;
			nodes[c].h = Math.max(h1, h2);
			deque.poll();
		}
	}

	private void setDepth(int u, int d, Node[] nodes) {
		Deque<Integer> deque = new ArrayDeque<Integer>();
		deque.offer(u);
		while (!deque.isEmpty()) {
			int size = deque.size();
			for (int i = 0; i < size; i++) {
				int c = deque.poll();
				nodes[c].d = d;
				Node node = nodes[c];
				if (node.left != -1)
					deque.offer(node.left);
				if (node.right != -1)
					deque.offer(node.right);
			}
			d++;
		}
	}

	class Node {
		int parent = -1;
		int left = -1;
		int right = -1;
		int d;
		int h = -1;
	}
}

Measured memory_bytes: 19512
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
 
    int n;
    scanf("%d",&n);
 
    int c = n,sum = 0;
    while(c){sum+=c%10; c/=10;}
    if(!(n%sum))printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::Ordering::{Equal, Greater, Less};
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;

// make-them-even.rs --- Make Them Even
// author: Seong Yong-ju <sei40kr@gmail.com>

// tanakah's input macro
// cf https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        h: usize,
        w: usize,
        data: [[i32; w]; h],
    };

    let mut memo = data;
    let mut ops = Vec::<(usize, usize, usize, usize)>::with_capacity(h * (w - 1) + h - 1);

    for i in 0..h {
        for j in 0..(w - 1) {
            if memo[i][j] % 2 == 1 {
                memo[i][j] -= 1;
                memo[i][j + 1] += 1;
                ops.push((i + 1, j + 1, i + 1, j + 2));
            }
        }
    }
    for i in 0..(h - 1) {
        if memo[i][w - 1] % 2 == 1 {
            memo[i][w - 1] -= 1;
            memo[i + 1][w - 1] += 1;
            ops.push((i + 1, w, i + 2, w));
        }
    }

    println!("{}", ops.len());
    for (y1, x1, y2, x2) in ops {
        println!("{} {} {} {}", y1, x1, y2, x2);
    }
}


Measured memory_bytes: 10236
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for (int &x : p) {
    cin >> x;
  }
  sort(p.begin(), p.end());
  int ans = 0;
  for (int i = 0; i < k; ++i) {
    ans += p.at(i);
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  int N;
  vector<int> d(100010);

  cin >> N;
  for(int i=0; i<N; i++) cin >> d[i];

  sort(d.begin(), d.begin()+N);

  cout << d[N/2] - d[N/2-1] << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
    public static void main(String[] arg){
        int a, b, c, i, n;
        n = 0;
        Scanner scan = new Scanner(System.in);
        a = scan.nextInt();
        b = scan.nextInt();
        c = scan.nextInt();
        for(i = a; i <= b; i++){
            if(c % i == 0) n++;
        }
        System.out.println(n);
        scan.close();
    }
}


Measured memory_bytes: 26248
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Prison
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);

  int ll = 0, rr = n;

  for (int i = 0; i < m; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    l--;
    if (ll < l) ll = l;
    if (rr > r) rr = r;
  }

  printf("%d\n", (rr > ll) ? rr - ll : 0);
  return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                ans += 1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <numeric> //lcm


#define ERROR() cout << "ERROR!!" << endl; return 0;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1000000000; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

inline bool maxch(int& a, int b) { if (a < b) { a = b; return true; } else return false; }

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

	if (a+b == 0) { cout << 0 << endl; return 0;}

	ll c = n / (a+b);
	if (n % (a + b) >= a) {
		cout << (c+1)*a << endl;
	}
	else {
		cout << c*a + n % (a+b) << endl;

	}
	
}




Measured memory_bytes: 256
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=broadcast(parseInt,x)

function main()
	n,m = readline() |> split |> parseMap
	dp = (10^9)*ones(Int,m+1,2^n)
	dp[1,1] = 0
	for i in 1:m
		a,b = readline() |> split |> parseMap
		c = readline() |> split |> parseMap
		d = 0
		for j in 1:b
			d += 2^(c[j]-1)
		end
		for j in 1:2^n
			dp[i+1,j] = dp[i,j]
		end
		for j in 1:2^n
			dp[i+1,((j-1)|d)+1] = min(dp[i+1,((j-1)|d)+1],dp[i,j]+a)
		end
	end
	if dp[m+1,2^n] == 10^9
		println(-1)
	else
		println(dp[m+1,2^n])
	end
end
main()

Measured memory_bytes: 178928
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  string a,b,c;
  cin >> a>>b;
  c=a+b;
  int d = stoi(c);
  
  vector<int> p={};
  repo(i,320){
  p.pb(i*i);
  }
  
  for(int x : p){
    if(x==d) {
    cout << "Yes" << endl;
    return 0;
    } 
  }
  
  cout << "No" << endl;
  
}

Measured memory_bytes: 256
N,K = map(int,input().split())
A = list(map(int,input().split()))
S = sum(A)
ans = 1
C = []
for i in range(1,int(S**0.5+1)):
    if S%i == 0:
        C.append(i)
        C.append(S//i)
for c in C:
    B = []
    for i in A:
        B.append(i%c)
    B.sort()
    hoge = 0
    sum_b = sum(B)
    for i in range(N):
        hoge += B[i]
        sum_b -= B[i]
        if hoge <= K and hoge == c*(N-i-1)-sum_b:
            ans = max(ans,c)
print(ans)

Measured memory_bytes: 42332
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			int w = sc.nextInt();
			int h = sc.nextInt();
			int n = sc.nextInt();
			sc.nextLine();

			int left = 0;
			int right = w;
			int bottom = 0;
			int top = h;

			for (int i = 0; i < n; i++) {
				int x = sc.nextInt();
				int y = sc.nextInt();
				int a = sc.nextInt();
				sc.nextLine();

				if (a == 1) {
					if (left < x) left = x;
				} else if (a == 2) {
					if (right > x) right = x;
				} else if (a == 3) {
					if (bottom < y) bottom = y;
				} else if (a == 4) {
					if (top > y) top = y;
				}
			}

			if (right > left && top > bottom) {
				System.out.println((right - left) * (top - bottom));
			} else {
				System.out.println(0);
			}

		} finally {
			sc.close();
		}
	}
}

Measured memory_bytes: 23892
#include <iostream>
#include <stdio.h>
#include <iterator>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <unordered_map>
#include <iomanip>

using namespace std;

void solve() {
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    for(int i = 0; i < m; i++){
        cin >> b[i];
    }
    vector<vector<int>> a(n, vector<int>(m));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }

    int count = 0;
    for(int i = 0; i < n; i++){
        int sum = 0;
        for(int j = 0; j < m; j++){
            sum += a[i][j]*b[j];
        }
        if(sum+c > 0) count++;
    }
    cout << count << endl;
}

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

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//
#include<cmath>
#include<iomanip>

using namespace std;

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

typedef long long ll;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0,-1,0}; //次に行くところ
int dx[] = {0,1,0,-1}; //s上に同じ

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

  int ans = INT_MAX;
  vector<int> a(3);

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

  for (int i = 0; i < 3; i++){
    for (int j = 0; j < 3; j++){
      for (int k = 0; k < 3; k++){
        int c = 0;
        if (i == j|| j == k || k == i){
          continue;
        }
        c += abs(a[j]-a[i]);
        c += abs(a[k]-a[j]);
        chmin(ans,c);
      }  
    }  
  }
  
  cout << ans << '\n';
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
  return 0;
}

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

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var x = Read().Decimal();
            long ans = 0;
            decimal m = 100;
            while (m < x)
            {
                m = Math.Floor(m * (decimal)(1.01));
                ans++;
            }
            WriteRead(ans);
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int Int(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long Long(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal Decimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double Double(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 17824
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <utility>
#include <unordered_set>
#include <math.h>
#include <set>
#include <queue>
using namespace std; 

typedef long long ll;

int main()  {  
    string s;
    cin >> s;
    for(int i = 0; i < 3; i++){
        if(s[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;  
}  

Measured memory_bytes: 3624
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <typeinfo>
#include <cmath>
#include <numeric>
#include <queue>
#include <set>
using namespace std;

int main(){
    int A, P;
    std::cin >> A >> P;
    int kakera;
    kakera = A*3 + P;
    std::cout << kakera/2 << "\n";
}

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

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

signed main(){
	fastio
	int n,x,t;
	cin >> n >> x >> t;
	cout << (n/x + (n%x ? 1 : 0)) * t << "\n";
}

Measured memory_bytes: 3648
#include <stdio.h>

typedef struct {
	int suuji;
	char name[10];
}Que;

int head, tail, samplesuu;
Que hairetu[100000];

void enqueue(Que x);
Que dequeue(void);


void enqueue(Que x) {

	hairetu[tail] = x;
	if (tail == samplesuu) {
		tail = 0;
	}
	else
		tail++;
}

Que dequeue(void) {
	Que x;
	x = hairetu[head];
	if (head  == samplesuu) {
		head = 0;
	}
	else
		head++;
	return x;
}

int main(void) {
	int quantum, time;
	time = 0;

	scanf("%d %d", &samplesuu, &quantum);

	for (int i = 0; i < samplesuu; i++) {
		scanf("%s", &hairetu[i].name, 100);
		scanf("%d", &hairetu[i].suuji);
	}

	head = 0;
	tail = samplesuu;

	Que hairetu2;
	

	while (head != tail) {
		hairetu2 = dequeue();
		if (hairetu2.suuji > quantum) {
			hairetu2.suuji -= quantum;
			time += quantum;
			enqueue(hairetu2);
		}
		else {
			time += hairetu2.suuji;
			printf("%s %d\n", hairetu2.name, time);
		}


	}
	return 0;
}





Measured memory_bytes: 2488
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    S=ST().replace("hi","")
    if(S):
        print("No")
    else:
        print("Yes")

if __name__ == '__main__':
    main()

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int k;
	cin>>k;
	vector<int>sum(8);
	int lunlun=0;
	if(k<10){
		cout<<k<<"\n"s;
	}else{
		for(int a=0;a<10;++a){
			for(int b=0;b<10;++b){
				sum.at(0)=a;
				if(sum.at(0)!=0&&abs(a-b)>1)continue;
				for(int c=0;c<10;++c){
					sum.at(1)=sum.at(0)+b;
					if(sum.at(1)!=0&&abs(b-c)>1)continue;
					for(int d=0;d<10;++d){
						sum.at(2)=sum.at(1)+c;
						if(sum.at(2)!=0&&abs(c-d)>1)continue;
						for(int e=0;e<10;++e){
							sum.at(3)=sum.at(2)+d;
							if(sum.at(3)!=0&&abs(d-e)>1)continue;
							for(int f=0;f<10;++f){
								sum.at(4)=sum.at(3)+e;
								if(sum.at(4)!=0&&abs(e-f)>1)continue;
								for(int g=0;g<10;++g){
									sum.at(5)=sum.at(4)+f;
									if(sum.at(5)!=0&&abs(f-g)>1)continue;
									for(int h=0;h<10;++h){
										sum.at(6)=sum.at(5)+g;
										if(sum.at(6)!=0&&abs(g-h)>1)continue;
										for(int i=0;i<10;++i){
											sum.at(7)=sum.at(6)+h;
											if(sum.at(7)!=0&&abs(h-i)>1)continue;
											for(int j=0;j<10;++j){
												if(abs(i-j)<=1)++lunlun;
												if(k==lunlun+7){
													string ans=to_string(a)+to_string(b)+to_string(c)+to_string(d)+to_string(e)+
																to_string(f)+to_string(g)+to_string(h)+to_string(i)+to_string(j);
													int cnt=0;
													while(ans.at(cnt)=='0')++cnt;
													for(;cnt<ans.size();++cnt)cout<<ans.at(cnt);
													cout<<"\n"s;
													return 0;
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
}

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

signed main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin>>n;
	int sa=0, sb=0, sc=0;
	for(int day=1; day<=n; ++day)
	{
		int a,b,c, ta, tb, tc;
		cin>>a>>b>>c;

		ta = max(sb+a, sc+a);
		tb = max(sa+b, sc+b);
		tc = max(sa+c, sb+c);
		sa=ta, sb=tb, sc=tc;
	}
	cout<<max(max(sa, sb), sc);
	return 0;	
}

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

int main(){
	string s;
	while(getline(cin, s)){
		if(s==".") break;
		stack<int> st;
		bool ans=true;
		
		while(!st.empty()) st.pop();
		
		for(int i=0; i<s.size(); ++i){
			if(s[i]=='(') st.push(1);	
			else if(s[i]=='[') st.push(2);
			
			if(s[i]==')'){
				if(st.empty()) ans=false;
				else{
					int ch=st.top();
					st.pop();
					if(ch!=1) ans=false;
				}	
			}
			else if(s[i]==']'){
				if(st.empty()) ans=false;
				else{
					int ch=st.top();
					st.pop();
					if(ch!=2) ans=false;	
				}	
			}
			
			if(!ans) break;
		}
		
		if(!st.empty()) ans=false;
		if(s[s.size()-1] != '.') ans=false;
		
		if(ans) printf("yes\n");
		else printf("no\n");
	}
	return 0;
}

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


def main():
  N = int(input())
  counts = [0] * N

  for b in map(int, input().split()):
    counts[b - 1] += 1

  for c in counts:
    print(c)


if __name__ == '__main__':
  main()


Measured memory_bytes: 92576
tree = [ [] for _ in range(4) ]

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

for i in range(4):
    visited = [ False for _ in range(4) ]
    cur = i
    visited[cur] = True
    for j in range(3):
        for v in tree[cur]:
            if not visited[v]:
                next_v = v
                break
        visited[next_v] = True
        cur = next_v

    if all(visited):
        print ("YES")
        exit()

print("NO")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long; 
int main(){
  string a;
  cin>>a;
  ll b=0;
  if(a=="RRR"){
    cout<<3<<endl;
  }
  else if(a=="RRS"||a=="SRR"){
    cout<<2<<endl;
  }
  else if(a=="SSS"){
          cout<<0<<endl;
  }
  else{
    cout<<1<<endl;
  }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
  
using namespace std;
  
int segMin[1 << 20], segAdd[1 << 20];
int n, q;
char s[300001];
  
void add(int a, int b, int x, int k = 0, int l = 0, int r = n)
{
    if (r <= a || b <= l) return;
      
    if (a <= l && r <= b){
        segAdd[k] += x;
        return;
    }
      
    add(a, b, x, k * 2 + 1, l, (l + r) / 2);
    add(a, b, x, k * 2 + 2, (l + r) / 2, r);
    segMin[k] = min(segMin[k * 2 + 1] + segAdd[k * 2 + 1], segMin[k * 2 + 2] + segAdd[k * 2 + 2]);
}
  
int getMin(int a, int b, int k = 0, int l = 0, int r = n)
{
    if (r <= a || b <= l) return (INT_MAX);
      
    if (a <= l && r <= b) return (segMin[k] + segAdd[k]);
      
    int left = getMin(a, b, k * 2 + 1, l, (l + r) / 2);
    int right = getMin(a, b, k * 2 + 2, (l + r) / 2, r);
      
    return (min(left, right) + segAdd[k]);
      
}
  
void fix(set<int> *a, set<int> *b, char before, int x)
{
    a->erase(x);
    b->insert(x);
      
    int base = before == '(' ? -1 : 1;
    s[x] = before == '(' ? ')' : '(';
      
    add(x, n, 2 * base);
      
    int l = 0, r = x;
    int p;
      
    while (l != r){
        int mid = l + r >> 1;
        p = *b->lower_bound(mid);
        if (getMin(p, n) >= 2 * base) r = mid;
        else l = mid + 1;
    }
      
    p = *b->lower_bound(l);
    add(p, n, -2 * base);
    b->erase(p);
    a->insert(p);
    s[p] = before;
      
    printf("%d\n", p + 1);
}
  
int main()
{
    scanf("%d %d", &n, &q);
    scanf("%s", s);
      
    set<int> lf, rg;
      
    for (int i = 0; s[i]; i++){
        if (s[i] == '('){
            add(i, n, 1);
            lf.insert(i);
        }
        else {
            add(i, n, -1);
            rg.insert(i);
        }
    }
      
    for (int i = 0; i < q; i++){
        int x;
        scanf("%d", &x); x--;
          
        if (s[x] == '(') fix(&lf, &rg, '(', x);
        else fix(&rg, &lf, ')', x);
    }
      
    return (0);
}

Measured memory_bytes: 23440
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
Y = 0
su = 0
i = 1
while su < N:
    su += i
    i += 1
    Y = i
i = 0
sa = su - N
for i in range(1, Y):
    if i == sa:
        continue
    print(i)


Measured memory_bytes: 9960
#include <bits/stdc++.h>
using namespace std;
int main(){
    int w,h,n;
    cin>>w>>h>>n;
    int x[n],y[n],a[n];
    int ak[w][h];
    int kai=0;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i]>>a[i];
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            ak[j][i]=0;
        }
    }
    for(int i=0;i<n;i++){
        if(a[i]==1){
           for(int k=0;k<h;k++){
               for(int j=0;j<x[i];j++){
                   ak[j][k]=1;
               }
           }
        }
        else if(a[i]==2){
           for(int k=0;k<h;k++){
               for(int j=x[i];j<w;j++){
                   ak[j][k]=1;
               }
           }
        }
        else if(a[i]==3){
           for(int k=0;k<y[i];k++){
               for(int j=0;j<w;j++){
                   ak[j][k]=1;
               }
           }
        }
        else{
            for(int k=y[i];k<h;k++){
                for(int j=0;j<w;j++){
                    ak[j][k]=1;
                }
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(ak[j][i]==0){
                kai++;
            }
        }
    }
    cout<<kai<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#define LL long long
using namespace std;

LL k;
LL ans[100];

int main(){
	scanf("%lld",&k);
	LL i;
	LL t1=k/50;
	LL t2=k%50;
	for(i=1;i<=50;i++){
		ans[i]=i+t1-1;
	}
	for(i=50;i>=1 && t2;i--,t2--)
		ans[i]++;
	puts("50");
	for(i=1;i<=50;i++)
		printf("%lld ",ans[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
//using P = pair<int,int>;
//pow(x,n)
//cout << fixed << setprecision(桁数);
//string = to_string(数値)
//int = stoi(文字列)
//(int)(char-'0')
//string = itoa(int)
//円周率: M_PI


int main() {
    int k; cin>>k;
    string s; cin>>s;
    if(s.size()<=k) cout<<s<<endl;
    else{
        rep(i,k) cout<<s[i];
        cout<<"..."<<endl;
    }
}


Measured memory_bytes: 3628
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []
    did = {}
    did['N'] = 0
    did['E'] = 1
    did['S'] = 2
    did['W'] = 3

    while True:
        h,w,l = LI()
        if h == 0:
            break

        a = [[c for c in S()] for _ in range(h)]
        s = None
        for i in range(h):
            for j in range(w):
                if a[i][j] in 'NEWS':
                    s = (i,j,did[a[i][j]])
                    break

        i = 0
        t = s
        td = {}
        tt = 0
        i,j,dk = t
        while tt < l:
            tt += 1
            for ddi in range(4):
                di,dj = dd[(dk+ddi) % 4]
                ni = i + di
                nj = j + dj
                if ni < 0 or ni >= h or nj < 0 or nj >= w or a[ni][nj] == '#':
                    continue
                dk = (dk + ddi) % 4
                i = ni
                j = nj
                break
            if (i,j,dk) in td:
                tt += (l-tt) // (tt - td[(i,j,dk)]) * (tt - td[(i,j,dk)])
            else:
                td[(i,j,dk)] = tt
        rr.append('{} {} {}'.format(i+1,j+1,'NESW'[dk]))

    return '\n'.join(map(str,rr))



print(main())



Measured memory_bytes: 9704
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define INF (long)1e9
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, h;
	cin >> a >> b >> h;
	cout << (a+b) * h / 2 << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
 
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int ans=0;
	// while(!((a<=0) || (b<=0))){
	// 	ans++;
	// 	//cout<<a<<" "<<c<<endl;
	// 	if(ans%2 == 1)
	// 		c -= b;
	// 	else
	// 		a -= d;
	// }
	// if(a<=0){
	// 	cout<<"No"<<endl;
	// }
	// else if(b<=0){
	// 	//if(ans%2 == 1)
	// 		cout<<"No"<<endl;
	// 	// else
	// 	// 	cout<<"Yes"<<endl;
	// }

	int p = ceil(a/(float)d);
	int q = ceil(c/(float)b);

	if(q<=p)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  cin>>S;
  cout<<S[0]<<S.size()-2<<S[S.size()-1]<<endl;
}



Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a + b + c >= 22 ? "bust" : "win") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,a;
  cin>>n>>a;
	long long int arr[n+1];
  long long	int sum=0;
  for(int i=1;i<=n;i++)
  {
    cin>>arr[i];
    
  }
  sort(arr+1,arr+n+1);
  if(n<=a)
    cout<<"0"<<endl;
  else
  {
    for(int j=1;j<=n-a;j++)
      sum=sum+arr[j];
    
    cout<<sum<<endl;
  }


}

Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
int r,d;
  scanf("%d%d",&r,&d);
  int x[11];
  scanf("%d",&x[0]);
  for(int i=1;i<11;i++){
	x[i]=r*x[i-1]-d;
    printf("%d\n",x[i]);
  }
  return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
import sys


def solve(X: int, Y: int, A: int, B: int, C: int, p: "List[int]", q: "List[int]", r: "List[int]"):
    sp = list(reversed(sorted(p)))
    sq = list(reversed(sorted(q)))
    sr = list(sorted(r))
    # print(X)
    # print(Y)
    spi = sp[:X]
    sqi = sq[:Y]
    # print(spi)
    # print(sqi)
    # print(sr)
    rIndex = len(sr)-1
    pIndex = len(spi)-1
    qIndex = len(sqi)-1
    while rIndex >= 0:
        if (pIndex < 0 or sr[rIndex] < spi[pIndex]) and (qIndex < 0 or sr[rIndex] < sqi[qIndex]):
            break
        if pIndex < 0:
            sqi[qIndex] = sr[rIndex]
            qIndex-=1
            rIndex-=1
            continue
        if qIndex < 0:
            spi[pIndex] = sr[rIndex]
            pIndex-=1
            rIndex-=1
            continue
        if sr[rIndex] - spi[pIndex] > sr[rIndex] - sqi[qIndex]:
            spi[pIndex] = sr[rIndex]
            pIndex-=1
        else:
            sqi[qIndex] = sr[rIndex]
            qIndex-=1
        rIndex-=1
    print(sum(spi)+sum(sqi))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(A)]  # type: "List[int]"
    q = [int(next(tokens)) for _ in range(B)]  # type: "List[int]"
    r = [int(next(tokens)) for _ in range(C)]  # type: "List[int]"
    solve(X, Y, A, B, C, p, q, r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 102560
#include<iostream>
#include<string>
#include <cstdlib>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include <assert.h>
#include<map>
#include<set>
#include<bitset>
#include <iomanip>
#include<stack>
#include <unordered_map>
#include<cmath>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define INF 0x7f7f7f7f //2139062143
#define INF1 0x3f3f3f3f //1061109567
#define INF2 2147483647
#define llINF 9223372036854775807
#define pi 3.14159265358979323846264338327950254
#define pb push_back
#define ll long long
#define debug cout << "debug\n";
#define STDIN freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);
#define scai(x) scanf("%d", &x)
#define sca2i(x, y) scanf("%d %d", &x, &y)
#define scaf(x) scanf("%lf", &x)
#define sca2f(x, y) scanf("%lf %lf", &x, &y)
#define For(m,n) for (int i = m;  i < n; i++)
#define PII pair<int,int>
#define PLL pair<long, long>
#define ft first
#define sd second
#define pb push_back
const int maxn=333333,mod=1000000009;
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
inline int read(){char ch=getchar();int x=0,f=0;while(ch<'0'||ch>'9')f|=ch=='-',ch=getchar();while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();return f?-x:x;} 
const int N = 2e5 + 10;
int a[N];

int main()
{
    // STDIN
    unordered_map<int, int> umap;
    int n; cin >>n;
    ll cnt = 0;
    for (int i = 1; i <= n; i++)
    {
        int t; cin >> t;
        int y = i - t;
        cnt += umap[y];
        umap[t+i] += 1;
    }
    cout << cnt <<endl;
}

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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 998244353;
const int N = 1e6+5;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int ans = 1;
    int dp[c+1][d+1];
    memset(dp, 0, sizeof(dp));
    dp[a][b]=1;
    for(int i=a;i<=c;i++) {
        for(int j=b;j<=d;j++) {
            if(i==a && j==b)
                continue;
            dp[i][j]=(dp[i-1][j]*j+dp[i][j-1]*i-dp[i-1][j-1]*(i-1)*(j-1))%MOD;//-dp[i][j-1]*(i-1);
            dp[i][j]+=MOD;
            dp[i][j]%=MOD;
        }
    }
    // cout<<dp[1][2]<<" "<<dp[2][1]<<"\n";
    cout<<dp[c][d];

    return 0;
}


Measured memory_bytes: 73940
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S.size()
using namespace std;
typedef unsigned long long ll;

int main(void){
	ll n, m;
	cin >> n >> m;
	ll a[n], b[n];
	vector<pair<ll, ll>> shops(n);
	rep(i, n) {
		cin >> a[i] >> b[i];
		shops[i] = make_pair(a[i], b[i]);
	}
	SORT(shops);
	ll sum = 0;
	ll cnt = 0;
	rep(i, n){
		if(shops[i].second + cnt <= m){
			sum += (ll) shops[i].first * shops[i].second;
			cnt += shops[i].second;
		}
		else {
			sum += (ll) shops[i].first * (m - cnt);
			break;
		}
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 3328
from collections import deque


n, k = map(int, input().split())
a = [int(i) - 1 for i in input().split()]

total = 0
s = [0] * (n + 1)
for i in range(n):
    total += a[i]
    s[i+1] = total % k

queue = deque()
mp = {}

ans = 0
for j in range(n+1):
    rem = s[j]
    queue.append(rem)
    if rem in mp:
        ans += mp[rem]
        mp[rem] += 1
    else:
        mp[rem] = 1
    
    if len(queue) == k:
        mp[queue.popleft()] -= 1

print(ans)

Measured memory_bytes: 41224
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S; cin >> S;
    int a = (S[0] - '0') * 10 + (S[1] - '0');
    int b = (S[2] - '0') * 10 + (S[3] - '0');
    int ta = 1 <= a && a <= 12;
    int tb = 1 <= b && b <= 12;
    if (ta == 1 && tb == 0) cout << "MMYY\n";
    else if (ta == 0 && tb == 1) cout << "YYMM\n";
    else if (ta == 1 && tb == 1) cout << "AMBIGUOUS\n";
    else cout << "NA\n";
    return 0;
}

Measured memory_bytes: 256