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

int main()
{
  int n, m, p, ac = 0, wa = 0;
  string s;
  cin >> n >> m;
  vector<bool> AC(n, false);
  vector<int> w_count(n, 0);

  for (int i = 0; i < m; i++)
  {
    cin >> p >> s;
    if (s == "WA")
    {
      w_count[p - 1]++;
    }
    if (s == "AC" and !AC[p - 1])
    {
      ac++;
      AC[p - 1] = true;
      wa += w_count[p - 1];
    }
  }
  cout << ac << " " << wa << endl;
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;  cin >> n;
    vector<int> x(n), dp(n + 1, Inf);
    rep(i, n) {
      cin >> x[i];
    }
    dp[0] = 0;
    rep(i, n + 1) {
      dp[i + 1] = min(dp[i + 1], dp[i] + abs(x[i + 1] - x[i]));
      dp[i + 2] = min(dp[i + 2], dp[i] + abs(x[i + 2] - x[i]));
    }
    cout << dp[n - 1] << '\n';

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
signed main(){
  char a;
  cin>>a;
  char b=a+1;
  cout<<b;
}


Measured memory_bytes: 256
n = int(input())
lis = [0,0,0,0,0,0,0,0]
pro = 0
li = list(map(int,input().split()))
for i in range(n):
	if li[i] >= 3200:
		pro += 1
	else:
		lis[(li[i])//400] = 1
su = lis.count(1)
print(max(su,1),min(su+pro,n))

Measured memory_bytes: 3064
N = int(input())
TXY = [[int(x) for x in input().split()] for _ in range(N)]

pt,px,py = 0,0,0

bl = True
for t,x,y in TXY:
  dt = abs(t-pt)
  dx = abs(x-px)
  dy = abs(y-py)
  px = x
  py = y
  pt = t
  if dt < dx+dy:
    bl = False
    break
  if (dt-(dx+dy))&1:
    bl = False
    break

print('Yes' if bl else 'No')

Measured memory_bytes: 21052
import java.util.*;
import java.io.*;
import java.math.*;

public class Main{
	public static void main(String[] args)throws IOException{
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		BigInteger md = BigInteger.valueOf(1000000007);
		BigInteger ten = BigInteger.valueOf(10);
		BigInteger nine = BigInteger.valueOf(9);
		BigInteger eight = BigInteger.valueOf(8);
		BigInteger n = BigInteger.valueOf(N);
		BigInteger sub1 = ten.modPow(n, md);
		sub1 = sub1.subtract(eight.modPow(n, md));
		BigInteger sub2 = nine.modPow(n, md);
		sub2 = sub2.subtract(eight.modPow(n, md));
		sub1 = sub1.subtract(sub2.multiply(BigInteger.valueOf(2)));
		sub1 = sub1.mod(md);
	//	long seq = (long)((Math.pow(10, N) - Math.pow(8, N)) - 2 * (Math.pow(9, N) - Math.pow(8, N)));
		System.out.println(sub1.toString());
	}
}

Measured memory_bytes: 35872
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
#include <cstdlib>
#define INT_MAX 2147483647
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i < (int)n; i++)

using namespace std;
typedef long long int ll;

bool judge(int n, int k, int p, vector<int> a) {
	bool ret = true;
	int s = 1, t = 0;
	Loop(i, n) {
		if (t + a[i] > p) {
			s++;
			if (s > k) {
				ret = false;
				break;
			}
			t = 0;
		}
		t += a[i];
	}
	return ret;
}

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> w(n);
	int wmax = 0, sumw = 0;
	Loop(i, n) {
		cin >> w[i];
		if (w[i] > wmax) wmax = w[i];
		sumw += w[i];
	}
	int left = wmax, right = sumw;
	int p = (left + right) / 2;
	while (left < right) {
		if (judge(n,k,p,w)) right = p;
		else left = p + 1;
		p = (left + right) / 2;
	}
	cout << p << endl;
	return 0;
}

Measured memory_bytes: 3672
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                Out.Flush();
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var x = IO.RInt;
            if (x <= 599)
            {
                WriteLine(8);
            }
            else if (x <= 799)
            { WriteLine(7); }
            else if (x <= 999) WriteLine(6);
            else if (x <= 1199) WriteLine(5);
            else if (x <= 1399) WriteLine(4);
            else if (x <= 1599) WriteLine(3);
            else if (x <= 1799) WriteLine(2);
            else WriteLine(1);

        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n){
		cin >> a[i];
	}
	int count = 0;
	rep(i,n-1){
		if(a[i] == a[i+1]){
			count++;
			a[i+1] = -1;
		}
	}
	cout << count << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    int h, w;
    cin >> h >> w;
    char s[h][w];
    int sharp = 0;
    queue<PII> q;
    rep(i,h){
        rep(j,w) {
            char tmp;
            cin >> tmp;
            s[i][j] = tmp;
            if (tmp == '#') {
                q.emplace(i, j);
                sharp++;
            }
        }
    }

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

    int preve = 0;
    int ans = 0;
    while(sharp < h * w) {
        int tmp = sharp - preve;
        preve = sharp;
        rep(j,tmp) {
            PII now = q.front();
            q.pop();
            rep(i,4) {
                int nx = now.first + dx[i];
                int ny = now.second + dy[i];
                if (nx < 0 || nx >= h || ny < 0 || ny >= w
                        || s[nx][ny] == '#')
                    continue;
                s[nx][ny] = '#';
                q.emplace(nx, ny);
                sharp++;
            }
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9360
export class Main {
  static main(input): string {
    const tmp: string[] = input.split("\n");
    const n: number = Number(tmp[0]);
    const v: number[] = tmp[1].split(" ").map(Number);
    const c: number[] = tmp[2].split(" ").map(Number);
    let result: number = 0;
    for (let i = 0; i < n; i++) {
      if (v[i] > c[i]) {
        result += v[i] - c[i];
      }
    }
    return `${result}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 11468
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  int mp[3][3];
  bool b[3][3];
  for(int i = 0; 3 > i; i++){
    for(int j = 0; 3 > j; j++){
      cin>>mp[i][j];
      b[i][j] = false;
    }
  }
  int n;cin>>n;
  for(int i = 0; n > i; i++){
    int t;cin>>t;
    for(int j = 0; 3 > j; j++){
      for(int k = 0; 3 > k; k++){
        if(mp[j][k] == t){
          b[j][k] = true;
          break;
        }
      }
    }
  }
  bool ok = ((b[0][0] && b[1][1] && b[2][2])||(b[0][2] && b[1][1] && b[2][0]));
  for(int i = 0; 3 > i; i++){
    if(b[i][0] && b[i][1] && b[i][2])ok = true;
    if(b[0][i] && b[1][i] && b[2][i])ok = true;
  }
  cout << YesNo(ok) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

ll C[55][55];

void solve() {
	int n, a, b;
	cin >> n >> a >> b;
	vector<ll> v(n);
	for(int i = 0; i < n; i++) cin >> v[i];
	sort(all(v));
	reverse(all(v));
	
	int cnt = 1;
	ll avg = v[0];
	for(int i = 1; i < a; i++) {
		avg += v[i];
		if(v[i] != v[i - 1]) cnt = 0;
		cnt++;
	}
	
	int nums = 0;
	for(int i = 0; i < n; i++) {
		if(v[a - 1] == v[i]) nums++;
	}
	
	ll ans = 0;
	if(v[a - 1] == v[0]) for(int i = min(b, nums); i >= a; i--) {
//		cout << C(nums, i) << endl;
		ans += C[nums][i];
	} else ans = C[nums][cnt];
	
	cout << fixed << setprecision(6);
	cout << (long double) avg / a << endl << ans << endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	C[0][0] = 1;
	for(int i = 1; i <= 50; i++) {
    	C[i][0] = C[i][i] = 1;
    	for(int j = 1; j < i; j++) C[i][j] = C[i-1][j-1] + C[i-1][j];
	}
	
	solve();
    return 0;
}

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

template <typename T>
class BinaryIndexedTree
{
    vector<T> arr;
    T initial_value;
    long long size;
    function<T(T, T)> operation;

public:
    BinaryIndexedTree(const long long N, function<T(T, T)> func, T init)
    {
        set_size(N);
        set_initial_value(init);
        initialize_array();
        set_operation(func);
    }

    void set_size(const long long N)
    {
        this->size = N + 1;
    }

    void set_initial_value(const T init)
    {
        this->initial_value = init;
    }

    void initialize_array()
    {
        this->arr = vector<T>(size, initial_value);
    }

    void initialize_array(const T init)
    {
        set_initial_value(init);
        initialize_array();
    }

    void set_operation(const function<T(T, T)> func)
    {
        this->operation = func;
    }

    void update(long long idx, T value)
    {
        while (idx <= this->size)
        {
            this->arr[idx] = this->operation(this->arr[idx], value);
            idx += (idx & -idx);
        }
    }

    T query(long long idx)
    {
        T ret = this->initial_value;
        while (idx > 0)
        {
            ret = this->operation(ret, this->arr[idx]);
            idx -= (idx & -idx);
        }
        return ret;
    }
};

int main()
{
    int N;
    string S;
    cin >> N >> S;
    S = " " + S;

    vector<BinaryIndexedTree<int>> bit(
        26,
        BinaryIndexedTree<int>(N + 1, [](int a, int b) { return a + b; }, 0));

    for (int i = 1; i <= N; i++)
    {
        bit[S[i] - 'a'].update(i, 1);
    }

    int Q;
    cin >> Q;
    for (int q = 0; q < Q; q++)
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            int i;
            char c;
            cin >> i >> c;

            bit[S[i] - 'a'].update(i, -1);
            bit[c - 'a'].update(i, 1);
            S[i] = c;
        }
        if (t == 2)
        {
            int l, r;
            int ans = 0;
            cin >> l >> r;
            for (BinaryIndexedTree<int> &b : bit)
            {
                if (b.query(r) - b.query(l - 1) > 0)
                {
                    ans++;
                }
            }
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 53660
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
ll modpow(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2, M);
        return t*t % M;
    }
    return N * modpow(N, P-1, M) % M;
}
class cum_sum{
  private:
    vector<long long>sum;
    vector<long long>tmp;
    int n;
  public:
    cum_sum(vector<long long>v):tmp(v),n(v.size()){
      sum.resize(n + 1);
      for(int i = 0; i < n; i++){
        sum[i + 1] = sum[i] + tmp[i];
      }
    };
    long long range_sum(int l, int r){
      if(l > r)swap(l,r);
      return sum[r + 1] - sum[l];
    }
}; 
int main(){
  string s;
  cin >> s;
  int n = s.size();
  vector<ll>v;
  for(int i = n - 1; i >= 0; i--){
    ll num = modpow(10,n - i,2019);
    num *= s[i] - '0';
    num %= 2019;
    v.push_back(num);
  }
  reverse(all(v));
  map<long long, long long> nums;
  long long sum = 0;
  nums[sum]++;
  for (int i = 0; i < n; ++i) {
    sum += v[i];
    nums[sum % 2019]++;
  }
  long long res = 0;
  for (map<long long, long long>::iterator it = nums.begin(); it != nums.end(); ++it) {
    res += it->second * (it->second - 1) / 2;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 5508
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b,t;
    int ans = 0;
    
    scanf("%d %d %d",&a,&b,&t);
    
    ans = (t / a) * b;
    
    printf("%d\n",ans);
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

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

    vector<int> x(N);
    for (int i = 0; i < N; ++i) {
        cin >> x[i];
    }

    int ans = numeric_limits<int>::max();
    for (int i = 0; i < N-K+1; ++i) {
        int t = abs(x[i+K-1] - x[i]) + min(abs(x[i+K-1]), abs(x[i]));
        ans = min(ans, t);
    }

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



Measured memory_bytes: 640
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <bitset>
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rrep(i,a,n) for(ll i=n;i>=a;i--)
#define elif else if
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF = 1e+17;
const ll MODcdf = 998244353;
bool pairCompare(const P& firstElof,const P& secondElof){
    return firstElof.first<secondElof.first;
}
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll a[5];
    ll k;cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>k;
    rep(i,1,5){
      rep(j,0,i)
        if(a[i]-a[j]>k){
            cout<<":("<<endl;
            return 0;
        }
    }
    cout<<"Yay!"<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdlib>
using namespace std;
const int maxn = 100005;
long long a[maxn], b[maxn];
int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; ++i)
    {
        scanf("%lld%lld", &a[i], &b[i]);
    }
    long long sum = 0;
    for(int i = n - 1; i >= 0; --i)
    {
        if((a[i] + sum) % b[i])
            sum += b[i] - (a[i] + sum) % b[i];
    }
    printf("%lld\n", sum);
}


Measured memory_bytes: 1920
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
//#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;

struct Node{
    int key;
    Node *next, *prev;
};

Node *nil;

Node* listSearch(int key){
    Node *cur = nil->next;
    while(cur != nil && cur->key != key){
        cur = cur->next;
    }
    return cur;
}

void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList(){
    Node *cur = nil->next;
    int isf = 0;
    while(1){
        if(cur == nil) break;
        if(isf++ > 0) cout << " ";
        cout << cur->key;
        cur = cur->next;
    }
    printf("\n");
}

void deleteNode(Node *t){
    if (t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void DeleteFirst(){
    deleteNode(nil->next);
}

void deleteLast(){
    deleteNode(nil->prev);
}

void deleteKey(int key){
    deleteNode(listSearch(key));
}

void insert(int key){
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

int main(){
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for (int i=0;i<n;i++){
        scanf("%s%d", com, &key);
        if (com[0] == 'i'){ insert(key); np++;size++;}
        else if(com[0] == 'd'){
            if (strlen(com) > 6) {
                if (com[6] == 'F') DeleteFirst();
                else if(com[6] == 'L') deleteLast();
            }else{
                deleteKey(key); nd++;
            }
            size--;
        }
    }
    printList();
    
}



Measured memory_bytes: 34388
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;
    ll a, b, c;
    cin >> a >> b >> c;
    ll ans = INF;
    chmin(ans, a + b);
    chmin(ans, b + c);
    chmin(ans, c + a);
    cout << ans << endl;

    return 0;
}

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

int cmmdc(int a, int b)
{
    while (a) {
        b %= a;
        a ^= b ^= a ^= b;
    }
    return b;
}

int main()
{
    vector <int> nr;
    int c = 0, n, k, x;
    cin >> n >> k;

    while (n--) {
        cin >> x;
        c = cmmdc(c, x);
        nr.push_back(x);
    }

    bool posible = 0;

    for (auto i : nr)
        if (i >= k && (i - k) % c == 0)
            posible = 1;

    cout << (posible ? "POSSIBLE" : "IMPOSSIBLE");
    return 0;
}


Measured memory_bytes: 892
using System;
using System.Text;


namespace ALDS1_2_D
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int N = int.Parse(input);
            int[] arr = new int[N];
            for (int i = 0; i < N; i++)
            {
                arr[i] = int.Parse(Console.ReadLine());
            }

            shellSort(arr, N);

            for (int i = 0; i < N; i++)
            {
                Console.WriteLine(arr[i]);
            }

        }

        public static int insertionSort(int[] arr, int n, int g)
        {
            int count = 0;
            for (int i = g; i < n; i++)
            {
                int tmp = arr[i];
                int j = i - g;
                while (j >= 0 && arr[j] > tmp)
                {
                    arr[j + g] = arr[j];
                    j = j - g;
                    count++;
                }
                arr[j + g] = tmp;
            }
            return count;
        }

        public static void shellSort(int[] arr, int n)
        {
            int count = 0;
            int m = 1;
            int tmp = 1;
            for (int i = 1; i < 100; i++)
            {
                tmp = tmp * 3;
                if (tmp > 2 * n + 1)
                {
                    m = i - 1;
                    break;
                }    
            }

            int[] G = new int[m];
            G[0] = 1;
            for (int i = 1; i < m; i++)
            {
                G[i] = 3 * G[i - 1] + 1;
            }

            for (int i = m - 1; i >= 0; i--)
            {
                count += insertionSort(arr, n, G[i]);
            }

            string output = ArrayJoin(G);
            Console.WriteLine(m);
            Console.WriteLine(output);
            Console.WriteLine(count);
        }

        public static string ArrayJoin(int[] arr)
        {
            StringBuilder sb = new StringBuilder();
            for (int i = arr.Length - 1; i >= 0; i--)
            {
                if (sb.Length > 0)
                {
                    sb.Append(" ");
                }
                sb.Append(arr[i]);
            }
            return sb.ToString();
        }
    }
}

Measured memory_bytes: 16504
#include <bits/stdc++.h>
using namespace std;
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; }

const int INF = 1e9;
int n;

int main() {
    cin >> n;
    vector<int> a(n, 0);
    for(int i = 0; i < n; ++i) cin >> a.at(i);
    sort(a.begin(), a.end());
    int amax = a.at(n-1);
    int half = amax/2;
    int absmin = INF;
    int ansno = 0;
    for(int i = 0; i < n-1; ++i) {
        int check = 0;
        if(a.at(i) > half) check = amax - a.at(i);
        else check = a.at(i);
        if(abs(check - half) < absmin) {
            absmin = abs(check - half);
            ansno = i;
        }
    }
    cout << amax << " " << a.at(ansno) << endl;
}

Measured memory_bytes: 640
program main
  implicit none
  integer i,a
  character(10) s 
  read(*, *) a
  read(*, *) s
  !read(*, *) (L(i), i = 1,N)
  if (a < 3200) then
    write(*, *) 'red'
  else
    write(*, *) trim(s)
  end if
end program main


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;

#define fi first
#define se second
#define pb push_back
#define sz(x) (int) ((x).size())
#define fast ios_base::sync_with_stdio(0); cin.tie(0);
#define testcase int _; cin >> _; while (_--)
#define all(x) ((x).begin(), (x).end())


/*A - NOT*/
void Solve() {
	int x;	cin >> x;
	cout << !x << "\n";
}

int main() {
	fast
	//testcase
		Solve();
	return 0;
}

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

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

typedef int64_t ll;

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

#define SPRE(x) setprecision(x) // 精度を指定

int main()
{
	cin.tie(0);
    ios::sync_with_stdio(false);
	int N;
	map<int, int> a;
	cin >> N;
	a[0] = 4;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		a[tmp]++;
	}
	ll x,y;
	x = y = -1;
	auto p = a.rbegin();
	while(x < 0){
		if(p->second > 1){
			x = p->first;
			p->second-=2;
		}
		else
			p++;
	}
	while(y < 0){
		if(p->second > 1){
			y = p->first;
			p->second-=2;
		}
		else
			p++;
	}
	cout << x * y << '\n';
}



Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

string s, t;

int main(){
	while (cin >> s >> t){
		if (s == "0"&&t == "0")break;
		int h = 0, b = 0;
		REP(i, s.size()){
			if (s[i] == t[i])h++;
		}
		REP(i, s.size()){
			REP(j, s.size()){
				if (i == j)continue;
				if (s[i] == t[j])b++;
			}
		}
		cout << h << " " << b << endl;
	}
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
 	ll cost;
 };
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = LLONG_MAX;
string ch = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
/****** define constant end ********/
/****** define variable start ******/
ll n, k;
vl x, y;
/******* define variable end *******/
int solve() {
	cin >> n >> k;
	x.resize(n);
	y.resize(n);
	REP(i, n){
		cin >> x[i] >> y[i];
	}
	ll ans = INF;

	for(auto& tate1 : x){
		for(auto& tate2 : x){
			if(tate1 == tate2){
				continue;
			}
			for(auto& yoko1 : y){
				for(auto& yoko2 : y){
					if(yoko1 == yoko2){
						continue;
					}
					ll count = 0;
					REP(i, n){
						if((x[i] <= tate1 && x[i] >= tate2) || (x[i] >= tate1 && x[i] <= tate2)){
							if((y[i] <= yoko1 && y[i] >= yoko2) || (y[i] >= yoko1 && y[i] <= yoko2)){
								count++;
							}
						}
					}
					if(count == k){
						ans = min(ans, abs(tate1-tate2) * abs(yoko1-yoko2));
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main()
{
  long long N,T;
  cin>>N>>T;
  vector <long long> t(N);
  for(int i=0;i<N;i++){
    cin>>t[i];
  }
  long long ans=T;
  for(int i=1;i<N;i++){
    if(t[i]-t[i-1]<T){
      ans+=t[i]-t[i-1];
    }else{
      ans+=T;
    }
  }

  cout<< ans <<endl;
}


Measured memory_bytes: 1792
n, k = map(int, input().split())
A = list(map(int, input().split()))
visited = [0]*n
n_city = 1
while visited[n_city-1] == 0:
    visited[n_city-1] = 1
    n_city = A[n_city-1]
cnt = 1
root = n_city
n_city = A[n_city-1]
while n_city != root:
    n_city = A[n_city-1]
    cnt += 1
to_root = 0
n_city = 1
while n_city != root:
    n_city = A[n_city-1]
    to_root += 1
loop_num = k if k < to_root else (k-to_root)%cnt + to_root
cnt = 0
n_city = 1
while cnt < loop_num:
    n_city = A[n_city-1]
    cnt += 1
print(n_city)

Measured memory_bytes: 32284
import sys
sys.setrecursionlimit(10 ** 6)

n = int(input())
links = [[] for _ in range(n)]
colors = [0] * (n - 1)

for i in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    links[a].append((b, i))

def dfs(a, color):
    c = 1
    for b, i in links[a]:
        if c == color:
            c += 1
        colors[i] = c
        dfs(b, c)
        c += 1


dfs(0, 0)
print(max(colors))
for color in colors:
    print(color)

Measured memory_bytes: 69096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[200010];
bool ch[21],ne[21],ho[21];
int main() {
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	ll ans=0;
	ll j=0;
	for(ll i=0;i<n;i++){
		ll now1=a[i];
		ll m=0;
		for(ll k=0;k<20;k++){
			ho[k]=0;
		}
		while(now1!=0){
			ll num=now1%2;
			ho[m]=num;
			m++;
			now1/=2;
		}
		for(ll k=0;k<20;k++){
			ch[k]+=ho[k];
		}
		for(;j<n;j++){
			if(i==j){
				continue;
			}
		for(ll k=0;k<20;k++){
			ne[k]=0;
		}			
			m=0;
			ll now2=a[j];
			while(now2!=0){
			ll num=now2%2;
			ne[m]=num;
			m++;
			now2/=2;
			}
			bool CH=true;
			for(ll k=0;k<20;k++){
				if(ch[k]+ne[k]==2){
					CH=false;
					break;
				}
			}
			if(CH){
				for(ll k=0;k<20;k++){
					ch[k]+=ne[k];
				}
			}
			if(CH!=true){
				break;
			}
		}
		//cout << j << " "<<i<<endl;
		ans+=j-i;
		for(ll k=0;k<20;k++){
			ch[k]-=ho[k];
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int H,W,wh,ww;
	cin>>H>>W>>wh>>ww;
	cout<<(H-wh)*(W-ww)<<endl;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n;
  cin>>n;
  if(n==2){
    cout<<-1<<endl;
    return 0;
  }
  vv<int> g(n);
  rep(i,n)reps(j,1,n) g[i].pb((i+j)%n);
  //out(g,1);
  if(n%2==0){
    rep(i,n)if(g[i][n/2-1]>i) swap(g[i][n/2],g[i][n/2-1]);
  }
  for(auto v:g){
    for(int x:v) cout<<x+1<<" ";cout<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;


int main() {
  string s; cin >> s;
  int n = s.size();
  int cnt = 0;
  rep(i,n) {
    if (s[i] == '1') cnt++;
  }
  cout << cnt << endl;
}

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

int main() {
    int a[] = {12, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
    int A, B; cin >> A >> B;
    if (a[A - 1] < a[B - 1]) {
        cout << "Bob" << endl;
    } else if (a[A - 1] > a[B - 1]) {
        cout << "Alice" << endl;
    } else {
        cout << "Draw" << endl;
    }
}


Measured memory_bytes: 256
import sys, math

ifnt = 168430090

def lg(x):
	bwl = 0
	while x > 0:
		x /= 10
		bwl = bwl + 1
	
	return bwl


#sys.stdin = open("test.in", "r")
n = input()
ans = ifnt
for i in range(int(math.sqrt(n))):
	if n % (i + 1) == 0:
		ans = min(ans, max(lg(i + 1), lg(n / (i + 1))))
	
print ans


Measured memory_bytes: 5764
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
#include<regex>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl; }
const LL MOD = 1e9 + 7;
const LL LLINF = 1LL << 60;
const int INF = 1 << 30;


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

	cout << N * N * N << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

int main() {
    int N; cin >> N;
    vector<int> a(N); rep(i, N) cin >> a[i];
    vector<vector<int>> G(N);
    rep(i, N - 1) {
        int u, v; cin >> u >> v; u--; v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    vector<int> ans(N);
    vector<int> lis(N + 1, INT_MAX);
    auto dfs = [&](auto dfs, int u, int p) -> void {
        int k = lower_bound(range(lis), a[u]) - lis.begin();
        int tmp = lis[k];
        lis[k] = a[u];
        ans[u] = lower_bound(range(lis), INT_MAX) - lis.begin();
        for (int v : G[u]) if (v != p) {
            dfs(dfs, v, u);
        }
        lis[k] = tmp;
    };
    dfs(dfs, 0, -1);
    rep(i, N) {
        cout << ans[i] << '\n';
    }
}

Measured memory_bytes: 36604
import math
from decimal import Decimal as dec

def main():
    a, b, h, m = map(int, input().split())
    deg = abs(6*m-(30*h+m/2))
    if not deg:
        print(abs(a-b))
    elif deg == 180:
        print(a+b)
    else:
        deg = deg if deg < 180 else 360 - deg
        y = dec(math.radians(deg))
        x = dec(math.sqrt(dec(a**2 + b**2 - dec(2*a*b)*dec(math.cos(y)))))
        print(x)

if __name__ == "__main__":
    main()

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
typedef vector<int> vi;typedef vector<vi> vvi;typedef pair<int,int> pii;typedef vector<pii> vpii;
typedef long long ll;

const long long mod = 1000000007;

long long powMod(long long x, long long y) {
  long long r = 1, a = x % mod;
  while (y) {
    if (y & 1) r = (r * a) % mod;
    a = a * a % mod;
    y /= 2;
  }
  return r;
}

long long invMod(long long x) {
  return powMod(x, mod - 2);
}

void Main() {
  int N;
  string S;
  cin >> N >> S;
  int M = SZ(S);

  vector<vector<ll>> dp(N+3, vector<ll>(N+2));
  dp[0][0] = 1;
  rep(i, N) rep(j, N) if (dp[i][j]) {
    // 最初のi回でj文字入れる方法が dp[i][j] 通り
    (dp[i+1][j+1] += dp[i][j] * 2) %= mod;
    (dp[i+1][max(0,j-1)] += dp[i][j]) %= mod;
  }

  ll ans = dp[N][M];
  ll im2 = invMod(2);
  rep(i, M) {
    (ans *= im2) %= mod;
  }
  _p("%lld\n", ans);
}
int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 195968
#include <stdio.h>

int main()
{
  int n;

  if (scanf("%d", &n) != 1) {
    return 1;
  }

  int x = 0;
  int y = 0;

  x = n * 800;
  y = n / 15 * 200;

  printf("%d\n", x - y);
  
  return 0;
}


Measured memory_bytes: 128
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

dic = defaultdict(int)
for i in range(2, N+1):
    own_snum = i
    joshi = A[i-2]
    # dic[joshi].append(i)
    dic[joshi] += 1
for i in range(1, N+1):
    print(dic[i])


    


Measured memory_bytes: 38304
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin >> n;

    string str;
    cin >> str;

    int res = 1;
    for (int i = 1; i < n; i++) {
        if (str[i] != str[i - 1]) ++res;
    }

    cout << res << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
using namespace std;
#define maxn 0x3f3f3f
#define ll long long


int main()
{
    int n;
    int t[110];
    scanf("%d",&n);
    int ans=0;
    for(int i=1;i<=n;i++)
        scanf("%d",&t[i]);
    for(int i=1;i<=n;i++)
        for(int j=i;j<=n;j++)
        for(int k=j;k<=n;k++)
    {
        if(i!=j&&j!=k&&k!=i&&t[i]!=t[j]&&t[j]!=t[k]&&t[k]!=t[i])
        {
            if(t[i]+t[j]>t[k]&&t[i]+t[k]>t[j]&&t[j]+t[k]>t[i])
                ans++;
        }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 3812
#include<cstdio>

#include<cstring>

#include<iostream>

#include<algorithm>

#define LL long long

#define ls k<<1

#define rs k<<1|1

using namespace std;

const int N=200005;

struct node

{

    int u,v,nxt;

}edge[2*N];

struct Tree

{

    int l,r,w,siz,f;

}T[2*N];

int n,m,cnt=0,num=1,root=1,a[N],b[N],head[N];

int deep[N],fa[N],son[N],tot[N],top[N],idx[N];

void AddEdge(int x,int y)

{

    edge[num].u=x;

    edge[num].v=y;

    edge[num].nxt=head[x];

    head[x]=num++;

}

int dfs1(int now,int f,int dep)

{

    deep[now]=dep;

    fa[now]=f;

    tot[now]=1;

    int maxson=-1;

    for(int i=head[now];i!=-1;i=edge[i].nxt)

    {

        if(edge[i].v==f) continue;

        tot[now]+=dfs1(edge[i].v,now,dep+1);

        if(tot[edge[i].v]>maxson) maxson=tot[edge[i].v],son[now]=edge[i].v;

    }

    return tot[now];

}

void update(int k)

{

    T[k].w=T[ls].w+T[rs].w;

}

void Build(int k,int ll,int rr)

{

    T[k].l=ll;T[k].r=rr;T[k].siz=rr-ll+1;

    if(ll==rr)

    {

        T[k].w=a[ll];
        //cout<<T[k].w<<endl;
        return;

    }

    int mid=(ll+rr)>>1;

    Build(ls,ll,mid);

    Build(rs,mid+1,rr);

    update(k);

}

void dfs2(int now,int topf)

{

    idx[now]=++cnt;

    a[cnt]=b[now];

    top[now]=topf;

    if(!son[now]) return;

    dfs2(son[now],topf);

    for(int i=head[now];i!=-1;i=edge[i].nxt)

      if(!idx[edge[i].v]) dfs2(edge[i].v,edge[i].v);

}

void pushdown(int k)

{

    if(!T[k].f) return ;

    T[ls].w=T[ls].w+T[ls].siz*T[k].f;

    T[rs].w=T[rs].w+T[rs].siz*T[k].f;

    T[ls].f=T[ls].f+T[k].f;

    T[rs].f=T[rs].f+T[k].f;

    T[k].f=0;

}

void IntervalAdd(int k,int ll,int rr,int val)

{

    if(ll<=T[k].l&&T[k].r<=rr)

    {

        T[k].w+=T[k].siz*val;

        T[k].f+=val;

        return;

    }

    pushdown(k);

    int mid=(T[k].l+T[k].r)>>1;

    if(ll<=mid) IntervalAdd(ls,ll,rr,val);

    if(rr>mid) IntervalAdd(rs,ll,rr,val);

    update(k);

}

int IntervalSum(int k,int ll,int rr)

{

    int ans=0;

    if(ll<=T[k].l&&T[k].r<=rr)

        return T[k].w;

    pushdown(k);

    int mid=(T[k].l+T[k].r)>>1;

    if(ll<=mid) ans=ans+IntervalSum(ls,ll,rr);

    if(rr>mid)  ans=ans+IntervalSum(rs,ll,rr);

    return ans;

}

void TreeSum(int x,int y)

{

    int ans=0;

    while(top[x]!=top[y])

    {

        if(deep[top[x]]<deep[top[y]]) swap(x,y);

        ans=ans+IntervalSum(1,idx[top[x]],idx[x]);

        x=fa[top[x]];

    }

    if(deep[x]>deep[y]) swap(x,y);

    ans=ans+IntervalSum(1,idx[x],idx[y]);

    cout<<ans<<" ";

}

int main()

{

    cin>>n>>m;

    memset(head,-1,sizeof(head));

    for(int i=1;i<=n-1;i++)

    {

        int x,y;

        cin>>x>>y;

        AddEdge(x,y);

        AddEdge(y,x);

    }

    dfs1(root,0,1);

    dfs2(root,root);

    Build(1,1,n);

    while(m--)

    {

        int x,y;

        cin>>x>>y;

        IntervalAdd(1,idx[x],idx[x]+tot[x]-1,y);

    }

    for(int i=1;i<=n;i++) TreeSum(i,i);

    cout<<endl;

    return 0;

}


Measured memory_bytes: 37504
import java.util.*;
import java.util.stream.Collectors;



public class Main {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        final int N=scanner.nextInt();
        final int M=scanner.nextInt();
        final int[] pArray=new int[N];
        for(int i=0;i<N;i++){
            pArray[i]=scanner.nextInt();
        }
        UnionFind unionFind=new UnionFind(N);
        for(int i=0;i<M;i++){
            int x=scanner.nextInt();
            int y=scanner.nextInt();
            unionFind.union(x-1,y-1);
        }
        int result=0;
        for(int i=0;i<N;i++){
            if(unionFind.same(i,pArray[i]-1)) result++;
        }
        System.out.println(result);
    }
}
class UnionFind{
    int n;
    int[] ints;
    public UnionFind(int n) {
        this.n = n;
        ints = new int[n];
        for(int i=0;i<n;i++){
            ints[i]=i;
        }
    }
    public int root(int x){
        if(ints[x]==x){
            return x;
        }else{
            int root=root(ints[x]);
            ints[x]=root;
            return root;
        }
    }
    public boolean same(int x,int y){
        return root(x)==root(y);
    }
    public void union(int x,int y){
        ints[root(x)]=ints[root(y)];
    }
    @Override
    public String toString(){
        return Arrays.stream(ints).mapToObj(i->String.format("%d",i)).collect(Collectors.joining(","));
    }
}

Measured memory_bytes: 90228
import numpy as np
n,m=map(int,input().split())
info=np.zeros((n,n),dtype=int)

for i in range(m):
  a,b=map(int,input().split())
  info[a-1][b-1]=1
  info[b-1][a-1]=1

  
def f(v,visit):
  cnt=0
  ff=1
  for i in range(n):
    if visit[i]==0:
      ff=0
  if ff==1:
    return 1
  
  for i in range(n):
    if info[v][i]==1 and visit[i]==0:
      visit[i]=1
      cnt+=f(i,visit)
      visit[i]=0
    
  return cnt
  
visit=np.zeros(n,dtype=int)
visit[0]=1

print(f(0,visit))


Measured memory_bytes: 12504
fun main(args:Array<String>) {
    val (n,k) = readLine()!!.split(" ").map(String::toInt)
    val hl:List<Int> = readLine()!!.split(" ").map(String::toInt)
    var ans:Int = 0
    for (x in hl) {
        if (x >= k) {
            ans++
        }
    }
    println(ans)
}

Measured memory_bytes: 48900