akhauriyash/Code-Regression huggingface dataset:
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
alias route = Tuple!(long, "From", long, "To");
long bignum = 1_000_000_007;

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    long x, y;
    scan(x, y);
    if (x % y)
    {
        foreach (n; 0 .. y)
        {
            if(n * x % y)
            {
                writeln(n * x);
                return;
            }
        }
    }
    else
    {
        writeln(-1);
    }
}


Measured memory_bytes: 256
/*
...........__________                                                                           ___  __
.............|       |                                                                           |   /
.............|       |                                                                           |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
...........__|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int                 long long
#define ull                 unsigned long long int
#define ld                  long double
#define vi                  vector<int>
#define vii                 vector<pair<int,int>>
#define vvi                 vector<vector<int>>
#define pii                 pair<int,int>
#define prec(x)             fixed<<setprecision(15)<<x
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define rev(x)              reverse(x.begin(),x.end())
#define mset(a,b)           memset(a,b,sizeof(a))
#define mcpy(a,b)           memcpy(a,b,sizeof(a))
#define fo0(i,n)            for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n)            for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b)           for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)            for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)            for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
#define inf 1e18
const int mod=1e9+7;
const int N=2e5+9;

void raushan_kumar(){

    /////////////////variables///////////////
    int d=0,e=0,f=0,g=0;
    double f1=0.0,f2=0.0,f3=0.0;
    int flag=0,ans=0,res=0,cnt=0,sum=0;
    /////////////////////////////////////////
    int s,w;cin>>s>>w;
    if(w>=s){
    	cout<<"unsafe"<<endl;
    }
    else
    	cout<<"safe";
    
}

int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    fast;int t=1;
    //cin>>t;
    while(t--){
        raushan_kumar();
    }

}

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

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        h: usize,
        w: usize,
        s: [chars; h],
    }
    let mut dp = vec![vec![h * w; w]; h];
    dp[0][0] = 0;
    for i in 0..h {
        for j in 0..w {
            if j + 1 < w {
                let cost = if s[i][j + 1] == s[i][j] {0} else {1};
                dp[i][j + 1] = std::cmp::min(dp[i][j + 1], dp[i][j] + cost);
            }
            if i + 1 < h {
                let cost = if s[i + 1][j] == s[i][j] {0} else {1};
                dp[i + 1][j] = std::cmp::min(dp[i + 1][j], dp[i][j] + cost);
            }
        }
    }
    let v = dp[h - 1][w - 1];
    let ans = match (s[0][0], s[h - 1][w - 1]) {
        ('.', '.') => v / 2,
        ('.', '#') => (v + 1) / 2,
        ('#', '.') => (v + 1) / 2,
        ('#', '#') => 1 + v / 2,
        _ => unreachable!(),
    };
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <iomanip>

using namespace std;

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    int cur = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        cur = gcd(cur, a[i]);
    }
    for (int i = 0; i < n; i++) {
        if (a[i] >= k && (a[i] - k) % cur == 0) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}


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



int main(){
    int n; cin >>n;
    int ans=0;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    for(int i=0;i<n-2;i++){
        if((p[i+1]-p[i])*(p[i+1]-p[i+2])<0){
            ans++;
        }
    }
    cout <<ans<<endl;
}




Measured memory_bytes: 256
#include <stdio.h>

#define MAXLENGTH 200001

int main(void)
{
  char s[MAXLENGTH];
  int i;
  int index_a, index_z;

  scanf("%s", s);

  for (index_a = 0; s[index_a] != 'A'; index_a++);
  for (i = index_a + 1; i < MAXLENGTH && s[i] != '\n'; i++) {
    if (s[i] == 'Z')index_z = i;
  }

  printf("%d\n", index_z - index_a + 1);

  return(0);
}

Measured memory_bytes: 384
import math
S = str(input())

RL_counter = []  # 最初の項はRの数を数える項である

now = 'R'
l_count = 0
r_count = 1
for i in range(1, len(S)):
    if S[i] == now:
        if S[i] == 'R':
            r_count += 1
        else:
            l_count += 1
    elif S[i] != now:  # マスの文字が変わった時の処理
        if S[i] == 'L':
            l_count = 1
            RL_counter.append(r_count)
            r_count = 0
            now = 'L'

        if S[i] == 'R':
            r_count = 1
            RL_counter.append(l_count)
            l_count = 0
            now = 'R'
# 最後の処理
if S[-1] == 'R':
    RL_counter.append(r_count)
else:
    RL_counter.append(l_count)

# RL_counterは完成した
# print(RL_counter)
# 3 // 2 = 1
# math.ceil(3/2) = 2
ans = [0 for _ in range(len(S))]
# print(ans)

pointa = RL_counter[0]  # 左端のLを指している
# pointa-1は右端Rのマス
# pointaは左端のLのマス
for i in range(len(RL_counter)):
    if i % 2 == 0:  # Rの処理
        ans[pointa-1] += math.ceil(RL_counter[i]/2)
        ans[pointa] += RL_counter[i]//2

    else:  # Lの処理
        ans[pointa] += math.ceil(RL_counter[i]/2)
        ans[pointa-1] += RL_counter[i]//2
        if i != (len(RL_counter)-1):
            pointa += RL_counter[i] + RL_counter[i+1]  # 次のLの左端ところにpointaを動かす

print(" ".join(map(str, ans)))


Measured memory_bytes: 11260
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(
			new InputStreamReader(System.in));
		String str = br.readLine();
		char[] input = str.toCharArray();
		input[5] = ' ';
		input[13] = ' ';
		String strr = String.valueOf(input);
		System.out.println(strr);
	}
}

Measured memory_bytes: 22868
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using pci = pair<char, int>;
using vpci = vector<pci>;
using vb = vector<bool>;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(int i=0;i<(b);i++)
#define rREP(i,b) for(int i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define Foreach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))
#define Yes out("Yes")
#define No out("No")
#define NO out("NO")
#define YES out("YES")
#define INF 1e10;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define IfOut(condition,text) if((condition)){out(text);return 0;}
#define IfeOut(condition,itext,etext) if(condition){out(itext);return 0;}else{out(etext);return 0;}
#define Select(collection,condition,result) Foreach(i,collection){result+=condition;}
#define GetAuto(_N,vect) {cin>>_N;vect.resize(_N);REP(i,_N){cin>>vect[i];}}
#define beginend(vec) (vec).begin(),(vec).end()
#define pb(item) push_back(item)
#define removeAll(vec,deleg) auto itr=remove_if(beginend(vec),deleg);vec.erase(itr,vec.end());
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
ll manhattanDistance(ll x1, ll y1, ll x2, ll y2) { return (abs(x2 - x1) + abs(y2 - y1)); }
vector<ll> sieveOfEratosthenes(int max) { ll prime; double sqrtmax = sqrt(max); vector<ll> primeVec, searchVec; FOR(i, 2, max + 1) searchVec.push_back(i); do { prime = searchVec[0]; primeVec.push_back(prime); auto itr = remove_if(beginend(searchVec), [=](ll x)->bool {return x%prime == 0; }); searchVec.erase(itr, searchVec.end()); } while (prime < sqrtmax); primeVec.reserve(primeVec.size() + searchVec.size()); primeVec.insert(primeVec.end(), beginend(searchVec)); return primeVec; }
bool isPrime(ll x) { if (x == 2) return true; if (x < 2 || x % 2 == 0) return false; ll i = 3; while (i <= sqrt(x)) { if (x%i == 0) return false; i += 2; }return true; }
vi seq(int max, int start = 0) {
	vi rt(max - start+1);
	FOR(i, start, max+1) rt[i] = i;
	return rt;
}
template<typename T> size_t find_first_of(vector<T> v, T val) {
	auto itrfind = find(beginend(v), val);
	size_t dis = distance(v.begin(), itrfind);
	if (dis == v.size())return -1;
	return dis;
}

int main(){
	int N, M;
	while (cin>>M>>N,(N||M))
	{
		vb box(7368791 + 1);
		int k = M;
		REP(i, N) {
			while (box[k]) ++k;
			for (int x = k; x < box.size(); x += k) box[x] = true;
		}
		while (box[k])++k;
		out(k);
	}
	return 0;
}

Measured memory_bytes: 3952
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,m;
  cin>>n>>m;
  int l[m],r[m];
  int i=0;
  for(i=0;i<m;i++){
    cin>>l[i]>>r[i];
  }
  int L=l[0],R=r[0];
  for(i=1;i<m;i++){
    L=max(L,l[i]);
    R=min(R,r[i]);
  }
  cout<<max(R-L+1,0)<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <climits>
#include <functional>
#include <array>
#include <cmath>

using namespace std;

int H, W;
char s[50][50]{};

int map[50][50]{};

bool IsWhite(int i, int k) {
	if (i < 0) return false;
	if (k < 0) return false;
	if (i >= H) return false;
	if (k >= W) return false;

	return s[i][k] == '.';
}

bool WriteMap(int i, int k, int step) {
	if (IsWhite(i, k) &&
		((map[i][k] == 0) || (map[i][k] > step + 1)))
	{
		map[i][k] = step + 1;
		return true;
	}

	return false;
}

bool Check4d(int i, int k, int step) {
	bool ret1 = WriteMap(i - 1, k, step);
	bool ret2 = WriteMap(i + 1, k, step);
	bool ret3 = WriteMap(i, k - 1, step);
	bool ret4 = WriteMap(i, k + 1, step);

	return ret1 || ret2 || ret3 || ret4;
}

int main(){
	
	cin >> H >> W;

	int wcnt = 0;
	for (int i = 0; i < H; ++i) {
		for (int k = 0; k < W; ++k) {
			cin >> s[i][k];
			if (s[i][k] == '.') ++wcnt;
		}
	}

	int step = 1;
	map[0][0] = step;

	bool cont = true;
	while (cont) {
		cont = false;
		for (int i = 0; i < H; ++i) {
			for (int k = 0; k < W; ++k) {
				if (map[i][k] == step) {
					if ((i == H - 1) && (k == W - 1)) {
						cout << wcnt - step << endl;
						return 0;
					}

					bool r = Check4d(i, k, step);
					cont = cont || r;
				}
			}
		}

 		++step;
	}
	

	cout << -1 << endl;

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int bubbleSort(int a[],int n,char c[]){
    int flag =1,i,tmp,ct =0;
    char tmpc;
    while(flag ==1){
        flag = 0;
        for(i = n-1;i>0;i--){
            if(a[i] < a[i-1]){
                tmp = a[i];
                a[i] = a[i-1];
                a[i-1] = tmp;
                tmpc = c[i];
                c[i] = c[i-1];
                c[i-1] = tmpc;
                flag = 1;
                ct++;
            }
        }
    }
    return ct;
}
int selectionSort(int a[],int n,char c[]){
    int ct=0,i,j,min_index,tmp;
    char tmpc;
    for(i = 0;i<n-1;i++){
        min_index = i;
        for(j =i;j<n;j++){
            if(a[min_index]>a[j]){
                min_index = j;
            }
        }
        if(i != min_index){
        tmp = a[i];
        a[i] = a[min_index];
        a[min_index]=tmp;
        tmpc = c[i];
        c[i] = c[min_index];
        c[min_index] = tmpc;
        ct++;
        }
    }
    return ct;
}
int stable_or_not(char c[],char cc[],int a[],int aa[],int num){
    int i,j,k,l;
    for(i = 0;i<num;i++){
        for(j=i+1;j<num;j++){
            if(a[i]==a[j]){
                for(k=0;k<num;k++){
                    for(l = k+1;l<num;l++){
                        if(a[i]==aa[k] && c[i]==cc[l] && a[j]==aa[l] && c[j] ==cc[k]){
                            return 0;
                        }
                    }
                }
            }
        }
    }
    return 1;
}
void display(char c[],int a[],int n){
    int i ;
    for(i=0;i<n-1;i++){
        printf("%c%d ",c[i],a[i]);
    }
    printf("%c%d\n",c[n-1],a[n-1]);
}
int main(){
    int a[36],aa[36];
    char c[36],cc[36];
    int n,i,ct;
    scanf("%d",&n);
    getchar();
    for(i = 0;i<n;i++){
        scanf(" %c%d",&c[i],&a[i]);
    }
    for(i=0;i<n;i++){
        aa[i]=a[i];
        cc[i]=c[i];
    }
    bubbleSort(aa,n,cc);
    display(cc,aa,n);
    if(stable_or_not(c,cc,a,aa,n)==0){
        printf("Not stable\n");
    }else{
        printf("Stable\n");
    }
    for(i=0;i<n;i++){
        aa[i]=a[i];
        cc[i]=c[i];
    }
    selectionSort(aa,n,cc);
    display(cc,aa,n);
    if(stable_or_not(c,cc,a,aa,n)==0){
        printf("Not stable\n");
    }else{
        printf("Stable\n");
    }
    
    return 0;
}


Measured memory_bytes: 2088
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int a, b, c;

class J {    
public:
    bool operator () (int x) const
    {   return x != a && x != b && x != c && x <= 20 - a - b;   }
};

int main()
{
    J j;
    int n[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
    while(cin >> a >> b >> c)
        cout << (count_if(n, n + 10, j) < 4 ? "NO" : "YES") << endl;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define SUM(n) ((n)+1)*(n)/2
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
 
using namespace std;

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

  string s;
  cin >> s;
  int ans = (s[0]-'0')*100 + (s[1]-'0')*10 + s[2]-'0';
  int minv = abs( ans , 753 );
  for( int i = 3 ; i < s.size() ; i ++ ){
    // cout<<ans<<" ";
    ans = ans%100;
    ans = ans*10 + s[i]-'0';
    minv = min( minv , abs( ans , 753 ) );
  }

  cout<<minv<<'\n';
  
  return 0;
}


Measured memory_bytes: 256
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

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

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


S = sys.stdin.buffer.readline().decode().rstrip()

b = 0
ans = 0
for i, c in enumerate(S):
    if c == 'W':
        ans += i - b
        b += 1

print(ans)


Measured memory_bytes: 13712
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	vector<int> res(110000);
	for(int i = 2;i < 100000;i++){
		if(res[i])continue;
		for(int j = i*2;j < 110000;j += i){
			res[j]++;
		}
	}
	// trace(res);
	vector<int> dp(110000,0);
	dp[3] = 1;
	for(int i = 4;i < 110000;i++){
		if(res[i])continue;
		if(res[(i+1)/2] == 0){
			dp[i] = 1;
		}
	}
	rep(i,100010)dp[i+1] += dp[i];

	
	int q;cin >> q;
	while(q--){
		int l,r;cin >> l >> r;
		cout << dp[r] - dp[l-1] << endl;
	}

	return 0;
}

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

#define FIO ios_base::sync_with_stdio(0); cin.tie(0);
#define T() int tt; cin >> tt; rep1(qq,1,tt)
#define rep(i,start,lim) for(int i=start;i<lim;i++)
#define rep1(i,start,lim) for(int i=start; i<=lim; ++i)
#define repd(i,start,lim) for(int i=start;i>=lim;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define br cout<<"\n"
#define MOD (1000000007LL)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define eps (1e-6)
#define what_is(x) cerr << #x << " is " << x << "\n";
#define int long long int
#define infll 9e18
#define inf 1e12

#define lnode (2 * node + 1)
#define rnode (2 * node + 2)

using namespace std;

typedef pair<int, int> pii;

const int N = 300005;

int n, m;
int a[200];


int32_t main(){

  FIO
  //cout << fixed << setprecision(10);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  cin >> n >> m;
  int tot = 0;
  rep(i,0,n){
    cin >> a[i];
    tot += a[i];
  }
  int res = 0;
  rep(i,0,n){
    if(4*m*a[i] >= tot) ++res;
  }
  if(res >= m) cout << "Yes\n";
  else cout << "No\n";

	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define inf 9999999999999
signed main(){
	int l,r;
	cin>>l>>r;
	 if(l/2019!=r/2019){
	 	cout << 0 << endl;return 0;
	 }
            
	l%=2019;r%=2019;
	if(l>r) swap(l,r);
	int ans=inf;
	for(int i=l;i<=r;i++){
		for(int j=i+1;j<=r;j++){
			ans=min(ans,(i*j)%2019);
		}
	}
	cout<<ans;
	return 0;
}

/*
54
55
*/

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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

signed main()
{   
    gearup;
    ll n;
    string x; cin >> n >> x;
    ll num = 0;
    rep(i,n)if(x[i] == '1')num++;
    if(num==0){
        rep(i,n){
            out(1);
        }
        return 0;
    }
    vl memo(200001,0);
    rep1(i,n){
        ll bit = 0;
        rep(j,30){
            if(1 & (i >> j))bit++;
        }
        memo[i] = memo[i % bit] + 1;
    }
    //mod num+1の値
    vl pmod(n);
    ll pnum = 1;
    rep(i,n){
        pmod[n-i-1] = pnum;
        pnum = pnum * 2 % (num+1);
    }
    //mod num-1の値
    vl mmod(n);
    ll nnum = 1;
    rep(i,n){
        if(num-1 > 0){
            mmod[n-i-1] = nnum;
            nnum = nnum * 2 % (num-1);
        }
    }
    ll pres = 0, mres = 0;
    rep(i,n){
        if(x[i] == '1'){
            pres += pmod[i];
            mres += mmod[i];
        }
    }

    //いずれかのビットが立っている
    rep(i,n){
        ll n_num = num;
        if(x[i] == '0')n_num++;
        else n_num--;
        //立っているビット数はn_num
        if(n_num == num+1){
            ll sum = pres;
            sum += pmod[i];
            sum %= n_num;
            ll cnt = 1;
            cnt += memo[sum];
            out(cnt);
        }
        else{
            if(n_num == 0)out(0);
            else{
                ll sum = mres;
                sum -= mmod[i];
                while(sum <= 0)sum += n_num;
                sum %= n_num;
                ll cnt = 1;
                cnt += memo[sum];
                out(cnt);
            }
        }
    }
}

Measured memory_bytes: 8336
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int k, q;
    cin >> k >> q;
    VL d(k);
    REP(i,k) d[i] = in();
    while (q--){
        ll n = in(), x = in(), m = in();
        VL a(d);
        ll s = 0, se = 0, e = 0;
        REP(i,k){
            a[i] = d[i] % m;
            s += a[i];
            se += (a[i] == 0);
        }
        // REP(i,k) cout << a[i] << " ";
        // cout << endl;
        x %= m;
        x += (n - 1) / k * s;
        e += (n - 1) / k * se;
        REP(i,(n-1)%k){
            x += a[i];
            e += (a[i] == 0);
        }
        // cout << x << endl;
        cout << n - 1 - x / m - e << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(All(v)),v.end())
typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
typedef pair<string, int> Psi;
const int INF = (1<<30);
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

int main()
{
  int N;
  vector<int> A, B;
  map<int, bool> m;

  cin >> N;
  Rep(i, N) {
    int a; cin >> a;
    A.pb( a ); B.pb( a );
  }

  sort( All( B ) );
  for(int i=0; i<N; i+=2) {
    m[A[i]] = true;
  }

  int cnt = 0;
  for(int i=1; i<N; i+=2) {
    if( m[B[i]] ) cnt++;
  }

  cout << cnt << endl;
}

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

const int N = 1e5 + 5;
const int INF = 1e9 + 5;
vector<int> adj[N];
long long dp[N][2];
int n;

void dfs(int u, int par) {
	long long mx = 0, sz = 0;
	for (int nxt : adj[u]) {
		if (nxt == par)
			continue;
		sz++;
		dfs(nxt, u);
		dp[u][1] += dp[nxt][1];
		mx = max(mx, dp[nxt][1] - dp[nxt][0]);
	}

	dp[u][0] = dp[u][1] - mx;
	if (sz == 0) {
		dp[u][1] = 1;
	} else if (sz >= 2) {
		dp[u][1] -= mx;
	}

}

int main() {

	int a, b;
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		scanf("%d%d", &a, &b);
		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	int best = 0, mx = adj[0].size();
	for (int i = 0; i < n; i++) {
		if (adj[i].size() > mx) {
			mx = adj[i].size();
			best = i;
		}
	}

	dfs(best,-1);
	printf("%lld\n", max(dp[best][0], 1LL));

	return 0;
}


Measured memory_bytes: 14976
#include<stdio.h>

class dice{
    private:
        int curface;
        int faces[6] = {};
    
    public: int GetCurface(){return curface;}
    
    dice(){
        for(int i = 0;i < 6;i++) scanf("%d",&faces[i]);
        curface = faces[0];
    }
    
    public: void Move(char toward){
        switch(toward){
            case 'N':
                faces[0] = faces[1];
                faces[1] = faces[5];
                faces[5] = faces[4];
                faces[4] = curface;
                break;
            case 'E':
                faces[0] = faces[3];
                faces[3] = faces[5];
                faces[5] = faces[2];
                faces[2] = curface;
                break;
            case 'S':
                faces[0] = faces[4];
                faces[4] = faces[5];
                faces[5] = faces[1];
                faces[1] = curface;
                break;
            case 'W':
                faces[0] = faces[2];
                faces[2] = faces[5];
                faces[5] = faces[3];
                faces[3] = curface;
                break;
        }
        curface = faces[0];
    }
    
    
};



int main(){
    char c;
    dice dsumilator;
    while((c = getchar()) != EOF){
        dsumilator.Move(c);
    }
    printf("%d\n",dsumilator.GetCurface());
}




Measured memory_bytes: 2756
import bisect

n = int(input())
lstA = sorted(list(map(int,input().split())))
lstB = sorted(list(map(int,input().split())))
lstC = sorted(list(map(int,input().split())))

ans = 0
for i in range(n):
    num = lstB[i]
    top = bisect.bisect_left(lstA, num)
    btm = n - bisect.bisect_right(lstC, num)
    ans += top*btm
print(ans)

Measured memory_bytes: 23092
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#define ll long long
#define out(a) printf("%d",a);
int n;
int x,m,ans;
int a[105];
int read()
{
	int s=0,t=1; char c;
	while (c<'0'||c>'9') {if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9') {s=s*10+c-'0'; c=getchar();}
	return s*t;
}
int main()
{
	n=read(); m=-233333;
	for (int i=1;i<=n;i++) {
	  x=read();
	  a[x]++; if (x>m) m=x;
    }
	for (int i=1;i<=m;i++)
	  if (a[i]) ans++;
	out(ans);
	return 0;
}

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

int main(){
	char s[110];
	scanf("%s", s);
	int a = 0;
	for(int i=0; s[i]!='\0'; i++){
		if(a==0 and s[i]=='C') a++;
		if(a==1 and s[i]=='F') a++;
	}
	if(a==2) puts("Yes");
	else puts("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
typedef pair<int,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
ll mad=998244353;
int ans;
int n,m,a,b;
string x;
int main() {
	cin>>a>>b;
	if(a>9||b>9){
		cout<<-1<<endl;
		return 0;
	}
	cout<<a*b<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);

int main(){
    int n,w;
    cin >> n>>w;
    vector<vector<int>>dp(n+3,vector<int>(w+1010,0));  
    vector<pair<int,int>>data(n,mp(0,0));
    rep(i,n){
        cin>>data[i].F>>data[i].S;
    }
    

    for(int i=1;i<=n;i++){
        for(int j=0;j<=w+2;j++){
            chmax(dp[i][j],dp[i-1][j]);
            if(j >= data[i-1].S){
                chmax(dp[i][j],dp[i-1][j-data[i-1].S]+data[i-1].F);
            }
            
           // clog<<dp[i][j]<<" ";

        }//clog<<endl;
    }


    cout << dp[n][w]<< endl;
}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


struct Node{
    vector<int> v;
    vector<int> del;

    bool operator< (const Node &r) const{
        return v.size() > r.v.size();
    }
};

int main(){
    int n;
    cin >> n;
    vector<int> b(n);
    rep(i, n) cin >> b[i];

    priority_queue<Node> que;
    que.push({b, vector<int>()});

    while(!que.empty()){
        Node a = que.top(); que.pop();

        if(a.v.empty()){
            rep(i, n) cout << a.del[n-i-1]+1 << endl;
            return 0;
        }

        for(int i = a.v.size()-1; 0 <= i; i--){
            if(i+1 == a.v[i]){
                Node c = a;
                c.v.erase(c.v.begin()+i);
                c.del.push_back(i);
                que.push(c);
                break;
            }
        }
    }

    cout << -1 << endl;
    
    return 0;
}


Measured memory_bytes: 256
#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 int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 998244353;
const int N = 1e6 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n, x, m;
	cin >> n >> x >> m;
	int ans = x;
	bool vis[m] = {0};
	int cur = x * x % m;
	vi v;
	while(!vis[cur]) {
		v.pb(cur);
		vis[cur] = 1;
		cur = cur * cur % m;
	}
	if(v.back() == 0) {
		for(int i = 0; i < min(n - 1, (int)v.size()); i++) {
			ans += v[i];
		}
	}
	else {
		int j = 0;
		for(int i = 0; i < (int)v.size(); i++) {
			if(v[i] == cur) {
				j = i;
				break;
			}
		}
		int cnt = 0;
		for(int i = 0; i < min(n - 1, j); i++) {
			ans += v[i];
			cnt++;
		}
		n -= (cnt + 1);
		int tot = 0;
		for(int i = j; i < v.size(); i++) {
			tot += v[i];
		}
		int sz = (int)v.size() - j;
		ans += (n / sz) * tot;
		for(int i = j; i < j + (n % sz); i++) {
			ans += v[i];
		}
	}
	cout << ans;

	return 0;
}

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

const long long mod = 1e9 + 7;

long long modpow(long long a, long long b) {
	if (b == 0) return 1;
	return modpow(a * a % mod, b / 2) * (b & 1 ? a : 1) % mod;
}

long long modinv(long long a) {
	return modpow(a, mod - 2);
}

vector<long long> fact, inv_fact;

void init_fact(int n) {
	fact.resize(n);
	fact[0] = 1;
	for (int i = 1; i < n; i++) {
		fact[i] = i * fact[i - 1] % mod;
	}
	inv_fact.resize(n);
	inv_fact[n - 1] = modinv(fact[n - 1]);
	for (int i = n - 2; i >= 0; i--) {
		inv_fact[i] = (i + 1) * inv_fact[i + 1] % mod;
	}
}

long long nPr(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return fact[n] * inv_fact[n - r] % mod;
}

long long nCr(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return fact[n] * inv_fact[r] % mod * inv_fact[n - r] % mod;
}

long long nHr(int n, int r) {
	if (n == 0 && r == 0) return 1;
	return nCr(n + r - 1, r);
}

int main() {
	init_fact(101010);

	int n;
	cin >> n;

	vector<int> a(n), b(n);
	static long long dp[4400][4400];
	for (int i = 0; i < n; i++) {
		scanf("%d %d", &a[i], &b[i]);
		dp[2010 - a[i]][2010 - b[i]]++;
	}

	for (int i = 0; i < 4200; i++) {
		for (int j = 0; j < 4200; j++) {
			(dp[i + 1][j] += dp[i][j]) %= mod;
			(dp[i][j + 1] += dp[i][j]) %= mod;
		}
	}

	long long ans = 0;
	for (int i = 0; i < n; i++) {
		(ans += dp[2010 + a[i]][2010 + b[i]]) %= mod;
		(ans += mod - nCr(a[i] * 2 + b[i] * 2, a[i] * 2)) %= mod;
	}
	ans = ans * modinv(2) % mod;
	cout << ans << endl;
}

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

int n,k,ans,temp,rough;
int main()
{
    cin>>n>>k;
    if(n<k)
        cout<<'1';
    else
    {
        ans = 1;
        temp = pow(k,ans);
        while((n-(temp*(k-1))>=temp))
        {
            ++ans;
            temp = pow(k,ans);
        }
        cout<<++ans;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static final int BIG_NUM = 2000000000;
	public static final int MOD = 1000000007;
	public static final long HUGE_NUM = 99999999999999999L;
	public static final double EPS = 0.000000001;



	@SuppressWarnings("unchecked")
	public static void main(String[] args) {

		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();

		Boolean dp[][][] = new Boolean[N][N][10];

		for(int left = 0; left < N; left++){
			for(int right = left; right < N; right++){
				for(int i = 0; i < 10; i++){

					dp[left][right][i] = false;
				}
			}
		}

		int tmp;

		for(int loc = 0; loc < N; loc++){

			tmp = scanner.nextInt();
			dp[loc][loc][tmp] = true;
		}

		for(int length = 2; length <= N; length++){
			for(int left = 0; left+length <= N; left++){
				int right = left+length-1;

				for(int mid = left; mid <= right-1; mid++){
					for(int num = 0; num <= 9; num++){

						//その区間を消せるか
						if((dp[left][mid][0] == true && dp[mid+1][right][0] == true) || //消え&消え
								(dp[left][mid][num] == true && dp[mid+1][right][num] == true)){ //2個以上の同じ数字

							dp[left][right][0] = true;
						}

						if(num == 0)continue;

						//その区間をnumだけにできるか(同じ数字が1個だけの場合あり)
						if((dp[left][mid][0] == true && dp[mid+1][right][num] == true) ||
								(dp[left][mid][num] == true && dp[mid+1][right][0] == true) ||
								(dp[left][mid][num] == true && dp[mid+1][right][num] == true)){

							dp[left][right][num] = true;
						}
					}
				}
			}
		}

		if(dp[0][N-1][0]){

			System.out.println("yes");

		}else{

			System.out.println("no");
		}

	}
}

class UTIL{

	//最大公約数
	public static long gcd(long x,long y){

		x = Math.abs(x);
		y = Math.abs(y);

		if(x < y){

			long tmp = y;
			y = x;
			x = tmp;
		}

		if(y == 0){

			return x;
		}else{

			return gcd(y,x%y);
		}
	}

	//最小公倍数
	public static long lcm(long x,long y){

		return (x*y)/gcd(x,y);
	}

	//String→intへ変換
    public static int getNUM(String tmp_str){

        return Integer.parseInt(tmp_str);
    }

    //文字が半角数字か判定する関数
    public static boolean isNumber(String tmp_str){

        if(tmp_str == null || tmp_str.length() == 0){

            return false;
        }

        Pattern pattern = Pattern.compile("\\A[0-9]+\\z");
        Matcher matcher = pattern.matcher(tmp_str);
        return matcher.matches();
    }
}


Measured memory_bytes: 29476
package main
 
import "fmt"
// import "math"
 
func main(){
	var A, B int
	var N int
	var a int
 
	fmt.Scan(&N, &A, &B)
	ab := A + B 
	syo := N / ab * A
	amari := N % ab

	if A <= amari{
		a = A
	}else {
		a = amari
	}
	// fmt.Println(syo*A, a)
	ans := syo + a
 
	fmt.Println(ans)
}

Measured memory_bytes: 512
#include <stdio.h>

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

void insertSort(int A[], int N){
    int j, i, v;
    for(i=1;i<N;i++){
        v = A[i];
        j = i - 1;
        while(j>=0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        trace(A, N);
    }
}

int main(){
    int N, i, j;
    int A[100];
    scanf("%d", &N);
    for(i=0;i<N;i++) scanf("%d", &A[i]);
    trace(A,N);
    insertSort(A,N);

    return 0;
}

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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	int n, sb = 0, ea = 0, sbea = 0, ab = 0;
	cin >> n;
	while (n--) {
		string str;
		cin >> str;
		if (str[0] == 'B' && str.back() == 'A') sbea++;
		else if (str[0] == 'B') sb++;
		else if (str.back() == 'A') ea++;
		for (int i = 0; i + 1 < str.size(); i++) {
			ab += str.substr(i, 2) == "AB";
		}
	}
	int ans = ab;
	if (sb || ea) {
		ans += sbea;
		ans += min(sb, ea);
	}
	else {
		ans += max(sbea - 1, 0);
	}
	cout << ans << "\n";
}


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


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

const ll MOD=1'000'000'007;
ll N,K;

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

    ll ans=0;
    for(ll i=K;i<=N+1;i++){
        ans+=N*(N+1)/2-(N-i)*(N-i+1)/2-i*(i-1)/2+1;
        ans%=MOD;
    }

    if(ans<0) ans+=MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 3640
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ll N, K;
  cin >> N >> K;
  ll answer = 0;
  REP(i, N) {
    ll x;
    cin >> x;
    const auto Kd = K - x > x - K ? K - x : x - K;
    answer += (x < Kd) ? x + x : Kd + Kd;
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    string s;
    cin >> s;
    yorn(
        s.find('a') != std::string::npos &&
        s.find('b') != std::string::npos &&
        s.find('c') != std::string::npos);
    return 0;
}

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

int main() {

  int N;
  cin >> N;

  int count = 0;

  for (int i = 1; i <= N; i++) {
    int p;
    cin >> p;
    if (p != i) {
      count++;
    } 
  }

  if (count <= 2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {


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

		while(true){
			int ans_cnt = 0;
			int n = scan.nextInt();//???????????°???????????????
			int x = scan.nextInt();//???????±?????????°???????????????
			if(n == 0 && x == 0)
				break;
			for(int cnt1 = 1; cnt1 <= n; cnt1++){
				for(int cnt2 = cnt1 + 1; cnt2 <= n; cnt2++){
					for(int cnt3 = cnt2 +1; cnt3 <= n; cnt3++){
						if((cnt1 + cnt2 + cnt3) == x)
							ans_cnt++;
					}
				}
			}
			System.out.println(ans_cnt);	
		}
		scan.close();
	}
}

Measured memory_bytes: 26612
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int H,W,N;
    cin >> H >> W >> N;
    if((N%max(H,W)) == 0){
        pr(N / max(H,W));
    }else{
        pr(N / max(H,W)+1);

    }
}

Measured memory_bytes: 256
n, k = map(int, input().split())

okashi = [0 for _ in range(n)]
#print(okashi)
for i in range(k):
    d = int(input())
    lis = list(map(int,input().split()))
    for j in lis:
        okashi[j-1] = 1
        
#print(okashi)
print(okashi.count(0))

Measured memory_bytes: 9176