akhauriyash/Code-Regression huggingface dataset:
type Scanner() = class
    let mutable hold = [||]
    let mutable index = 0
    member public this.Next() =
        if hold.Length > index
        then 
            index <- index + 1
            hold.[index - 1]
        else
            let mutable st = stdin.ReadLine()
            while st = "" do st <- stdin.ReadLine()
            hold <- st.Split(' ')
            if hold.Length = 0
            then
                this.Next()
            else
                index <- 1
                hold.[index - 1]
            
    member public this.NextI32() =
        this.Next() |> int

    member public this.ArrayI32(n: int) =
        [for _ in 0 .. n - 1 -> this.NextI32()]

    member public this.NextI64() =
        this.Next() |> int64
    
    member public this.ArrayI64(n: int) =
        [for _ in 0 .. n - 1 -> this.NextI64()]

    member public this.NextF32() =
        this.Next() |> float32
    
    member public this.ArrayF32(n: int) =
        [for _ in 0 .. n - 1 -> this.NextF32()]

    member public this.NextF64() =
        this.Next() |> double
    
    member public this.ArrayF64(n: int) =
        [for _ in 0 .. n - 1 -> this.NextF64()]

    member public __.Tuple2List n (f : int -> 'a list) =
        [for _ in 0 .. n - 1 -> f 2 |> fun x -> x.[0], x.[1]]
    
    member public __.Tuple3List n (f : int -> 'a list) =
        [for _ in 0 .. n - 1 -> f 3 |> fun x -> x.[0], x.[1], x.[2]]

end

[<EntryPoint>]
let main _ =
    let scanner = Scanner()
    let n = scanner.NextI32()
    let s = scanner.Next()
    let mutable h, co = 0, 0
    for c in s do
        match h with
            | 0 -> if c = 'A' then h <- 1
            | 1 -> h <- if c = 'B' then 2 else if c = 'A' then 1 else 0
            | 2 -> if c = 'C' then
                    h <- 0
                    co <- co + 1
                    else if c = 'A' then h <- 1
                    else h <- 0
            | _ -> co <- 0

    co
    |> printfn "%i"

    0


Measured memory_bytes: 14044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)

int main(){
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> v(m);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        v[i] = {b,a};
    }
    sort(v.begin(),v.end());
    int end = v[0].first;
    int cnt = 1;

    for(int i = 1; i < m;i++){
        if (end <= v[i].second){
            cnt++;
            end = v[i].first;
        }
    }
    cout << cnt << endl;

    return 0;

}


Measured memory_bytes: 1024
N = int(input())
W = [input() for _ in range(N)]
S = set()
ans = 'Yes'
for i in range(N-1):
    if W[i] in S:
        ans = 'No'
        break
    else:
        S.add(W[i])
    
    if W[i][-1] != W[i+1][0]:
        ans = 'No'
        break 

if W[N-1] in S:
    ans = 'No'

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N;
  cin >> N;
  VEC<int> A(N);
  VEC<int> B(N, 0);
  REP(i, 0, N) cin >> A[i];
  int ball =0;
  for (int i = N - 1; i >= 0; i--) {
    int t = i + 1;
    int j = 2 * t;
    int cnt = 0;
    while (j <= N) {
      cnt += B[j - 1];
      j += t;
    }
    if (cnt % 2 != A[i]) {
      B[i] = 1;
      ball++;
    }
  }
  cout<<ball<<endl;
  REP(i,0,N){
    if(B[i])cout<<i+1<<endl;
  }

  return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
using namespace std;
ll binpow(ll x,ll y)/* (x^y)%p in O(log y) */{ll res=1;while (y > 0){if(y&1)res=(res*x);y = y>>1;x=(x*x);}return res;}
ll binpowmod(ll x,ll y,ll p)/* (x^y)%p in O(log y) */{ull res=1;x=x%p;while (y > 0){if(y&1)res=(res*x)%p;y = y>>1;x=(x*x)%p;}return res;}
ll mod_inverse(ll n,ll p)/* Returns n^(-1) mod p */{return binpowmod(n,p-2,p);}
ull gcd(ull x,ull y)
{
    if(y==0)
        return x;
    return gcd(y,x%y);
}
bool comp(pair<int,int> x,pair<int,int> y)
{
    return x.first<y.first;
}
bool comp_pairs_by_s(pair<ll,ll> &x ,pair<ll,ll> &y)
{
    return x.second<y.second;
}
bool isPowerOfTwo (ll x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}

class cmp      //comparator for priority_queue 
{               //declaration: priority_queue<int,vector<int>,cmp>
public:         
    bool operator()(pair<int,int> A,pair<int,int> B)
    {
        if(abs(A.first-A.second)==abs(B.first-B.second))
            return A.first>B.first;
        return abs(A.first-A.second)<abs(B.first-B.second);
    }
};
// int prime[100005]={0};
// void sieve(void)
// {
//  int i,j;
//  for(i=0;i<100005;i++)
//         prime[i]=1;
//  prime[0]=0,prime[1]=0;
//  for(i=2;i<=sqrt(100005);i++){
//      if(prime[i]){
//          for(j=i*i;j<100005;j+=i){
//              prime[j]=0;
//          }
//      }
//  }
    
// }
void swap(int &x,int &y){
    int temp=x;
    x=y;
    y=temp;
}
  
unsigned int onesComplement(unsigned int n) 
{ 
   // Find number of bits in the given integer 
   int number_of_bits = floor(log2(n))+1; 
  
   // XOR the given integer with poe(2,  
   // number_of_bits-1 and print the result  
   return ((1 << number_of_bits) - 1) ^ n; 
}
vector<ll> dp;
void solve()
{   
    ll n,k;
    cin>>n>>k;
    dp=vector<ll>(k+1,0);
    for(ll gcd=k;gcd>=1;--gcd){
        ll cnt=binpowmod(k/gcd,n,mod);
        dp[gcd]=(dp[gcd]+cnt)%mod;
        if(gcd!=1)
            dp[1]=(dp[1]-dp[gcd])%mod;
        for(int i=2;i*i<=gcd;++i){
            if(gcd%i==0){
                dp[i]=(dp[i]-dp[gcd])%mod;
                if(i!=gcd/i)
                    dp[gcd/i]=(dp[gcd/i]-dp[gcd])%mod;
            }
        }
    }
    ll ans=0;
    // for(int i=1;i<=k;++i)
        //cout<<i<<' '<<dp[i]<<'\n';
    for(ll i=1;i<=k;++i){
        ans=(ans+(i*dp[i])%mod)%mod;
    }
    cout<<ans;

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


Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
 
bool sosuu_hantei(int N, int i) {// i ~ N-1の範囲にNの約数が存在するか
  if (i == N) return false;//iがNになったら終了
  if (N % i == 0)return true;//iで割り切れたら終了
  return sosuu_hantei(N, i + 1);
} 
bool hantei_kekka(int N) {
  if (N == 1)return false;//1は素数
  else if (N == 2)return true;//2は素数
  else return !sosuu_hantei(N, 2);// 2~(N-1)の範囲に約数が無ければ、Nは素数
} 
int main() {
  int kazu;
  cin >>kazu;
  for(int i=kazu;i<INT_MAX;i++){
    if(hantei_kekka(i)){
      cout << i<< endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
n=gets.to_i
d=$<.map{|l|l.split.map(&:to_i)} #配列の配列(整数)
d=d.unshift([0,0,0])
for k in 1..n
t=d[k][0]
if t-d[k][1].abs<0
puts "No"
exit
else
t=t-d[k][1].abs
end

if t-(d[k][2]).abs<0
puts "No"
exit
else
t=t-(d[k][2]).abs
end

if t%2!=0
puts "No"
exit
end
end
puts "Yes"

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

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

using namespace std;
using lint=long long;

template<class T> T gcd(const T& a,const T& b){ return b==0?a:gcd(b,a%b); }
template<class T> T lcm(const T& a,const T& b){ return a/gcd(a,b)*b; }

int main(){
	int n,m; scanf("%d%d",&n,&m);
	vector<lint> a(n);
	rep(i,n) scanf("%lld",&a[i]), a[i]/=2;

	vector<int> c(n);
	rep(i,n) for(int t=a[i];t%2==0;t/=2) c[i]++;

	rep(i,n-1) if(c[0]!=c[i+1]) return puts("0"),0;

	lint L=1;
	rep(i,n){
		L=lcm(L,a[i]);
		if(L>m) return puts("0"),0;
	}
	printf("%lld\n",(m/L+1)/2);

	return 0;
}


Measured memory_bytes: 1408
n = int(input())
a = [int(i) for i in (input().split())]
b = [int(i) for i in (input().split())]
cnt = 0
for i in range(len(b)):
    if b[i]-a[i] >= 0:
        cnt += a[i]
        if a[i+1] - (b[i] - a[i]) >= 0:
            cnt += b[i] - a[i]
            a[i+1] -= b[i] - a[i]
        else:
            cnt += a[i+1]
            a[i+1] = 0
    else:
        cnt += b[i]
print(cnt)

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

int main(void){
  int n, d, x, a, chocolates = 0;
  cin >> n >> d >> x;
  for(int i = 0; i < n; i++){
    cin >> a;
    for(int day = 1; day <= d; day += a){
      chocolates++;
    }
  }
  cout << chocolates + x << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <limits.h>
#include <memory.h>


using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef vector<double> vec;
typedef vector<vec> mat;



int main() {

	int a,b,c,d;
	cin >> a>>b>>c>>d;

	int l,h;
	l=max(a,c);
	h=min(b,d);
	cout << max(0,h-l) << endl;
	
	return 0;
}




Measured memory_bytes: 256
def main():
    N = int(input())
    a = 1
    t = 1
    for _ in range(N):
        T, A = map(int, input().split())
        if t <= T and a <= A:
            t = T
            a = A
        elif t <= T and a > A:
            tmp = a // A
            if a % A != 0:
                tmp += 1
            t = T * tmp
            a = A * tmp
        elif t > T and a <= A:
            tmp = t // T
            if t % T != 0:
                tmp += 1
            t = T * tmp
            a = A * tmp
        else:
            tmp_A = a // A
            if a % A != 0:
                tmp_A += 1
            tmp_T = t // T
            if t % T != 0:
                tmp_T += 1
            tmp = max(tmp_A, tmp_T)
            t = T * tmp
            a = A * tmp
    print(a + t)



if __name__ == "__main__":
    main()

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

#define For(i, j, k) for(int i = j; i <= k; i++)
#define pb push_back

using namespace std;

const int N = 100010;

vector<int> G[N];
int n;
bool ans;

bool DFS(int o, int f){
	int cnt = 0;
	for(int v : G[o]){
		if(v == f) continue;
		cnt += DFS(v, o);
	}
	if(cnt > 1) ans = true;
	return !cnt;
}

int main(){
	
	while(scanf("%d", &n) == 1){
	
		For(i, 1, n) G[i].clear();
		ans = n & 1;

		For(i, 2, n){
			int u, v;
			scanf("%d%d", &u, &v);
			G[u].pb(v), G[v].pb(u);
		}

		DFS(1, 0);

		puts(ans ? "First" : "Second");
	}

	return 0;
}

Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,ans=0;
    cin>>n;
    for (long long i=1;i*i<n;i++) if (n%i==0 && n/(n/i-1)==n%(n/i-1)) ans+=n/i-1;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int W,H;
bool inrange(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define MP make_pair
signed main(){
    string s;cin>>s;
    sort(all(s));
    if(s=="abc")cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());
  printYesNo(s < t);
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
class BiOp {
public:
	ll operator()(ll a, ll b) const {
		return min(a, b);
	}
};

template<typename T, typename BiOp>
struct SegmentTree {
	vector<T> data;
	T e;
	BiOp op;
	int size;

	SegmentTree(int n, T e, BiOp op) : e(e), op(op) {
		size = 1;
		while (size < n) size *= 2;
		data.resize(2 * size - 1);
		for (int i = 0; i < 2 * size - 1; i++) data[i] = e;
	}

	void update(int k, T v) {
		k += size - 1;
		data[k] = v;
		while (k > 0) {
			k = (k - 1) / 2;
			data[k] = op(data[k * 2 + 1], data[k * 2 + 2]);
		}
	}

	T query(int a, int b, int k, int l, int r) const {
		if (b <= l || r <= a) return e;
		if (a <= l && r <= b) return data[k];
		return op(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
	}

	T query(int a, int b) {
		return query(a, b, 0, 0, size);
	}

	T get(int i) {
		return data[i + size - 1];
	}
};
int x[200001];
int main() {
	int N, Q, A, B;
	cin >> N >> Q >> A >> B;
	A--; B--;
	x[0] = B;
	for (int i = 1; i <= Q; i++) {
		cin >> x[i];
		x[i]--;
	}
	SegmentTree<ll, BiOp> dp(N, INF, BiOp());
	SegmentTree<ll, BiOp> dpL(N, INF, BiOp());
	SegmentTree<ll, BiOp> dpR(N, INF, BiOp());
	dp.update(A, 0);
	dpL.update(A, -A);
	dpR.update(A, A);
	ll add = 0;
	for (int i = 0; i < Q; i++) {
		ll d = abs(x[i + 1] - x[i]);
		ll minL = dpL.query(0, x[i + 1] + 1) + x[i + 1];
		ll minR = dpR.query(x[i + 1], N) - x[i + 1];
		ll m = min(minL, minR);
		dp.update(x[i], m - d);
		dpL.update(x[i], m - x[i] - d);
		dpR.update(x[i], m + x[i] - d);
		add += d;
	}
	cout << dp.query(0, N) + add << endl;
}


Measured memory_bytes: 13312
MAX = 1000000
MOD = 1000000007

fac = [0] * MAX
finv = [0] * MAX
inv = [0] * MAX


def com_init():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD


def com(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD


def resolve():
    com_init()
    X, Y = map(int, input().split())
    if (X + Y) % 3 != 0 or max(X, Y) > min(X, Y) * 2:
        print(0)
        return
    c = (X + Y) // 3
    X -= c
    Y -= c
    print(com(X + Y, X))
    
    
if __name__ == '__main__':
    resolve()

Measured memory_bytes: 62704
//C
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;

    int dp[300005];
    if(S[0] == 'W') dp[0] = 1;
    else dp[1] = 0;
    for(int i=1; i<N; i++){
        if(S[i] == 'W') dp[i] = 1 + dp[i-1];
        else dp[i] = dp[i-1];
        //cout << dp[i] << endl;
    }

    int ans = N-1 - (dp[N-1] - dp[0]);
    for(int i=1; i<N; i++){
        ans = min(ans, dp[i-1] + N-1-i - (dp[N-1] - dp[i]));
        //cout << dp[i-1] + N-1-i - (dp[N-1] - dp[i]) << endl;
    }

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


Measured memory_bytes: 1796
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

void solve() {
  ll n, m, d;
  cin >> n >> m >> d;
  ll numInterval = m-1;
  ll nn = 0;
  if(d == 0) nn = n;
  else nn = 2*(n-d);
  ll dd = n*n;
  cout << fixed << setprecision(10) << (numInterval * nn) / ((double)dd) << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using VVI = vector<vector<int>>;
const int INF = 1001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    int l, r, d;
    cin >> l >> r >> d;
    int cnt = 0;
    for (int i = l; i <= r; i++)
    {
        if (i % d == 0)
        {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL sum = a;
    LL res = 1;
    while(b){
        if(b&1){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

int main(){
    int N;
    int W, H;
    while(cin>>N>>W>>H&&N){
        vector<vector<int> > counts(101, vector<int>(101, 0));
        vector<PII> line(N);    
        foreach(i, line){
            cin>>i.first>>i.second;
            ++counts[i.first][i.second];
        }
        REPA(i, counts.size()){
            REPA(j, counts[i].size()){
                counts[i][j] += counts[i-1][j];
            }
        }
        REPA(i, counts.size()){
            REPA(j, counts[i].size()){
                counts[i][j] += counts[i][j-1];
            }
        }
        int S, T;
        cin >> S >> T;
        int ans = 0;
        REPA(i, 101){
            REPA(j, 101){
                int x = min(100, i+S-1);
                int y = min(100, j+T-1);
                ans = max(ans, counts[x][y]-counts[x][j-1]-counts[i-1][y]+counts[i-1][j-1]);
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3116
import java.util.Scanner;

class Main
{
    static Scanner sc = new Scanner(System.in);
    public static void main(String args[])
    {
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] l = new int[w+1];
        for(int i=0;i<w+1;i++)
        	{
        		l[i] = i;
        	}
        for(int i=0;i<n;i++)
            {
                String[] s = sc.next().split(",");
                int a = Integer.parseInt(s[0]);
                int b = Integer.parseInt(s[1]);
                int tmp = l[a];
                l[a] = l[b];
                l[b] = tmp;
            }

        for(int i=1;i<w+1;i++)
            {
                System.out.println(l[i]);
            }
    }
}

Measured memory_bytes: 12000
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=100005;

long long N,A[MAXN],M,K,ans[MAXN];
int P[MAXN],stk[MAXN],tp;
bool vis[MAXN];

int main()
{
	scanf("%lld",&N);
	for(int i=1;i<=N;i++)
	{
		scanf("%lld",&A[i]);
		P[i]=i;
	}
	scanf("%lld%lld",&M,&K);
	for(int i=N;i>=1;i--)
		A[i]=A[i]-A[i-1];
	for(int i=1;i<=M;i++)
	{
		int x;
		scanf("%d",&x);
		swap(P[x],P[x+1]);
	}
	for(int i=1;i<=N;i++)
		if(!vis[i])
		{
			int u=i;
			tp=0;
			while(!vis[u])
			{
				stk[++tp]=u;
				vis[u]=true;
				u=P[u];
			}
			for(int j=1;j<=tp;j++)
				ans[stk[j]]=A[stk[(K+j-1)%tp+1]];
		}
	for(int i=1;i<=N;i++)
		ans[i]+=ans[i-1];
	for(int i=1;i<=N;i++)
		printf("%lld.0\n",ans[i]);
	
	return 0;
}//

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

int main(){
    unordered_map <string,int> mp;
    mp.insert({"MON",6});
    mp.insert({"TUE",5});
    mp.insert({"WED",4});
    mp.insert({"THU",3});
    mp.insert({"FRI",2});
    mp.insert({"SAT",1});
    mp.insert({"SUN",7});
    string s;
    cin>>s;
    cout<<mp[s];
}

Measured memory_bytes: 256
S = list(input())
L = list('keyence')
while len(L)*len(S) > 0 and L[0] == S[0]:
    del L[0]
    del S[0]
while len(L)*len(S) > 0 and L[-1] == S[-1]:
    del L[-1]
    del S[-1]
if L == []:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];

		for (int i=0;i<N;i++) {
			A[i] = sc.nextInt();
		}
		Arrays.sort(A);
		long ans = A[N-1];

		int index = N-2;
		int cnt = 0;
		for (int i=0;i<N-2;i++) {
			ans += A[index];

			cnt++;
			if (cnt==2) {
				cnt=0;
				index--;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 59600
#include <iostream>
#include <cstdio>
#include <string>
#define MAX 1001

using namespace std;


string a,b;
int lcs_memo[1001][1001];

int lcs(int i,int j){
  if(i==0 || j==0) return 0;
  if(lcs_memo[i][j]!=-1) return lcs_memo[i][j];
  if(a[i]==b[j]){
    lcs_memo[i][j] = lcs(i-1,j-1)+1;
  }else{
    lcs_memo[i][j] = max(lcs(i,j-1),lcs(i-1,j));
  }
  return lcs_memo[i][j];
}

void clear(){
  for(int i=0;i<1001;i++){
  for(int j=0;j<1001;j++){
    lcs_memo[i][j] = -1;
  }}
}

int main(){
  int n; cin>>n;
  
  for(int i=0;i<n;i++){
    clear();
    cin>>a>>b;
    a = ' ' + a;
    b = ' ' + b;
    cout<<lcs(a.size()-1,b.size()-1)<<endl;
  }
}

Measured memory_bytes: 7088
#include<stdio.h> 
#include<stdlib.h>



int main ()  {
	int i,nb,a,b,k ;
	
	scanf("%d %d %d",&a,&b,&k) ;
	nb=0 ;
	i=101 ;
	while (nb<k ) {
	i-- ;
	if (a%i==0 && b%i==0)	{
		nb++ ;
		}
		

	}
	printf("%d",i) ;
	
	return(0) ;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int grid[2012][2012];
int ans[2012][2012];
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int H, W;
    cin >> H >> W;
    for(int i = 0; i < H; i++) {
        string S;
        cin >> S;
        for(int j = 0; j < W; j++) {
            grid[i][j] = S[j] == '.';
        }
        grid[i][W] = 0;
    }
    for(int i = 0; i <= H; i++) {
        int j0 = -1;
        int n = 0;
        for(int j = 0; j <= W; j++) {
            if(grid[i][j]) {
                if(j0 < 0) j0 = j;
                n++;
            } else {
                if(j0 >= 0) {
                    for(int k = j0; k <= j; k++) {
                        ans[i][k] += n;
                    }
                }
                n = 0;
                j0 = -1;
            }
        }
    }

    for (int i = 0; i <= W; i++) {
        int j0 = -1;
        int n = 0;
        for (int j = 0; j <= H; j++) {
            if (grid[j][i]) {
                if (j0 < 0) j0 = j;
                n++;
            } else {
                if (j0 >= 0) {
                    for (int k = j0; k < j; k++) {
                        ans[k][i] += n;
                    }
                }
                n = 0;
                j0 = -1;
            }
        }
    }
    int A = 0;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            A = max(A, ans[i][j] - 1);
        }
    }
    cout << A << endl;
    return 0;
}

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

int main(){
  ll n,q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<ll> dp(n,0);
  
  rep(i,n-1){
    if(s[i] == 'A' && s[i+1] == 'C'){
      dp[i+1] = dp[i]+1;
    }else{
      dp[i+1] = dp[i];
    }
  }
  
  /*
  rep(i,n){
    cout << i << " " << dp[i] << endl;
  }
  */
  
  rep(i,q){
    ll l,r;
    cin >> l >> r;
    l--;
    r--;
    cout << dp[r] - dp[l] << endl;
  }
  
  return(0);
}


Measured memory_bytes: 4316
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int main(){
	string A;
	cin>>A;
	string B;
	REP(i,A.size()){
	    B.push_back(A[A.size()-1-i]);
	}
        cout<<B<<endl;
	return(0);
}

Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <utility>
#include <set>

using namespace std;

long long n, sav;
bool used[40], ok=false;
set<long long> S;

void dfs1 (int dep)
{
    long long val=0;
    if (dep==18)
    {
        for (int i=0; i<=17; i++) if (used[i]) val+=pow(-2, i);
        S.insert(val);
        if (val==n)
        {
            int last;
            for (int i=0; i<=17; i++)
            {
                if (used[i]) last=i;
            }
            for (int i=last; i>=0; i--)
            {
                cout<<used[i];
            }
            cout<<endl;
            ok=true;
        }
        return;
    }
    else
    {
        used[dep]=true;
        dfs1(dep+1);
        used[dep]=false;
        dfs1(dep+1);
        return;
    }
}

void dfs2 (int dep)
{
    long long t=0;
    if (dep==33)
    {
        for (int i=18; i<=33; i++) if (used[i]) t+=pow(-2, i);
        if (S.count(n-t))
        {
            int last;
            for (int i=18; i<=33; i++)
            {
                if (used[i]) last=i;
            }
            for (int i=last; i>=18; i--)
            {
                cout<<used[i];
            }
            sav=n-t;
        }
        return;
    }
    else
    {
        used[dep]=true;
        dfs2(dep+1);
        used[dep]=false;
        dfs2(dep+1);
        return;
    }
}

void dfs3 (int dep, int num)
{
    long long val=0;
    if (dep==18)
    {
        for (int i=0; i<=17; i++) if (used[i]) val+=pow(-2, i);
        if (val==num)
        {
            for (int i=17; i>=0; i--)
            {
                cout<<used[i];
            }
            cout<<endl;
        }
        return;
    }
    else
    {
        used[dep]=true;
        dfs3(dep+1, num);
        used[dep]=false;
        dfs3(dep+1, num);
        return;
    }
}

int main()
{
    cin>>n;
    memset(used, false, sizeof(used));
    if (n==0) { cout<<0<<endl; return 0; }
    if (n==1) { cout<<1<<endl; return 0; }
    dfs1(0);
    if (ok) return 0;
    dfs2(18);
    memset(used, false, sizeof(used));
    dfs3(0, sav);
    return 0;
}


Measured memory_bytes: 12544
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
#define lint long long
auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;};
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail){
  std::cerr << " " << head;
  debug_impl(tail...);
}
#ifndef STOPIT
#define debug(...)\
  std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
  debug_impl(__VA_ARGS__);\
  std::cerr << std::noboolalpha;
#else
#define debug 0;
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

void err () {
  std::cout << "Impossible" << std::endl;
  exit(0);
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n, l; std::cin >> n >> l;
  std::vector< int > a(n); std::cin >> a;
  auto center = -1;
  rep(i, 0, n - 1) {
    if (l <= a.at(i) + a.at(i + 1))
      { center = i; }
  }
  if (center == -1) err();
  std::vector< int > ret{};
  rep(i, 0, center)
    { ret.emplace_back(i); }
  for (auto i = n - 2; i > center; i--)
    { ret.emplace_back(i); }
  ret.emplace_back(center);
  std::cout << "Possible" << std::endl;
  for (auto x : ret)
    { std::cout << x + 1 << std::endl;}
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=1000000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> divisor(ll x){vector<ll> div;
	for(ll i=1;i*i<=x;i++){if(x%i==0){div.pb(i);if(i*i!=x)div.pb(x/i);}}
	sort(div.bg,div.ed);return div;}

//a,b x
int main(){
	//rep1(i,50) pw2[i]=2*pw2[i-1];
	//rep1(i,18) pw10[i]=10*pw10[i-1];
    ll N; cin>>N;
	vector<P> p;
	rep(i,N){
		ll A; cin>>A;
		p.pb(mp(A,1ll));
	}
	rep(i,N){
		ll A; cin>>A;
		p.pb(mp(A,-1ll));
	}
	sort(p.bg,p.ed);
	ll Acnt=0,Bcnt=0,ans=1;
	rep(i,p.sz){
		if(p[i].b==1){//A
			if(Bcnt>0){
				ans*=Bcnt;
				ans%=MOD;
				Bcnt--;
			}
			else{
				Acnt++;
				Acnt%=MOD;
			}
		}
		else{//B
			if(Acnt>0){
				ans*=Acnt;
				ans%=MOD;
				Acnt--;
			}
			else{
				Bcnt++;
				Bcnt%=MOD;
			}
		}
		//cout<<Acnt<<" "<<Bcnt<<endl;
	}
	cout<<ans;
}

Measured memory_bytes: 6256
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail+1)%LEN;
}

P dequeue(){
  P res = Q[head];
  head = (head+1)%LEN;
  return res;
}

int empty(){
  return (head==tail?1:0);
}

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
  head = 1;
  tail = n+1;

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  while(empty()==0){
    u = dequeue();
    if(u.t > q){
      u.t -= q;
      enqueue(u);
      elaps += q;
    }else{
      elaps += u.t;
      printf("%s %d\n",u.name, elaps);
    }
  }
  return 0;
}

Measured memory_bytes: 10756
from collections import deque
S = deque(list(input()))
Q = int(input())
rev = False
for i in range(Q):
    query = input()
    if query == "1":
        rev = not(rev)
    else:
        T,F,C = query.split()
        if rev:
            if F == "1":
                S.append(C)
            else:
                S.appendleft(C)
        else:
            if F == "1":
                S.appendleft(C)
            else:
                S.append(C)
if rev:
    print("".join(list(reversed(S))))
else:
    print("".join(S))


Measured memory_bytes: 8548
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rept(i,s,n) for (int i = (s); i < (n); ++i)

#include <iostream>
#include <cmath>
#include <bitset>
#include <algorithm>
using namespace std;

int main(){

    int n;
    cin >> n;
    n %= 10;
    string str = "";
    switch (n) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            str = "hon";
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            str = "pon";
            break;
        case 3:
            str = "bon";
            
        default:
            break;
    }
    
    cout << str << endl;

    return 0;
}


/**
 
 N
 の
 1
 の位が
 2
 ,
 4
 ,
 5
 ,
 7
 ,
 9
 のとき hon
 N
 の
 1
 の位が
 0
 ,
 1
 ,
 6
 ,
 8
 のとき pon
 N
 の
 1
 の位が 
 3
 のとき bon
*/

/*
 4 5
 s####
 ....#
 #####
 #...g
 
 */


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define maxi 10000000000
#define pll pair<ll,ll>
int main(){
    string s,t;
    cin>>s>>t;
    ll ans=0;
    for(ll i=0;i<3;i++){
        ans+=s[i]==t[i];
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int A,B,C,K;
  scanf("%d%d%d%d",&A,&B,&C,&K);
  int point=0;
  
    while(K>0&&A>0){
      point++;
      K--;
      A--;
    }
    while(K>0&&B>0){
      K--;
      B--;
    }
    while(K>0&&C>0){
      point--;
      K--;
      C--;
    }
  
  printf("%d",point);
  
  return 0;
  
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	int n;
	cin >> n;
	int k = n%10;
	string ans;
	if(k == 3) cout << "bon" << endl;
	else if(k == 0 || k== 1|| k== 6 || k== 8) cout << "pon" << endl;
	else cout << "hon" << endl;
	return 0;
}


Measured memory_bytes: 3640
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int ans = 0;
  for (int i = 0; i <= A; i++) {
    for (int j = 0; j <= B; j++) {
      for (int k = 0; k <= C; k++) {
        if (i * 500 + j * 100 + k * 50 == X) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <climits>
#include <string.h>
#include <algorithm>

using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define pb push_back
#define sz(s) (int)s.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
const int N = (int) 2e5 + 77;
const int D = 18; //log2(N);

int n,m,L;
int x[N];
int par[D+1][N];

int main(){
    fast;
    cin>>n;
    for1(i,n) cin>>x[i];
    cin>>L;
    
    memset(par,-1,sizeof par);
    
    int j=1;
    for(int i=1;i<=n;i++){
        while(x[j]-x[i]<=L and j<=n) j++;
        par[0][i] = j-1;
    }
    
    for(int d=1; d<=D; d++){
        for(int i=1;i<=n;i++){
            int jump = par[d-1][i];
            if(jump!=-1)
                par[d][i] = par[d-1][jump];
        }
    }
    
    cin>>m;
    while(m--){
        int a, b;
        cin>>a>>b;
        if(a>b) swap(a,b);
        int ans=0;
        for(int d=D;d>=0;d--){
            if(par[d][a]!=-1 and par[d][a] < b){
                a = par[d][a];
                ans+=(1<<d);
            }
        }
        cout<<ans+1<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 16128
#include<iostream>

using namespace std;

int main(){
	long long a, b, c, k, z, ans = 0;
	cin >> a >> b >> c >> k;
	if(k % 2) z = -1;
	else z = 1;
	ans = (a - b) * z;
	cout << ans << endl;
	return 0;
}

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

int main(){
    string S;
    cin >> S;
    int count = 0;
    while(true) {
        bool deleted = false;
        if(S.length() < 2)
            break;
        for(size_t i = 0; i < S.length()-1; i++)
        {
            if(S[i] != S[i+1]){
                S.erase(i,2);
                deleted = true;
                count = count + 2;
                break;
            }
        }
        if(!deleted)
            break;
    }
    cout << count << endl;
    return 0;
}

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

using ll=long long; 

void solve(){
	int n;
	cin>>n;
	for(int i=n; i<1000; i++){
		if(i%10==(i/10)%10 && i%10==i/100){
			cout<<i<<endl;
			return;
		}
	}
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
import numpy as np
import math

# primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163 ,167, 173, 179, 181, 191, 193, 197, 199]

N = int(input())

def num_divisors_trial_division(n):
    num = 0
    for i in range(1, int(math.sqrt(n) + 1e-9) + 1):
        if n % i == 0:
            num += 1
            if n != i**2:
                num += 1
        if num > 8:
            return 100
    return num

total = 0
for n in range(1, N+1):
    if n % 2 == 0:
        continue
    if num_divisors_trial_division(n) == 8:
        total +=1

print(total)


Measured memory_bytes: 21524
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

#[allow(unused_macros)]
macro_rules! echo {
    ($($e:expr),+) => ( { $(println!("{}", $e))+ } );
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
        q: usize,
        bc: [(usize, usize); q],
    }

    let mut kv = std::collections::HashMap::new();
    let mut sum = 0;

    for e in a {
        *kv.entry(e).or_insert(0) += 1;
    }

    for (&k, &v) in kv.iter() {
        sum += k * v; // initialized sum
    }

    for (b, c) in bc {
        if let Some(count) = kv.remove(&b) {
            *kv.entry(c).or_insert(0) += count;

            if c >= b {
                sum += (c - b) * count;
            } else {
                sum -= (b - c) * count;
            }
        }
        echo!(sum);
    }
}


Measured memory_bytes: 9460
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define vi vector<int>
#define vll vector<long long>  
#define vf vector<float>
#define pi (int,int)
#define vpi vector<pair<int,int>>
#define vs vector<string>
#define mp make_pair
#define ll long long
#define vc vector<char>
#define rng(x) x.begin(),x.end()
#define b(x) x.begin()
#define e(x) x.end()
#define F first
#define S second
#define me max_element
#define ne min_element
using namespace std;
int main() 
{
  int a;
  cin>>a;
  cout<<a+(a*a)+(a*a*a);
  return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
typedef long long ll;
using namespace std;

int main(){
  int n, k, x, y;
  int result;

  scanf("%d", &n);
  scanf("%d", &k);
  scanf("%d", &x);
  scanf("%d", &y);

  if(n <= k){
    result = n*x;
  }else{
    result = k*x+(n-k)*y;
  }
  printf("%d\n", result);

  return 0;
}


Measured memory_bytes: 256
n=int(input())
mod=10**9+7
dp=[0]*2001
dp[0]=1
sdp=[0]*2001
sdp[0]=1
for i in range(2000):
  dp[i+1]=sdp[i-2]
  sdp[i+1]=dp[i+1]+sdp[i]
print(dp[n]%mod)

Measured memory_bytes: 9268
import java.util.*;

public class Main {
public static void main(String[] args) {

			Scanner keyboard = new Scanner(System.in);

			int N = keyboard.nextInt();
			//キーが棒の長さで中身が本数のHashMapを作る
			HashMap<Long, Integer> count = new HashMap<Long, Integer>();
			
			for (int s=0; s<N; s++) {
				long L = keyboard.nextLong();
				if (count.containsKey(L)) { //HashMapに既にキーがあるとき
					int now = count.get(L); //キーSのに紐づく中身のintを取得
					count.replace(L, now + 1);
				}
				else {
					count.put(L, 1); //まだHashMapにキーが登録されていないなら、登録する
				}
			}
			
			int ans = 0;
			//拡張for文（左が確認する1個の名前、右が確認するものの集合）
			//HashMapで登録されているキーの集合を、keyとして1個ずつ順番に全部確認する
			for (long key1: count.keySet()) {
				for (long key2: count.keySet()) {
					if(key1 < key2) {
					for (long key3: count.keySet()) {
						if(key2 < key3 && key1+key2 > key3){
							int a = count.get(key1);
							int b = count.get(key2);
							int c = count.get(key3);
							 ans += a*b*c;
							}
						}
					}
				}
			}
		
		System.out.println(ans);
		keyboard.close();	
	}
}


Measured memory_bytes: 50056
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int MAXN = 10;
unsigned N, dist[MAXN][MAXN];
int mark[MAXN];

int main() {
    //freopen("0189.txt", "r", stdin);
    while (~scanf("%d", &N) && N) {
        memset(mark, 0, sizeof(mark));
        memset(dist, 0x7f, sizeof(dist));

        for (int i = 0; i < N; i++) {
            int u, v, d;
            scanf("%d%d%d", &u, &v, &d);
            dist[u][v] = dist[v][u] = d;
            dist[u][u] = dist[v][v] = 0;
            mark[u] = mark[v] = 1;
        }
        for (int k = 0; k < MAXN; k++) if (mark[k]) {
            for (int u = 0; u < MAXN; u++) if (mark[u]) {
                for (int v = 0; v < MAXN; v++) if (mark[v]) {
                    if (dist[u][v] > dist[u][k] + dist[k][v]) {
                        dist[u][v] = dist[u][k] + dist[k][v];
                    }
                }
            }
        }

        int start_pos = 0;
        int distance = 0x7f7f7f7f;
        for (int s = 0; s < MAXN; s++) if (mark[s]) {
            int tmp = 0;
            for (int e = 0; e < MAXN; e++) if (mark[e]) {
                tmp += dist[s][e];
            }
            if (tmp < distance) {
                start_pos = s;
                distance = tmp;
            }
        }
        printf("%d %d\n", start_pos, distance);
    }
}

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

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

	if (a < b)
	{
		cout << "a < b" << endl;
	}
	else if (a > b)
	{
		cout << "a > b" << endl;
	}
	else
	{
		cout << "a == b" << endl;
	}
	return 0;
}


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

long long int N, L;
string ans;

int main(void) {
  cin >> N >> L;
  vector<string> S(N);
  for (int i=0; i<N; i++) cin >> S[i];
  sort(S.begin(),S.end());
  for (int i=0; i<N; i++) ans += S[i]; 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  string s;
  cin >> n >> s;
  if (s[0] == 'W' || s[2 * n - 1] == 'W') {
    cout << 0 << endl;
    return 0;
  }
  string t = "L";
  REP(i, 2 * n) {
    if (i == 0) continue;
    if (s[i - 1] == s[i]) {
      t += (t[i - 1] == 'L' ? 'R' : 'L');
    } else {
      t += (t[i - 1] == 'L' ? 'L' : 'R');
    }
  }
  int l = 0, r = 0;
  REP(i, 2 * n) { (t[i] == 'L' ? l : r)++; }
  if (l != r) {
    cout << 0 << endl;
    return 0;
  }
  l = 0, r = 0;
  ll ans = 1;
  REP(i, 2 * n) {
    if (t[i] == 'R') {
      ans *= (l - r);
      ans %= MOD;
    }
    (t[i] == 'L' ? l : r)++;
  }
  REP1(i, n) {
    ans *= i;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n, m, tmpa, tmpb, ans, right_lim;
    vector<pair<int, int>> request;
    cin >> n >> m;
    request.resize(m);
    request.resize(m);
    for (int i=0; i<m; ++i){
        cin >> tmpa >> tmpb;
        request[i] = make_pair(tmpa, tmpb);
    }

    sort(request.begin(), request.end());
    
    ans = 0;
    right_lim = 0;
    for (int i=0; i<m; ++i){
        if(request[i].first >= right_lim){
            ans++;
            right_lim = request[i].second;
        }
        else {
            if(request[i].second < right_lim){
                right_lim = request[i].second;
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int a[3];
int main() {
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    if (a[0] + a[1] == a[2])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3652