akhauriyash/Code-Regression huggingface dataset:
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

n, p = map(int,input().split())

fac = factorize(p)

ans = 1
for v, k in fac:
    ans *= v**(k//n)

print(ans)

Measured memory_bytes: 62892
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    e = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b = ns()
        a, b = a - 1, b - 1
        e[a].append(b)
        e[b].append(a)

    c = na()
    c.sort(reverse=True)
    cost = collections.deque(c)

    notvisited = [True for _ in range(n)]
    ans = [-1 for _ in range(n)]

    que = collections.deque(e[0])
    notvisited[0] = False
    ans[0] = cost.popleft()

    while que:
        for _ in range(len(que)):
            q = que.popleft()
            if notvisited[q]:
                ans[q] = cost.popleft()
                notvisited[q] = False
                for ei in e[q]:
                    que.append(ei)

    res = 0
    for i in range(n):
        for ei in e[i]:
            if i < ei:
                res += min(ans[i], ans[ei])

    print(res)
    print(*ans, sep=" ")


if __name__ == '__main__':
    main()


Measured memory_bytes: 13912
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N;cin>>N;
	long L[N],R[N];
	rep(i,0,N) cin>>L[i]>>R[i];
	auto it1=max_element(L,L+N);long l=*it1;long b=R[it1-L];
	auto it2=min_element(R,R+N);long r=*it2;long a=L[it2-R];
	long d=0;
	rep(i,0,N){
		//if(L[i]==l||R[i]==r) continue;
		d=max(d,R[i]-L[i]+1);
	}
	rep(i,0,N)if(L[i]==l&&R[i]==r){ cout<<r-l+1+d<<endl; return 0; }
  
	vector<pair<long,long>> vp;
	rep(i,0,N)if(a<=L[i]&&R[i]<=b) vp.push_back({L[i],R[i]});
	int n=vp.size();
	if(n==0){ cout<<b-l+r-a+2<<endl; return 0; }
  
	sort(vp.begin(),vp.end());
	long lg[n+1],rs[n+1];lg[0]=a;rs[n]=b;
	rep(i,1,n+1) lg[i]=max(lg[i-1],vp[i-1].first);
	for(int i=n-1;i>=0;i--) rs[i]=min(rs[i+1],vp[i].second);
	long ans=0;long s,t;
	rep(i,0,n+1){
		s=max((long)0,rs[i]-l+1);
		t=max((long)0,r-lg[i]+1);
		ans=max(ans,s+t);
	}cout<<max(ans,max((long)0,r-l+1)+d)<<endl;
}

Measured memory_bytes: 5104
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(10);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
using P = pair<int,int>; using vp = vector<P>;
constexpr int MOD = /** 1000000007; //*/ 998244353;
////////////////



void solve(){
  ini(M , N);
  vi a(N); in(a);
  if(M == 2){
    // 1 2 1 2
    int c1 = 0 , c2 = 0;
    rep(i , N){
      if(a[i] == 1 + (i & 1)) c1++;
      if(a[i] == 2 - (i & 1)) c2++;
    }
    trc(c1 , c2);
    out(min(c1 , c2));
    exit(0);
  }

  int ans = 0;
  for(int i = 0 ; i < N - 1; ){
    if(a[i] == a[i + 1]){
      // i + 1を変える
      ans++;
      i += 2;
    }
    else i++;
  }
  out(ans);

}


Measured memory_bytes: 3512
from bisect import bisect_right as br
n,m,k = map(int,input().split())
a = [int(i) for i in input().split()]
sa = [0]*(n+1)
for i in range(n): sa[i+1] = sa[i]+a[i]
b = [int(i) for i in input().split()]
sb = [0]*(m+1)
for i in range(m): sb[i+1] = sb[i]+b[i]
ans = 0
for i in range(n+1):
    if sa[i] > k: break
    ans = max(ans,br(sb,k-sa[i])-1+i)
print(ans)

Measured memory_bytes: 53300
n=int(input())
a=[[0,0,0]]

for i in range(n):
  a.append(list(map(int, input().split(" "))))
for i in range(n):
  check =  a[i + 1][0] - a[i][0] - (abs(a[i+1][1]-a[i][1]) + abs(a[i+1][2]-a[i][2]))
  if check >= 0 and check % 2 == 0:
    continue
  else:
    print("No")
    break
else:
  print("Yes")

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

int main(){
    string s;cin>>s;
    char c=s[0];
    int ans=1;
    for(int i=1;i<s.length();++i){
        if(s[i]!=c){
            ans++;
            c=s[i];
        }
    }
    cout<<ans-1<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<ll, int>;
using Graph = vector<vector<P>>;

Graph g;

int main(){
  int v, e, r;
  cin >> v >> e >> r;
  g.resize(v);
  for(int i = 0; i < e; ++i){
  	int s, t, d;
  	cin >> s >> t >> d;
  	g[s].push_back({t, d});
  }

  vector<ll> dist(v, LINF);
  priority_queue<P, vector<P>, greater<P>> que;
  dist[r] = 0;
  que.push({dist[r], r});

  while(!que.empty()){
  	auto v = que.top();
  	que.pop();
    int from = v.second;

  	for(auto nv : g[from]){
  		int cost = nv.second;
  		if(dist[from] + cost < dist[nv.first]){
  			dist[nv.first] = dist[from] + cost;
  			que.push({dist[nv.first], nv.first});
  		}
  	}
  }

  for(int i = 0; i < v; ++i){
  	if(dist[i] == LINF){
  		cout << "INF" << endl;
  	}
  	else cout << dist[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 19324
use std::str::FromStr;
use std::io::*;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = AtRead::from(i);
    let s = i.read_line();
    let s = s.as_bytes();
    let mut p = 0;
    for &si in s {
        if si == b'p' {
            p += 1;
        }
    }
    writeln!(o, "{}", s.len() / 2 - p).unwrap();
}

mod utils {
    #![allow(dead_code)]
    use super::*;

    pub struct AtRead<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        {$f:ident($($v:ident: $t:ident),*)} => {
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                $(
                    let $v = next(i);
                )*
                ($($v),*)
            }
        };
    }

    impl<R: BufRead> AtRead<R> {
        pub fn from(r: R) -> Self {
            AtRead {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(v1: T1, v2: T2) }
        fn_read! { read3(v1: T1, v2: T2, v3: T3) }
        fn_read! { read4(v1: T1, v2: T2, v3: T3, v4: T4) }

        pub fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            self.read_line()
                .split(' ')
                .take(n)
                .map(|x| x.parse().ok().unwrap())
                .collect()
        }
    }

    fn next<'a, T: FromStr, I: std::iter::Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c)
    {
        cout << 1 << endl;
    }
    else if (a == b || b == c || c == a)
    {
        cout << 2 << endl;
    }
    else
    {
        cout << 3 << endl;
    }
    
}

Measured memory_bytes: 256
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
INF = 1000000000000

a,v = LI()
b,w = LI()
T = I()

if(a == b):
    print('YES')
elif(a > b):
    diff = a - b
    diff2 = v - w
    if(diff2 <= 0):
        print('NO')
    else:
        if(diff / diff2 <= T):
            print('YES')
        else:
            print('NO')
else:
    diff = b - a
    diff2 = v - w
    if(diff2 <= 0):
        print('NO')
    else:
        if(diff / diff2 <= T):
            print('YES')
        else:
            print('NO')


Measured memory_bytes: 9228
n = int(input())
hlis = list(map(int, input().split()))
hlis.reverse()

cnt = 0
for i in range(n):
    tmp = "ok"
    for j in range(i+1,n):
        if hlis[i]<hlis[j]:
            tmp = "ng"
    if tmp == "ok":
        cnt = cnt + 1
        
print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod=7+1e9;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
ll qpow(ll a,ll b,ll p){a%=p; ll ret=1;for(;b;b>>=1,a=a*a%p) if(b&1) ret=ret*a%p; return ret;}
ll getInv(ll x,ll p){return qpow(x,p-2,p);}

int main(){
    string s; cin>>s;
    for(int i='a';i<'a'+26;i++){
        for(int j=0;j<s.size()-1;j++){
            if(s[j]==i&&s[j+1]==i){
                cout<<j+1<<' '<<j+1+1<<'\n';
                return 0;
            }
        }
        for(int j=0;j<s.size()-2;j++){
            if(s[j]==i&&s[j+2]==i){
                cout<<j+1<<' '<<j+2+1<<'\n';
                return 0;
            }
        }
    }
    puts("-1 -1");
}

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

using namespace std;

int N, M, mod, a[59][59];
int DBG = 0;

namespace localTester {
    int s[59][59], a[59][59];
    void init (int overall)
    {
        if (DBG == 1)
        {
            int nr = 0, x[N * M + 1], y[N * M + 1];
            for (int i=1; i<=N; i++)
                for (int j=1; j<=M; j++)
                    x[++nr] = i, y[nr] = j;
            bool type[nr + 1];
            for (int i=1; i<=nr; i++)
                type[i] = (i <= overall);
            random_shuffle (type + 1, type + nr + 1);
            for (int i=1; i<=nr; i++)
                if (type[i])
                    a[x[i]][y[i]] = s[x[i]][y[i]] = 1;
        }
        else
        if (DBG == 2)
        {
            for (int i=1; i<=N; i++)
                for (int j=1; j<=M; j++)
                    scanf ("%d", &a[i][j]), s[i][j] = a[i][j];
        }
        for (int i=1; i<=N; i++)
            for (int j=1; j<=M; j++)
                s[i][j] += s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];
    }
    int query (int a1, int b1, int a2, int b2)
    {
        return s[a2][b2] - s[a1 - 1][b2] - s[a2][b1 - 1] + s[a1 - 1][b1 - 1];
    }
}

int queries = 0;
int query (int a1, int b1, int a2, int b2)
{
    queries ++;
    if (DBG) return localTester::query (a1, b1, a2, b2);
    printf ("? %d %d %d %d\n", a1 - 1, b1 - 1, a2 - 1, b2 - 1);
    fflush (stdout);
    int x;
    scanf ("%d", &x);
    return x;
}

void solve (int a1, int b1, int a2, int b2, int sum)
{
    if (sum == 0 || sum == (a2 - a1 + 1) * (b2 - b1 + 1))
    {
        for (int i=a1; i<=a2; i++)
            for (int j=b1; j<=b2; j++)
                a[i][j] = (sum > 0);
        return ;
    }
    if (a2 - a1 < b2 - b1)
    {
        int mid = (b1 + b2) / 2, s0 = query (a1, b1, a2, mid);
        solve (a1, b1, a2, mid, s0);
        solve (a1, mid + 1, a2, b2, sum - s0);
    }
    else
    {
        int mid = (a1 + a2) / 2, s0 = query (a1, b1, mid, b2);
        solve (a1, b1, mid, b2, s0);
        solve (mid + 1, b1, a2, b2, sum - s0);
    }
}

void finish ()
{
    if (DBG)
    {
        for (int i=1; i<=N; i++)
            for (int j=1; j<=M; j++)
                if (localTester::a[i][j] != a[i][j])
                {
                    printf ("WA\n");
                    exit (0);
                }
        printf ("OK %d\n", queries);
        //exit (0);
    }
    int p2[N * M + 10], ans = 0;
    p2[0] = 1;
    for (int i=1; i<=N * M; i++)
        p2[i] = (p2[i - 1] + p2[i - 1]) % mod;
    for (int i=0; i<N; i++)
        for (int j=0; j<M; j++)
            if (a[i + 1][j + 1])
                ans = (ans + p2[i * M + j]) % mod;
    printf ("! %d\n", ans);
/*    for (int i=1; i<=N; i++, printf ("\n"))
        for (int j=1; j<=M; j++)
            printf ("%d", a[i][j]);*/
    fflush (stdout);
}

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

int overall;
scanf ("%d %d %d %d", &N, &M, &overall, &mod);
localTester::init (overall);
solve (1, 1, N, M, overall);
finish ();

return 0;
}


Measured memory_bytes: 848
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int R = scanner.nextInt();

		if((0<=R) && (R<1200)) {
			System.out.println("ABC");
		}else if((1200<=R) && (R<2800)) {
			System.out.println("ARC");
		}else {
			System.out.println("AGC");
		}


	}

}


Measured memory_bytes: 23764
object Main extends App {
	val N = scala.io.StdIn.readLine.split(" ").map(_.toInt)
	val L = scala.io.StdIn.readLine.split(" ").map(_.toInt).toList

	def sort(x: List[Int]): List[Int] = {
		x match {
			case Nil => List[Int]()
			case r::Nil => List(r)
			case r::rest =>{
				val temp = rest.toArray
				var right = List(r)
				var left = List[Int]()

				for(i<-0 until rest.size){
					if(temp(i) > r) right = temp(i)::right
					else left = temp(i)::left
				}

				sort(left):::sort(right)
			}
		}
	}

	def sum(x: List[Int], y: Int): Int = {
		x match {
			case Nil => y
			case r::rest => sum(rest,r+y)
		}
	}

	def get(x: List[Int], y: Int): List[Int] = {
		y match {
			case 0 => x
			case _ => get(x.tail, y-1) 
		}
	}

	println(sum(get(sort(L), N(0)-N(1)),0))
}



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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル

	int n;
	cin >> n;

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

	ll ans = 0;
	int mx = 0;
	rep(i,n){
		chmax(mx, a[i]);
		if(mx != a[i]){
			ans += mx - a[i];
		}
	}
	cout << ans << endl;

}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

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

using namespace std;


/// Bismilahir Rahmanir Rahim


typedef unsigned int ui;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef short int si;
typedef unsigned short int usi;
typedef double dd;
typedef pair <int, int> pii;


#define CASE false
#define TEST false
#define BUFFER false
#define TIME false
#define DEBUG true
#define SET_GEN false
#define _ << " " <<
#define __ << "\n"
#define ff first
#define ss second
#define RANGE(a, b) (rand() % (b-a+1) + a)


const double pi = acos(-1.);
const double eps = 1e-7;
const int inf = 2147483647;
const int _inf = -2147483648;
const int mod = 1e9+7;


void delay(int sec); // DEBUG


void solution(void)
{
    int n, w;

    cin >> n >> w;

    vector <ulli> ks(w+1);
    ulli ans = 0;

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

        cin >> weight >> val;
        for(int weight_already = w-weight; weight_already >= 0; --weight_already) {
            ks[weight_already+weight] = max(ks[weight_already+weight], ks[weight_already]+val);
            ans = max(ks[weight_already+weight], ans);
        }
    }

    cout << ans << "\n";

   // ks.clear();



    return ;
}

int main(int argc, char *arv[])
{
    #if BUFFER
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #endif

    #if SET_GEN
    srand((unsigned int) time(0));
    #endif


    unsigned short int t = 1;

    #if CASE
    int cnt = 1;
    #endif

    #if TEST
    cin >> t;
    #endif

    #if TIME
    clock_t start_time, end_time;
    double time_elapsed;
    #endif


    while(t--) {

        #if TIME
        start_time = clock();
        #endif

        #if CASE
        cout << "Case " << cnt++ << ": ";
        #endif

        solution();

        #if TIME
        end_time = clock();

        time_elapsed = (double) (end_time - start_time) / CLOCKS_PER_SEC;

        cout << "\nRuntime: " << fixed << setprecision(7) << time_elapsed << "\n";
        #endif
    }


    return 0;
}

void delay(int sec)
{
    int mili_sec = 1000 * sec;

    clock_t start_time = clock();

    while (clock() < start_time + mili_sec);

    return ;
}


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

typedef vector<int> vi;
typedef pair<int, int> pii;
#define endl "\n"
#define sd(val) scanf("%d", &val)
#define ss(val) scanf("%s", &val)
#define sl(val) scanf("%lld", &val)
#define debug(val) printf("check%d\n", val)
#define all(v) v.begin(), v.end()
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
#define MOD 1000000007
#define clr(val) memset(val, 0, sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define OJ                            \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

int main()
{

    int n;

    cin >> n;

    if (n % 1000 == 0)
        cout << "0";

    else
    {
        int ans = abs((n % 1000) - 1000);
        cout << ans;
    }

    return 0;
}

Measured memory_bytes: 3620
N = gets.to_i
strs = readlines.map { |l| l.chomp.split(//).sort }.sort_by { |a| a.length }
 
str1 = strs.shift
result = []
str1.each do |c|
  if strs.all? { |s| s.include?(c) }
    strs.each do |s|
      i = s.index(c)
      s.delete_at(i)
    end
    result << c
  end
end
 
puts(result.join)

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

void solve(){
	
	int n ,m ;
	cin>>n>>m ;

	//pair--------------->penalty,mark if ac

	vector<int> AC(n) ;
	vector<int> pen(n) ;

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

		int p ;
		string s ;

		cin>>p>>s ;
		p-- ;

		if(AC[p]==1){
			continue ;
		}
		else{

			if(s=="WA"){
				pen[p]++ ;
			}
			else
			{
				AC[p]=1; 
			}

		}

	}

	int ac=0 ;
	int penalty=0 ;

	for(int i=0;i<n;i++){
		
		ac+=AC[i] ;
		
		if(AC[i])
		penalty+=pen[i] ; 
	}

	cout<<ac<<" "<<penalty ;
}

int main(){
	
	int y ;

	y=1 ;
	//cin>>y ;

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

}

Measured memory_bytes: 4028
import java.util.*;

public class Main {
  // constant
  static final int MAX_N = 1000;

  // subroutines
  static int lower_bound(int[] arr, int key, int i0, int i1) {
    int lb = i0 - 1;
    int ub = i1;

    while (lb + 1 < ub) {
      int m = (lb + ub) / 2;
      if (arr[m] <= key)
        lb = m;
      else
        ub = m;
    }

    return lb;
  }

  // main
  public static final void main(String[] args) throws Exception {
    Scanner sc = new Scanner(System.in);

    for (;;) {
      int n = sc.nextInt();
      int m = sc.nextInt();
      if ((n | m) == 0) break;

      int[] ps = new int[n + 1];
      ps[0] = 0;

      for (int i = 1; i <= n; i++)
        ps[i] = sc.nextInt();

      int[] p2s = new int[(n + 1) * (n + 2) / 2];
      int np2s = 0;

      for (int i = 0; i <= n; i++) {
        int pi = ps[i];
        for (int j = i; j <= n; j++)
          p2s[np2s++] = pi + ps[j];
      }

      Arrays.sort(p2s);

      int max_s = 0;

      for (int p2: p2s) {
        if (m < p2) break;
        int rem = p2s[lower_bound(p2s, m - p2, 0, np2s)];
        int s = p2 + rem;
        if (max_s < s) max_s = s;
      }

      System.out.println(max_s);
    }
  }
}

Measured memory_bytes: 39612
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x);
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

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

    //start from here

    read(n) readarr(t, n)
    read(m) int p[m+1], x[m+1], sum = 0;

    fori (i, 1, m) cin >> p[i] >> x[i];

    fori (i, 1, n) sum += t[i];

    fori (i, 1, m)
    {
    	cout << sum - t[p[i]] + x[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Author: z0marlin
Title: c.cpp
Time: 15-08-2019T12:54:33+0530 
I suck at CP T_T
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
#include <bits/stdc++.h>
#if DEBUG
#define dprintf(...) printf(__VA_ARGS__)
#else
#define dprintf(...)
#endif
#define FOR(i, a, n) for(int i = a; i < n; ++i)
#define FORE(a, v) for(auto a:v)
#define MAX(a, b) ((a>b)?a:b)
#define MIN(a, b) ((a<b)?a:b)
#define MP(i, j) make_pair(i, j)
#define PB(a) push_back(a)
#define PPB(a) pop_back(a)
#define all(a) a.begin(), a.end()

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii_t;
typedef pair<ll,ll> pll_t;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;

const int MAX_SZ=1e6+2;
const int MOD=1e9+7;
int t = 1, n, m, q, ql, qr;
char ch[15];
vector<string> inp;
unordered_map<string, ll> mp;

ll solve(){
    FOR(i,0,n){
        sort(all(inp[i]));
        mp[inp[i]]++;
    }
    ll count = 0;
    FORE(p, mp){
        count+= (p.second*(p.second-1))/2;
    }
    return count;
}

int main(){
	// scanf("%d", &t);
	while(t--){
		scanf("%d",&n);
        inp.resize(n);
        FOR(i,0,n){
            cin>>inp[i];
        }
        printf("%lld\n", solve());
	}
}

Measured memory_bytes: 17700
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int hotel = sc.nextInt();

		ArrayList<Integer> mountains = new ArrayList<Integer>();

		for (int i = 0; i < hotel; i++) {
			final int mountain = sc.nextInt();
			mountains.add(mountain);
		}

		int firstHotel = mountains.get(0);
		int largestHotel = mountains.get(0);
		int result = 0;
		for (int j = 1; j < hotel; j++) {
			if (firstHotel <= mountains.get(j) && largestHotel <= mountains.get(j)) {
				largestHotel = mountains.get(j);
				result++;
			}

		}

		System.out.println(result + 1);

	}

}


Measured memory_bytes: 22868
import math

n, d = map(int, input().split())

ans = 0
for _ in range(n):
    x, y = map(int, input().split())
    # print(f"{x} {y}")
    
    kyori = math.sqrt((x ** 2) + (y **2))
    # print(kyori)
    if kyori <= d:
        ans += 1

print(ans)

Measured memory_bytes: 9080
n = int(input())
l = []
flag = False
ans = 0

for i in range(n):
    s, t = input().split()
    t = int(t)
    l.append([s, t])

x = input()

for s, t in l:
    if flag == True:
        ans += t
    elif s == x:
        flag = True

print(ans)

Measured memory_bytes: 9128
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val arr = arrayOf(1,2,4,8,16,32,64,128)
    for (i in arr.indices) {
        if (arr[i+1] > n) {
            println(arr[i])
            break
        }
    }
}



Measured memory_bytes: 35772
#include<stdio.h>
int main()
{
    int a,i,j=0;
 
    scanf("%d",&a);
 
    int A[a];
 
    for(i = 0;i < a; i++)
    {
        scanf("%d", &A[i]);
 
        if(A[i] != i+1) 
            j++;
    }
 
    if(j > 2) 
        printf("NO\n");
    else 
        printf("YES\n");
 
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n,k;
constexpr int inf = 1e5 + 104;
vector<int> dp(inf);
vector<bool> vis(inf);
vector<int>v;
int f(int x) {
	int& ans = dp[x];
	if (x >= n - 1) {
		return 0;
	}
	if (vis[x]) {
		return ans;
	}
	else {
		vis[x] = 1;
		ans = abs(v[x] - v[x + 1]) + f(x + 1);
		for (int i = 2; (i<=k)&&((i+x)<n); i++) {
			ans = min(ans, abs(v[x] - v[x + i]) + f(x + i));
		}
		return ans;
	}
}
int main() {
	int t;
	cin >> n>>k;
	for (int i = 0; i < n; i++) {
		cin >> t;
		v.push_back(t);
	}
	cout << f(0);
}

Measured memory_bytes: 7420
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		
		int a = 4*x-y;
		int b = y-2*x;

		if (a>=0 && a%2 == 0 && b>=0 && b%2 == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 35764
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include<limits.h>
using namespace std;
using T = tuple<int,int,int>;

#define eb emplace_back
#define pb push_back
#define MP make_pair
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define rep(i,j,n) for (int i = j; i < n; ++i)
#define repn(i,j,n) for (int i = j; i <= n; ++i)
#define revn(i,j,n) for (int i = j; i >= n; --i)
#define sz(i) i.size()
#define mem(i,v) memset(i,v,sizeof(i))
#define all(v) v.begin(), v.end()
//#define endl '\n'
#define int long long
#define INF 1e7
#define ss second
#define ff first
#define vi vector<int>
#define pri(arr,a,b) repn(i,1,a){repn(j,i+1,b){cout<<arr[i][j]<<" ";}cout<<endl;}

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair<int,pair<int,int>> piii;
 
string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

const int mod=1e9+7;
//const int mod=998244353;
const int up=2e5+10;
const int MAXN=100;

int mxe[up],mxo[up],a[up];

void solve()
{
    int n;
    cin>>n;
    int p[n][n];
    rep(i,0,n){
        rep(j,0,n){
            cin>>p[i][j];
        }
    }
    int dp[1LL<<n];
    rep(i,0,1LL<<n){
        vi v;
        rep(j,0,n){
            if(i&(1LL<<j))
                v.pb(j);
        }
        dp[i]=0;
        for(auto u:v){
            for(auto k:v){
                dp[i]+=p[u][k];
            }
        }
        dp[i]/=2;
    }
    rep(i,1,1LL<<n){
        for(int j=i;j>0;j=(j-1)&i){
            dp[i]=max(dp[i],dp[j]+dp[j^i]);
        }
    }
    cout<<dp[(1LL<<n)-1]<<endl;
}



int32_t main()
{
    // #ifndef ONLINE_JUDGE
    //     freopen("inputf.in", "r", stdin);
    //     freopen("outputf.in", "w", stdout);
    // #endif
    fast_cin();
    int T;
    //sieve();
    //Sieve(100);
    //cin>>T;
    T=1;
    int t1=1;
    while(true)
    {  
        solve();  
        t1++;
        if(t1>T)
            break;
    }
}

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

int main() {
    int a, b, k;
    cin >> a >> b >> k;

    int counter = 0;
    for (int i = min(a, b); i > 0; i--) {
        if (a % i == 0 && b % i == 0) {
            counter++;
            if (counter == k) {
                cout << i << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int ball_invest(int balls[11],int ball_num,int B[11],int C[11],int bn,int cn){
	int is_possible = 0;
	int i;

	if(B[bn] < balls[ball_num]){
		if(ball_num == 10)return 1;

		B[bn+1] = balls[ball_num];
		is_possible += ball_invest(balls,ball_num + 1,B,C,bn+1,cn);
		B[bn+1] = 0;
	}
	
	if(C[cn] < balls[ball_num]){
		if(ball_num == 10)return 1;

		C[cn+1] = balls[ball_num];
		is_possible += ball_invest(balls,ball_num + 1,B,C,bn,cn+1);
		C[cn+1] = 0;
	}
	
	return is_possible;
}

int main(void){
	int B[11];
	int C[11];
	int balls[11];
	int i;
	int n;
	int is_possible = 0;
	
	scanf("%d",&n);
	for(;n > 0;n--){
		B[0] = 0;
		C[0] = 0;
		for(i = 1;i <= 10;i++){
			scanf("%d",&balls[i]);
			B[i] = 0;
			C[i] = 0;
		}
		is_possible = ball_invest(balls,1,B,C,0,0);
		
		if(is_possible >= 1)printf("YES\n");
		else printf("NO\n");
	}
	
	return 0;
}

Measured memory_bytes: 580
import numpy as np
N,M=[int(x) for x in input().split()]

L=np.zeros((2,N))
for n in range(N):
  l=[int(x) for x in input().split()]
  L[0][n]=l[0]
  L[1][n]=l[1]
  
L=L[:, L[0,:].argsort()]

d_num=0
price=0

for l in range(len(L[0])):
  a=L[0][l]
  b=L[1][l]
  
  if d_num < M:
    if d_num+b < M:
      price+=a*b 
      d_num+=b 
    else:
      price+=a*(M-d_num)
      d_num=M
                
print(int(price))

Measured memory_bytes: 16360
//============================================================================
// Name        : ATcoder.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main() {


	char chr[101][101];
	int h,w;

	cin>>h>>w;

	for(int i=0; i<h; ++i){
		for(int j=0; j<w; ++j){
			cin>>chr[i][j];
		}
	}
	for(int j=0; j<w+2; ++j){
		cout<<"#";
	}
	cout<<endl;

	for(int i=0; i<h; ++i){
		cout<<"#";
		for(int j=0; j<w; ++j){
			cout<<chr[i][j];
		}
		cout<<"#"<<endl;
	}
	for(int j=0; j<w+2; ++j){
		cout<<"#";
	}
	cout<<endl;



	return 0;
}



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

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

    int n,m;cin>>n>>m;

    vector<vector<int>> g(n+1);
    for(int i=0;i<m;i++)
    {
        int a,b;cin>>a>>b;
        g[a].push_back(b);
    }

    bool ans=false;

    for(auto g1:g[1])
    {
        for(auto g2:g[g1])if(g2==n){ans=true;break;}
        if(ans)break;
    }

    puts(ans?"POSSIBLE":"IMPOSSIBLE");

    return 0;
}


Measured memory_bytes: 11272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 2e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
int n, ans;
int a[maxx];

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	int minT = Inf;
	for(int i = 1; i <= n; i++) {
		minT = min(minT, a[i]);
		if(a[i] <= minT) ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
using namespace std;
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 LLINF=1LL<<60;
//set<int>::iterator it;


int gcd(int x,int y){
	int t;
	while(y!=0){
		t=x%y;x=y;y=t;
	}
	return x;
}


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	int i,n,j;
	cin>>n;
	int a[n];
	rep(i,n)cin>>a[i];
	vector<int> l,r(n,0);
	l.push_back(a[0]);
	rep(i,n-1) l.push_back(gcd(a[i+1],l[i]));
	r[n-1]=a[n-1];
	for(i=n-2;i>=0;i--) r[i]=gcd(a[i],r[i+1]);
	
	int ans=1;
	for(i=0;i<n;i++){//消す要素 
		if(i!=0&&i!=n-1){
			ans=max(ans,gcd(l[i-1],r[i+1]));
		}
		else if(i==0)ans=max(ans,r[1]);
		else ans=max(ans,l[n-2]);
	}
	cout<<ans<<endl;
	
//////////////////////////////////////////////////////
	return 0;
}








Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

int main() {
    int N;
    cin >> N;
    vector<PII> data;
    for(int i=0; i<N; i++) {
        int a,b;
        cin >> a >> b;
        data.push_back(PII(b,a));
        
    }
    sort(data.begin(), data.end());
    LL L = 0;
    bool ok  = true;
    for(auto elem : data ) {

        LL b  = elem.first;
        LL a = elem.second;
        L += a;
        if(L >b) {
            ok = false;
        } 
    }
    cout << (ok ? "Yes" : "No") << endl;

    return 0;
} 

Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define REP(i, n) for (LL i = 0; i < (LL)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0)
#define vLL(v,n) vector<LL> v(n); REP(i,n)cin>>v[i];
#define vstr(v,n) vector<string> v(n); REP(i,n)REP(i,n)cin>>v[i];
#define mina(a,b) a=min(a,b);
LL INF = 1e9 + 1;
LL MOD = 1e9+7;
  LL a,b,c,d,e,n,m,l,r,x,y,z,ans=9999999,ans2=9999999;
string s,S,t;
int main() {
ios_base::sync_with_stdio(false);
  cin >>x>>n;
  vector<bool> P(102);
  REP(i,102){
  P[i]=false;
  }
  REP(i,n){
    cin>>a;
    P[a]=true;
  }
  for(int i=0;i<=101;i++){
     if(P[i]==false){
       ans=min(abs(i-x),ans);
       if(ans==abs(i-x)){
         if(abs(i-x)!=abs(ans2-x))
         ans2=i;
       }
     }
  }

  cout << ans2;
}

Measured memory_bytes: 3656
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    int cnt = 0;
    while(x > 0){
        ++ cnt;
        x -= cnt;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int D, T, S;
    cin >> D >> T >> S;
    if (D > T * S) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    int W=0,E=0;
    rep(i,m)rep(j,n)
    {
        if(d[i][j]=='W') ++W;
        else ++E;
    }

    int er = 19191919;
    int b = 0;
    int w=0,e=0;
    rep(i,n+1)
    {
        int t = e+(W-w);
        if(er>t)
        {
            er = t;
            b = i;
        }

        if(i<n)
        {
            rep(j,m)
            {
                if(d[j][i]=='W') ++w;
                else ++e;
            }
        }
    }

    cout << b << " " << b+1 << endl;
    return 0;
}

Measured memory_bytes: 4504
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    for(ll b = K + 1; b <= N; b++){
        ll c = N / b;
        ans += c * (b - K);
        ll d = N % b;
        ans += max(0LL, d - K + 1);
        if(K == 0) ans--;
    }
    output(ans);
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int W=0,X=0;
  string S;cin>>S;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='W'){X+=i-W;W++;}
  }
  cout<<X<<endl;
}

Measured memory_bytes: 640
N = int(input())
p = list(map(int,input().split()))
import queue
from math import ceil
que = queue.Queue()
ans = 0
for i in range(N):
    if p[i]==i+1:
        que.put(i)
    else:
        ans+=ceil(que.qsize()/2)
        que = queue.Queue()
ans+=ceil(que.qsize()/2)
print(ans)

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

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

    int res = 0;
    while(n > 0)
    {
        n /= k;
        res++;
    }

    cout << res << "\n";
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    int a = 0, w = 0, t = 0, r = 0;
    for (int i = 0; i < N; i++) {
        string S;
        cin >> S;
        if (S == "AC") a++;
        if (S == "WA") w++;
        if (S == "TLE") t++;
        if (S == "RE") r++;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << w << endl;
    cout << "TLE x " << t << endl;
    cout << "RE x " << r << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
bool isSafe(int i , int j, int n , int k){
    if(i >= 0 && j >= 0 && i <= k && j <= n)
        return true ;
    return false ;
}
int main(){
    ios_base::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    int n = 0 , k = 0 , mn = INT_MAX ;
    cin >> n >> k ;
    int arr[n+1] ;
    bool TaroWins[k+1][n+1] ;
    for(int i = 1 ; i <= n ; i++)
        cin >> arr[i] ;
    sort(arr+1, arr+n+1) ;
    mn = arr[1] ;
    for(int i = 0 ; i <= k ; i++)
        for(int j = 0 ; j <= n ; j++)
            TaroWins[i][j] = false ;
    for(int i = 1 ; i <= k ; i++){
        for(int j = 1 ; j <= n ; j++){
            if(isSafe(i-arr[j] , j , n , k)) TaroWins[i][j] = !(TaroWins[i-arr[j]][n]) ;
            TaroWins[i][j] = TaroWins[i][j] || TaroWins[i][j-1] ;
        }
    }
    if(TaroWins[k][n]) cout << "First" ;
    else cout << "Second" ;
}


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

int main()
{
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << " " << y << " " << z << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
#define nl '\n'
 
#define y1 aza_ibagaliev
 
#define f first
#define s second
	
#define ed end()
#define bg begin()
#define rbg rbegin()
 
#define rv reverse
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define ppf pop_front
 
#define sz size()
#define all(x) x.bg, x.ed
 
#define pll pair < ll, ll >
#define pii pair < int, int >
 
#define sqr(x) ((x) * 1ll * (x))
#define sqrd(x) ((x) * 1.0 * (x))
 
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define rnl cout << "----------------------------------------" << nl
 
#define bit __builtin_popcount
 
inline ll bip(ll x, ll n, ll mod){ll res=1;while(n){if(n & 1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}
        	
const int ppr = 257;
const ll INF = 2e18;
const int inf = 2e9;
const int mod = 1e9 + 7;
const int N = 1e6 + 123;
const ld pi = acos(-1.0);
 
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int n, c[N], u[N];
vector<pii>g[N]; 

void dfs(int v) {
	u[v] = 1;
	for(pii p : g[v]) {
		int to = p.f;
		int w = p.s;

		if(!u[to]) {
			c[to] = (w ? c[v] ^ 1 : c[v]);
			dfs(to);
		}
	}
}
 
main() {             	
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);
 
//	srand(time(NULL));

//	speed;

	cin >> n;

	for(int i = 1; i < n; i++) {
		int x, y, w;
		cin >> x >> y >> w;
		w %= 2;
		g[x].pb(mp(y, w));
		g[y].pb(mp(x, w));    
	}
	                           
	for(int i = 1; i <= n; i++)
		if(!u[i]) dfs(i); 
                
	for(int i = 1; i <= n; i++)
		cout << c[i] << nl;

    return 0;                                        
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
 
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}
 
void solve(){
 
 
}

const ll mod = 1e9+7;

ll n;
ll sm(ll k){ return (k*(k-1)/2)%mod;}
ll lr(ll k){ return (k*n%mod-sm(k)+mod)%mod;}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();

    int k;cin>>n>>k;
    ll a=0;
    repA(i,k,n+1) a=a+lr(i)-sm(i)+1, a=(a+mod)%mod;
    cout<<a;


	return 0;
}
 



Measured memory_bytes: 3644