akhauriyash/Code-Regression huggingface dataset:
public class Main {

  private static void solve() {
    int k = ni();
    int a = ni();
    int b = ni();
    for (int i = a; i <= b; i++) {
      if (i % k == 0) {
        System.out.println("OK");
        return;
      }
    }
    System.out.println("NG");


  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



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

int main(){
  int n;
  cin >> n;
  int a[n];
  int b[n];
  int ans = 0;
  for(int i = 0;i < n;i++){
    cin >> a[i];
  }
  for(int i = 0;i < n;i++){
    cin >> b[i];
  }
  for(int i = 0;i < n;i++){
    if(a[i] - b[i] > 0){
      ans += a[i] - b[i];
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>

using namespace std;


int main(int argc, const char * argv[]) {

    int n;
    long long ans = 0;
    
    cin >> n;
    
    for(int i=1; i<=n; i++)
    {
        if(i % 3 != 0 && i % 5 != 0 && i % 15 != 0)
        {
            ans += i;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int a[100100];
std::vector<int> v[100100],u[100100];

int main(void){
	int n,m,i,j;
	ll ans = 0ll, tmp = 0ll, on = 0ll;
	std::cin >> n >> m;
	for(i=0; i<n; ++i){
		std::cin >> a[i]; --a[i];
	}
	for(i=1; i<n; ++i){
		if(a[i-1]>a[i]){
			ans += m;
			tmp -= (m-a[i-1]);
			++on;
		}
		ans += (a[i]-a[i-1]);
		v[a[i-1]].push_back(i);
		u[a[i]].push_back(i);
	}
	tmp += ans;
	for(i=0; i<m; ++i){
		ans = std::min(ans,tmp+on);
		for(j=(u[i].l_ength()-1); j>=0; --j){
			--on;
			tmp += (a[u[i][j]]-a[u[i][j]-1]+m)%m;
		}
		for(j=(v[i].l_ength()-1); j>=0; --j){
			++on;
		}
		tmp -= on;
	}
	std::cout << ans << std::endl;
	return 0;
}


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

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

    vector<int> a(N);
    vector<int> b(N);

    int i;

    a.at(0) = 0;
    b.at(0) = 0;

    for (i = 1; i <= N - 1; ++i) {
        cin >> a.at(i);
        b.at(i) = 0;
    }

    for (i = 1; i <= N - 1; ++i) {
        ++b.at(a.at(i) - 1);
    }

    for (i = 0; i <= N - 1; ++i) {
        cout << b.at(i) << endl;;
    }

}

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

int main() {
    vector<char> c;
    string s;
    cin >> s;

    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'B') {
            if (c.size()) c.pop_back();
        } else {
            c.push_back(s[i]);
        }
    }
    for (int i = 0; i < c.size(); i++) {
        cout << c[i];
    }
    cout << endl;
}


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

#define pb push_back
#define mp make_pair

#define fi first
#define se second

typedef long long ll;

using namespace std;
int n, r[20005];

int main(){

scanf("%d", &n);
for(int i=1,x;i<=n;i++){
    scanf("%d", &x);
    r[x] = i;
}

for(int i=1;i<=n;i++){
    cout << 30000 * i << ' ';
}
cout << '\n';
for(int i=1;i<=n;i++){
    cout << 30000 * (n - i) + r[i] << ' ';
}

return 0;
}


Measured memory_bytes: 640
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)*}
    };
}

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)*}
    };
}

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, usize1) => {
        read_value!($next, usize) - 1
    };

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

fn main() {
    input! {
    c: [i32; 5],
    k: i32
    }
    for i in 0..5 {
        for j in 0..5{
            if i == j{ continue }
            if (c[i] - c[j]).abs() > k {
                println!(":(");
                return
            }
        }
    }
    println!("Yay!")
}


Measured memory_bytes: 2136
import java.util.Scanner;

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

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

        boolean ab = (a.charAt(a.length() - 1) == b.charAt(0));
        boolean bc = (b.charAt(b.length() - 1) == c.charAt(0));

        System.out.println(ab && bc ? "YES" : "NO");
    }
}

Measured memory_bytes: 23636
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 200010

long long kai[N];
long long rkai[N];
long long xx[30];
int yy[30];

void kaiz(void) {
	kai[0] = 1;
	f(i, N - 1) {
		kai[i + 1] = kai[i] * (i + 1);
		kai[i + 1] = kai[i + 1] % MOD;
	}
	int x = MOD - 2;
	f(i, 30) {
		if (x % 2 == 1)yy[i] = 1;
		else yy[i] = 0;
		x = x / 2;
	}
	f(i, N) {
		xx[0] = kai[i];
		f(j, 29) {
			xx[j + 1] = xx[j] * xx[j];
			xx[j + 1] = xx[j + 1] % MOD;
		}
		rkai[i] = 1;
		f(j, 30) {
			if (yy[j] == 1) {
				rkai[i] = rkai[i] * xx[j];
				rkai[i] = rkai[i] % MOD;
			}
		}
	}
}

long long ni(long long x, long long y) {
	if ((x < 0) || (y < 0) || (y > x))return 0;
	long long re = kai[x];
	re = re * rkai[x - y];
	re = re % MOD;
	re = re * rkai[y];
	re = re % MOD;
	return re;
}


int main() {
	vector<pair<long long, long long> >a;
	long long dp1[N];
	long long dp2[N];
	f(i, N) {
		dp1[i] = 0;
		dp2[i] = 0;
	}
	long long n, m, k;
	long long x, y;
	long long s, ans;
	kaiz();

	scanf("%lld %lld %lld", &n, &m, &k);
	n--;
	m--;
	a.push_back(make_pair(0, 0));
	f(i, k) {
		scanf("%lld %lld", &x, &y);
		x--;
		y--;
		a.push_back(make_pair(x, y));
	}
	a.push_back(make_pair(n, m));
	sort(a.begin(), a.end());
	dp1[0] = 1;
	dp2[0] = 0;
	for (int i = 1; i <= (k + 1); i++) {
		f(j, i) {
			x = a[i].first - a[j].first;
			y = a[i].second - a[j].second;
			s = ni(x + y, x);
			x = (dp1[j] * s) % MOD;
			dp2[i] = (dp2[i] + x) % MOD;
			y = (dp2[j] * s) % MOD;
			dp1[i] = (dp1[i] + y) % MOD;
		}
	}
	ans = (dp2[k + 1] - dp1[k + 1] + MOD) % MOD;
	printf("%lld\n", ans);

	return 0;
}

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

using namespace std;
using ll = long long;


int main()
{
    int n, m;
    cin >> n >> m;
    int a[m], sum = 0;
    for(int i = 0; i < m; i++)cin >> a[i];
    for(int i = 0; i < m; i++) {
        sum += a[i];
    }
    cout << (n - sum < 0 ? -1 : n - sum) << endl;
}

Measured memory_bytes: 3636
/*
	author: Ibrahim-Elsayed (Codeforces Handle)
	date: 9/17/2020
*/
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int64_t INF = (int64_t)1e18;
const int mxN = 1e5+20;

int n;
int64_t arr[mxN+1][3];

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

	cin >> n;
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j < 3; j++) {
			cin >> arr[i][j];
		}
	}
	// dp[i][j] max happ points can get ending at day i with last used j;
	vector<vector<int64_t>> dp(n+1, vector<int64_t>(3));
	dp[0][0] = dp[0][1] = dp[0][2] = 0; // empty set of activities, max we can get here is 0;
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j < 3; j++) {
			dp[i][j] = -INF;
			if(i == 1) {
				dp[i][j] = max({arr[i][0], arr[i][1], arr[i][2]});
			} else {
				if(j != 0) {
					dp[i][j] = max(dp[i][j], dp[i-1][0] + arr[i][0]);
				}
				if(j != 1) {
					dp[i][j] = max(dp[i][j], dp[i-1][1] + arr[i][1]);
				}
				if(j != 2) {
					dp[i][j] = max(dp[i][j], dp[i-1][2] + arr[i][2]);
				}
			}
		}
	}
	cout << max({dp[n][0], dp[n][1], dp[n][2]}) << "\n";

	return 0;
}


Measured memory_bytes: 11156
import itertools


def add_operators(numbers, operators):
    return ''.join([operators[i] + numbers[i] for i in range(len(numbers))])


def main(s):
    numbers = list(s)
    operators = [['']]
    operators.extend([['', '+']] * (len(numbers) - 1))
    products = itertools.product(*operators)
    sum_numbers = 0
    for p in products:
        sum_numbers += sum(map(int, add_operators(numbers, p).split('+')))
    return sum_numbers


if __name__ == '__main__':
    S = input()
    print(main(S))


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

main() {
    int X,A; cin >> X >> A;
    if(X<A){
       cout << 0 << endl;
    }
    else cout << 10 << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
abc_list = [[int(i) for i in input().split()] for _ in range(n)]

dp = [[0 for i in range(3)] for _ in range(n+1)]


for i, abc in enumerate(abc_list):
    for j in range(3):
        temp = dp[i][:]
        temp.pop(j)
        dp[i+1][j] = max(temp) + abc[j]

print(max(dp[-1]))

Measured memory_bytes: 45664
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try(Scanner scn = new Scanner(System.in)) {
            int a, b;
            while((a = scn.nextInt()) > 0 | (b = scn.nextInt()) > 0) {
                int[][] field = new int[-~a][-~b];

                for(int[] ary : field) {
                    Arrays.fill(ary, -1);
                }
                for(int i = 0; i <= a; i++) {
                    field[i][0] = 0;
                }
                for(int i = 0; i <= b; i++) {
                    field[0][i] = 0;
                }

                field[1][1] = 1;

                for(int n = scn.nextInt(); n > 0; n--) {
                    field[scn.nextInt()][scn.nextInt()] = 0;
                }

                for(int x = 1; x < field.length; x++) {
                    for(int y = 1; y < field[x].length; y++) {
                        if(field[x][y] < 0) {
                            field[x][y] = field[~-x][y] + field[x][~-y];
                        }
                    }
                }

                System.out.println(field[a][b]);
            }
        }
    }
}

Measured memory_bytes: 26168
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

int main() {

    long long int n;
    cin >> n;

    if ( ( n % 2 ) == 0 ) {
        cout << "0.5" << endl;
    } else {
        cout << fixed << setprecision(10) << 1.00L * (n+1) / 2 / n << endl;
    }

    return 0;

}


Measured memory_bytes: 256
import sys

N,X,D = map(int,sys.stdin.readline().rstrip().split())

if D == 0:
    if X == 0:
        print(1)
    else:
        print(N+1)
    exit()

from collections import defaultdict

d = defaultdict(list)
for a in range(N+1):
    d[(a*X)%D].append(((a*X-(a*X)%D)//D+a*(a-1)//2,1))
    d[(a*X)%D].append(((a*X-(a*X)%D)//D+(N-1)*a-a*(a-1)//2+1,-1))

from itertools import accumulate

ans = 0
for i in d.keys():
    d[i].sort()
    l = len(d[i])
    A = [d[i][j][0] for j in range(l)]
    B = [d[i][j][1] for j in range(l)]
    C = list(accumulate(B))
    r,s = 0,0
    for j in range(l):
        if s == 0:
            r = A[j]
            s = 1
        elif C[j] == 0:
            ans += A[j]-r
            s = 0

print(ans)


Measured memory_bytes: 176432
#include<cstdio>

int n,br1,br2,br3;
int a[100010];

int main()
{
    scanf ("%d",&n);
    for (int i=1;i<=n;i++) scanf ("%d",&a[i]);
    br1=0; br2=0; br3=0;
    for (int i=1;i<=n;i++)
        if (!(a[i]%4)) br1++;
        else
        if (!(a[i]%2)) br2++;
        else br3++;

    if (br2)
    {
        if (br3<=br1) printf ("Yes");
        else printf ("No");
    }
    else
    {
        if (br3<=(br1+1)) printf ("Yes");
        else printf ("No");
    }
    return 0;

}


Measured memory_bytes: 512
#include <iostream>
#include <string> 
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <vector>
using namespace std;

int main(void) {
	string	O, E, ans;
	cin >> O >> E;

	for (int i = 0; i < E.size(); i++)
	{
		ans.push_back(O[i]);
		ans.push_back(E[i]);
	}
	if (O.size() > E.size())ans.push_back(O[O.size() - 1]);
	if (O.size() < E.size())ans.push_back(E[E.size() - 1]);
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int n;
long long w;
char s[10];
map <string,int> m;

signed main() {
	scanf("%d",&n);
	for (int i=0; i<n; ++i) {
		scanf("%s",s);
		sort(s,s+10);
		if (m.find(s)==m.end()) {
			m[s]=1;
		} else {
			w+=m[s];
			m[s]=m[s]+1;
		}
	}
	printf("%lld\n",w);
	return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <list>
#include <math.h>
using namespace std;

typedef pair<int, int> P;
#define ll long long
#define int ll


signed main(){

	int A[3];
	cin >> A[0] >> A[1] >> A[2];
	sort(A, A + 3);
	int r = 0;
	if (A[0] % 2 == 0 || A[1] % 2 == 0 || A[2] % 2 == 0) r = 0;
	else
		r = A[0] * A[1];

	cout << r << endl;

	return 0;
}




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

// #define MULTI_TEST
#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#define pc(...)
#endif

#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
auto TimeStart = chrono::steady_clock::now();
auto seed = TimeStart.time_since_epoch().count();
std::mt19937 rng(seed);
using ll = long long;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using Random = std::uniform_int_distribution<T>;

const int NAX = 2e5 + 5, MOD = 1000000007;

class Solution
{
private:
public:
    Solution() {}
    ~Solution() {}
    void solveCase()
    {
        int n, m;
        cin >> n >> m;
        vector<int> d(n);
        vector<pair<int, int>> sD(n);
        for (size_t i = 0; i < n; i++)
        {
            cin >> d[i];
            sD[i] = {d[i], i};
        }
        sort(all(sD));
        vector<vector<pair<int, int>>> adj(n);
        string S(n, 'W');
        vector<int> ans(m, 1e9);
        for (size_t i = 0; i < m; i++)
        {
            int u, v;
            cin >> u >> v;
            --u, --v;
            adj[u].pb({v, i});
            adj[v].pb({u, i});
        }
        vector<bool> aaa(n, false);
        for (size_t i = 0; i < n; i++)
        {
            int node = sD[i].s;
            if (aaa[node])
                continue;
            bool ok = false;
            for (auto &it : adj[node])
            {
                auto child = it.f;
                if (d[child] <= d[node])
                {
                    if (S[child] == 'W')
                        S[node] = 'B';
                    else
                        S[node] = 'W';
                    if (d[child] == d[node])
                        aaa[child] = true;
                    ans[it.s] = d[node];
                    ok = true;
                    break;
                }
            }
            if (ok == false)
            {
                cout << -1 << '\n';
                return;
            }
        }
        cout << S << '\n';
        for (auto &x : ans)
            cout << x << '\n';
    }
};

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
#ifdef MULTI_TEST
    cin >> t;
#endif
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef TIME
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}

Measured memory_bytes: 12416
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>

int cmp(const void *a, const void *b) {
  return strcmp(a, b);
}

int main() {

  uint32_t N, L;
  scanf("%u %u", &N, &L);

  char S[101][101];
  for(uint32_t i=0;i<N;i++)
    scanf("%s", S[i]);

  qsort(S, N, sizeof(char) * 101, &cmp);

  for(uint32_t i=0;i<N;i++)
    printf("%s", S[i]);

  puts("");

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,k;
  cin >> n >> k;
  vector<int> hp(n);
  for (int i=0; i<n; i++) {
    cin >> hp.at(i);
  }
  bool vic = false;
  sort(hp.begin(),hp.end());
  if (k >= n) {
    vic = true;
  } else {
    for (int i=0; i<k; i++) {
      hp.pop_back();
    }
    reverse(hp.begin(),hp.end());
  }
  if (vic) {
    cout << 0 << endl;
  } else {
    long int a = 0;
    for (int i=0; i<hp.size(); i++) {
      a += hp.at(i);
    }
    cout << a << endl;
  }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;cin>>n>>k;
	int ar[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>ar[i];
	}
	vector<int>dp(n,INT_MAX);
	dp[0]=0;
//	dp[1]=abs(ar[0]-ar[1]);
	for (int i = 1; i <k&&i<n; ++i)
	{
		for (int j = 1; j <=i; ++j)
		{
			dp[i]=min(dp[i],(dp[i-j]+abs(ar[i]-ar[i-j])));
		}
	}
	for (int i = k; i < n; ++i)
	{
		for (int j = 1; j <=k; j++)
		{
			dp[i]=min(dp[i],(dp[i-j]+abs(ar[i]-ar[i-j])));
		}
	}
//	for (int i = 0; i < n; ++i)
//	{
//		cout<<dp[i]<<" ";
//	}
	cout<<dp[n-1];
	return 0;
}

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

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

using namespace std;

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


  if (k == 1)
	cout << 0 << endl;
  else
	cout << n - k << endl;

  return 0;
}


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

int main() {
    int n; cin >> n;
    pair<pair<string, int>, int> R[n];
    for (int i = 0; i < n; i++) {
        string s;
        int p; 
        cin >> s >> p;
        R[i] = {{s, -p}, i + 1};
    }
    sort(R, R + n);
    for (int i = 0; i < n; i++) {
        cout << R[i].second << endl;
    }
}

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

#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

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

    int N; cin >> N;
    
    cout << (N%2==0?N:N*2) << endl;
}


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

typedef long long ll;

const ll INF=0x7fffffff;

const int MAXN=50+5;
struct COOR{
	ll x,y; 
}coor[MAXN];

int x[MAXN],y[MAXN];

bool cmpx(COOR A,COOR B){
	return A.x<B.x;
}

bool cmpy(COOR A,COOR B){
	return A.y<B.y;
}



int main()
{
	int num,n;
	cin>>n>>num;
	ll mnx=INF,mxx=-INF,mny=INF,mxy=-INF;
	for(int i=1;i<=n;i++){
		cin>>coor[i].x>>coor[i].y;
		x[i]=coor[i].x,y[i]=coor[i].y;
		if(coor[i].x>mxx)	mxx=coor[i].x;
		if(coor[i].x<mnx)	mnx=coor[i].x;
		if(coor[i].y>mxy)	mxy=coor[i].y;
		if(coor[i].y<mny)	mny=coor[i].y;
	}
	if(n==num){
		cout<<(mxx-mnx)*(mxy-mny)<<endl;
		return 0;
	}
	ll ans=9*(1e18);
	sort(x+1,x+1+n);
	sort(y+1,y+1+n);
	for(int i=1;i<n;i++){//x
		for(int j=i+1;j<=n;j++){
			for(int k=1;k<n;k++){//y
				for(int h=k+1;h<=n;h++){
					mnx=x[i],mxx=x[j],mny=y[k],mxy=y[h];
					int cnt=0;
					for(int q=1;q<=n;q++){
						if(coor[q].x>=mnx&&coor[q].x<=mxx&&coor[q].y>=mny&&coor[q].y<=mxy){
							cnt++;
						}
					}
					if(cnt>=num){
						ll area=(ll)(mxx-mnx)*(mxy-mny);
					 	ans=ans<area?ans:area;
					}
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
} 
	
	
	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    INT(n);
    int a = 0,b = 0;
    VI x(n); VIin(x);
  	SORT(x);
    rep(i,n){
        if(i % 2 == 0) a += x[i];
        else b+= x[i]; 
    }
    OUT(abs(a-b));

    return 0;
}

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

int a, b;
int nr, s;

int main() {
    cin >> a >> b;
    s = a;
    nr = 1;
    if(b == 1) {
        cout << 0;
        return 0;
    }
    while(s < b) {
        nr++;
        s = s + a - 1;
    }
    cout << nr;
    return 0;
}

Measured memory_bytes: 3636
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
ll mod = 1000000007;

int main(){
    int n;cin>>n;
    int p1,p2,p3,p4;cin>>p1>>p2>>p3>>p4;
    int t1,t2,t3,t4;cin>>t1>>t2>>t3>>t4;
    int ans = 10000000;
    rep(i1,0,n/t1+2){
        rep(i2,0,n/t2+2){
            rep(i3,0,n/t3+2){
                rep(i4,0,n/t4+2){
                    int sum = p1*i1+p2*i2+p3*i3+p4*i4;
                    if (t1*i1+t2*i2+t3*i3+t4*i4>=n){
                        ans = min(ans,sum);
                    } 
                }
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3104
#pragma region
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
#pragma endregion

void solve() {
  i64 n;
  cin >> n;
  cout << n * (n - 1) / 2 << endl;
}


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

int main() {
    string stra;
    int x;
    bool r=false;
    cin >> stra;
    for(int i=97;i<=122;i++){
        if(stra.find((char)i)==-1){
            cout << (char)i << endl;
            r=true;
            break;
        }
    }
    if(r==false){
        cout << "None" << endl;
    }
}

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

int main() {
    int N; cin >> N;
    vector<ll> A(N);
    rep(i, N){
        cin >> A[i];
    }

    vector<ll> S(N+1);
    for (int i = 1; i <= N; i++){
        S[i] = S[i-1] + A[i-1];
    }

    map<ll, ll> m;
    rep(i, N+1){
        m[S[i]]++;
    }

    ll ans = 0;
    for(auto p : m){
        auto value = p.second;
        ans += (value * (value-1)) / 2;
    }

    cout << ans << endl;

    return 0;
}

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

  int N, M;   cin >> N >> M;
  vector<pair<int , int>> pairs(N);
  for(int i = 0 ; i < N ; i++)	cin >> pairs[i].first >> pairs[i].second;

  sort(pairs.begin() , pairs.end());
  priority_queue<int> que;
  int j = 0, ans = 0;
  for(int i = 1 ; i <= M ; i++){
    
    //期限内の報酬を入れる
    while(j < N && pairs[j].first == i)
		que.push(pairs[j++].second);
     
    if(!que.empty()){
    	ans += que.top();
    	que.pop();
    }
    
  }
  
  cout << ans << endl;

  return 0;
}


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

int main() 
{
	
	int b[4]={4,6,9,11};
	int x,y;
	
    cin>>x>>y;
	
	if(x==2 || y==2)
	{
	    printf("No\n");
	}
	
	else
	{
	    if( (x==b[0] || x==b[1] || x==b[2] || x==b[3]) && ( y==b[0] || y==b[1] || y==b[2] || y==b[3]))
	    {
	        
	        printf("Yes\n");
	    }
	    
	    else if(((x==b[0] ||x==b[1] || x==b[2] || x==b[3]) && (y!=b[0] || y!=b[1] || y!=b[2] || y!=b[3])) || ((x!=b[0] ||x!=b[1] || x!=b[2] || x!=b[3]) && (y==b[0] || y==b[1] || y==b[2] || y==b[3])))
	    
	    {
	        printf("No\n");
	    }
	    
	    else
	    {
	        printf("Yes\n");
	    }
	}
	
	return 0;
}

Measured memory_bytes: 3572
import sys,queue,math,copy,itertools,bisect,collections,heapq
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

A,B,Q = LI()
s = [NI() for _ in range(A)]
t = [NI() for _ in range(B)]
x = [NI() for _ in range(Q)]

s.sort()
t.sort()
s = [-2*INF,-INF] + s + [INF,2*INF]
t = [-2*INF,-INF] + t + [INF,2*INF]

for p in x:
    ans = INF

    si = bisect.bisect_left(s,p)
    s1 = s[si-1]
    s2 = s[si]

    ti1 = bisect.bisect_left(t,s1)
    t11 = t[ti1-1]
    ans = min(ans,p - t11)
    t12 = t[ti1]
    ans = min(ans,(p - s1) + (t12 - s1)  * (t12 > p))

    ti2 = bisect.bisect_left(t,s2)
    t21 = t[ti2-1]
    ans = min(ans,(s2 - p) + (s2 - t21) * (t21 < p))
    t22 = t[ti2]
    ans = min(ans, t22 - p)

    ti = bisect.bisect_left(t, p)
    t1 = t[ti - 1]
    t2 = t[ti]

    si1 = bisect.bisect_left(s, t1)
    s11 = s[si1 - 1]
    ans = min(ans, p - s11)
    s12 = s[si1]
    ans = min(ans, (p - t1) + (s12 - t1) * (s12 > p))

    si2 = bisect.bisect_left(s, t2)
    s21 = s[si2 - 1]
    ans = min(ans, (t2 - p) + (t2 - s21) * (s21 < p))
    s22 = s[si2]
    ans = min(ans, s22 - p)

    print (ans)



Measured memory_bytes: 128600
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define prique priority_queue
#define umap unordered_map
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.1415926
#define coutdb cout<<fixed<<setprecision(15)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const int_fast64_t MOD = 1e9+7;

// typedef int_fast64_t ll;
#define int int_fast64_t
using Graph = vector<vector<int> >;
typedef pair<int, int> P;

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int N; cin >> N;
  bool ok = 0;
  int siz = 0;
  for(int i = 1; i < 1000; i++){
  	if(i*(i+1) == 2*N){
  		ok = 1;
  		siz = i+1;
  	}
  }
  if(!ok){
  	cout << "No" << endl;
  	return 0;
  }
  cout << "Yes" << endl;
  cout << siz << endl;
  vector<vector<int> > ans(siz);
  int cnt = 1;
  REP(i, siz){
  	for(int j = i+1; j < siz; j++){
  		ans[i].eb(cnt);
  		ans[j].eb(cnt);
  		cnt++;
  	}
  }
  REP(i, siz){
  	cout << siz-1 << " ";
  	for(int a : ans[i]){
  		cout << a << " ";
  	}
  	cout << endl;
  }
}


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

int main(void){
    int n; cin >> n;
    int l[n];
    int r[n];
    int sum = 0;

    for (int i=0;i<n;i++){
        cin >> l[i] >> r[i];
        sum += r[i] - l[i];
    }

    cout << sum + n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <cmath>
#include <cstdio>
using namespace std;

#define PI 4*atan(1);

int main(){
  string s;
  while(cin >> s){
    int JOI = 0, IOI = 0;
    for(int i= 0; s[i] != '\0'; i++){
      if(s[i + 1] != '\0' && s[i + 2] != '\0'){
        if(s[i] == 'J' && s[i + 1] == 'O' && s[i + 2] == 'I'){
          JOI++;
        }
        if(s[i] == 'I' && s[i + 1] == 'O' && s[i + 2] == 'I'){
          IOI++;
        }
      }
    }
    cout << JOI << endl << IOI << endl;
  }
}

Measured memory_bytes: 1196
N=int(input())
D=[input()for i in range(N)]
count=0
max_count=0
for i in range(N):
    if D[i].split()[0]==D[i].split()[1]:
        count+=1
        if count>max_count:
            max_count=count
    else:
        count=0
if max_count>=3:
    print("Yes")
else:
    print("No")

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

// 方針1　：　LCAを求めることで2点間の距離はO(logN)で出せる。
// 方針2　：　2点間の距離　－　その間の変更される色の辺のコストの総和　＋ 変更される色の数＊次のコスト
// クエリ先読みしてdfsしながらクエリに対する答えを更新していく。

struct Edge {
    int src, dst, cost, color;
    Edge(int s,int d,int c=1,int co=0) : src(s), dst(d), cost(c), color(co){}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

struct Query {
    int color, cost, qid, d;
    Query(int co, int c, int q, int d) : color(co), cost(c), qid(q), d(d) {}
};

template<typename T>
struct LCA {
    vector<T> cost;
    vector<int> depth;
    vector<vector<int>> par;
    Graph g;
    int logn;

    LCA(int n, Graph g) : cost(n), depth(n), g(g) {
        logn = 0;
        while((1<<logn) < n) ++logn;

        par.assign(n+1, vector<int>(logn, n));
        dfs(0, -1, 0, 0);

        for(int i = 0; i < logn-1; ++i) {
            for(int v = 0; v < n; ++v) {
                par[v][i+1] = par[par[v][i]][i];
            }
        }
    }

    void dfs(int v, int p, int d, T c) {
        if(p != -1) par[v][0] = p;
        depth[v] = d;
        cost[v] = c;

        for(Edge e : g[v]) {
            if(e.dst == p) continue;
            dfs(e.dst, v, d+1, cost[v] + e.cost);
        }
    }

    int get_lca(int x, int y) {
        if(depth[x] > depth[y]) swap(x, y);

        for(int i = logn-1; i >= 0; --i) {
            if(((depth[y] - depth[x])>>i) & 1) y = par[y][i];
        }
        if(x == y) return y;

        for(int i = logn-1; i >= 0; --i) {
            int nx = par[x][i], ny = par[y][i];
            if(nx != ny) x = nx, y = ny; 
        }
        return par[y][0];
    }

    T get_length(int x, int y) {
        int z = get_lca(x, y);
        return cost[x] + cost[y] - cost[z] * 2;
    }
};

Graph g;
vector<Query> qs[100010];
long sum[100010], cnt[100010], ans[100010];

int N, Q, a, b, c, d;

void solve(int v, int p) {
    for(Query q : qs[v]) {
        ans[q.qid] += (cnt[q.color] * q.cost - sum[q.color]) * q.d;
    }

    for(Edge e : g[v]) {
        if(e.dst == p) continue;
        sum[e.color] += e.cost; ++cnt[e.color];
        solve(e.dst, v);
        sum[e.color] -= e.cost; --cnt[e.color];
    }
}

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

    g.resize(N);
    for(int i = 0; i < N-1; ++i) {
        cin >> a >> b >> c >> d;
        --a, --b;
        g[a].emplace_back(a, b, d, c);
        g[b].emplace_back(b, a, d, c);
    }

    LCA<long> lca(N, g);

    for(int i = 0; i < Q; ++i) {
        cin >> a >> b >> c >> d;
        --c, --d;
        qs[c].emplace_back(a, b, i, 1);
        qs[d].emplace_back(a, b, i, 1);
        qs[lca.get_lca(c,d)].emplace_back(a, b, i, -2);
        ans[i] = lca.get_length(c, d);
    }
    solve(0, -1);

    for(int i = 0; i < Q; ++i) cout << ans[i] << '\n';
    return 0;
}

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

using namespace std;
using ll = long long;

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

const int mod = 1e9 + 7;
ll dp[100005][2];

int main() {
  string s;
  cin >> s;
  int n = s.size();
  dp[0][0] = 1;
  rep(i, n) {
    { // a+b = 0
      if (s[i] == '0') {
        dp[i + 1][0] = dp[i][0];
        dp[i + 1][1] = dp[i][1];
      } else {
        dp[i + 1][1] = (dp[i][0] + dp[i][1]) % mod;
      }
    }
    { // a+b = 1
      if (s[i] == '0') {
        (dp[i + 1][1] += dp[i][1] * 2 % mod) %= mod;
      } else {
        (dp[i + 1][0] += dp[i][0] * 2 % mod) %= mod;
        (dp[i + 1][1] += dp[i][1] * 2 % mod) %= mod;
      }
    }
    // if (s[i] == '0') {
    //   dp[i + 1][0] = (dp[i + 1][0] + dp[i][0]) % mod;
    //   dp[i + 1][1] = (dp[i + 1][1] + dp[i][1] * 4 % mod) % mod;
    // }
    // if (s[i] == '1') {
    //   dp[i + 1][0] = (dp[i + 1][0] + dp[i][0] * 2 % mod) % mod;
    //   dp[i + 1][1] = (dp[i + 1][1] + dp[i][1] * 4 % mod + dp[i][0]) % mod;
    // }
  }
  cout << (dp[n][0] + dp[n][1]) % mod << endl;
  return 0;
}


Measured memory_bytes: 5276
import itertools 
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

l = 0
c = 0

for v in itertools.permutations(xy):
  for i in range(len(v)-1):
    l += ((v[i][0] - v[i+1][0])**2 + (v[i][1] - v[i+1][1])**2)**0.5
  c += 1

print(l/c)


Measured memory_bytes: 3060
#import math
#import bisect
#import numpy as np
import itertools
import sys
input = sys.stdin.readline
MOD = 10**9 + 7
INF = float('INF')
sys.setrecursionlimit(10**5)

def main():
    n = int(input())
    s = input()
    ans = 0
    pin = list(itertools.product(range(10), repeat=3))

    for cur in pin:
        a, b, c = map(str,cur)
        if a in s:
            aidx = s.index(a)
            if b in s[aidx+1:]:
                bidx = s[aidx+1:].index(b) + (aidx + 1)
                if c in s[bidx+1:]:
                    ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int x=n/1.08;
	if((int)((x-1)*1.08)==n){
		cout<<x-1<<endl;
		return 0;
	}
	if((int)(x*1.08)==n){
		cout<<x<<endl;
		return 0;
	}
	if((int)((x+1)*1.08)==n){
		cout<<x+1<<endl;
		return 0;
	}
	cout<<":("<<endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc143/tasks/abc143_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, sum = 0;
    cin >> n;
    string s;
    cin >> s;
    s = ' ' + s;
    REP(i, n) {
        if (s[i] != s[i + 1]) {
            sum++;
        }
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=998244353;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
vector<int>kaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    //if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
signed main(){
    int n,ans=1,r=0,g=0,b=0;
    string s;
    cin>>n>>s;
    rep(i,3*n){
        if(s[i]=='R'){
            if(g&&b){
                ans*=min(g,b);
                ans%=mod;
                g--,b--;
            }
            else{
                ans*=max(max(g,b)-r,1ll);
                ans%=mod;
                r++;
            }
        }
        if(s[i]=='G'){
            if(r&&b){
                ans*=min(r,b);
                ans%=mod;
                r--,b--;
            }
            else{
                ans*=max(max(r,b)-g,1ll);
                ans%=mod;
                g++;
            }
        }
        if(s[i]=='B'){
            if(r&&g){
                ans*=min(r,g);
                ans%=mod;
                r--,g--;
            }
            else{
                ans*=max(max(r,g)-b,1ll);
                ans%=mod;
                b++;
            }
        }
    }
    rep(i,n){
        ans*=(i+1);
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}


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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif



void solve(){
    string S, T;
    int A, B;
    string U;
    cin >> S >> T >> A >> B >> U;
    
    if(U==S) cout << A-1 << " " << B << endl;
    else cout << A << " " << B-1 << endl;
    
}

signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


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

#define ll long long
#define ar array

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll d, t, s;
	cin >> d >> t >> s;
	cout << (s*t>=d?"Yes":"No") << "\n";
}


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

using namespace std;

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

    int hall=0,cnt=0;
    for(int i=0;i<n;i++){
        int tmp;
        cin>>tmp;
        if(tmp>=hall){
            hall = tmp;
            cnt++;
        }
    }
    cout<<cnt;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

int A,B,X,ans=-1;
scanf("%d%d",&A,&B);
X = A*12.5;

while ((int)(X*0.08)<A+1)
{
  if((int)(X*0.08) == A && (int)(X*0.1) == B){
    ans = X;
    break;
  }else{
    X++ ;
  }
}

printf("%d",ans);

return 0;

}

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

int mod = 1000000007;

int main()
{
    int N, K;
    cin >> N >> K;
    bool x = false;
    for (int i = 0; i <= N; i++)
    {
        for (int j = 0; j <= N; j++)
        {
            int k = N - i - j;
            if (k >= 0 &&i * 10000 + j * 5000 + k * 1000 == K)
            {
                cout << i << " " << j << " " << k;
                x = true;
                break;
            }
            if(x)
                break;
        }
        if (x)
            break;
    }
    if(!x)
        cout << "-1 -1 -1";
}

Measured memory_bytes: 256
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>n;
    a=0;
    while(sum<n){
            a++;
      sum+=a;
    }
    cout<<a<<endl;
    return 0;
}


Measured memory_bytes: 3656
import sys
import fractions
from functools import reduce
input = sys.stdin.readline
N = int(input())
T = []
for _ in range(N):
    T.append(int(input()))
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
print(lcm_list(T))

Measured memory_bytes: 5076