akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int N, M, K;


const int MAX_N = 200000;

ll fact[MAX_N+100];
ll frev[MAX_N+100];

ll rev(ll a, ll p){
    if(p == 0) return 1;
    ll tmp = rev(a, p/2);
    tmp = tmp * tmp % MOD;
    if(p % 2 == 1) tmp = tmp * a % MOD;
    return tmp;
}


void calc_fact(){
    fact[0] = frev[0] = 1;
    for(int i = 1; i <= MAX_N; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        frev[i] = rev(fact[i], MOD-2);
    }
}


ll comb(int n, int k){
    if(n < 0 || k < 0 || n < k) return 0;
    if(n == 0 || k == 0) return 1;
    return fact[n] * frev[k] % MOD * frev[n-k] % MOD;
}

ll solve(ll n, ll m){
    ll ret = 0;
    for(ll d = 1; d < m; d++){
        ret += d*(m-d);
        ret %= MOD;
    }

    ret *= n*n;
    ret %= MOD;
    ret *= comb(n*m-2, K-2);
    ret %= MOD;
    return ret;
}

int main(){
    cin >> N >> M >> K;

    ll ans = 0;

    //in main function
    fact[0] = frev[0] = 1;
    for(int i = 1; i <= MAX_N; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        frev[i] = rev(fact[i], MOD-2);
    }

    ans += solve(N, M);
    //cout << ans << endl;
    ans += solve(M, N);

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


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

vector<vector<int>> s;
vector<int> c, t;
vector<pair<int, int>> last;
vector<int64_t> b_score;
vector<vector<int64_t>> c_score;

int64_t calc_score() {
    last.assign(26, {0, 0});
    for (auto i = 0; i < (int)t.size(); i++) {
        if(i != 0) {
            b_score[i] = b_score[i - 1];
            c_score[i] = c_score[i - 1];
        } else {
            b_score[i] = 0;
            c_score[i].assign(26, 0);
        }
        b_score[i] += s[i][t[i]];
        last[t[i]] = {i + 1, last[t[i]].first};
        for (auto j = 0; j < 26; j++) {
            c_score[i][j] -= c[j] * (i + 1 - last[j].first);
        }
    }

    int64_t ret = b_score.back();
    for (auto i = 0; i < 26; i++) ret += c_score[(int)t.size() - 1][i];
    return ret;
}

int64_t calc_score(pair<int, int>& q) {
    last.assign(26, {0, 0});
    for (auto i = 0; i < (int)t.size(); i++) {
        if(i != 0) {
            b_score[i] = b_score[i - 1];
            c_score[i][q.first] = c_score[i - 1][q.first];
            c_score[i][q.second] = c_score[i - 1][q.second];
        } else {
            b_score[i] = 0;
            c_score[i][q.first] = 0;
            c_score[i][q.second] = 0;
        }
        last[t[i]] = {i + 1, last[t[i]].first};
        b_score[i] += s[i][t[i]];
        c_score[i][q.first] -= c[q.first] * (i + 1 - last[q.first].first);
        c_score[i][q.second] -= c[q.second] * (i + 1 - last[q.second].first);
    }

    int64_t ret = b_score.back();
    for (auto i = 0; i < 26; i++) ret += c_score[(int)t.size() - 1][i];
    return ret;
}

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

    c.resize(26);
    for (auto i = 0; i < 26; i++) cin >> c[i];

    s.assign(d, vector<int>(26));
    for (auto i = 0; i < d; i++) {
        for (auto j = 0; j < 26; j++) cin >> s[i][j];
    }

    int64_t ans = 0;
    int index = 0;
    for (auto i = 0; i < d; i++) {
        t.resize(i + 1);
        for (auto j = 0; j < 26; j++) {
            t[i] = j;
            b_score.assign(t.size(), 0);
            c_score.assign(t.size(), vector<int64_t>(26, 0));
            auto tmp = calc_score();
            if(tmp > ans) {
                ans = tmp; index = j;
            }
        }
        t[i] = index;
    }

    for (auto i = 0; i < (int)t.size(); i++) cout << t[i] + 1 << endl;

    return 0;
}

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


ll gcd(ll a, ll b){
	return b == 0 ? a : gcd(b, a % b);
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);

	ll x, y;
	cin >> x >> y;
	ll lcm = x * y / gcd(x, y);
	if(lcm == x){
		cout << -1 << endl;
	}
	else{
		cout << x << endl;
	}
	
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

//#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}

int n, k, r, s, p,tot;
string t;

int main() {
	cin >> n >> k >> r >> s >> p >> t;
	rep(i, n) {
		if (i - k >= 0 && t[i] == t[i - k]) {
			t[i] = ' ';
			continue;
		}
		if (t[i] == 'r') {
			tot += p;
		}
		else if (t[i] == 's') {
			tot += r;
		}
		else if (t[i] == 'p') {
			tot += s;
		}
	}
	cout << tot << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

char mp[111][111];
ll dp[2][111][111];
ll h, w;

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

	cin >> h >> w;
	REP(i, h){
		REP(j, w)cin >> mp[i][j];
	}

	REP(seica, 2)REP(i, 111)REP(j, 111)dp[seica][i][j] = INF;

	if(mp[0][0] == '.')dp[0][0][0] = 0;
	else dp[1][0][0] = 1;

	REP(i, h){
		REP(j, w){
			REP(type, 2){
				if(dp[type][i][j] == INF)continue;

				//cout << type << " " << i << " " << j << endl;

				if(mp[i+1][j] == mp[i][j])dp[type][i+1][j] = min(dp[type][i+1][j], dp[type][i][j]);
				else dp[(type+1)%2][i+1][j] = min(dp[(type+1)%2][i+1][j], dp[type][i][j] + (type == 0));

				if(mp[i][j+1] == mp[i][j])dp[type][i][j+1] = min(dp[type][i][j+1], dp[type][i][j]);
				else dp[(type+1)%2][i][j+1] = min(dp[(type+1)%2][i][j+1], dp[type][i][j] + (type == 0));

			}
		}
	}

	cout << min(dp[0][h-1][w-1], dp[1][h-1][w-1]) << endl;

	//SHOW2d(dp[0], h, w);
	//SHOW2d(dp[1], h, w);

	return 0;
}


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


void solve(long long A, long long B){
  if (A >= 1 and A <= 9 and B >= 1 and B <= 9) {
      cout << A*B;
  } else {
      cout << -1;
  }
  cout << endl;
}

// 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)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

int main(void) {
	int num, i = 0, j, ans = 1;
	bool ok;
	cin >> num;
	vector<int> h(num);
	for (; i < num; i++)
		cin >> h[i];
	for (i = 1; i < num; i++) {
		ok = true;
		for (j = i - 1; j >= 0; j--) {
			if (h[i] < h[j]) {
				ok = false;
				break;
			}
		}
		if (ok)
			ans++;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a,b,t,cnt,x;
  scanf("%d%d%d",&a,&b,&t);
  cnt=0;
  x = 1;
  while(x*a < t+0.5){
    cnt += b;
    x ++;
  }
  printf("%d",cnt);
}
    


Measured memory_bytes: 128
N = int(input())
ans = [0]*(N+1)
f = lambda x, y, z: x**2 + y**2 + z**2 + x*y + y*z + z*x
root_N = int(N**0.5)

for x in range(1, root_N+1):
    for y in range(1, root_N+1):
        for z in range(1, root_N+1):
            i = f(x, y, z)
            if i <= N:
                ans[f(x, y, z)] += 1

print('\n'.join(map(str, ans[1:])))


Measured memory_bytes: 68948
import java.util.Scanner;

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

		String a = scn.next();
		String b = scn.next();
		String c = scn.next();

		char d = (char) (a.charAt(0) - 'a' + 'A');
		char e = (char) (b.charAt(0) - 'a' + 'A');
		char f = (char) (c.charAt(0) - 'a' + 'A');

		System.out.println("" + d+e+f);

		scn.close();
    }
}

Measured memory_bytes: 21716
N, A, B = list(map(int, input().split()))
S = input()
AP, BP = 0, 0
for s in S:
    if s == 'a':
        if (AP+BP) < (A+B):
            print('Yes')
            AP += 1
        else:
            print('No')
    elif s == 'b':
        if ((AP+BP) < (A+B)) and (BP < B):
            print('Yes')
            BP += 1
        else:
            print('No')
    else:
        print('No')

Measured memory_bytes: 9092
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  int N;
  cin >> N;
  ll ans = 0, count = 0;
  vi A(N);
  REP(i, N) cin >> A[i];

  sort(A.begin(), A.end(), greater());
  ans += A.at(0);
  count = 2;
  for (int i = 1; i < N && count < N; i++) {
    ans += A.at(i);
    count++;
    if (count == N) break;
    ans += A.at(i);
    count++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3964
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<complex>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
#define EPS (long double) 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};

int main(void) {
	while(1) {
		int d, e;
		cin>>d>>e;
		if(d == 0 && e == 0) break;
		long double res = INF;
		REP(i, d + 1) {
			int x = (int)i;
			int y = d - (int)i;
			res = min(res, (long double)abs(sqrt(x * x + y * y) - e));
		}
		cout<<fixed<<showpoint<<setprecision(13)<<res<<endl;
	}
}

Measured memory_bytes: 3216
#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#include <map>
#include <list>
//#include <bits/stdc++.h>


using namespace std;

#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
typedef long long ll;

int main(){
    string s,t;
    cin >> s >> t;
    if(s + t[t.size()-1] == t)cout << "Yes" <<  endl;
    else cout << "No" << endl;

    return 0;
}

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

using namespace std;

int main(){
  int n;
  int m;
  cin >> n >> m;
  
  vector<pair<long long, int>> ab(n);
  for(int i = 0; i < n; i++){
    long long a;
    int b;
    cin >> a >> b;
    ab[i] = make_pair(a, b);
  }
  sort(ab.begin(), ab.end());
  
  long long money = 0;
  for(int i = 0; i < n; i++){
    int buy = min(ab[i].second, m);
    money += ab[i].first * (long long)buy;
    m -= buy;
    if(m == 0){
      break;
    }
  }
  cout << money << endl;
  
  return 0;
}


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

// 解説聞いた後にコーディングした

int main(void)
{
    int n, m, i, j;
    cin >> n >> m;
    vector<int> x(m);
    vector<int> diff(m - 1);
    
    for (i = 0; i < m; i++) {
        cin >> x.at(i);
    }

    sort(x.begin(), x.end());

    for (i = 0; i < (m - 1); i++) {
        diff.at(i) = (x.at(i + 1) - x.at(i));
    }
    
    sort(diff.begin(), diff.end(), greater<int>() );

    for (i = 0; i < n - 1 && i < diff.size(); i++) {
        diff.at(i) = 0;
    }
    cout << accumulate(diff.begin(), diff.end(), 0) << endl;
        
    return 0;
}


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

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

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

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

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

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

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

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

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

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

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

fn main() {
    input! {
        n: usize,
        xys: [(i64, i64); n],
    }
    let mut distances = vec![];
    for &(x0, y0) in xys.iter() {
        for &(x1, y1) in xys.iter() {
            if x0 == x1 && y0 == y1 {
                continue;
            }
            let dsq = (x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0);
            let d = (dsq as f64).sqrt();
            distances.push(d);
        }
    }
    let avg = distances.iter().fold(0.0, |sum, x| sum + x) / n as f64;
    println!("{}", avg);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long a,v,b,w,t;
	cin>>a>>v>>b>>w>>t;
	if (llabs(a-b)<=t*(v-w))
		cout<<"YES";
	else
		cout<<"NO";
	return 0; 
}

Measured memory_bytes: 3652
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func strSprit(str string) []string {
	cols := strings.Split(str, "")
	return cols
}

func parseInt(str string) int {
	n, _ := strconv.Atoi(str)
	return n
}

func intSprit(str string) []int {
	strs := strSprit(str)
	cols := make([]int, len(strs))
	for i, v := range strs {
		cols[i] = parseInt(v)
	}
	return cols
}

type SortSlice []int

func (s SortSlice) Len() int {
	return len(s)
}

func (s SortSlice) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s SortSlice) Less(i, j int) bool {
	return s[i] < s[j]
}

func reverseString(str string) string {
	buf := []rune(str)
	for i, j := 0, len(buf)-1; i < j; i, j = i+1, j-1 {
		buf[i], buf[j] = buf[j], buf[i]
	}
	return string(buf)
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////

func main() {
	line := nextLine()
	spl := strSprit(line)

	for bit := 0; bit < (1 << 3); bit++ {
		tmpbit := bit
		sum := parseInt(spl[0])
		for i := 0; i < 3; i++ {
			if (1 & (tmpbit >> uint(i))) == 1 {
				sum += parseInt(spl[i+1])
			} else {
				sum -= parseInt(spl[i+1])
			}
		}
		if sum == 7 {
			fmt.Print(spl[0])
			for i := 0; i < 3; i++ {
				if (1 & (tmpbit >> uint(i))) == 1 {
					fmt.Print("+")
					fmt.Print(spl[i+1])
				} else {
					fmt.Print("-")
					fmt.Print(spl[i+1])
				}

			}
			fmt.Print("=7")
			fmt.Println()
			return
		}
	}

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb emplace_back
ll const  MOD =1000000007;
int main()
{
    ll n,total_candy;
    cin >>n>>total_candy;
    ll no_of_candies[n];
    for(int i=0;i<n;i++)
        cin >>no_of_candies[i];
    ll no_of_ways[n+1][total_candy+1];
    for(int i=0;i<=total_candy;i++)
    {
        no_of_ways[0][i]=0;
    }
    no_of_ways[0][0]=1;
    ll sum_no_of_ways[n+1][total_candy+1];

    for(int i=1;i<=n;i++)
    {
        sum_no_of_ways[i-1][0]=no_of_ways[i-1][0];
        for(int j=1;j<=total_candy;j++)
        {
            sum_no_of_ways[i-1][j]=(sum_no_of_ways[i-1][j-1]+no_of_ways[i-1][j])%MOD;
        }

        for(int candy=0;candy<=total_candy;candy++)
        {
            no_of_ways[i][candy]=sum_no_of_ways[i-1][candy];
            if(candy>no_of_candies[i-1])
            {
                no_of_ways[i][candy]=(no_of_ways[i][candy]+MOD-sum_no_of_ways[i-1][candy-no_of_candies[i-1]-1])%MOD;
            }
        }
    }
    // for(int i=0;i<=n;i++)
    // {
    //     for(int j=0;j<=total_candy;j++)
    //     {
    //         cout<<no_of_ways[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    cout<<no_of_ways[n][total_candy];
    
    




}

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

using namespace std;

long long A, B, C, D;

long long gcd (long long a, long long b)
{
    long long r;
    while (b)
        r = a % b, a = b, b = r;
    return a;
}

long long gcd (vector < long long > v)
{
    long long ans = *(v.begin ());
    for (auto it : v)
        ans = gcd (ans, it);
    return ans;
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

int tests;
scanf ("%d\n", &tests);
while (tests --)
{
    scanf ("%lld %lld %lld %lld", &A, &B, &C, &D);
    if (A < B || D < B)
    {
        printf ("No\n");
        continue;
    }
    if (C >= B - 1)
    {
        printf ("Yes\n");
        continue;
    }
    long long Q = D % B, x = A % B, d = gcd (Q, B);
    if (d == 0)
    {
        printf ("Yes\n");
        continue;
    }
    x += ((B - x - 1) / d) * d;
    if (x > C) printf ("No\n");
    else printf ("Yes\n");
}
return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int ar[n];
  int sum=0;
  for(int i=0;i<n;i++)
  {
    cin>>ar[i];
    if(i%2==0&& ar[i]%2!=0)
      sum=sum+1;
  }
  cout<<sum;
  return 0;
}
    

Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#define PI 3.14159265359

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

	int N,M;
	cin >> N >>  M;
	vector<pair<LL,int> > v;
	for(int i=0; i<N; i++){
		LL a,b;
		cin >> a >> b;
		v.push_back(MP(a,b));
	}
	sort(v.begin(), v.end());
	LL ans = 0;
	int nokori = M;
	for(int i=0; i<N; i++){
		if(nokori - v[i].second > 0){
			ans += v[i].first * v[i].second;
			nokori -= v[i].second;
		}
		else{
			ans += v[i].first * nokori;
			break;
		}
	}
	cout << ans << endl;

	return 0;
}

/*

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



return 0;
}
*/

Measured memory_bytes: 2420
#include <stdio.h>

void print(int A[], int N) {
    for (int k = 0; k < N; k++) {
        if (k > 0) {
            printf(" ");
        }
        printf("%d", A[k]);
    }
    printf("\n");
}

int main() {
    int N;
    scanf("%d", &N);
    int A[N];
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }
    print(A, N);

    for (int i = 1; i < N; i++) {
        int key = A[i];
        int j = i-1;
        while (j >= 0 && A[j] > key) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = key;
        print(A, N);
    }
}


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

int main() {
	int n, x;
	cin >> n >> x;
	vector<int>l(n);
	for (int i = 0; i < n; i++)cin >> l.at(i);
	ll ans = 1;
	ll pos = 0;
	for (int i = 0; i < n; i++) {
		pos += l.at(i);
		if (pos <= x)ans++;
		else break;
	}
	cout << ans << endl;
}

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

int main() {
  int k, x;
  cin>>k>>x;
  if (x-k+1 >= -1000000) {
    cout<<x-k+1;
  }
  for (int i=1; i<2*k-1; i++) {
    int tmp = x-k+i+1;
    if (tmp >= -1000000 && tmp<= 1000000) {
      cout<<" "<<x-k+i+1;
    }
  }
  cout<<endl;

}

Measured memory_bytes: 256
// agrawal117
//chahat agarwal
#include<bits/stdc++.h>  
#define mod 1000000007
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long int ll;
ll dp[300000];
ll arr[300000];
ll n=10;
ll MinimumNumIncreasingSubsequences() 
{ 
	multiset<ll> last; 

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

		multiset<ll>::iterator it = last.lower_bound(arr[i]); 

		if (it == last.begin()) 

			last.insert(arr[i]); 

		else { 
			it--; 

			last.erase(it); // erase the largest element smaller than arr[i] 
			last.insert(arr[i]); // and replace it with arr[i] 
		} 
	} 
	return last.size(); // our answer is the size of last 
} 
int main()
{
    cin>>n;
   
    for(int i=0;i<n;i++){
        ll a;
        cin>>a;
        arr[i]=a;
    }
    cout<<MinimumNumIncreasingSubsequences(); 
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout<<setprecision(10)<<fixed;
	int n;
	double v[55];
	cin>>n;
	REP(i, n){
		cin>>v[i];
	}
	sort(v, v+n);
	double ans=0;
	ans+=v[0]/(1ll<<(n-1));
	REP(i, n-1){
		// DEBUG(ans);
		ans+=v[i+1]/(1ll<<(n-1-i));
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>
inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    ll n,t,a;cin>>n>>t>>a;
    vector<ll> h(n);
    rep(i,n) cin>>h[i];

    ll ABS=INF,ans;
    rep(i,n){
        if(ABS>abs(1000*a-(1000*t-6*h[i]))){
            ans=i;
            ABS = abs(1000 * a - (1000 * t - 6 * h[i]));
        }
    }

    cout<<ans+1<<endl;

    return 0;
}

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

import sys


def input():
    return sys.stdin.readline()


def down_pleasure(c_list, day_num, contest_last_day):
    """その日の満足度低下を返す"""
    sum_down_pl = 0
    for i in range(26):
        sum_down_pl += c_list[i] * (day_num - contest_last_day[i])

    return sum_down_pl


def calc_pleasure(s_list, t_list, d, c_list, contest_last_day):
    pleasure = 0

    for day, t_num in zip(range(d), t_list):
        pleasure += s_list[day][t_num-1]
        contest_last_day[t_num-1] = day + 1
        pleasure -= down_pleasure(c_list, day+1, contest_last_day)
        print(pleasure)

    return pleasure






def resolve():
    d = int(input().rstrip())
    c_list = list(map(int, input().split()))
    s_list = [list(map(int, input().split())) for i in range(d)]
    t_list = []

    for i in range(d):
        t_list.append(int(input().rstrip()))

    contest_last_day = []
    for i in range(26):
        contest_last_day.append(0)

    pleasure = calc_pleasure(s_list, t_list, d, c_list, contest_last_day)




if __name__ == "__main__":
    resolve()



Measured memory_bytes: 67964
#include <iostream>
using namespace std;
int main()
{
	int n, m;
	cin >> n >> m;
	int  k[30][31];

	for (int i = 0; i < n; i++)
	{
		cin >> k[i][0];
		for (int j = 1; j <= k[i][0]; j++)
		{
			cin >> k[i][j];
			
		}
	}
	int foods=0;
	int mcounts[31];
	for (int i = 0; i <= 30; i++)
	{
		mcounts[i] = 0;
	}
	for (int t = 1; t <= m; t++)//食べ物を順番に　
	{
		for (int i = 0; i < n; i++)
			for (int j = 1; j <= k[i][0]; j++)
			{
				if (k[i][j] == t)
					mcounts[t]=mcounts[t]+1;
				
			}
	}
	for (int i = 1; i <= m; i++)
	{
		if (mcounts[i] == n)
			foods=foods +1;

	}

	cout << foods;
	



}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = sc.nextInt();
        int M = sc.nextInt();
        int C = sc.nextInt();

        int[] b = new int[M];
        for (int i = 0; i < M; i++) {
            b[i] = sc.nextInt();
        }
        int[][] values = new int[N][M];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < M; j++) {
                values[i][j] = sc.nextInt();
            }
        }

        int ans = 0;
        for (int i = 0; i < N; i++) {
            int sum = 0;
            for (int j = 0; j < M; j++) {
                sum += values[i][j] * b[j];
            }
            if (sum + C > 0) {
                ans++;
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()
 

int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << max(max(a*c,a*d),max(b*c,b*d)) << endl;
}

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

long long n;

long long a[1000000+50],b[1000000+50];

long long pre(long long x){
    return (x-1+n)%n;
}
long long nxt(long long x){
    return (x+1)%n;
}
int main(){
    ios::sync_with_stdio(false);
    
    cin>>n;
    for(long long i=0;i<n;i++){
        cin>>a[i];
    }
    priority_queue <pair <long long,long long> > pq;
    for(long long i=0;i<n;i++){
        cin>>b[i];
        if(b[i]>a[i])
        pq.push({b[i],i});
    }
    long long ans=0;
    bool poss=true;
    while(pq.empty()==0){
        auto frnt=pq.top();
        pq.pop();
        long long cur=frnt.second;
        long long pre=(cur-1+n)%n;
        long long nxt=(cur+1)%n;
        if(b[pre]+b[nxt]<b[cur]&&b[cur]>a[cur]){
            long long cnt=(b[cur]-a[cur])/(b[pre]+b[nxt]);
            ans+=cnt;
            b[cur]-=cnt*(b[pre]+b[nxt]);
            
            frnt.first=b[cur];

            if(cnt==0){
                poss=false;
                break;
            }

            if(b[cur]>a[cur]){
                pq.push(frnt);
            }

        }
        else{
            poss=false;
            break;
        }
        
    }

    // for(long long i=0;i<n;i++){
    //     if(a[i]!=b[i])poss=false;
    // }

    if(!poss){
        cout<<-1;
    }
    else{

        cout<<ans;
    }
    // cout<<"\n";
    // for(long long i=0;i<n;i++){
    //     cout<<b[i]<<" ";
    // }


    return 0;
}

Measured memory_bytes: 11632
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a=0,b=0,c=0,d=0,n=0,x,y;
    string s,s1,s2;
    VI m(n);
    cin >> n >> a >> b;

    if (n*a > b) cout << b << endl;
    else cout << n*a << endl;
    return 0;
} 

Measured memory_bytes: 256
n = int(input())
A = [int(x) for x in input().split()]
sum_start_plus = 0
sum_start_minus = 0
ans_start_plus = 0
ans_start_minus = 0
flag_start_plus = True
flag_start_minus = True

# プラス始まりの場合を計算する
for a in A:
    sum_start_plus += a
    if flag_start_plus:
        flag_start_plus = False
        if sum_start_plus > 0:
            continue
        else:
            ans_start_plus += abs(1 - sum_start_plus)
            sum_start_plus = 1
    else:
        flag_start_plus = True
        if sum_start_plus < 0:
            continue
        else:
            ans_start_plus += abs(-1 - sum_start_plus)
            sum_start_plus = -1

# マイナス始まりの場合を計算する
for a in A:
    sum_start_minus += a
    if flag_start_minus:
        flag_start_minus = False
        if sum_start_minus < 0:
            continue
        else:
            ans_start_minus += abs(-1 - sum_start_minus)
            sum_start_minus = -1
    else:
        flag_start_minus = True
        if sum_start_minus > 0:
            continue
        else:
            ans_start_minus += abs(1 - sum_start_minus)
            sum_start_minus = 1

print(min(ans_start_plus, ans_start_minus))

Measured memory_bytes: 14468
import numpy as np
N,M=map(int,input().split())
X=list(map(int,input().split()))
X=sorted(X)
Y=[X[i+1]-X[i] for i in range(M-1)]
ans=sum(Y)
Z=np.argsort(Y)[::-1]
N-=1
for z in Z:
  if N==0:
    break
  ans-=Y[z]
  N-=1
print(ans)

Measured memory_bytes: 23068
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
A_cnt = [0] * 100001
A_sum = 0

# 各数値の数を数えておく
for a in A:
    A_cnt[a]+=1
    # ついでに現時点の総和も出しておく
    A_sum+=a

for _ in range(Q):
    B, C = map(int, input().split())
    A_cnt[C] = A_cnt[C] + A_cnt[B]
    A_sum = A_sum + ((C-B) * A_cnt[B])
    A_cnt[B] = 0
    print(A_sum)


Measured memory_bytes: 20824
#include <bits/stdc++.h>
using namespace std;
int main() {
    
   int N;
   int L;
   cin >> N >> L;
   
   int un =0;
   int sa =1000000000;
   
   for(int i=1;i<N+1;i++){
       if(abs(L+i-1)<sa){
           un = i;
           sa = abs(L+i-1);
       }
   }
   
   int sum = 0;
   
   for(int i=1;i<N+1;i++){
       if(i==un) sum = sum+0;
       else sum = sum + (L+i-1);
   }
   
   cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c){
    return b / c - (a - 1) / c;
}

int main() {
    int n, min = 0, s = 0;
    cin >> n;
    vector<long> as(n);
    map<int, int> cnt;
    for (int i = 0; i < n; i++){
        cin >> as[i];
    }
    for (int i = 0; i < n; i++){
        cnt[as[i]/ 400]++;
        if (as[i] >= 3200){
            s++;
        }
    }
    for (int i = 0; i < 8; i++){
        if (cnt[i] > 0){
            min++;
        }
    }
    if (s == n){
        cout << 1 << " " << s << endl;
        return 0;
    }
    cout << min << " " << min + s << endl;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import defaultdict, Counter

dic = defaultdict(int)

h,w,n = li()

dhs = [-1,-1,-1, 0, 0, 0, 1, 1, 1]
dws = [-1, 0, 1,-1, 0, 1,-1, 0, 1]

for _ in range(n):
    r,c = li()
    for dh, dw in zip(dhs, dws):
        if 1 < r+dh < h and 1 < c+dw < w:
            dic[(r+dh, c+dw)] += 1
            
vals = Counter(dic.values())

for i in range(10):
    if i == 0:
        print((h-2)*(w-2) - sum(vals.values()))
    else:
        print(vals[i])

Measured memory_bytes: 166868
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> H(N);
  for_each(begin(H), end(H), [](auto& x) { cin >> x; });
  vector<vector<ll>> matrix(N);
  for (ll i = 0; i < M; i++) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    matrix[a].push_back(b);
    matrix[b].push_back(a);
  }
  ll count = 0;
  for (ll i = 0; i < N; i++) {
    auto x = matrix[i];
    if (x.size() == 0) {
      count++;
      continue;
    }
    ll height = H[i];
    if (all_of(begin(x), end(x), [&](auto value) { return height > H[value]; })) {
      count++;
    }
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 9772
n = int(input())

ashiba_list = list(map(int,input().split()))

dp = [0 for _ in range(n)]

for i,ashiba in enumerate(ashiba_list):
    if i==1:
        dp[i] = abs(ashiba_list[i]-ashiba_list[i-1])
    elif i>1:
        a = abs(ashiba_list[i]-ashiba_list[i-1])
        b = abs(ashiba_list[i]-ashiba_list[i-2])
        dp[i] += min(dp[i-1] + a, dp[i-2] + b)
print(dp[n-1])

Measured memory_bytes: 52720
#include <iostream>
#include <vector>
#include <cmath>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)

using namespace std;
typedef long long ll;

int main()
{
    ll k, x;
    vector <ll> ans(0);
    ll cnt = 0;
    cin >> k >> x;
    for (int i = x-k+1; i<x+k; i++) {
        ans.push_back(i);
    }
    for (auto p: ans) {
        cout << p << " ";
    }
    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  string ans = "Yes";
  if(N != 1){
  for(int j=N-1; j>0; j--){
    if(vec.at(j) >= vec.at(j-1)){
      continue;
    }
    else{
      vec.at(j-1)--;
      if(vec.at(j) < vec.at(j-1)){
        ans = "No";
        break;
      }
    }
  }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>

using namespace std;

template<class T> using lheap = priority_queue<T, vector<T>, greater<T>>;
template<class T> using rheap = priority_queue<T, vector<T>, less<T>>;

int main() {
  int n;
  cin >> n;
  vector<int> l(n), r(n);
  for (int i = 0; i < n; i++) {
    cin >> l[i] >> r[i];
  }
  long long ans = 0;
  for (int ii = 0; ii < 2; ii++) {
    lheap<pair<int, int>> lh;
    rheap<pair<int, int>> rh;
    vector<bool> used(n);
    for (int i = 0; i < n; i++) {
      lh.emplace(r[i], i);
      rh.emplace(l[i], i);
    }
    long long x = 0;
    long long total = 0;
    auto f = [&](int k, long long x) -> long long {
      if (x < l[k]) return l[k] - x;
      if (x > r[k]) return x - r[k];
      return 0;
    };
    auto g = [&](int k, long long x) -> long long {
      if (x < l[k]) return l[k];
      if (x > r[k]) return r[k];
      return x;
    };
    bool fst = true;
    while (!lh.empty() || !rh.empty()) {
      while (!lh.empty() && used[lh.top().second]) lh.pop();
      while (!rh.empty() && used[rh.top().second]) rh.pop();
      if (lh.empty() && rh.empty()) break;
      int xl = lh.top().second;
      int xr = rh.top().second;
      if (fst || f(xl, x) > f(xr, x)) {
        total += f(xl, x);
        x = g(xl, x);
        used[xl] = true;
      } else {
        total += f(xr, x);
        x = g(xr, x);
        used[xr] = true;
      }
      fst = false;
    }
    total += abs(x);
    for (int i = 0; i < n; i++) {
      long long tmpL = l[i];
      long long tmpR = r[i];
      l[i] = -tmpR;
      r[i] = -tmpL;
    }
    ans = max(ans, total);
  }
  cout << ans << endl;
}

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

int main() {
 int N, t = 0;
 cin >> N;
 vector<int> s(N);
 for (int i = 0; i < N; i++) {
   cin >> s.at(i);
 }
 for (int i = 0; i < N - 1; i++) {
   if (s.at(i + 1) + 1 < s.at(i)) {
     cout << "No" << endl;
     return 0;
    }
  }
  for(int i = 0; i < N - 1; i++) {
    if (s.at(i) < s.at(i + 1)) {
        t = 0;
    }
    else if (s.at(i) > s.at(i + 1)) {
        t += 1; 
    }  
    if (t == 2) {
      cout << "No" << endl;
      return 0;
    }
  } 
  cout << "Yes" << endl;
}


Measured memory_bytes: 640
import Data.Bool
import Data.List
import Data.Maybe
import Data.Vector.Generic ((!))
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM

main = interact $ sub . lines

sub (l1:l2:l3:ls) = sol v bs
  where
  v = V.fromListN 3 $ V.fromListN 3 . fmap (read::String->Int) . words <$> [l1,l2,l3]
  bs = fmap read $ tail ls :: [Int]

sol v bs = bool "No" "Yes" . bingo $ V.map (\u -> foldl' mark u bs) v

bingo v = V.any (V.all (==0)) v
  || any (\j -> V.all (\u -> u!j==0) v) [0..2]
  || all (\i -> v!i!i==0) [0..2]
  || all (\i -> v!i!(2-i)==0) [0..2]

mark u b = maybe u (\i -> V.modify (\w -> VM.write w i 0) u) $ V.findIndex (==b) u

Measured memory_bytes: 508
import bisect

n = int(input())
a = sorted(list(map(int, input().split())))
b = list(map(int, input().split()))
c = sorted(list(map(int, input().split())))
ans = 0

for i in range(n):
    mid = b[i]
    hi = bisect.bisect_left(a, mid)
    lo = n - bisect.bisect_right(c, mid)
    ans += hi * lo

print(ans)

Measured memory_bytes: 23744
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  char S[101], T[101];
  for(int i = 0;i < N; i++)cin >> S[i];
  for(int i = 0;i < N; i++)cin >> T[i];
  for(int i = 0;i < N; i++){
    cout << S[i] << T[i] ;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 764
lst=[0 for i in range(10000)]
for x in range(1,102):
    for y in range(1,101):
        for z in range(1,101):
            a=x**2+y**2+z**2+x*y+y*z+z*x
            if a<10001:
                lst[a-1]+=1
n=int(input())
for i in range(n):
    print(lst[i])

Measured memory_bytes: 69532
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define req(i, j, n) for(int i = j; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
 int a,b;
  cin>>a>>b;
  int aa=a;
  int bb=b;
  for(int i=1;i<=a-1;i++){
    bb=bb*10+b;}
  for(int i=1;i<=b-1;i++){
    aa=aa*10+a;}
  
  a=aa;
  b=bb;
  vector<int> vec{};
  vector<int> vec2{};
  
  while(a>=1){
    int p=a%10;
    vec.push_back(p);
    a/=10;}
  while(b>=1){
    int p=b%10;
    vec2.push_back(p);
    b/=10;}
    
  int az=vec.size();
  int bz=vec2.size();
  
  int res=-1;
  
  for(int i=1;i<=30;i++){
    if(az-i<0 && bz-i>=0){
      res=0;
      break;}
    if(az-i>=0 && bz-i<0){
      res=1;
      break;}
    if(az-i==-1 && bz-i==-1){
      res=0;
      break;}
    if(vec[az-i]<vec2[bz-i]){
      res=0;
      break;}
    if(vec[az-i]>vec2[bz-1]){
      res=1;
      break;}
  }
  
  if(res==0){
    cout<<aa<<endl;}
  if(res==1){
    cout<<bb<<endl;}
    
    


}

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

using namespace std;

typedef pair<int,int> pi;
typedef long long ll;

int N;
string s;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> s;
	if (N >= 3200) cout << s << '\n';
	else cout << "red\n";
}

Measured memory_bytes: 892
package main

import "fmt"

func main() {
	var x int
	fmt.Scan(&x)
	x -= 400
	for i := 0; i < 8; i++ {
		min, max := i*200, (i+1)*200
		if min <= x && x < max {
			fmt.Println(8 - i)
			return
		}
	}
}


Measured memory_bytes: 1772
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>
 
 
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
typedef long long int ll;
#define ARRAY_MAX 100005

 
//ユークリッド互除法
ll gcd(ll x,ll y){
 
    if(y == 0){
        return x;
    }else{
        return gcd(y,x % y);
    }
}
 
/*最小公倍数*/
ll lcm(ll x,ll y){
    ll tmp = gcd(x,y);
    return x*y/tmp;
}
 
 
int main(){
 
    ll n,m;
    cin >> n >> m;
    string s,t;
    cin >> s >> t;
    ll tmp = lcm(n,m);
    if(s[0] != t[0]){
        cout << "-1" << endl;
        return 0;
    }

    ll s_i = tmp/n;
    ll t_i = tmp/m;
    bool ans = true;
    //cout << s_i << t_i << endl;
    for(ll i = 0; i < min(n/t_i,m/s_i); i++){
        //cout << s[t_i*i] << t[s_i*i] << endl;
        if(s[t_i*i] != t[s_i*i]){
            ans = false;
            break;
        }
    }



 
    if(ans){
        cout << tmp << endl;
    }else{
        cout << "-1" << endl;
    }
    
    
   
    return 0;
}

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

#define pb push_back
#define MAX 100005
#define ff first
#define ss second
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;

int n, k, a[105], dp[100005];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>k;
    for(int i =0; i<n; ++i)
        cin>>a[i];
    for(int i =1; i<=k;++i){
        for(int j = 0; j<n; ++j){
            if(a[j]>i)continue;
            dp[i]|=(!dp[i-a[j]]);
        }
    }
    cout<<(dp[k]?"First\n":"Second\n");
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <numeric>
#include <iomanip>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_N 20000
#define MAX_M 16

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, k, t;

struct edge{
	int to, cost;
	edge(int _to, int _cost) :to(_to), cost(_cost){};
};

vector<edge> G[101];

int d[101];

void djikstra(int s){
	fill(d, d + 101, INF);

	priority_queue<P> que;
	que.push(P(s, 0));
	d[s] = 0;

	while (que.size()){
		P p = que.top(); que.pop();
		int v = p.first;

		if (d[v] < p.second)continue;

		for (int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(P(e.to, d[e.to]));
			}
		}
	}

}

int main(){
	while (cin >> n >> k&&n + k){
		REP(i, 101)G[i].clear();
		REP(i, k){
			cin >> t;
			if (t == 0){
				int a, b;
				cin >> a >> b;
				djikstra(a);
				if (d[b] == INF)cout << -1 << endl;
				else cout << d[b] << endl;
			}
			else{
				int c, d, e;
				cin >> c >> d >> e;
				G[c].push_back(edge(d, e));
				G[d].push_back(edge(c, e));
			}
		}
	}
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<ll> C(N);
    vector<ll> S(N);
    vector<ll> F(N);

    REP(i, N-1){
        cin >> C[i] >> S[i] >> F[i];
    }

    REP(i, N){
        ll ans = 0;
        if(i == N-1){
            cout << 0 << endl;
            return 0;
        }
        for(ll j=i; j<N-1; j++){
            if(i==j){
                ans = S[j] + C[j];
            }
            else{
                ll t = max(ans, S[j]);
                ll t2 = (F[j] - t % F[j]) % F[j];
                ans = t + t2 + C[j];
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import copy

n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

ans = 0
for i in range(0,n):
    if A[i] <= B[i]:
        ans += A[i]
        B[i] -= A[i] 
        if A[i+1] <= B[i]:
            ans += A[i+1]
            A[i+1] = 0
        else:
            ans += B[i]
            A[i+1] -= B[i]
    else:
        ans += B[i]

print(ans)
    


Measured memory_bytes: 18908