akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vec h = ivec(n);
    sort(all(h));
    int v = distance(h.begin(), lower_bound(all(h), k));
    print(n - v);

    return 0;
}


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

int main()
{
    int N;
    cin >> N;
    int L[N],max=0;
    for(int i=0;i<N;i++){
        cin >> L[i];
        if(max < L[i]){
            max = L[i];
        }
    }
    int sum=0,count=0;
    for(int i=0;i<N;i++){
        sum+=L[i];
    }
    if(sum-max > max)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
#define ld long double
using namespace std;
// For ordered_set
//using namespace __gnu_pbds;
//template <typename T>
//using ord_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll N = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);

int main(){
    int n;
    cin >> n;
    bool k = true;
    loop(i,0,n){
        int a;
        cin >> a;
        if(a&1)continue;
        if(a % 3 != 0 && a % 5 != 0)k = false;
    }
    if(k)cout << "APPROVED\n";
    else cout << "DENIED\n";
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

mint f(int n){
    if(n==0) return 1;
    mint x = f(n/2);
    x *= x;
    if(n%2==1) x*=2;
    return x;
}

mint choose(int n,int a){
    mint x = 1, y = 1;
    rep(i,a){
        x *= n-i;
        y *= i+1;
    }
    return x / y;
}

int main(){
    cout << fixed << setprecision(10);
    ll n,a,b;
    cin >> n >> a >> b;
    mint ans = mint(2).pow(n);
    ans -= 1;
    ans -= choose(n,a);
    ans -= choose(n,b);
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
  int n, a, b, c, d, i, j, k;
  cin >> n;
  a=n/1000;
  b=n/100%10;
  c=n/10%10;
  d=n%10;
  for(i=0; i<2; i++)
    for(j=0; j<2; j++)
      for(k=0; k<2; k++)
	if(a+(1-2*i)*b+(1-2*j)*c+(1-2*k)*d==7){
	  cout << a;
	  if(i==0) cout << "+";
	  else cout << "-";
	  cout << b;
	  if(j==0) cout << "+";
	  else cout << "-";
	  cout << c;
	  if(k==0) cout << "+";
	  else cout << "-";
	  cout << d << "=" << 7;
	  return 0;
	}
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int64 INF = 1LL << 60;
const int MOD = 1e9 + 7;

const int N = 1e3 + 10;
vector<ii> a[N];
int64 d[N];
bool visit[N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  while (m--) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    --x; --y;
    a[x].push_back({y, z});
  }
  fill(d, d + n, -INF);
  d[0] = 0;
  int k;
  for (k = 0; k < n - 1; ++k) {
    bool found = false;
    for (int u = 0; u < n; ++u) {
      if (d[u] == -INF) continue;
      for (auto& it : a[u]) {
        int v = it.first;
        if (d[v] < d[u] + it.second) {
          d[v] = d[u] + it.second;
          found = true;
        }
      }
    }
    if (!found) break;
  }
  queue<int> Q;
  for (int u = 0; u < n; ++u) {
    if (d[u] == -INF) continue;
    for (auto& it : a[u]) {
      int v = it.first;
      if (d[v] < d[u] + it.second) {
        visit[v] = true;
        Q.push(v);
      }
    }
  }
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (auto& it : a[u]) {
      int v = it.first;
      if (!visit[v]) {
        visit[v] = true;
        Q.push(v);
      }
    }
  }
  if (visit[n - 1]) {
    puts("inf");
  } else {
    printf("%lld\n", d[n - 1]);
  }
  return 0;
}


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

const int MAXN = 1e5 + 10;

int N, C, K;
int T[MAXN];

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

	for(int i = 0; i < N; i++) 
		cin >> T[i];
	sort(T, T + N);

	int c = C, t = K, b = 0;

	for(int i = 0; i < N; i++){
		if(c < C && t + T[i] - T[i-1] <= K){
			c++;
			t += T[i] - T[i-1];
		}
		else {
			b++;
			c = 1;
			t = 0;
		}
	}
	cout << b << '\n';
	return 0;
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    S = [x for x in sys.stdin.readline().split()][0]  # 文字列 一つ
    # N = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ
    # N, D = [int(x) for x in sys.stdin.readline().split()]  # 複数int
    # h_list = [int(x) for x in sys.stdin.readline().split()]  # 複数int

    # grid = [list(sys.stdin.readline().split()[0]) for _ in range(N)]  # 文字列grid
    # v_list = [int(sys.stdin.readline().split()[0]) for _ in range(N)]
    # grid = [[int(x) for x in sys.stdin.readline().split()]
    #         for _ in range(N)]  # int grid

    logger.debug('{}'.format([]))

    N = len(S)
    if S != S[::-1]:
        print('No')
        return

    S1 = S[:((N - 1) // 2)]
    if S1 != S1[::-1]:
        print('No')
        return

    S2 = S[(N + 3) // 2 - 1:]
    if S2 != S2[::-1]:
        print('No')
        return

    print('Yes')


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """akasaka"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """level"""
        output = """No"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """atcoder"""
        output = """No"""
        self.assertIO(input, output)


Measured memory_bytes: 6580
#include <cstdio>
#include <iostream>
#include <cstring>
#include <map>
#include <string>
#include <vector>
#include <queue>

using namespace std;
int main()
{
	int n;
	cin>>n;
	int m=n/15;
	cout<<n*800-m*200<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	static long[][] memo;

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

		int n = sc.nextInt();
		int p = sc.nextInt();
		int count = 0;
		for (int i = 0; i < n; i++) {
			if (sc.nextInt() % 2 == 1) count++;
		}

		memo = new long[n + 1][n + 1];

		long ans = 0;

		for (int i = p; i <= count; i += 2) {
			ans += combi(count, i);
		}

		ans *= Math.pow(2, n - count);

		out.println(ans);
		out.flush();
	}

	static long combi(int n, int m) {
		m = (n - m < m ? n - m : m);
		if (memo[n][m] > 0) return memo[n][m];
		else if (m == 0) return memo[n][m] = 1;
		else if (m == 1) return memo[n][m] = n;
		return memo[n][m] = combi(n - 1, m - 1) + combi(n - 1, m);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) return true;
		else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) return false;
		}
		return true;
	}

	private byte readByte() {
		if (hasNextByte()) return buffer[ptr++];
		return -1;
	}

	private boolean isPrintableChar(byte c) {
		return '!' <= c && c <= '~';
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public int nextInt() {
		if (!hasNext()) throw new NoSuchElementException();
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		return a;
	}

	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		return a;
	}
}

Measured memory_bytes: 21204
function main(input) {
    var value = input.trim();
    var result = value.split("");
    var winCount = result.filter((v) => v === "o").length;
    console.log(winCount >= 8 - (15 - result.length) ? 'YES' : 'NO');
}
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
//I forgot you...
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)2e5 + 3;
const int infint = (int)1e9 + 3;
const ll inf = (ll)1e18;
int n, m, ans, mika = infint, dp[MAXN], part[MAXN];
string s;
int add(int a, int b)
{
	int c = a + b;
	if(c >= MOD)
		c -= MOD;
	if(c < 0)
		c += MOD;
	return c;
}
int mul(int a, int b)
{
	int c = 1LL * a * b % MOD;
	return c;
}
void find_mika()
{
	mika = n - 1;
	if(n % 2 == 1)
		mika--;
	if(s[0] == 'R')
	{
		bool first = 0;
		int ted = 0;
		for (int i = 0; i < m; i++)
			if(s[i] == 'R')
				ted++;
			else
			if(s[i] == 'B' && ted > 0)
			{
				if(ted % 2)	
					mika = min(mika, ted);
				else
				if(first == 0)
					mika = min(mika, ted + 1);
				first = 1;
				ted = 0;
			}
	}
	else
	{
		int ted = 0;
		bool first = 0;
		for (int i = 0; i < m; i++)
			if(s[i] == 'B')
				ted++;
			else
			if(s[i] == 'R' && ted > 0)
			{
				if(ted % 2)
					mika = min(mika, ted);
				else
				if(first == 0)
					mika = min(mika, ted + 1);
				first = 1;
				ted = 0;
			}
	}
}
int getzarib(int kaman)
{
	int emp = n - kaman;
	if(emp == 0)
		return 1;
	else
		return n - emp;
}
int main()
{
	ios::sync_with_stdio(false); 
	cin.tie(0); cout.tie(0);
	cin >> n >> m >> s;
	bool flg = 1;
	for (int i = 1; i < m; i++)
		if(s[i] != s[0])	
			flg = 0;
	if(flg)
	{
		dp[0] = 1, dp[1] = 1, dp[2] = 2;
		for (int i = 3; i <= n; i++)
			dp[i] = add(dp[i - 1], dp[i - 2]);
		
		ans = dp[n];
		if(n >= 2)
			ans = add(ans, dp[n - 2]);
		cout << ans;
		return 0;
	}
	find_mika();
	//cout << mika << endl;

	dp[0] = 1;
	part[0] = 1;
	for (int i = 2; i <= n; i += 2)
	{
		dp[i] = part[i - 2];
		if(i - mika - 3 >= 0)
			dp[i] = add(dp[i], -part[i - mika - 3]);
		part[i] = add(part[i - 2], dp[i]);
	}
	ans = add(ans, dp[n]);
	for (int i = 1; i <= mika; i += 2)
		if(i != n - 2 && i != n)
			ans = add(ans, mul(getzarib(i), dp[n - i - 1]));
		else
		if(i == n)
			ans = add(ans, 1);
	cout << ans;
}




/*
8 10
RRRRBRRBBR
*/


Measured memory_bytes: 2196
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

typedef long long LL;

int bottom(int n){
    int res = 1;
    while(res * 10 <= n){
        res *= 10;
    }
    return res;
}

int slow(int A, int B, int P){
    map<int, int> dp;
    map<int, int> sum[12];
    int ans = 0;
    for(int i = A; i <= B; i++){
        dp[i] = 1;
        dp[i] = (dp[i] + sum[ to_string(i).size() ][i - 1]) % P;
        /*
        for(int k = bottom(i); k < i; k++){
            dp[i] = (dp[i] + dp[k]) % P;
        }
        */
        for(int k = i / 10; k > 0; k /= 10){
            dp[i] = (dp[i] + sum[to_string(k).size()][k]) % P;
        }
        sum[to_string(i).size()][i] = (sum[ to_string(i).size() ][i - 1] + dp[i]) % P;
        ans = (ans + dp[i]) % P;
    }
    return ans;
}
int main(){
    LL A, B, P;
    while(cin >> A >> B >> P && A > 0){
        cout << slow(A, B, P) << endl;
        /*
        const int N = B - A + 1;
        // [A, border - 1], [border, border * 10 - 1], ... [border * 10^n, B] 
        LL border = 10;
        while(border - 1 < A){
            border *= 10;
        }
        if(border > B){
            LL ans = 1;
            REP(i, N) ans = ans * 2 % P;
        }else if(B < 10 * A){
            const int N1 = border - A;
            const int N2 = B - border + 1;
            LL ans1 = 1, ans2 = 1;
            REP(i, N1) ans1 = ans1 * 2 % P;
            REP(i, N2) ans2 = ans2 * 2 % P;
            cout << (ans1 + ans2 + P - 2) % P << endl;
        }else{
        }
        */
    }
    return 0;
}

Measured memory_bytes: 11132
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000
int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  vector<pair<int,int>>a(n);
  int e;
  for(int i=0;i<n;i++)
  {
    if(s[i]=='E')e++;
    if(i!=0)a[i].first=a[i-1].first;
    if(s[i]=='W')a[i].first++;;
  }
  int w=n-e;
  for(int i=n-1;i>=0;--i)
  {
    if(i!=n-1)a[i].second=a[i+1].second;
    if(s[i]=='E')a[i].second++;
  }
  int ans=INF;
  for(int i=0;i<n;i++)
  {
    int c=a[i].first+a[i].second-1;
    //cout<<c<<endl;
    if(c<ans)ans=c;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int)(n); i++)
#define ALL(x) x.begin(),x.end()
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
 

// HOW TO DO 
// 1. input 
//    int N 
//    vector P,Q
// 2. 入力されたそれぞれの順列が何番目にあるか返す =  next-permutation(first, last)
//    first = 1つ目の順列
//    last = 入力された順列
// 3.  output |a-b|

// 入力された順列が何番目にあるか返す
// next_permutation (first、last)
// first = 1つ目の順列, last = 入力された順列
int solve(vector<int> v, vector<int> P)
{
    int ret = 0;
    while (v != P)
    {
        next_permutation(ALL(v));
        ret++;
    }
    return ret;
}

int main()
{
    // input 
    int N;  
    cin >> N;  
    vector<int> P(N), Q(N);
    cin >> P >> Q;

    // 順列の1つ目　
    // Ex) 大きさ3の順列：v = (1,2,3)
    vector<int> v(N);
    REP(i, N) v[i] = i + 1;

    // 入力された順列が何番目にあるか返す
    // next_permutation (first、last)
    // first = 1つ目の順列
    // last = 入力された順列
    cout << abs(solve(v, P) - solve(v, Q)) << endl;
}


Measured memory_bytes: 3600
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node { int p, l, r;};

Node T[MAX];
int n, D[MAX];

void print(int u) {
  int i,c;
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].p << ", ";
  cout << "depth = " << D[u] << ", ";

  if( T[u].p == NIL ) cout << "root, ";
  else if( T[u].l == NIL ) cout << "leaf, ";
  else cout << "internal node, ";

  cout << "[";

  for(i=0, c=T[u].l; c!=NIL; i++,c=T[c].r) {
    if(i) cout <<", ";
    cout << c;
  }
  cout << "]" << endl;
}

void rec(int u, int p) {
  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r,p);
  if(T[u].l != NIL) rec(T[u].l,p+1);
}

int main(void) {
  int i,j,d,v,c,l,r;
  cin >> n;
  for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = NIL;
  for(i=0;i<n;i++) {
    cin >> v >> d;
    for(j=0;j<d;j++) {
      cin >> c;
      if(j==0) T[v].l=c;
      else T[l].r =c;
      l = c;
      T[c].p = v;
    }
  }
  for(i=0;i<n;i++) {
    if(T[i].p == NIL) r = i;
  }
  
  rec(r,0);
  
  for(i=0;i<n;i++) print(i);
  
  return 0;
}


Measured memory_bytes: 7736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    string a,b;
    cin>>a>>b;
    string n=a+b;
    ll num=(ll)(stoi(n));
    rep(i,1,1001){
        if(i*i==num){cout<<"Yes"<<endl;return 0;}
    }
    cout << "No" << endl;
    return 0;
}


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

int main()
{
  int N;
  cin >> N;
  string S;
  cin >> S;
  int max_cnt = 0;
  for (int i = 1; i < N - 1; i++)
  {
    int cnt = 0;
    string X = S.substr(0, i);
    string Y = S.substr(i, N - i);
    set<char> st;
    for (int k = 0; k < X.size(); k++)
    {
      st.insert(X[k]);
    }
    for (auto x : st)
    {
      if (Y.find(x) != string::npos)
        cnt++;
    }
    max_cnt = max(cnt, max_cnt);
  }
  cout << max_cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
 long int k=0,i;
 string s;
 cin>>s;
for(i=0;i<s.size();i++)
 {
   if(i%2==0 && s[i]=='L')
    {
     k=1;
     break;
    }
    else if(i%2!=0 && s[i]=='R')
    {
     k=1;
     break;

    }

 }

 if(k==1)
 cout<<"No"<<endl;
 else
 cout<<"Yes"<<endl;
 return 0;
}






Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define INF 10000000
#define PI 3.14159265358979323846
using namespace std;
typedef long long ll;
typedef pair<int, int> p;
typedef vector<int> v;
typedef vector<int, int> v2;
typedef vector< pair<int, int> > vp;
int dx[4] = {  0, 1, 0, -1 };
int dy[4] = { -1, 0, 1, 0 };

int w, h;
char c[21][21];

int bfs(int y, int x){
	int sum = 1;
	for (int i = 0; i < 4; i++){
		int nx = x + dx[i], ny = y + dy[i];
		if (0 <= nx && nx < w && 0 <= ny && ny < h && c[ny][nx] == '.'){
			c[ny][nx] = '#';
			sum += bfs(ny, nx);
		}
	}
	
	return sum;
}

int main(){
	ios::sync_with_stdio(false);

	while (1){
		cin >> w >> h;
		if (w == 0 && h == 0) break;

		int sx,sy;
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++){
				cin >> c[i][j];
				if (c[i][j] == '@'){
					sy = i;
					sx = j;
				}
			}		

		cout << bfs(sy, sx) << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#define pb push_back 
#define ff first
#define ss second
#define MOD 1000000007
#define ll long long int
#define P pair<int,int>
 
using namespace std;
 
 
ll add(ll x,ll y)
{
    x += y;
    while(x >= MOD) x -= MOD;
    while(x < 0) x += MOD;
    return x;
}
 
ll mul(ll x,ll y)
{
    return (x * 1ll * y) % MOD;
}
 
ll binpow(ll x,ll y)
{
    ll z = 1;
    while(y)
    {
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}
 
ll inv(ll x)
{
    return binpow(x, MOD - 2);
}
 
 
ll divide(ll x,ll y)
{
    return mul(x, inv(y));
}


bitset<10000000> bits;

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

   
   int t=1;
   //cin>>t;

   bits.set(0);
   
   while(t--)
   {
         int n;
         cin>>n;

         int sum=0;
         for(int i=0;i<n;i++)
         {
             int y;
             cin>>y;
             sum+=y;
             bits=((bits<<y)|bits);
         }

         for(int i=(sum+1)/2;;i++)
         {
           if(bits.test(i))
           {
             cout<<i;
             return 0;
           }
         }
        
   }
   
   return 0;
}

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

int main(void){
   int N,K;
   cin>>N>>K;
   vector<int> x(N);
   for(int i=0;i<N;i++){
      cin>>x[i];
   }
   vector<int> dist;
   for(int i=0;i<N;i++){
      dist.push_back(min(2*x[i],2*(K-x[i])));
   }
   int ans=0;
   for(int i=0;i<dist.size();i++){
      ans+=dist[i];
   }
   cout<<ans<<endl;
   return 0;
}



Measured memory_bytes: 256
#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++)
#define repi(i,a,b) for(int i = (a); i < (b); 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},dy[]={0,-1,0,1};
int x,h;
int main(){
	while(cin>>x>>h,x||h){
		printf("%.7f\n",x*x+sqrt(x*x*0.25+h*h)*4*x*0.5);
	}
	return 0;
}

Measured memory_bytes: 1192
s = str(input())
cnt = 0
prev = s[0]
stock = 1
for i in range(1, len(s)):
    if stock == 0:
        prev = s[i]
        stock += 1
    else:
        if s[i] != prev:
            cnt += 2
            stock -= 1
            if stock > 0:
                if s[i] == '0':
                    prev = '1'
                else:
                    prev = '0'
        else:
            prev = s[i]
            stock += 1
print(cnt)

Measured memory_bytes: 3188
import java.util.Scanner;

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

		try (Scanner sc = new Scanner(System.in);) {
			int n = sc.nextInt();

			int ans = 0;

			for (int i = 0; i < n; i++) {
				int l = sc.nextInt();
				int r = sc.nextInt();
				ans = ans + r - l + 1;
			}

			System.out.println(ans);

		}
	}
}

Measured memory_bytes: 25716
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <stdlib.h>
/******memore********/
#define maxn
#define inf 
#define mod 1000000007

int main()
{
	int n, i ;
	long long m  = 1;
	scanf("%d", &n);
	for(i = 1; i <= n; i++)
	{
		m = m * i % mod;
	}
	printf("%lld", m % (mod) );
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
//#define int long  long int
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main(){
	int K;
	cin >> K;
	int ans = 0;
	for (int i = 1; i <= K; i++) {
		int num = i;
		for (int j = 1; j < i; j++) {
			if (num % 2 == 0 && j % 2 == 1)ans++;
			else if(num % 2 == 1 && j % 2 == 0)ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#b
N, D = map(int, input().split())
x = [0] * N
y = [0] * N
for i in range(N):
     x[i], y[i] = map(int, input().split())
ans=0        
for i in range(N):
    h=x[i]**2+y[i]**2
    if h<=D**2:
        ans+=1
print(ans)

Measured memory_bytes: 24700
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
typedef pair<ll,ll> P;
//12:20-12:21
const ll MAX_N=2e3;
ll N,L[MAX_N];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N;
	REP(i,N){
		cin>>L[i];
	}
	sort(L,L+N);
	ll ans=0;
	REP(i,N)FOR(j,i+1,N){
		ll a=L[i],b=L[j];
		ans+=max(lower_bound(L,L+N,a+b)-L-j-1,0ll);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=3.1415926535897932384626433832795;
const ll INF = 1LL<<62;
const ll MINF = -1LL<<62;

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


int main() {
	IO;
	ll a,b;
	cin>>a>>b;
	a%=b;
	cout<<min(a,b-a)<<"\n";

	return 0;
}


Measured memory_bytes: 256
H, N = map(int, input().split())
A = [0 for _ in range(N)]
B = [0 for _ in range(N)]
for i in range(N):
    A[i], B[i] = map(int, input().split())

dp = [[0 for _ in range(H+1)] for _ in range(N+1)]
for j in range(H+1):
    dp[0][j] = float("inf")
#print(*dp, sep="\n")
for i in range(1,N+1):
    for j in range(1,H+1):
        #print(i,j)
        dp[i][j] = min(dp[i-1][j], dp[i][max(j-A[i-1],0)]+B[i-1])

#print(*dp, sep="\n")
print(dp[N][H])


Measured memory_bytes: 125788
#include<iostream>
#include<string>
#include <cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define ll long long
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(a,b) (a += b,b = a - b,a -= b)
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  char x,y;
  cin >> x >> y;
  if(int(x)>int(y)){
    cout << '>' << endl;
  }
  else if(int(x)<int(y)){
    cout << '<' << endl;
  }
  else cout << '=' << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        String S1 = sc.next();
        String str = String.valueOf(S1);
       String W2=null;
       String W1=null;
        for(int count=1; count<=4;count++){
            
         W1 = str.substring(count-1,count);
        
         
            if(W1.equals(W2)){
            System.out.print("Bad");
            return;
            
        }
        
        W2=W1;
        }
        System.out.print("Good");
    }
    
}


Measured memory_bytes: 23764
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

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

  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++) cin >> a[i];

  ll sum[n + 1];
  sum[0] = 0;
  for(int i = 1; i <= n; i++){
    sum[i] = sum[i - 1] + a[i - 1];
  }

  int i = 2;
  int j = 1;
  int k = j + 1;
  ll ans = INF_INT;
  while(i < n - 1){
    ll left = sum[i];
    ll right = sum[n] - sum[i];
    while(j + 1< i &&
        abs(sum[j] - (left - sum[j])) > abs(sum[j + 1] - (left - sum[j + 1]))){
      ++j;
    }
    while(k + 1 < n &&
        abs(sum[k] - sum[i] - (right - (sum[k] - sum[i]))) > 
        abs(sum[k + 1] - sum[i] - (right - (sum[k + 1] - sum[i])))){
      ++k;
    }
    ll p = sum[j];
    ll q = sum[i] - sum[j];
    ll r = sum[k] - sum[i];
    ll s = sum[n] - sum[k];
    ll mx = max(max(p, q), max(r, s));
    ll mi = min(min(p, q), min(r, s));
    ans = min(ans, mx - mi);
    ++i;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
import collections
H, W, *S = open(0).read().split()
H, W = [int(_) for _ in [H, W]]
dist = [[float('inf')] * W for _ in range(H)]
dist[0][0] = 0
Q = collections.deque([0])
while True:
    if not Q:
        break
    i = Q.popleft()
    x, y = divmod(i, W)
    d = dist[x][y]
    for dx, dy in ((1, 0), (0, 1)):
        nx, ny = x + dx, y + dy
        if 0 <= nx < H and 0 <= ny < W:
            if S[nx][ny] == '#' and S[x][y] == '.':
                if dist[nx][ny] > d + 1:
                    dist[nx][ny] = d + 1
                    Q += [nx * W + ny]
            elif dist[nx][ny] > d:
                dist[nx][ny] = d
                Q += [nx * W + ny]
ans = dist[-1][-1]
if S[0][0] == '#':
    ans += 1
print(ans)


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

int main(){
	long long N; cin >> N; int tms = 1; while((1ll << tms) - 1 <= N) ++tms;
	N -= (1ll << (tms - 1)) - 1; int cnt = 1; static int pos[103];
	for(int i = tms / 2 ; i ; --i){
		long long fac = 1; for(int j = 1 ; j <= i ; ++j) fac = fac * (tms - j + 1) / j;
		while(N >= fac){N -= fac; pos[++cnt] = i;}
	}

	vector < int > ans; int cnt1 = cnt;
	for(int i = 6 ; i >= 2 ; --i){
		while(N >= (1 << (i - 1)) - 1){N -= (1 << (i - 1)) - 1; ++cnt1; for(int j = 1 ; j <= i ; ++j) ans.push_back(cnt1);}
	}
	for(int i = 1 , p = cnt ; i <= tms ; ++i){ans.push_back(1); while(pos[p] == i) ans.push_back(p--);}
	for(int i = 2 ; i <= cnt ; ++i) ans.push_back(i);
	cout << ans.size() << endl;
	for(auto t : ans) cout << t << ' ';
	return 0;
}
	


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
INF = 10**10
n,m = map(int, input().split())
d = [[INF for _ in range(n)] for _ in range(n)]
el = []

for _ in range(m):
    a,b,c = map(int,input().split())
    d[a-1][b-1] = c
    d[b-1][a-1] = c
    el.append([a-1,b-1,c])

for k in range(n):
    for i in range(n):
        for j in range(n):
            if i==j:
                d[i][j] = 0

            d[i][j] = min(d[i][j], d[i][k]+d[k][j])

ret = 0
for ei in range(m):
    a = el[ei][0]
    b = el[ei][1]
    c = el[ei][2]
    flag = False
    for s in range(n):
        if d[s][a]+c==d[s][b]:
            flag = True
            break
    if not flag:
        ret += 1
print(ret)


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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)


typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
//////////////////////////





int main(){fastio
    ll n;cin>>n;
    if(n%2==1)cout<<0<<endl;
    else{
        LL ans=0;
        LL c=10;
        while(n>=c){
            ans+=n/c;
            c*=5;
        }
        cout<<ans<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
int main() {
  int n;
  cin>>n;
  int v[n],g[n];
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  for(int i=0;i<n;i++){
    cin>>g[i];
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(v[i]>g[i]) ans+=v[i]-g[i];
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(N: int, S: str):
    E = []
    W = []
    e, w = 0, 0
    for i in range(N):
        if S[i] == 'W':
            w += 1
        W.append(w)
        if S[N-1-i] == 'E':
            e += 1
        E.append(e)
    mn = 1e6
    for i in range(N):
        mn = min(mn, E[i] + W[N-1-i] - 1)
    print(mn)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 20304
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <limits>
using namespace std;

int main ()
{
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;

	int ans = numeric_limits<int>::max();
	for (int i = 0; i <= 100000; ++i)
	{
		ans = min(ans, i * 2 * c + max(0, x - i) * a + max(0, y - i) * b);
	}

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

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

int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int wa[n+5]; bool ac[n+5];
	for(int i=0;i<=n;i++){
		wa[i]=0;ac[i]=0;
	}
	int p; char s[5];
	for(int i=0;i<m;i++){
		scanf("%d %s",&p,s);
		if(s[0]=='A'){
			ac[p]=1;
		}else{
			if(!ac[p])wa[p]++;
		}
	}
	int ans=0,pen=0;
	for(int i=1;i<=n;i++){
		if(ac[i]){
			ans++;
			pen+=wa[i];
		}
	}
	printf("%d %d",ans,pen);
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
ll mulmod(ll a,ll b,ll c) 
{ 
    if (b==0) 
        return 0; 
    ll s = mulmod(a, b/2, c); 
    if (b%2==1) 
        return (a%c+2*(s%c)) % c; 
 
    else
        return (2*(s%c)) % c; 
} 

  
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
int main()
{ll int t;
t=1;
//cin>>t;

while(t--)
{ll int h,i,n,k=1,ans=0;
cin>>h;
while(h>0)
{
    ans+=k;
    k*=2;
    h/=2;
}
cout<<ans<<endl;
    
}
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

ll digitsum(ll b, ll n){
    ll res = 0;
    while(n > 0){
        res += n%b;
        n /= b;
    }
    return res;
}

vector<ll> div(ll n){
    vector<ll> ret;
    ret.emplace_back(n);
    for (ll i = 1; i*i< n; ++i) {
        if(n%i == 0){
            ret.emplace_back(i);
            if(i != 1 && i*i!=n){
                ret.emplace_back(n/i);
            }
        }
    }
    return ret;
}
int main() {
    ll n, s;
    cin >> n >> s;
    if(n < s){
        cout << "-1\n";
        return 0;
    }else if(n == s){
        cout << n+1 << "\n";
        return 0;
    }
    for (ll b = 2; b*b <= n+1 ; ++b) {
        if(digitsum(b, n) == s){
            cout << b << "\n";
            return 0;
        }
    }
    auto v = div(n-s);
    sort(v.begin(), v.end());
    for (auto &&i : v) {
        if(digitsum(i+1, n) == s){
            cout << i+1 << "\n";
            return 0;
        }
    }
    cout << "-1\n";
    return 0;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        float N = (float)sc.nextInt();
        sc.close();

        float tmp = 180;

        float result = (180 - (360 / N)) * N;

        System .out.println((int)result);

    }
}


Measured memory_bytes: 20820
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, K, x, ans = 0;

	cin >> N >> K;
	rep(i, N) {
		cin >> x;
		ans += 2 * min(x, K - x);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <time.h>
#include <stdlib.h>
using namespace std;

	

int main(){
	int g,a,b,c,n,count=0;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> n;
	if(a<b){
		g=b;
		b=a;
		a=g;
	}
	if(b<c){
		g=c;
		c=b;
		b=g;
	}
	if(a<b){
		g=b;
		b=a;
		a=g;
	}
	
	for(int i=0;i*a<=n;i++){
		for(int j=0;j*b+i*a<=n;j++){
			if( (n-j*b-a*i)%c==0){
				count++;
			}
		}
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int N;  cin >> N;
	string s, t;  cin >> s >> t;
	string ans;
	REP(i, N){
		ans += s[i];
		ans += t[i];
	}

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


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

int triple_max(int x, int y, int z);

int main(){
    string n;
    cin >> n;
    cout << (n.find('9') != -1 ? "Yes" : "No");

    return 0;
}

int triple_max(int x, int y, int z){
    int ans = x;
    if (y > x && y > z) ans = y;
    else if (z > x && z > y) ans = z;

    return ans;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] arr = new int[n];
    for(int i=0;i<n;i++){
      arr[i]=sc.nextInt();
    }
    Arrays.sort(arr);
    long ans =0;
    for(int i=0;i<k;i++){
      ans=ans+arr[i];
    }
    System.out.println(ans);
  }
}


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

int main() {
    string S;
    cin >> S;
    int n = S.size();
    ll sum = 0;
    for(int bit = 0; bit < (1<<(n-1)); bit++) {
        ll t = S[0] - '0';
        for(int i = 0; i < n-1; i++) {
            if((1<<i) & bit) {
                sum += t;
                t = S.at(i+1) - '0';
            }
            else {
                t *= 10;
                t += S.at(i+1) - '0';
            }
        }
        sum += t;
        //cout << ex << endl;
        //cout << eval(ex) << endl;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256