akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF INT_MAX
#define LINF 1LL<<60

struct SegTree {
	int N;
	ll init_v = INF;
	vector<ll> node, lazy;

	SegTree(int _N) {
		N = 1;
		while (N < _N) N *= 2;
		node.resize(2 * N - 1, init_v);
		lazy.resize(2 * N - 1, -1);
	}

	void lazy_evaluate(int k) {
		if (lazy[k] == -1) return;
		node[k] = lazy[k];
		if (k < N - 1) {
			lazy[2 * k + 1] = lazy[k];
			lazy[2 * k + 2] = lazy[k];
		}
		lazy[k] = -1;
	}

	/* [a,b) ?????°??????????????¨???!! s~t?????§?????´??°???update(s,t+1,~) */
	ll update(int a, int b, int x) { return update(a, b, 0, 0, N, x); }
	ll update(int a, int b, int k, int l, int r, int x) {
		if (r <= a || b <= l) {
			lazy_evaluate(k); // node?????????????????¨?????????????????¶???????????´??°??????
			return node[k];
		}
		if (a <= l && r <= b) {
			lazy[k] = x;
			lazy_evaluate(k);
			return node[k];
		}
		else {
			lazy_evaluate(k);
			ll vl = update(a, b, 2 * k + 1, l, (l + r) / 2, x);
			ll vr = update(a, b, 2 * k + 2, (l + r) / 2, r, x);
			return node[k] = min(vl, vr);
		}
	}

	/* [a,b) ?????°??????????????¨???!! */
	ll query(int a, int b) { return query(a, b, 0, 0, N); }
	ll query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return init_v;
		if (a <= l && r <= b) {
			lazy_evaluate(k);
			return node[k];
		}
		else {
			lazy_evaluate(k);
			ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
			ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
			return min(vl, vr);
		}
	}
};

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	SegTree ST(n);
	for (int i = 0; i < q; i++) {
		int com; cin >> com;
		if (com == 0) {
			int s, t, x; cin >> s >> t >> x;
			ST.update(s, t + 1, x);
		}
		else {
			int s, t; cin >> s >> t;
			cout << ST.query(s, t + 1) << endl;
		}


		//cout << "-----------------------------------" << endl;
		//for (auto X : ST.node) {
		//	if (X == INF) { cout << "INF "; }
		//	else cout << setw(3) << X << " ";
		//}
		//cout << endl;
		//for (auto Y : ST.lazy) {
		//  cout << setw(3) << Y << " ";
		//}
		//cout << endl;
		//cout << "==================================" << endl;
	}
}

Measured memory_bytes: 7060
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7


def main():
  A = int(input())
  B = int(input())
  C = int(input())
  D = int(input())
  E = int(input())
  
  a = (10 - A) % 10
  b = (10 - B) % 10
  c = (10 - C) % 10
  d = (10 - D) % 10
  e = (10 - E) % 10
 
  print(A+B+C+D+E+a+b+c+d+e-max([a,b,c,d,e]))
  
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 12492
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define P pair<int, int>
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define Int long long int 
const int MAX_N = 65010;

int main() {
  int N;
  while(cin >>N && N){
    Int p[MAX_N], j[MAX_N], sum = 0;
    REP(i, N){
      cin >>p[i];
      sum += (long)p[i];
    }
    REP(i, N - 1) cin >>j[i];
    sort(j, j + N - 1);
    reverse(j, j + N - 1);
    Int ans = sum * N;
    int n = N;
    REP(i, N - 1){
      sum += j[i];
      n--;
      Int tmp = (long)sum * (long)n;
      ans = max(ans, tmp);
    }
    cout <<ans <<endl;
  }
  return 0;
}

Measured memory_bytes: 2196
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long
#define MAX 100001

int a[MAX];
int n;

signed main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (n <= 2) {
    cout << 1 << endl;
    return 0;
  }
  int count = 1;
  int status = 0;
  for (int i = 0; i + 1 < n; i++) {
    int res;
    if (a[i] < a[i + 1]) res = 1;
    else if (a[i] > a[i + 1]) res = -1;
    else continue;
    if (status == 0) status = res;
    if (status != res) {
      count++;
      status = 0;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000

int main(){
  int64_t X, Y; cin >> X >> Y;
  int N=0;
  while (X<=Y){
    X*=2;
    N++;
  }
  cout << N << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int h,a;
	cin >> h >> a;
	cout << (h + a - 1) / a << endl;
}

Measured memory_bytes: 256
let m = 998244353

let n, k = Scanf.scanf "%d %d" (fun n k -> n, k)
let lr = Array.init (k * 2) (fun _ -> Scanf.scanf " %d" (fun i -> i))

let sum = Array.make (n + 2) 0

let rec f i =
  if i = n + 1 then sum.(n + 1) - sum.(n)
  else
    let rec g j dp =
      if j = 2 * k then dp
      else
        let r = i - lr.(j) in
        let l = max 1 (i - lr.(j + 1)) in
        if r < 1 then g (j + 2) dp
        else g (j + 2) ((dp + sum.(r + 1) - sum.(l)) mod m) in
    sum.(i + 1) <- (sum.(i) + g 0 0) mod m;
    f (i + 1)

let () =
  sum.(2) <- 1;
  Printf.printf "%d\n" ((m + f 2) mod m)


Measured memory_bytes: 7452
// May this submission get accepted
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// 標準入出力
struct inp {
    size_t sz;
    inp(size_t _sz = 1) : sz(_sz) {}
    template <typename T> operator T () const { T a; cin >> a; return a; }
    template <typename T> operator vector<T> () const { vector<T> a(sz); for (size_t i = 0; i < sz; i++) cin >> a[i]; return a; }
    template <typename T, typename U> operator pair<T, U> () const { T f; U s; cin >> f >> s; return pair<T, U>(f, s); }
};
inp inp1; // input one
template <typename T> void say(T &x, char end = '\n') { cout << x << end; }
template <typename T> void say(vector<T> &x, char sep = ' ', char end = '\n') { for (size_t i = 0, sz = x.size(); i < sz; i++) { cout << x[i] << (i == sz-1 ? end : sep); } }

// モジュール


// 処理内容
int main() {
    
    ios::sync_with_stdio(false); // stdioを使うときはコメントアウトすること
    cin.tie(nullptr);            // インタラクティブ問題ではコメントアウトすること
    
    ll n = inp1;
    vector<ll> x(n), l(n);
    REP(i, n) {
        x[i] = inp1;
        l[i] = inp1;
    }

    vector<pair<ll, ll>> a(n);
    REP(i, n) a[i] = make_pair(x[i]+l[i], x[i]-l[i]);
    sort(ALL_OF(a));
    ll ans = 0;
    ll lim = -LINF;
    REP(i, n) {
        if (a[i].second >= lim) {
            lim = a[i].first;
            ans++;
        }
    }
    say(ans);
    
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print1(a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=100005;
//i_am_noob
int n,q,a[maxn],ans1=0,ans2=0;
string str[maxn];
bitset<maxn> bs;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n >> q;
	rep(q) cin >> a[i] >> str[i];
	rep(q) if(str[i]=="AC") bs[a[i]]=1;
	ans1=bs.count();
	rep(q){
		if(str[i]=="AC") bs[a[i]]=0;
		if(str[i]=="WA"&&bs[a[i]]) ans2++;
	}
	print2(ans1,ans2); 
	return 0;
}

Measured memory_bytes: 6528
# import bisect
# import heapq
# from copy import deepcopy
# from collections import deque
# from collections import Counter
# from itertools import accumulate
# from itertools import permutations
# import numpy as np
# import math

n, m, k = map(int, input().split())
# a = list(map(int, input().split()))
# n = int(input())

class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.parents[self.find(x)]

uf = UnionFind(n)
friend =[[] for _ in range(n)]
block = [[] for _ in range(n)]
for i in range(m):
    a,b = map(int, input().split())
    a,b = a-1,b-1
    uf.union(a,b)
    friend[a].append(b); friend[b].append(a)

for i in range(k):
    c,d = map(int, input().split())
    c,d = c-1,d-1
    if uf.same(c,d):
        block[c].append(d); block[d].append(c)

w = [0] * n
for i in range(n):
    w[i] = uf.size(i) - len(friend[i]) - len(block[i]) - 1

print(*w)

Measured memory_bytes: 46760
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<ll> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    a[i]--;
  }
  ll ans = 0;
  set<ll> visited;
  for (int i = 0; i < N; i++) {
    if (visited.count(i)) continue;
    if (i == a[a[i]]) {
      ans++;
      visited.insert(i);
      visited.insert(a[i]);
    }
  }
  cout << ans << endl;
  return 0;
}

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

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

int N, K;
int X[100010];
int ans = 1001001001001001001;

signed main()
{
    cin >> N >> K;
    int flag = 0;
    rep(i, N)
    {
        cin >> X[i - flag];
        if(X[i - flag] == 0)
        {
            flag = 1;
            K--;
        }
    }

    if(!K)
    {
        cout << 0 << endl;
        return 0;
    }

    if(flag)N--;

    for(int i = 0; i + K - 1 <= N - 1; i++)
    {
        if(X[i] * X[i + K - 1] < 0)
        {
            ans = min(-1 * X[i] * 2 + X[i + K - 1], ans);
            ans = min(-1 * X[i] + X[i + K - 1] * 2, ans);
        }
    }

    for(int i = 0; i < N; i++)
    {
        if(i + K - 1 < N && X[i] < 0 && X[i] * X[i + K - 1] > 0)
            ans = min(ans, -X[i]);
        if(i + K - 1 < N && X[i] > 0 && X[i] * X[i + K - 1] > 0)
            ans = min(ans, X[i + K - 1]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4312
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
#ifdef KEV
#define DE(i, e) cerr << #i << ' ' << i << e
void debug(auto L, auto R) { while (L < R) cerr << *L << " \n"[L+1==R], ++L; }
#else
#define DE(...) 0
void debug(...) {}
#endif
const int maxn = 300010;
signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	ll d, t, s;
	cin >> d >> t >> s;
	if ( t * s >= d)
		puts("Yes");
	else
		puts("No");
}



Measured memory_bytes: 3652
import heapq

n, K = map(int, input().split())
A = list(map(int, input().split()))

from operator import mul
from functools import reduce

MOD = 10 ** 9 + 7

def mpow(a, n):
    if n == 0: return 1
    if n == 1: return a % MOD
    if n % 2 == 1: return (a % MOD * mpow(a, n - 1) % MOD) % MOD
    t = mpow(a, n // 2)
    return (t * t) % MOD

fac = [1] * (n + 1)
inv_fac = [1] * (n + 1)
for i in range(n):
    fac[i + 1] = (fac[i] * (i + 1)) % MOD
inv_fac[n] = mpow(fac[n], MOD - 2)
for i in range(n, 0, -1):
    inv_fac[i - 1] = (inv_fac[i] * i) % MOD

def cmb(n, r):
    if n == 0 and r == 0: return 1
    if n < r or n < 0: return 0
    return (fac[n] * (inv_fac[r] * inv_fac[n - r]) % MOD) % MOD

A.sort()

# cmb_list = {}
# cmb_list[(K - 1, K - 1)] = cmb(K - 1, K - 1)
# for i in range(K, n):
#     cmb_list[(i, K-1)] = cmb_list[(i-1, K-1)] * i // (i - (K - 1))

max_f = 0
min_f = 0

for idx in range(n):
    a = heapq.heappop(A)
    if idx >= K - 1:
        max_f += cmb(idx, K - 1) * a
        # print("max", cmb(idx, K-1), idx, K-1, a)

    if n - (idx + 1) >= K - 1:
        min_f += cmb(n - (idx + 1), K - 1) * a
        # print("min", cmb(N-(idx+1), K-1), N-(idx+1), K-1, a)

print((max_f - min_f) % (10**9+7))

Measured memory_bytes: 66600
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let x: u32 = read();
    let under = x % 100;
    let a = under / 5;
    let b = under % 5;
    let mut ans = 105 * a;
    if b > 0 {
        ans += 100 + b;
    }
    if ans <= x {
        println!("1");
    } else {
        println!("0");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

vector<int> to[200005];
vector<int> ans;
void dfs(int v, int p = -1) {
   for (int u : to[v]) {
      if (u == p) continue;
      ans[u] += ans[v];
      dfs(u, v);
   }
}
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   int n, q;
   cin >> n >> q;
   rep(i, 0, n - 1) {
      int a, b;
      cin >> a >> b;
      a--, b--;
      to[a].push_back(b);
      to[b].push_back(a);
   }
   ans.resize(n);
   rep(i, 0, q) {
      int p, x;
      cin >> p >> x;
      p--;
      ans[p] += x;
   }
   dfs(0);
   rep(i, 0, n) printf("%d%c", ans[i], i == n - 1 ? '\n' : ' ');
   return 0;
}

Measured memory_bytes: 23552
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <cstdint>
#include <numeric>
#define INF 1000000000
#define INF2 100000000000
#define LLINF 1000000000000000000
#define MOD 1000000007
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

signed main(){
  int n;
  cin >> n;
  int ans = 1;
  int a[n];
  LOOP(i,n){
    cin >> a[i];
    if(a[i] == 0){
      cout << 0 << endl;
      return 0;
    }
  }
  LOOP(i,n){
    if(ans > LLINF/a[i]){
      cout << -1 << endl;
      return 0;
    }
    ans *= a[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 4368
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "0" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<ll> P(N);
    vector<ll> Q(N);
    rep(i,N) cin>>P[i];
    rep(i,N) cin>>Q[i];
    vector<ll> r;
    rep(i,N) r.emplace_back(i+1);
    ll ctp=0,ctq=0;
    do{
        ++ctp;
        bool ok=true;
        rep(i,N){
            if(P[i]!=r[i]) ok=false;
        }
        if(ok) break;
    } while(next_permutation(r.begin(),r.end()));
    SORT(r);
    do{
        ++ctq;
        bool ok=true;
        rep(i,N){
            if(Q[i]!=r[i]) ok=false;
        }
        if(ok) break;
    } while(next_permutation(r.begin(),r.end()));
    cout<< abs(ctp-ctq) <<"\n";
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c,d;
    int n;
    scanf("%d",&n);
    d=n%10;
    n/=10;
    c=n%10;
    n/=10;
    b=n%10;
    n/=10;
    a=n;
    if(a+b+c+d==7)
    {

        printf("%d+%d+%d+%d=7\n",a,b,c,d);
        return 0;
    }
    if(a-b-c-d==7)
    {
        printf("%d-%d-%d-%d=7\n",a,b,c,d);
        return 0;
    }

    if(a+b-c+d==7)
    {
        printf("%d+%d-%d+%d=7\n",a,b,c,d);
        return 0;
    }

    if(a-b+c+d==7)
    {
        printf("%d-%d+%d+%d=7\n",a,b,c,d);
        return 0;
    }

    if(a+b+c-d==7)
    {
        printf("%d+%d+%d-%d=7\n",a,b,c,d);
        return 0;
    }

    if(a+b-c-d==7)
    {
        printf("%d+%d-%d-%d=7\n",a,b,c,d);
        return 0;
    }

    if(a-b-c+d==7)
    {
        printf("%d-%d-%d+%d=7\n",a,b,c,d);
        return 0;
    }

    if(a-b+c-d==7)
    {
        printf("%d-%d+%d-%d=7\n",a,b,c,d);
        return 0;
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N;cin >> N;
  if (N==100000 || N==10000 || N==1000 || N==100 || N==10) cout << 10 << endl;
  else cout << N/10000+(N-N/10000*10000)/1000
			+(N-N/1000*1000)/100
			+(N-N/100*100)/10
			+(N-N/10*10)
			<< endl;
  
}

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

int main() {
	int num;
    long long ans=1;
	cin >> num;
	vector<long long> n(num);
	for (int i = 0; i < num; i++) {
		cin >> n[i];
		if (n[i] == 0) {
			ans = 0;
		}
	}

	for (int i = 0; i < num; i++) {
		long long tmp = ans;
		if (n[i] == 0) {
			ans = 0;
			break;
		}

		if (ans * n[i] > 1000000000000000000) {
			ans = -1;
			break;
		}

		if (tmp < LLONG_MAX/n[i]) {
			ans = ans * n[i];
		}
		else {
			ans = -1;
			break;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 4048
import time


def data_input():
    D = int(input())
    C = tuple(map(int, input().split()))

    S = [list(map(int, input().split())) for _ in range(D)]

    return D, C, S


def score(D, C, S, T):
    """入力D, C, Sと出力Tからスコアを計算する関数"""

    last = [0] * 26  # 0で初期化されている

    def decrease(d):
        """d日めにiを開催した時の満足度の減少を返す関数"""
        res = 0
        base = sum(C)
        for i in range(26):
            res += S[d][i] - C[i] * (d+1 - last[i])
        return res

    v = 0
    for d, i in enumerate(T):
        last[i] = d + 1
        v += decrease(d)
    return v


start_time = time.time()
D, C, S = data_input()
input_time = time.time() - start_time

T = []
# Cum_v = []
max_v = 0
for d in range(D):
    max_t = 0
    for i in range(26):
        v = score(d, C, S[:d+1], T+[i])
        if v > max_v:
            # print(f'local_max at {d}-day is updated to {v}')
            max_t = i
            max_v = v
    T.append(max_t)
    print(max_t+1)

Measured memory_bytes: 76180
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int N, A, B;
    cin >> N >> A >> B;
    int *P;
    P = new int[N];
    int x;
    for (int i = 0; i < N; i++)
    {
        cin >> P[i];
    }
    sort(P, P + N);
    int countA = 0;
    int countB = 0;
    int countlargerB = 0;
    for (int i = 0; i < N; i++)
    {
        if (P[i] <= A)
        {
            countA++;
        }
        if (P[i] >= A + 1 && P[i] <= B)
        {
            countB++;
        }
        if (P[i] >= B + 1)
        {
            countlargerB++;
        }
    }
    cout << min(countlargerB, min(countA, countB)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M, 0), p(M);
    for (int i = 0; i < M; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int a;
            cin >> a;
            A.at(i) += pow(2,a - 1);
        }
    }
    for (int i = 0; i < M; i++) {
        cin >> p.at(i);
    }
    int a = pow(2, N), ans = 0;
    for (int i = 0; i < a; i++) {
        bool T = true;
        for (int j = 0; j < M; j++) {
            int b = A.at(j) & i, count = 0;
            while(b > 0) {
                if (b & 1) {
                    count++;
                }
                b >>= 1;
            }
            if (count % 2 != p.at(j)) {
                T = false;
            }
        }
        if (T) {
            ans++;
        }
    }
    cout << ans << endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	cin>>a;
	for(int i=0;i<a.size();i++)
	{
		if(a[i]=='1') a[i]='x';
		if(a[i]=='9') a[i]='y';
	}
	for(int i=0;i<a.size();i++)
	{
		if(a[i]=='x') a[i]='9';
		if(a[i]=='y') a[i]='1';
	}
	cout<<a;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cctype>
#include <algorithm>
#include <set>
#include <cmath>

using namespace std;
int main(){
  int n;
  cin >> n;
  for(int i = 0;i < n;i++){
	int cx = 0,cy = 0;
	int x,y;
	int ans = 0;
	int ans_x = 0;
	int ans_y = 0;
	while(cin >> x >> y && (x || y)){
	  cx += x;
	  cy += y;
	  if(ans <= (cx*cx + cy*cy)){
		if(ans == (cx*cx + cy*cy)){
		  if(ans_x < cx){
			ans_x = cx;
			ans_y = cy;
			ans = (cx*cx + cy*cy);
		  }
		}else{
		  ans_x = cx;
		  ans_y = cy;
		  ans = (cx*cx + cy*cy);
		}
	  }
	}
	cout << ans_x << " " << ans_y << endl;
  }
  return 0;
}

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

#define MOD 1000000007

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const vector<vector<T>>&obj) {
    o << "[" << endl; for (int i = 0; i < (int)obj.size(); ++i) o << "  " << obj[i] << endl; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const queue<T>&obj) {
    queue<T> obj_cp = obj;
    bool first = true;
    o << "{";
    while (!obj_cp.empty()) { o << (!first ? ", " : "") << obj_cp.front(); obj_cp.pop(); first = false; }
    o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}


vector<int> get_divisors(int n) {
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) {
                ret.push_back(n / i);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }

    vector<int> exist(1000001, 0);
    for (int i = 0; i < N; ++i) {
        exist[A[i]] += 1;
    }

    vector<vector<int>> divisors(N);
    for (int i = 0; i < N; ++i) {
        divisors[i] = get_divisors(A[i]);
    }


    int ans = 0;
    for (int i = 0; i < N; ++i) {
        bool found = false;
        for (int d : divisors[i]) {
            if (exist[d]) {
            }
            if (exist[d] > 0 && (d != A[i] || exist[d] > 1)) {
                found = true;
                break;
            }
        }
        if (!found) {
            ans += 1;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 65728
import java.util.Scanner;

// ABC100 at 2018/06/16

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solveB();
    }

    private void solveA() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if (A > 8 || B > 8) {
            System.out.println(":(");
        } else {
            System.out.println("Yay!");
        }
    }

    private void solveB() {
        Scanner sc = new Scanner(System.in);
        int D = sc.nextInt();
        int N = sc.nextInt();
        if (D == 0) {
            if (N == 100) {
                System.out.println((N + 1));
            } else {
                System.out.println(N);
            }
        } else if (D == 1) {
            if (N == 100) {
                System.out.println((N + 1) * 100);
            } else {
                System.out.println(N * 100);
            }
        } else {
            if (N == 100) {
                System.out.println((N + 1) * 10000);
            } else {
                System.out.println(N * 10000);
            }
        }
    }

    private void solveC() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveD() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveE() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveF() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

}

Measured memory_bytes: 23764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int[] hwd = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int h = hwd[0];
			int w = hwd[1];
			int d = hwd[2];

			Point[] a = new Point[h * w];
			for (int i = 0; i < h; i++) {
				int[] aa = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				for (int j = 0; j < w; j++) {
					a[aa[j] - 1] = new Point { Y = i + 1, X = j + 1 };
				}

			}

			int[] p = new int[h * w];
			for (int i = 0; i < h * w; i++) {
				if (i / d == 0) {
					p[i] = 0;
				} else {
					var dst = a[i];
					var src = a[i - d];
					p[i] = Math.Abs(src.X - dst.X) + Math.Abs(src.Y - dst.Y)
						+ p[i - d];
				}
			}

			StringBuilder sb = new StringBuilder();
			int q = int.Parse(Console.ReadLine());
			for (int i = 0; i < q; i++) {
				int[] lr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				sb.AppendLine((p[lr[1] - 1] - p[lr[0] - 1]).ToString()); 
			}

			Console.WriteLine(sb.ToString());
		}
	}

	public struct Point
	{
		public int X;
		public int Y;
	}
}


Measured memory_bytes: 24492
import copy
h,w = (int(i) for i in input().split())
x = [input() for i in range(h)]
cf,list1,num = [[0,0]],[[0,0]],1
while [h-1,w-1] not in cf and len(list1) != 0:
	list2 = []
	for j in list1:
		list3 = [[j[0]+1,j[1]],[j[0]-1,j[1]],[j[0],j[1]+1],[j[0],j[1]-1]]
		for j2 in list3:
			if (-1<j2[0]<h) and (-1<j2[1]<w) and (j2 not in cf) and (x[j2[0]][j2[1]]=="."):
				cf.append(j2)
				list2.append(j2)
	num += 1
	list1 = copy.deepcopy(list2)
num2 = 0
for k in x: num2 += k.count(".")
if [h-1,w-1] not in cf: answer = -1
else: answer = num2-num
print(answer)

Measured memory_bytes: 3700
#include "bits/stdc++.h"
using namespace std;

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int32_t main() {
    //ios::sync_with_stdio(false); cin.tie(nullptr);

    int n, r;
    cin >> n >> r;
    if (n >= 10) {
        cout << r << "\n";
    } else {
        cout << r + 100*(10-n) << "\n";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _K ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ld long double
#define ll long long
#define pb push_back
#define pi acos(-1)
#define eps 1e-7
#define F first
#define S second
#define X real()
#define Y imag()
#define cross(a,b) (conj(a)*(b)).X
#define dot(a,b) (conj(a)*(b)).Y
#define all(f) (f).begin(),(f).end()
#define allr(f) (f).rbegin(),(f).rend()
const int mod = 1e9+7 , A = 1e5 ;
typedef complex <ld> point ;
typedef vector <point> polygon ;
typedef tuple <int , int , int> line ;
//====================================
ll n , m , memo_aly[1005][1005] ;
char a[1005][1005] ;
ll solve(ll i , ll j)
{
	if (i == n-1 && j == m-1)
	{
		memo_aly[i][j] = 1 ;
		return  1 ;
	}
	ll val = 0 ;
	if (a[i][j] == '#')
	{
		memo_aly[i][j] = 0 ;
		return 0 ;
	}
	if (memo_aly[i][j] != -1)
		return memo_aly[i][j] ;

	{
		if (i+1 <= n-1 && j+1 <= m-1)
			val = (solve(i , j+1) + solve(i+1 , j)) %mod ;
		else if (j+1 <= m-1)
			val = solve(i , j+1) %mod ;
		else if (i+1 <= n-1)
			val = solve(i+1 , j) %mod ;
		else val = 0 ;
	}
	memo_aly[i][j] = val ;
	return val % mod ;
}
int main()
{
	_K
	cin >> n >> m ;
	for (int i =0 ; i < n ; i++)
		for (int j =0 ; j < m ; j++)
		{
			cin >> a[i][j] ;
			memo_aly[i][j] = -1 ;
		}
	cout << solve(0 , 0) ;
	return 0 ;
}

Measured memory_bytes: 9216
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };

    let n: usize = sc.read();
    let m: usize = sc.read();
    if m % 2 == 1 {
        println!("-1");
        return;
    }
    let mut graph = vec![vec![]; n];
    for i in 0..m {
        let a = sc.read::<usize>() - 1;
        let b = sc.read::<usize>() - 1;
        graph[a].push((b, i));
        graph[b].push((a, i));
    }
    let mut used = vec![false; m];
    dfs(0, &mut vec![false; n], &graph, &mut used);

    let mut direction = vec![None; m];
    for v in 0..n {
        for &(next, edge_id) in graph[v].iter() {
            if !used[edge_id] && direction[edge_id].is_none() {
                direction[edge_id] = Some((v, next));
            }
        }
    }
    dfs2(0, 0, &graph, &used, &mut direction);
    for i in 0..m {
        let (from, to) = direction[i].unwrap();
        println!("{} {}", from + 1, to + 1);
    }
}

fn dfs2(
    v: usize,
    p: usize,
    graph: &Vec<Vec<(usize, usize)>>,
    used: &[bool],
    direction: &mut [Option<(usize, usize)>],
) {
    for &(next, edge_id) in graph[v].iter() {
        if p == next {
            continue;
        }
        if used[edge_id] {
            dfs2(next, v, graph, used, direction);
        }
    }

    let forward = graph[v]
        .iter()
        .flat_map(|&(_, edge_id)| direction[edge_id])
        .filter(|&(from, _)| from == v)
        .count();

    for &(next, edge_id) in graph[v].iter() {
        if used[edge_id] && direction[edge_id].is_none() {
            if forward % 2 == 0 {
                direction[edge_id] = Some((next, v));
            } else {
                direction[edge_id] = Some((v, next));
            }
        }
    }
}

fn dfs(v: usize, visited: &mut [bool], graph: &Vec<Vec<(usize, usize)>>, used: &mut [bool]) {
    visited[v] = true;
    for &(next, edge_id) in graph[v].iter() {
        if visited[next] {
            continue;
        }
        used[edge_id] = true;
        dfs(next, visited, graph, used);
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 30716
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#include<limits.h>
int main(){
    char a;
    scanf("%c",&a);
    if(a>='a' && a<='z')  printf("a");
    else printf("A");
}


Measured memory_bytes: 1552
#include <stdio.h>
using namespace std;

int main(void) {
  int sum;
  while (scanf("%d", &sum)+1) {
    int count = 0;
    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    for (a = 0; a <= 9; a++) {
      for (b = 0; b <=9; b++) {
        for (c = 0; c <= 9; c++) {
          for (d = 0; d <= 9; d++) {
            if ((a + b + c + d) == sum) count++;
          }
        }
      }
    }
    printf("%d\n", count);
  }
}

Measured memory_bytes: 1024
N,M,Q=map(int,input().split())
B=[[0]*(N+1) for _ in range(N+1)]

for _ in range(M):
    l,r=map(int,input().split())
    B[l][r]+=1

for i in range(N):
    for j in range(N):
        B[i+1][j+1]+=B[i+1][j]


for i in range(N):
    for j in range(N):
        B[j+1][i+1]+=B[j][i+1]

for i in range(Q):
    q,p = map(int,input().split())
    print(B[p][p]-B[p][q-1]-B[q-1][p]+B[q-1][q-1])

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

int main() {
	int n, x = 0, m = 0,temp;
	string s;
	
	cin >> n >> s;
	for (int i=0; i < n; i++) {
		x += (s[i] - 'D') / 2 - 1;
		m = max(m,x);
	}
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n,a[200002],b[200002],ok,ans1,ans2;
int main(void){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)cin>>b[i];
    a[0]=a[n],a[n+1]=a[1];
    b[0]=b[n],b[n+1]=b[1];
    while(ok==0){
        ok=1;
        for(int i=1;i<=n;i++){
            if(a[i]>a[i-1]+a[i+1]){
                ans1+=a[i]/(a[i-1]+a[i+1]);
                a[i]%=a[i-1]+a[i+1];
                if(a[i]==0){a[i]=a[i+1]+a[i-1];ans1--;}
                ok=0;
                a[0]=a[n],a[n+1]=a[1];
            }
        }
    }
    ok=0;
    while(ok==0){
        ok=1;
        for(int i=1;i<=n;i++){
            if(b[i]>b[i-1]+b[i+1]){
                ans2+=b[i]/(b[i-1]+b[i+1]);
                b[i]%=b[i-1]+b[i+1];
                if(b[i]==0){b[i]=b[i-1]+b[i+1];ans2--;}
                ok=0;
                b[0]=b[n],b[n+1]=b[1];
            }
        }
    }
    for(int i=1;i<=n;i++){
        //cout<<a[i]<<b[i]<<endl;
        if(a[i]!=b[i]){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans2-ans1<<endl;
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

	public static long[] nums;

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int answer = 0;

		for (int i = 1; i < N; i++) {
			answer += (N - 1) / i;
		}

		System.out.println(answer);
	}
}

Measured memory_bytes: 35776
var
  n,l,i,j:longint;
  t:string;
  a:array[0..101] of string;
procedure kp(l,r:longint);
  var
    tl,tr:longint;
    m,t:string;
  begin  
    if l>=r then exit;
    tl:=l; tr:=r;
    m:=a[(tl+tr) div 2];
    while tl<tr do
      begin
        while a[tl]<m do inc(tl);
        while a[tr]>m do dec(tr);
        if tl<=tr then 
          begin
            t:=a[tl]; a[tl]:=a[tr]; a[tr]:=t; 
            inc(tl); dec(tr);
          end;
      end;
    kp(l,tr);
    kp(tl,r);
  end;
begin
  readln(n,l);
  for i:=1 to n do readln(a[i]);
  kp(1,n);
  for i:=1 to n do write(a[i]);
end.

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

  class Main  {
     public static void main(String[]args){
         Scanner scan = new Scanner(System.in);
         int n = scan.nextInt();
         String s = scan.next ();
         int max = 0 ;int count1 = 0 , count2 = 0;
         ArrayList<Character> a1 = new ArrayList<>();
         
         ArrayList<Character> a2 = new ArrayList<>();
         for(int i = 1 ; i<s.length();i++){
             String s1 = s.substring(0,i);
             String s2 = s.substring(i,n ); 
              for(int j = 0 ; j <s1.length();j++){     
                a1.add(s1.charAt(j));
                 //System.out.println(count);
             }
              for(int j = 0 ; j <s2.length();j++){     
                a2.add(s2.charAt(j));
                 //System.out.println(count);
             }
             
             for(int j = 0 ; j <s1.length();j++){     
                 if(s1.indexOf(s1.charAt(j) ) == j && a2.contains(s1.charAt(j))){
                  count1++; 
                }
                 //System.out.println(count);
             }
             
             for(int j = 0 ; j <s2.length();j++){
                 if(s2.indexOf(s2.charAt(j) ) == j && a1.contains(s2.charAt(j))){
                  count2 ++; 
                }
                 
                 //System.out.println(count);
             }
           
            // System.out.println(i +"th loop :"+count1); 
            //op :"+count2);
             if(count1 == count2 && count1>max) max = count1 ;
             count1 = 0 ;
             count2 = 0 ;
             //System.out.println("max:" +max);
             a1.clear();
             a2.clear();
         }         
         System.out.println(max);
     }
}


Measured memory_bytes: 23124
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>



using namespace std;

int k,x;

int main(){
    cin >> k >> x;
    if(k*500 >= x) cout << "Yes" << endl;
    else cout << "No" << endl;


return 0;
}

Measured memory_bytes: 256
A = int(input())+1
B = int(input())+1
C = int(input())+1
X = int(input())
count = 0
for x in range(A):
  for y in range(B):
    for z in range(C):
      if x*500 + y*100 + z*50 == X:
        count += 1
      else:
        pass
print(count)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main extends Exception{
    public static void main(String[] args) {
        Scanner s1 = new Scanner(System.in);
        String a = s1.next()+s1.next();
        int a1= Integer.parseInt(a);
        int a2=(int)Math.sqrt(a1);
        if (a1 == (a2*a2)){
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 21972
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int dp[3001][3001];

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

	string s, t;
	cin >> s >> t;
	int S = s.size(), T = t.size();
	int i = 0, j = 0;
	
	REP(i, S)REP(j, T) {
		if (s[i] == t[j]) {
			dp[i + 1][j + 1] = dp[i][j] + 1;
		}
		else {
			dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
		}
	}

	string res;
	while (S > 0 || T > 0) {
		while (S > 0 && dp[S][T] == dp[S - 1][T]) --S;
		if (S == 0) break;
		while (T > 0 && dp[S][T] == dp[S][T - 1]) --T;
		if (T == 0) break;
		res.push_back(s[S - 1]);
		--S;
		--T;
	}
	reverse(res.begin(), res.end());
	cout << res << endl;

	return 0;
}


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



// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    // Failed to predict input format
    long long N;
    int Q;
    string S;
    cin >> N;
    cin >> S;
    cin >> Q;
    vector<set<int>> alphabets(26);
    for(int i=0;i<N;i++){
        alphabets[S[i]-'a'].insert(i);
    }
    cerr << "read finish" << endl;
    for(int i=0;i<Q;i++){
        int j;
        cin >>j;
        if(j==1){
            int k;
            char c;
            cin >> k >> c;
            k--;
            alphabets[S[k]-'a'].erase(k);
            S[k] = c;
            alphabets[c-'a'].insert(k);
        }else{
            int s,t;
            cin >> s >> t;
            s--;
            t--;
            int ans =0;
            for(int l=0;l<26;l++){
                auto iter = alphabets[l].lower_bound(s);
                if(iter != alphabets[l].end() &&*iter <= t){
                    // cerr << *iter << endl;
                    ans++;
                }
            }
            cout << ans << "\n";

        }
    }
    return 0;
}


Measured memory_bytes: 24196
import java.util.*;
 
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        int left = a - b;

        if (left - c > 0) {
            System.out.println(0);
        } else {
            System.out.println(c - left);
        }
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define loop(i,k,n) for (ll i = k ; i < n ; ++i)
#define all(v) v.begin(),v.end()
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl

void Suhaib_Sawalha (){

    int n;
    ll ans = 0;
    cin >> n;
    for (int i = 1 ; i <= n ; ++i){
        int c = n/i;
        ans += c * 1ll * (c+1ll) / 2 * i;
    }
    cout << ans;
}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<endl)
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    int H, W; cin >> H >> W;
    vector<string> grid(H);
    rep(i, 0, H) cin >> grid[i];

    rep(hi, 0, H) {
        if (count(grid[hi].begin(), grid[hi].end(), '.') == W) {
            rep(wi, 0, W) grid[hi][wi] = '*';
        }
    }

    rep(wi, 0, W) {
        int count = 0;
        rep(hi, 0, H) if (grid[hi][wi] != '#') ++count;
        if (count == H) {
            rep(hi, 0, H) grid[hi][wi] = '*';
        }
    }

    rep(hi, 0, H) {
        bool printed = false;
        rep(wi, 0, W) {
            if (grid[hi][wi] != '*') {
                printed = true;
                cout << grid[hi][wi];
            }
        }
        if (printed) cout << "\n";
    }
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner sn, PrintWriter out) {
            int x = sn.nextInt();
            int a = sn.nextInt();
            int b = sn.nextInt();
            System.out.println(Math.abs(x - a) < Math.abs(x - b) ? "A" : "B");
        }

    }
}



Measured memory_bytes: 21844