akhauriyash/Code-Regression huggingface dataset:
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repe(i, n) REPN(i, 0, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	string s;
	cin >> s;
	ll k;
	cin >> k;
	ll n = s.size();

	Vec2<ll> dp0(n+1, Vec(k+1)), dp1(n+1, Vec(k+1));

	dp1[0][0] = 1;

	repn(i, n){
		repe(j, k){
			ll m = s[i-1]-'0';
			dp0[i][j] += dp0[i-1][j];
			if(m) dp0[i][j] += dp1[i-1][j];
			else dp1[i][j] += dp1[i-1][j];
			if(!j) continue;
			repn(l, 9){
				dp0[i][j] += dp0[i-1][j-1];
				if(l < m) dp0[i][j] += dp1[i-1][j-1];
				else if(l == m) dp1[i][j] += dp1[i-1][j-1];
			}
		}
	}
	co(dp0[n][k]+dp1[n][k]);

	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class A {
    public static void main(String... args) {
        final Scanner sc = new Scanner(System.in);
        final int[] N = new int[4];
        for (int i = 0; i < 4; i++)
            N[i] = sc.nextInt();
        Arrays.sort(N);
        System.out.println(Arrays.equals(N, new int[]{1, 4, 7, 9}) ? "YES" : "NO");
    }
}

public class Main {
    public static void main(String... args) {
        A.main();
    }
}


Measured memory_bytes: 25300
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int n, k, x, t;

int main(){
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> x;
        if(x >= k){
            t++;
        }
    }
    cout << t;
}

Measured memory_bytes: 256
#include <stdio.h>

int BubbleSort(int A[], int N)
{
    int cnt = 0;
    bool flag = true;
    while (flag)
    {
        flag = false;
        for (int j = N - 1; j > 0; j--)
        {
            if (A[j - 1] > A[j])
            {
                int val = A[j - 1];
                A[j - 1] = A[j];
                A[j] = val;
                flag = true;
                cnt++;
            }
        }
    }
    return cnt;
}

int main()
{
    int N;
    int A[100];

    scanf("%d", &N);
    for (int i = 0; i < N; i++)
        scanf("%d", &A[i]);
    int rel = BubbleSort(A, N);
    for (int i = 0; i < N; i++)
    {
        if (i != 0)
            printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
    printf("%d", rel);
    printf("\n");
    return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

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

  int ans = 0;
  for (int bit = 0; bit < 30; ++bit) {
    ll T = (1LL << bit);
    vector<ll> b(N);
    for (int i = 0; i < N; ++i) {
      b[i] = B[i] % (2 * T);
    }
    sort(b.begin(), b.end());
    ll cnt = 0;
    for (int i = 0; i < N; ++i) {
      int a = A[i] % (2 * T);
      cnt += distance(lower_bound(b.begin(), b.end(), T - a),
                      lower_bound(b.begin(), b.end(), 2 * T - a));
      cnt += distance(lower_bound(b.begin(), b.end(), 3 * T - a),
                      lower_bound(b.begin(), b.end(), 4 * T - a));
    }
    if (cnt % 2) { ans |= (1 << bit); }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 3428
#[allow(unused_macros)]
macro_rules! input_byline {
    ($($r:tt)* ) => {
        let stdin = std::io::stdin();
        let mut q = std::collections::VecDeque::new();
        let mut next = || {
            if q.is_empty() {
                let mut s = String::new();
                stdin.read_line(&mut s);
                for v in s.split_whitespace() {
                    q.push_back(v.to_string());
                }
            }
            q.pop_front().unwrap()
        };
        input_inner!{next, $($r)*}
    };

}

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

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

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

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

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

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

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

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

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

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

trait Printable {
    fn p(&self);
}

impl<T: std::fmt::Display> Printable for T {
    fn p(&self) {
        println!("{}", self);
    }
}

impl<T: std::fmt::Display> Printable for [T] {
    fn p(&self) {
        for i in 0..self.len() {
            if i != 0 {
                print!(" ");
            }
            print!("{}", self[i]);
        }
        println!("");
    }
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1e9 as usize + 9;

fn main() {
    input! {
        s: chars,
    }

    let mut ans = 0;
    for i in 0..s.len() / 2 {
        if s[i] != s[s.len() - 1 - i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
/*
    Problem 69j
    https://atcoder.jp/contests/abc084/tasks/abc084_d
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int MAX = 100005;
/* global variables */
vector<bool> isPrime;
/* function */
void eratos() {
    isPrime.assign(MAX + 1, true);
    isPrime[0] = isPrime[1] = false;
    for (int i = 2; i * i <= MAX; i++) {
        if (isPrime[i]) {
            int j = i + i;
            while (j <= MAX) {
                isPrime[j] = false;
                j += i;
            }
        }
    }
}
/* main */
int main(){
    int Q, r, l;
    cin >> Q;
    eratos();
    vector<int> like2017(MAX, 0);
    for (int i = 1; i < MAX; i += 2) {
        int j = (i + 1) / 2;
        if (isPrime[i] && isPrime[j]) like2017[i]++;
    }
    vector<int> sum(MAX + 1, 0);
    sum[0] = 0;
    for (int i = 1; i < MAX; i++){
        sum[i] = sum[i - 1] + like2017[i - 1];
    }
    for (int i = 0; i < Q; i++) {
        cin >> l >> r;
        cout << sum[r + 1] - sum[l] << '\n';
    }
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;
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
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= 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
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  string s, t;
  cin >> s >> t;
  int n = s.size(), m = t.size();
  int ans = INF;
  rep(i, n-m+1) {
    string ss = s.substr(i, m);
    int count = 0;
    rep(j, m) if(ss[j] != t[j]) ++count;
    chmin(ans, count);
  }
  cout << ans << endl;
}

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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
int x, y;
  cin >> x >> y;
  bool ans = false;
  vector<int> a{ 1, 3, 5, 7, 8, 10, 12 };
  vector <int> b{ 4, 6, 9, 11 };
  if (find(a.begin(),a.end(),x) != a.end() && find(a.begin(),a.end(),y) != a.end()){
ans = true;
  }

    if (find(b.begin(),b.end(),x) != b.end() && find(b.begin(),b.end(),y) != b.end()){
ans = true;
  }




  (ans) ? cout << "Yes\n" : cout << "No\n";
  return 0;
}


Measured memory_bytes: 384
import itertools

def do():
    N,M,R = list(map(int,input().split(" ")))
    rs = list(map(int,input().split(" ")))
    INF = 10 ** 20
    graph = [ [INF for _ in range(N + 1)]for _ in range(N + 1)]
    for _ in range(M):
        a,b,c = (map(int, input().split(" ")))
        graph[a][b] = c
        graph[b][a] = c
    for k in range(1,N+1):
        for j in range(1, N + 1):
            for i in range(1, N + 1):
                graph[j][i] = min(graph[j][i] , graph[j][k] + graph[k][i])

    perms = itertools.permutations(rs)
    ans = INF
    for temp in perms:
        cand = 0
        for i in range(0,R-1):
            fr = temp[i]
            to = temp[i + 1]
            cand+= graph[fr][to]
        ans = min(cand,ans)
    print(ans)

if __name__ == "__main__":
    do()

Measured memory_bytes: 59352
#include<cstdio>

using namespace std;

int main(){
    int N;
    scanf("%d", &N);
    char s[101];
    for(int i = 0; i < N; i++){
        scanf("%c", &s[i]);
    }
    for(int i = 0; i < N; i++){
        if (s[i]=='Y') {
            printf("Four\n");
            return 0;
        }
    }
    puts("Three");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H , W ,A ,B;
  cin>>H>>W>>A>>B;
  vector<vector<int>> X(A,vector<int>(B));
  for(int k=0;k<H;k++){
    for(int j=0;j<W;j++){
      int t=0;
      if(j<A) t=1;
      if(k<B) cout<<t;
      else cout<<(t+1)%2;
    }
    cout<<endl;
  }
}

Measured memory_bytes: 1920
package main

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

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	n := sc.nextInt()
	k := sc.nextInt()

	s := strconv.FormatInt(int64(n), k)
	fmt.Fprintln(wtr, len(s))
}

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	static class Plant implements Comparable<Plant> {
		String l;
		int p,t,f,s,m,a;
		public Plant(String l,int p, int t, int f, int s, int m, int a) {
			this.l = l;
			this.p = p;
			this.t = t;
			this.f = f;
			this.s = s;
			this.m = m;
			this.a = a;
		}
		public int compareTo(Plant o) {
			int e = (this.f * this.s * this.m - this.p) * (o.t + o.a + o.t * (o.m - 1)) - (o.f * o.s * o.m - o.p) * (this.t + this.a + this.t * (this.m - 1));
			if (e == 0)
				return this.l.compareTo(o.l);
			else if (e > 0)
				return -1;
			else
				return 1;
		}
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = Integer.parseInt(sc.next());
			if (n == 0) break;
			Plant[] q = new Plant[n];
			for (int i = 0; i < n; i++) {
				String l = sc.next();
				int p = Integer.parseInt(sc.next());
				int a = 0;
				for (int j = 0; j < 3; j++)
					a += Integer.parseInt(sc.next());
				int t = 0;
				for (int j = 0; j < 2; j++)
					t += Integer.parseInt(sc.next());
				int f = Integer.parseInt(sc.next());
				int s = Integer.parseInt(sc.next());
				int m = Integer.parseInt(sc.next());
				q[i] = new Plant(l, p, t, f, s, m, a);
			}
			Arrays.sort(q);
			for (int i = 0; i < n; i++) {
				System.out.println(q[i].l);
			}
			System.out.println("#");
		}
	}
}


Measured memory_bytes: 42548
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>

using namespace std;

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long

typedef pair<lint, lint> P;
const lint MOD = 1e9+7;
const lint INF = MOD * MOD;

int main(){
    int n; cin >> n; lint a[n][n]; bool b[n][n];
    rep(i, n) rep(j, n) cin >> a[i][j];
    rep(i, n) rep(j, n) b[i][j] = true;
    rep(i, n) rep(j, n) rep(k, n){
        if((i-j)*(j-k)*(k-i) == 0) continue;
        if(a[i][j] > a[i][k] + a[k][j]){
            cout << "-1" << endl; return 0;
        }
        else if(a[i][j] == a[i][k] + a[k][j]) b[i][j] = false;
    }
    lint res = 0;
    rep(i, n) rep(j, n){
        if(b[i][j]) res += a[i][j];
    }
    cout << res/2 << endl;
}

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

typedef long long       ll;

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

    string s;
    cin >> s;

    ll cur=0, ans=0, ten=1;
    map<int, int> freq;
    freq[0]=1;
    for (int i=s.size()-1; i>=0; --i) {
        cur+=1LL*(s[i]-'0')*ten;
        cur%=2019;
        ten*=10;
        ten%=2019;

        ans+=freq[cur];
        ++freq[cur];
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 3732
#include<iostream>
using namespace std;
int main(){

  int h,m,s;

  cin >> s;

  h=s/3600;
  s=s%3600;
  m=s/60;
  s=s%60;

  cout << h << ":"<< m << ":"<< s  <<endl;

  return 0;

}

Measured memory_bytes: 3112
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<functional>
#include<algorithm>
#include<stack>
#include<queue>
#include<iomanip>
#include<set>
#include<map>
#include<utility>
#include<string>
#include<vector>

using namespace std;

#define LL long long

int n,m,ac[100001]={},wa[100001]={},pt=0,pn=0;

int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int p;
		string s;
		cin>>p>>s;
		if(s=="AC"){
			if (ac[p]==0){
				ac[p]++;
				pt++;
				pn+=wa[p];
			}
		}
		else{
			wa[p]++;
		}
	}
	cout<<pt<<" "<<pn<<endl;

	return 0;
}

Measured memory_bytes: 1024
t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())

ave_a = t1 * a1 + t2 * a2
ave_b = t1 * b1 + t2 * b2
if ave_a == ave_b:
    print('infinity')
    exit()

half, all = t1 * (b1 - a1), ave_a - ave_b
ans = half // all * 2 + (half % all != 0)
print(max(0, ans))


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

using namespace std;
using ll = long long;

const int nax = 305;
double p[nax][nax][nax],ev[nax][nax][nax];
//ev[a][b][c] - the expected number of operations so far to get to state(a,b,c)
//easier: p-ability of getting to this state at

int main()
{  
    int n;
    scanf("%d",&n);
    vector<int> cnt(4);
    REP(i,n){
        int x;
        scanf("%d",&x);
        cnt[x]++;
    }
    p[cnt[1]][cnt[2]][cnt[3]] = 1;
    for(int c = n; c>= 0; c--){
        for(int b = n; b>=0; b--){
            for(int a = n; a >= 0; a--){
                if(a==0 && b==0 && c==0){
                    continue;
                }
                if(a+b+c > n){
                    continue;
                }
                //dp[a][b][c]
                
                double p_waste = (double)(n - (a+b+c)) / n;
                //p_waste + p_waste^2 + ... = S
                //1+S = S/p_waste
                double ev_waste = p_waste/(1-p_waste) + 1;
                ev[a][b][c] += ev_waste*p[a][b][c];
                //remove 1 -> dp[a-1][b][c]
                //we will eventually choose one of a+b+c
                if(a!=0){
                    double p_go = (double) a/(a+b+c);
                    p[a-1][b][c] += p[a][b][c]* p_go;
                    ev[a-1][b][c] +=ev[a][b][c] * p_go;
                }
                
                //remove 2 -> p[a+1][b-1][c]
                if(b != 0){
                    double p_go = (double) b/(a+b+c);
                    p[a+1][b-1][c] += p[a][b][c]*p_go;
                    ev[a+1][b-1][c] += ev[a][b][c]*p_go;
                }
                
                //remove 3 -> p[a][b+1][c-1]
                if(c != 0){
                    double p_go = (double) c/(a+b+c);
                    p[a][b+1][c-1] += p[a][b][c]*p_go;
                    ev[a][b+1][c-1] += ev[a][b][c]*p_go;
                }
            }
        }
    }
    printf("%.10lf\n", ev[0][0][0]);//+cnt[1]+2*cnt[2]+3*cnt[3]);
    return 0;
}


Measured memory_bytes: 438528
import bisect

n, q = map(int, input().split())
S = str(input())
L = []
for i in range(n-1):
    if S[i] + S[i+1] == 'AC':
        L.append(i+1)
for _ in range(q):
    l, r = map(int, input().split())
    s = bisect.bisect_left(L, l)
    t = bisect.bisect_left(L, r)
    print(t - s)


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;
  int g = __gcd(n, m);
  for (int i = 0; i < g; i++) {
    int x = n / g * i;
    int y = m / g * i;
    if (s[x] != t[y]) {
      cout << -1 << '\n';
      return 0;
    }
  }
  cout << (long long) n / g * m << '\n';
  return 0;
}


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

typedef unsigned long long ll;

ll ans = 1e19;

ll compute(ll a, ll b, ll c, ll d, ll n, ll cnt) {

	if (n == 0) ans = min(cnt, ans);

	else {

		//cout << n << cnt << '\n';

		if ( n / 25 > 0 ) {

			compute(a, b, c, d, n % 25, cnt + (n / 25) * a);

		}

		if ( n / 50 > 0) {

			compute(a, b, c, d, n % 50, cnt + (n / 50) * b);

		}


		if ( n / 100 > 0) {

			compute(a, b, c, d, n % 100, cnt + (n / 100) * c);

		}


		if ( n / 200 > 0) {

			compute(a, b, c, d, n % 200, cnt + (n / 200) * d);

		}

	}

}





int main() {

	ll a, b, c, d, n;

	cin >> a >> b >> c >> d >> n;

	n *= 100;

	compute(a, b, c, d, n, 0);

	cout << ans << '\n';

}

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

int main() {
	int n;
	cin >> n;
	int s=0, x=0, y=0;
	bool ok=true;
	for (int i = 0; i < n; i++) {
		int t,u,v;
		cin >> t >> u >> v;
		if ( !ok ) continue;
		int dt=t-s;
		int dx=abs(u-x);
		int dy=abs(v-y);
		if ( dx+dy>dt ) {
			ok=false;
		}
		dt-=dx+dy;
		if ( dt%2 ) {
			ok=false;
		}
	}
	if ( ok ) cout << "Yes" << '\n';
	else cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        int[] num = new int[n];
        for(int i = 0;i < n;i++){
            num[i] = sc.nextInt();
        }
        Arrays.sort(num);
        for(int i = 0;i < n-1;i++){
            if(num[i]==num[i+1]){
                System.out.println("NO");
                return;
            }
        }
        
        System.out.println("YES");
    }
}

Measured memory_bytes: 77252
#include<iostream>
using namespace std;
int main(){
    int n;
    int i;
    int inp,cur,max;
    while (cin>>n)
    {
        if(n == 0){
            break;
        }
        for(i=0;i<n;i++){
            cin>>inp;
            if(i == 0){
                max = inp;
                if(inp < 0){
                    cur = 0;
                }else{
                    cur = inp;
                }
            }else{
                cur = inp + cur;
                if(cur<0){
                    cur = 0;
                }else{
                    if(cur>max){
                        max = cur;
                    }
                }
            }
        }
        cout<<max<<endl;
    }

    
    return 0;
}


Measured memory_bytes: 2988
import java.io.IOException;
import java.util.Scanner;

public class Main {

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

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			StringBuilder[] builders = new StringBuilder[10];
			for (int i = 0; i < 10; i++)
				builders[i] = new StringBuilder();
			while (n-- > 0) {
				int a = scanner.nextInt();
				builders[a].append('*');
			}
			for (StringBuilder builder : builders)
				if (builder.length() == 0)
					System.out.println('-');
				else
					System.out.println(builder);
		}
	}
}

Measured memory_bytes: 51852
#include <iostream>
#include <vector>
#include <string>
 
using namespace std;
typedef long long ll;

ll countChar(ll lo, ll hi, ll d) {
  auto c = [hi, lo](ll n){return hi / n - lo / n;};
  ll c15 = c(15);
  ll c5 = c(5) - c15;
  ll c3 = c(3) - c15;
  ll cc = (hi - lo) - (c15 + c5 + c3);
  return c15 * 8 + c5 * 4 + c3 * 4 + cc * d;
}

ll f(ll n) {
  ll base = 1;
  ll ret = 0;
  int d = 1;
  for(; base * 10 < n; base *= 10) {
    ret += countChar(base - 1, base * 10 - 1, d);
    d++;
  }
  ret += countChar(base - 1, n, d);
  return ret;
}

string fizzbuzz(ll n) {
  if (n % 15 == 0) return "FizzBuzz";
  if (n % 5 == 0) return "Buzz";
  if (n % 3 == 0) return "Fizz";
  return to_string(n);
}
 
int main() {
  ll N;
  cin >> N;
  ll n = N;
  for(; n < N + 20; n++) {
    ll ok = 0, ng = 1e18;
    while(abs(ok - ng) > 1) {
      ll c = (ok + ng) / 2;
      if (f(c) < n) {
        ok = c;
      } else {
        ng = c;
      }
    }
    string last = fizzbuzz(ok + 1);
    cout << last[n - f(ok) - 1];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3280
#include <stdio.h>

int main(void)
{
	int a[31], b[31];
	int c[31];
	int w, n;
	int i, j;
	int dummy;
	
	scanf("%d", &w);
	scanf("%d", &n);
	
	for (i = 1; i <= 30; i++){
		c[i] = i;
	}
	for (i = 1; i <= n; i++){
		scanf("%d,%d", &a[i], &b[i]);
	}
	for (i = 1; i <= n; i++){
		dummy = c[a[i]];
		c[a[i]] = c[b[i]];
		c[b[i]] = dummy;
	}
	for (j = 1; j <= w; j++){
		printf("%d\n", c[j]);
	}
	
	return (0);
}

Measured memory_bytes: 596
/* 
   *********************************************************
    Code_Blooded Human == @{{ samrat_12   [  0_0  ^_^  ] }}
   *********************************************************
*/
#include <bits/stdc++.h>
#include<algorithm>
#include<queue>
#include<list>
#include<map>
#include <math.h>
#include<numeric>
using namespace std;
using i1=int;
#define E "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  ipfile    ifstream cin ("input.txt");std::cin.rdbuf(std::cin.rdbuf())
#define pb(x) push_back(x);
#define ll long long int
#define ull unsigned long long int
#define db long double
#define mod 1000000007
#define vll vector<ll>
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define REVVEC(v) reverse(v.begin(),v.end())
#define REVARR(a) reverse(a,a+n)
#define maxc(v) max_element(all(v))
#define minc(v) min_element(all(v))
#define inputarr(a,n) for(int xxx=0;xxx<n;++xxx) cin>>a[xxx]
#define outputarr(a,n) for(int xxx=0;xxx<n;xxx++) cout<<a[xxx]<<" "
#define rep(i,m, n)    for(int i = m; i < (n); ++i)
#define sp setprecison(10)
int main() {
    FAST
    int n;
    cin>>n;
    int a[n+1];
        inputarr(a,n);
    if(n==1)
    outputarr(a,n);
    else
    {
        int l=1;double s=0.0;
        rep(i,0,n)
        l=LCM(l,a[i]);
        rep(i,0,n)
        s=s+(l/a[i]);
        cout<<(l/s)<<endl;
    }
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int isEven(char *st, int len){
    int p1,p2;
        
    if (len % 2 == 1) return 0;
    for (p1=0, p2 = len/2; p1 < len/2; p1++, p2++){
        //printf("%c(%d) %c(%d)\n", st[p1], p1, st[p2],p2);
        if (st[p1] != st[p2]) return 0;
    }
    return 1;
}

int main(void){
    char str[200];
    int len;
    
    scanf("%s", str);
    for (len = strlen(str)-1; !isEven(str, len); len--);
    //for (int i=0; i<len; i++) putchar(str[i]);
    //puts("");
    printf("%d\n", len);
    return 0;
}

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

int main()
{
    int N, M, K;
    cin >> N >> M;
    vector<int> vc(M + 1);
    for (int i = 0; i < M; i++)
        vc[i] = 0;
    int val;
    int out = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> K;
        for (int j = 0; j < K; j++)
        {
            cin >> val;
            vc[val]++;
            if (vc[val] == N)
                out++;
        }
    }

    cout << out;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;



int main(){

	int n, m, x[101], y[101];
	cin >> n >> m >> x[0] >> y[0];
	for(int i=1; i<n+1; i++){
		cin >> x[i];
	}
	for(int i=1; i<m+1; i++){
		cin >> y[i];
	}
	sort(x, x+n+1);
	sort(y, y+m+1);
	if(x[n]>=y[0]){
		cout << "War" << endl;
	} else {
		cout << "No War" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        int       i, j, k;
        int       n;
        int       dt, dstnc;
        int       flg;
        int[,]    txy;
        string[]  str;

        n   = int.Parse(Console.ReadLine());    /* 標準入力                          */
        txy = new int[n + 1, 3];
        txy[0, 0] = 0;
        txy[0, 1] = 0;
        txy[0, 2] = 0;

        for(i = 1; i <= n; i++){
            str = Console.ReadLine().Split(' ');    /* 2つ以上のスペース区切り入力の取得 */
            for(j = 0; j < 3; j++){
                txy[i, j] = int.Parse(str[j]);
            }
        }

        for(k = 0; k < n; k++){
            flg   = 0;
            dt    = txy[k + 1, 0] - txy[k, 0];
            dstnc = Math.Abs(txy[k + 1, 1] - txy[k, 1]) + Math.Abs(txy[k + 1, 2] - txy[k, 2]);

            if(dstnc > dt){
                break;
            }

            if((dstnc % 2 == 0) && (dt % 2 == 0)){
                flg = 1;
            }
            else if((dstnc % 2 == 1) && (dt % 2 == 1)){
                flg = 1;
            }

            if(flg == 0){
                break;
            }
        }

        if(k == n){
            Console.WriteLine("Yes");     /* 改行付き出力 */
        }
        else{
            Console.WriteLine("No");     /* 改行付き出力 */
        }
    }
}


Measured memory_bytes: 16196
#pragma region
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define vd vector<double>
#define vs vector<string>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) revi(i, n, 0)
#define each(i, n) for(auto&& i: n)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size()) 
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define co(x) cout << x << endl
#define dump(x) cerr << #x << "=" << x <<endl
#define gcd __gcd
int lcm(int a, int b){return a / gcd(a, b) * b;}
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);
void solve();
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	solve();
}
#pragma endregion

void solve() {
    int A, B, K;
    cin >> A >> B >> K;
    int t, a;
    if (K <= A) {
        t = A - K; 
        a = B;
    }
    else if (K <= A + B) {
        t = 0;
        a = (A + B) - K;
    }
    else {
        t = 0;
        a = 0;
    }
    cout << t << " " << a << endl;
}

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

inline int gi()
{
	char c = getchar();
	while(c < '0' || c > '9') c = getchar();
	int sum = 0;
	while('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

const int maxn = 200005, mod = 1e9 + 7;

int n;
pair<int, int> p[maxn];
vector<int> vec[maxn];
int f[20][maxn], g[20][maxn], Log[maxn];
int sum[maxn];

inline int inc(int a, int b) {return a + b >= mod ? a + b - mod : a + b;}

void insert(int x, int a)
{
	++x;
	while (x) {
		sum[x] = inc(sum[x], a); x -= x & (-x);
	}
}

int query(int x)
{
	int res = 0; ++x;
	while (x <= n + 1) {
		res = inc(res, sum[x]);
		x += x & (-x);
	}
	return res;
}

int Min(int l, int r)
{
	int k = Log[r - l + 1];
	if (p[f[k][l]].second < p[f[k][r - (1 << k) + 1]].second) return p[f[k][l]].second;
	else return p[f[k][r - (1 << k) + 1]].second;
}

int Max(int l, int r)
{
	int k = Log[r - l + 1];
	if (p[g[k][l]].second > p[g[k][r - (1 << k) + 1]].second) return p[g[k][l]].second;
	else return p[g[k][r - (1 << k) + 1]].second;
}

int main()
{
	n = gi();
	for (int i = 1; i <= n; ++i) p[i] = make_pair(gi(), gi());
	sort(p + 1, p + n + 1);

	for (int i = 1; i <= n; ++i) f[0][i] = g[0][i] = i;
	for (int i = 2; i <= n; ++i) Log[i] = Log[i >> 1] + 1;
	for (int i = 0; (1 << (i + 1)) <= n; ++i)
		for (int j = 1; j <= n; ++j) {
			if (p[f[i][j]].second < p[f[i][j + (1 << i)]].second) f[i + 1][j] = f[i][j];
			else f[i + 1][j] = f[i][j + (1 << i)];
			if (p[g[i][j]].second > p[g[i][j + (1 << i)]].second) g[i + 1][j] = g[i][j];
			else g[i + 1][j] = g[i][j + (1 << i)];
		}
	
	for (int l, r, mid, L, i = 1; i <= n; ++i) {
		l = 1; r = i;
		while (l < r) {
			mid = (l + r) >> 1;
			if (Max(1, mid) >= p[i].second) r = mid;
			else l = mid + 1;
		}
		L = l;
		l = i; r = n;
		while (l < r) {
			mid = (l + r + 1) >> 1;
			if (Min(mid, n) <= p[i].second) l = mid;
			else r = mid - 1;
		}
		vec[L].push_back(l);
		//printf("%d %d\n", L, l);
	}

	insert(0, 1);
	
	for (int i = 1; i <= n; ++i) {
		sort(vec[i].begin(), vec[i].end());
		for (int r : vec[i])
			insert(r, query(i - 1));
	}

	printf("%d\n", query(n));
	
	return 0;
}



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


int main()
{
    int a,b;
    cin >> a >> b;
    
    if(a%3==0)
    {
        cout << "Possible";
    }
    else if(b%3==0)
    {
        cout << "Possible";
    }
    else if((a+b)%3==0)
    {
        cout << "Possible";
    }
    else
    {
        cout << "Impossible";
    }
}


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

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

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

    vector<long long> dp(110000);
    for(int i=0; i<110000; i++) dp[i] = N;

    dp[0] = 0;
    for(int i=1; i<=N; i++) {
        for(int pow6=1; pow6<=i; pow6*=6) {
            chmin(dp[i], dp[i-pow6] + 1);
        }
        for(int pow9=1; pow9<=i; pow9*=9) {
            chmin(dp[i], dp[i-pow9] + 1);
        }
    }

    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1152
S = input().strip()
l = len(S)

if l == 1:
    print(0)
    exit()

cnt10 = 0
cnt01 = 0
for i in range(l):
    if i % 2:
        # odd
        if S[i] == '1':
            cnt10 += 1
        else:
            cnt01 += 1
    else:
        # even
        if S[i] == '0':
            cnt10 += 1
        else:
            cnt01 += 1

print(min(cnt01, cnt10))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int main(){
    int N;
    cin >> N;
    int d[N];
    cins(d, d + N);
    int ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    #pragma GCC optimize("Ofast")
    typedef long long int lli;
    #define rep(i,x) for(int i = 0; i < x; ++i)
    #define nxt '\n'
    using namespace std;
 
    lli n,k,ar[100001]={},dp[100001]={};
     
    lli solve(lli x)
    {
    	if(x>=n-2) return dp[x];
    	if(dp[x]==-1) {
    		lli m=INT_MAX,temp=0;
    		for(lli i=x+1;i<=min(x+k,n-1);++i)
    		{
    			temp=abs(ar[x]-ar[i])+solve(i);
    			m=min(m,temp);
    		}
    		dp[x]=m;
    	}
    	return dp[x];
    }
     
    int main() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
     
    	cin >> n >> k;
    	rep(i,n) cin >> ar[i];
    	dp[n-2]=abs(ar[n-1]-ar[n-2]);
    	rep(i,n-2) dp[i]=-1;
    	cout << solve(0);
    	return 0;
    }

Measured memory_bytes: 11136
#include<iostream>
#include<string>
using namespace std;
string s;
int x,y,ans;
int main()
{ 
    cin >> s;
    for(unsigned i=0;i<s.size();i++)
	{
        if(x==y)
		{
            x++;
            ans-=bool(s[i]=='p');
        }
        else
		{
            y++;
            ans+=bool(s[i]=='g');
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

ll nxt()
{
    ll x;
    cin >> x;
    return x;
}

const ll L = 1e5+5;

void solve()
{
    ll n = nxt(), k = nxt(), c = nxt();

    string s;
    cin >> s;

    ll req = 0;

    basic_string <ll> ff, ss;

    for(ll i=0; i<n; i++)
    {
        if(s[i] == 'o')
        {
            ff += i;

            req++;
            if(req == k)
            {
                break;
            }

            i += c;
            // i--;
        }
    }   

    req = 0;

    for(ll i=n-1; i>=0; i--)
    {
        if(s[i] == 'o')
        {
            ss += i;

            req++;
            if(req == k)
            {
                break;
            }

            i -= c;
            // i++;
        }
    }

    reverse(all(ss));

    for(ll i=0; i<sz(ff); i++)
    {
        if(ff[i] == ss[i])
        {
            cout << ff[i]+1 << endl;
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll T = 1;
    // T = nxt();

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

    return 0;
}

Measured memory_bytes: 5140
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

class Magatro
{
    string A,B;
    public void Solve()
    {
        A=Console.ReadLine();
        B=Console.ReadLine();
        for(int i=0;i<3;i++)
        {
            if(A[i]!=B[2-i])
            {
                Console.WriteLine("NO");
                return;
            }
        }
        Console.WriteLine("YES");
    }
    static void Main(string[] args)
    {
        new Magatro().Solve();
    }
}

Measured memory_bytes: 13140
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,k = list(map(int, input().split()))
ans = 0
for b in range(k+1, n+1):
    val = (b-k) * (n//b) + max(0, (n%b)-k+1)
    if k==0:
        val -= 1
    ans += val
#     print(b,val)
print(ans)

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

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
	tx -= sx; ty -= sy; sx = 0; sy = 0;
	

	//URDL
	assert(tx > 0 and ty > 0);
	int i;
	for (i = 0; i < ty; i++){
		cout << 'U';
	}
	for (i = 0; i < tx; i++){
		cout << 'R';
	}
	for (i = 0; i < ty; i++){
		cout << 'D';
	}
	for (i = 0; i < tx + 1; i++){
		cout << 'L';
	}
	for (i = 0; i < ty + 1; i++){
		cout << 'U';
	}
	for (i = 0; i < tx + 1; i++){
		cout << 'R';
	}
	cout << 'D' << 'R';
	for (i = 0; i < ty + 1; i++){
		cout << 'D';
	}
	for (i = 0; i < tx + 1; i++){
		cout << 'L';
	}
	cout << 'U' << endl;
	
	return 0;
}

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

int main(){
    int N, M, A[9];
    cin >> N >> M;
    for(int i=0; i<M; i++) cin >> A[i];

    int num[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

    // mx[n] = n本使って作れる1つの数字の最大値（ない場合は-1）
    vector<int> mx(8, -1);
    for(int i=0; i<M; i++){
        mx[num[A[i]]] = max(mx[num[A[i]]], A[i]);
    }

    vector<int> MINUS_INF(10, -1e9);

    // dp[i] = マッチを合計i本使って作れる数字の最大値を、
    //         {桁数, 9の個数, 8の個数, ..., 1の個数} と表現したもの
    vector<int> dp[10001];
    dp[0].assign(10, 0);
    for(int i=1; i<=N; i++) dp[i] = MINUS_INF;

    for(int i=2; i<=N; i++){
        for(int n=2; n<=7; n++){
            if(i-n < 0 || mx[n] == -1) continue;

            // 遷移先の状態は、遷移前の状態から桁数とmx[n]の個数を1つ増やしたもの
            vector<int> d2 = dp[i-n];
            d2[0]++;
            d2[10-mx[n]]++;
            dp[i] = max(dp[i], d2);
        }
    }

    string ans = "";
    for(int n=9; n>=1; n--) for(int k=0; k<dp[N][10-n]; k++) ans.push_back('0'+n);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

typedef long long ll;

inline ll read()
{
	ll x=0;char ch=getchar();
	while(ch<'0' || '9'<ch)ch=getchar();
	while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
	return x;
}

const int N=100009;

struct guo
{
	ll v,id;
	bool operator < (guo o)const
	{
		return v<o.v;
	}
}p[N];

ll n,a[N];

int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		p[i].v=read(),p[i].id=i;
	sort(p+1,p+n+1);

	ll block;
	for(int i=1;i<=n;i++)
	{
		a[i]=a[i-1]+p[i].v;
		if(p[i].v>a[i-1]*2)
			block=i-1;
	}

	printf("%lld\n",n-block);
	return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
using ll = int64_t;
using VL = vector<ll>;
using VD = vector<double>;
using VVL = vector<VL>;

#define FOR(i, start, end) for(ll i = (start), (i ## xxxx_end)=(end); i < (i ## xxxx_end); ++i)
#define FORD(i, start, end) for(ll i = (start), (i ## xxxx_end)=(end); i > (i ## xxxx_end); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPD(i, n) FORD(i, n - 1, -1)

#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}

#define INF 1000000000000
#define MOD 10000007

ll N, K;
VL H, dp;

void solve() {
    cin >> N >> K;
    H = VL(N);
    for (auto &i : H) cin >> i;
    dp = VL(N, INF);
    dp[0] = 0;
    REP(i, N - 1) {
        FOR(j, i + 1, min(N, i + K + 1)) {
            chmin(dp[j], abs(H[i] - H[j]) + dp[i]);
        }
    }
    print(dp[N - 1]);
}

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

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,c;
	cin>>a>>b>>c;
	long long ans=0;
	if(a+b+1>=c){
		cout<<b+c<<endl;
	}else{
		if(c==0){
			cout<<0<<endl;
		}else{
			ans=1;
			c--;
			ans+=a+b+b;
			cout<<ans<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256