akhauriyash/Code-Regression huggingface dataset:
/*
 * sto Qingyu orz
 * 感谢真神sqy无私的教诲。膜时队者处处阿克，只因大师sqy在他背后。不膜大师者违背了真神的旨意，真神必将降下天谴,
 * 使其天天爆零
 * 我不由自主地膜拜真神sqy。
 * Author: RainAir
 * Time: 2019-10-16 10:52:50
 */
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define fi first
#define se second
#define U unsigned
#define P std::pair
#define LL long long
#define pb push_back
#define MP std::make_pair
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(int i = a;i <= b;++i)
#define ROF(i,a,b) for(int i = a;i >= b;--i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

const int MAXN = 1e5 + 5;
int a[MAXN],b[MAXN],n;

struct BIT{
    #define lowbit(x) ((x)&(-(x)))
    int tree[MAXN<<1];

    inline void clear(){
        CLR(tree,0);
    }

    inline void add(int pos,int d){
        while(pos <= n+233){
            tree[pos] += d;
            pos += lowbit(pos);
        }
    }

    inline int query(int pos){
        int res = 0;
        while(pos){
            res += tree[pos];
            pos -= lowbit(pos);
        }
        return res;
    }
}bit;

inline bool chk(int k){
    b[0] = 0;
    FOR(i,1,n) b[i] = a[i]<k ? -1 : 1;
    int mn = 0;LL ans = 0;
    FOR(i,1,n) b[i] += b[i-1],mn = std::min(mn,b[i]);// 0~n+1
    mn = -mn;++mn;
    FOR(i,0,n) b[i] += mn;
    bit.clear();bit.add(b[0],1);
    FOR(i,1,n){
        ans += bit.query(b[i]);
        bit.add(b[i],1);
    }
 //   DEBUG(4ll*ans);DEBUG(1ll*n*(n-1));
    return 4*ans >= 1ll*n*(n+1);
}

int main(){
   // freopen("a.in","r",stdin);
    scanf("%d",&n);
    int l = 1e9,r = 0;
    FOR(i,1,n) scanf("%d",a+i),l = std::min(l,a[i]),r = std::max(r,a[i]);
    int ans = -1;
//    DEBUG(chk(1));
//    return 0;
    while(l <= r){
        int mid = (l + r) >> 1;
        if(chk(mid)) ans = mid,l = mid+1;
        else r = mid-1;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1792
n, m = map(int,input().split())
A = [list(map(int,input().split())) for i in range(n)]
for i in range(n):
    for j in range(m):
        A[i][j] -= 1
S = [0] * m
for i in range(n):
    S[A[i][0]] += 1

l = 0
r = n+1
mi = (l+r) // 2
while r-l>1:
    T = S[:]
    ng = 0
    I = [0] * n
    Y = [0] * m
    while ng == 0:
        M = [0] * m
        for i in range(m):
            if T[i] > mi:
                M[i] = 1
                Y[i] = 1
        # print(T,M)
        if sum(M) == 0:
            break
        for i in range(n):
            if M[A[i][I[i]]] == 1:
                T[A[i][I[i]]] -= 1
                while I[i] < m and Y[A[i][I[i]]] == 1:
                    I[i] += 1
                if I[i] == m:
                    ng = 1
                    break
                T[A[i][I[i]]] += 1
    if ng == 1:
        l = mi
    else:
        r = mi
    mi = (l+r) // 2
print(r)

Measured memory_bytes: 48732
// Problem : 
// 			C - Walking Takahashi
// 			
// 		
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")  // disable
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define lll __int128
#define lp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define vec(v, type, sz) vector<type> v(sz)
#define in(v) \
    for (auto &i : v) cin >> i
#define all(v) v.begin(), v.end()
#define prv(v)                         \
    for (auto i : v) cout << i << " "; \
    cout << "\n"
#define MOD 1000000007
#define INF 1000000000
#define INFL 1000000000000000000ll
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vi vector<int>
#define vl vector<ll>
#define vii(v, n, m, val) vector<vector<int>> v(n, vector<int>(m, val))
#define viii(v, i, j, k, val)        \
    vector<vector<vector<int>>> v(i, \
                                  vector<vector<int>>(j, vector<int>(k, val)))
#define pii pair<int, int>
#define pb push_back
#define tos(x) string(1,x)
#define file_io                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define testc   \
    int tcc;    \
    cin >> tcc; \
    for (int tc = 1; tc <= tcc; tc++)
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while (!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(vector<string> __attribute__((unused)) args,
               __attribute__((unused)) int idx,
               __attribute__((unused)) int LINE_NUM) {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if (idx > 0)
        cerr << ", ";
    else
        cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss;
    ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef DB
#define debug(...) \
    debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
#define int ll

signed main() {
	fast_io;
	ll x,k,d; cin>>x>>k>>d;
	x=abs(x);
	if(k%2==0){
		ll cnt=min(x/d,k);
		ll ans=2*INFL;
		if(cnt&1){
			cnt--;
			if(cnt>=0){
				ans=min(ans,abs(x-cnt*d));
			}
			if(cnt+2<=k){
				ans=min(ans,abs(x-(cnt+2)*d));
			}
		}
		else{
			ans=min(ans,x-cnt*d);
		}
		cout<<ans;
	}else{
		ll cnt=min(x/d,k);
		ll ans=2*INFL;
		if(cnt%2==0){
			cnt--;
			if(cnt>=0){
				ans=min(ans,abs(x-cnt*d));
			}
			if(cnt+2<=k){
				ans=min(ans,abs(x-(cnt+2)*d));
			}
		}
		else{
			ans=min(ans,x-cnt*d);
		}
		cout<<ans;
	}
}
// code!=think
// least efficient code to get ac


Measured memory_bytes: 3648
import math

x = 0

def format_input(filename = None):
	global x
	if filename == None:
		x = int(input())

	elif filename == '__random__':
		from random import randint as rng
		x = rng(101, 10**18)
		print(x)

def get_answer():
	answer = 0
	deposit = 100
	while deposit < x:
		deposit = deposit + deposit // 100
		answer += 1
	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)


Measured memory_bytes: 9188
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int h,w,n;
	cin >> h >> w >> n;
	cout << ((n-1)/(max(h,w))+1) << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
Sn = [input() for _ in range(N)]
Sn.sort()
cnt = {}
ans = []
for k in range(N):
  if Sn[k] in cnt:
    cnt[Sn[k]] += 1 
  else:
    cnt[Sn[k]] = 1
max_val = max(cnt.values())
ans = list(filter(lambda x:cnt[x] == max_val, cnt))
ans.sort()
[print(a) for a in ans]


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

int main(){
    string s; cin >> s;
    reverse(s.begin(),s.end());
    int cnt=0;
    long long ans=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='C'&&s[i+1]=='B'){
            cnt++;
            i++;
        }else if(s[i]=='A'){
            ans+=cnt;
        }else{
            cnt=0;
        }
    }
    cout << ans << endl;
    
}

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

int main() {
  const int mod = 2019;
  string s;
  cin >> s;
  int n = s.size();

  ll mem[mod][2];
  for (int i=0; i<mod; i++) {
    mem[i][0] = 0LL;
    mem[i][1] = 0LL;
  }

  ll ans = 0;
  for (int i=0; i<n; i++) {
    int y = s[i] - '0';
    for (int m=0; m<mod; m++) {
      mem[(m*10+y)%mod][(i+1)%2] = mem[m][i%2];
    }
    mem[y][(i+1)%2]++;

    ans += mem[0][(i+1)%2];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3684
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  set<int> s;
  int n,i,j;
  cin >> n;
  int a[n+1]={};
  for(i=0;i<n;i++){
    int x;
    cin >> x;
    a[x]=i+1;
  }
  long long ret=0;
  set<int>::iterator it,it2;
  for(i=1;i<=n;i++){
    s.insert(a[i]);
    it2 = it = s.lower_bound(a[i]);
    long long cnt,cnt2;
    if(it==s.begin())cnt=0;
    else cnt = *--it;
    it2++;
    if(it2==s.end())cnt2=n+1;
    else cnt2 = *it2;
    //cout << cnt << endl;
    //cout << (a[i]-cnt)*(cnt2-a[i]) << endl;
    ret += i*(a[i]-cnt)*(cnt2-a[i]);
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 10368
n, m = map(int, input().split())
if m == 0: # 制約条件なし
  if n == 1:
    print(0)
  else:
    print(10 ** (n - 1))
  exit()
if n == 1: # 1桁のとき
  st = set()
  for i in range(m):
    s, c = map(int, input().split())
    st.add(c)
  if len(st) == 1:
    print(st.pop())
  else:
    print(-1)
  exit() # 1桁のときここまで
dic = {}
for i in range(m):
  s, c = map(int, input().split())
  if s in dic and c != dic[s]:
    print(-1)
    exit()
  dic[s] = c
if 1 in dic and dic[1] == 0:
  print(-1)
  exit()
dic.setdefault(1, 1)
dic.setdefault(2, 0)
if n == 3:
  dic.setdefault(3, 0)
s = ''
for i in range(1, n + 1):
  s += str(dic[i])
print(s)

Measured memory_bytes: 9236
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X,N,e;
  string kekka;
  cin >> X;
  e = X;
  N = 0;
  
  for(int i = 0; i < 8; i++){
    if(X < 1){
      break;
    }
     N += X % 10;
     X = X / 10;
   }
  if(e % N == 0){
    kekka = "Yes";
  }else{
    kekka = "No";
  }
   cout << kekka << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    ll sum = 0;
    map<ll,ll> mp;
    rep(i,0,N){
        int X;
        cin >> X;
        sum += X;
        mp[sum]++;
    }
    ll ans = 0;
    for(auto p:mp){
        if(p.first == 0)ans += p.second;
        ans += (p.second * (p.second - 1) ) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 12800
#include <iostream>
#include <stdexcept>
#include <cassert>
#include <cmath>
#include <vector>
#include <string>
using namespace std;

const long long MOD = 1000000007;

int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];

  long long sum = 0;
  for (int i = 0; i < N; i++) { sum += A[i]; sum %= MOD; }

  long long ans = 0;
  for (int i = 0; i < N - 1; i++) {
    sum -= A[i];
    if (sum < 0) sum += MOD;
    sum %= MOD;
    ans += (A[i] * sum) % MOD;
    ans %= MOD;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4792
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<ctime>
#include<random>
#define ll long long
using namespace std;
int n;
int a[450000];
int s[450000];
char c;

int main()
{
    while(true)
    {
        scanf("%c",&c);
        if (c=='B')
            a[n++]=1;
        else if (c=='W')
            a[n++]=0;
        else break;
    }
    for (int i=0; i<n; ++i)
    {
        if (i==0) s[i]=a[i];
        else s[i]=s[i-1]+a[i];
    }
    ll ans=0;
    for (int i=0; i<n; ++i)
        if (a[i]==0)
            ans+=s[i];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    double w = sc.nextDouble();
    double h = sc.nextDouble();
    double x = sc.nextDouble();
    double y = sc.nextDouble();
    System.out.println((w*h)/2);
    if((x == w/2)&&(y == h/2)){
      System.out.println("1");
    }else{
      System.out.println("0");
    }
  }
}
                         

Measured memory_bytes: 24148
module Main where

import Control.Monad
import Control.Applicative
import Data.List
import Text.Printf
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU

nextNumber n = [x | x <- [0 .. 9], abs (n - x) <= 1]
lunlunNumbers = [x * 10 + a | x <- 0 : lunlunNumbers, a <- if x == 0 then [0 .. 9] else nextNumber (mod x 10), x * 10 + a > 0]

main :: IO ()
main = do
    k <- readLn
    print $ lunlunNumbers !! (k - 1)
    


Measured memory_bytes: 13940
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, x, n) for (int i = x; i < (n); i++)
#define ALL(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int N, K;
    cin >> N >> K;
    vector<double> P(N);
    double max = 0;
    double v = 0;
    REP(i, N)
    {
        int _p;
        cin >> _p;
        double __p = double(_p - 1) * 0.5 + 1.0;
        P[i] = __p;
    }
    REP(i, N)
    {
        v += P[i];
        if (i < K)
        {
            max = v;
        }
        else
        {
            v -= P[i - K];
            if (max < v)
            {
                max = v;
            }
        }
    }
    cout << fixed;
    cout << setprecision(15) << max << endl;
    return 0;
}

Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//
#include<cmath>
#include<iomanip>

using namespace std;

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

typedef long long ll;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0,-1,0}; //次に行くところ
int dx[] = {0,1,0,-1}; //s上に同じ

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  vector<vector<int>> b(n,vector<int>(2));
  for (int i = 0; i < n; i++){
    for (int j = 0; j < 2; j++){
      cin >> b[i][j];
    }
  }
  
  for (int i = 0; i < n-2; i++){
    if (b[i][0] == b[i][1] && b[i+1][0] == b[i+1][1] && b[i+2][0] == b[i+2][1]){
      cout << "Yes\n";
      return 0;
    }
  }
  
  cout << "No\n";

  return 0;
}

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

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define X first
#define Y second

#define breakif(cond) if(cond) break; else

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

signed main() {
	int n, k, l;
	cin >> n >> k >> l;
	UnionFind uq(n), ur(n);
	rep(i, k) {
		int p, q; cin >> p >> q;
		p--; q--;
		uq.unionSet(p, q);
	}
	rep(i, l) {
		int p, q; cin >> p >> q;
		p--; q--;
		ur.unionSet(p, q);
	}
	map<P, int> mp;
	rep(i, n) {
		mp[P(uq.root(i), ur.root(i))]++;
	}
	rep(i, n) {
		cout << mp[P(uq.root(i), ur.root(i))] << (i + 1 == n ? "\n" : " ");
	}
	system("pause");
}

Measured memory_bytes: 15352
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int n;cin >> n;
	cout<<n*n<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >>N;
    vector<int>vec(N);
    for(int i=0;i<N;i++){
        cin >> vec.at(i);
    }
    int count=9999999;
    int summ=0;
    for(int i=0;i<N;i++){
    count =min(vec.at(i),count);
       if(count>=vec.at(i)){
          summ++;
       }
    }
    cout <<summ<<endl;
}

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

bool judge(string a, string b, int Apow, int Bpow){
  if(a == "kougekida"){
    if(Apow == 0)return false;
    if(Apow >= 5)return true;
    if(b == "tameru")return true;
    if(b == "mamoru")return false;
    if(b == "kougekida")return Apow > Bpow;
  }
  if(b == "kougekida" && Bpow == 0)return true;
  return false;
}

void update(string a, int &Apow){
  if(a == "kougekida")Apow = 0;
  if(a == "tameru")Apow++;
}

int main(){
  int n;
  cin >> n;
  vector<string> a(n),b(n);
  for(int i=0;i<n;i++)cin >> a[i];
  for(int i=0;i<n;i++)cin >> b[i];
  
  int res = 0, Apow = 0, Bpow = 0;
  for(int i=0;i<n;i++){
    bool Awin = judge(a[i],b[i],Apow,Bpow);
    bool Bwin = judge(b[i],a[i],Bpow,Apow);
    if(Awin != Bwin){
      res = (Awin ? 1 : -1);
      break;
    }
    update(a[i],Apow);
    update(b[i],Bpow);
  }
  cout << (res ? (res>0 ? "Isono-kun" : "Nakajima-kun") : "Hikiwake-kun") << endl;
}

Measured memory_bytes: 3212
#include<stdio.h>
int main()
{
    int n,hour,min,sec;
    scanf("%d", &n);
    min=n/60;
    sec=n%60;
    hour=min/60;
    min=min%60;
    printf("%d:%d:%d\n", hour,min,sec);

    return 0;
}



Measured memory_bytes: 2100
import sys
import heapq
input = sys.stdin.readline
sys.setrecursionlimit(100000)

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

l = [int(c)*(-1) for c in input().split()]
# 優先度付きキューにする
heapq.heapify(l)

for _ in range(m):
    tmp = heapq.heappop(l)*(-1)
    heapq.heappush(l, (tmp // 2)*(-1))

print(sum(l)*(-1))


Measured memory_bytes: 68248
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int main(){
    vector<int> a(5);
    int max_diff = 10000;
    int index = 0;
    for(int i=0;i<5;i++){
        cin >> a[i];
        if(a[i]%10 < max_diff && a[i]%10 != 0){
            index = i;
            max_diff = a[i]%10;
        }
    }
    int sum = 0;
    for(int i=0;i<5;i++){
        if(i!=index){
            if(a[i]%10!=0){
                sum += (a[i]/10)*10+10;
            }else{
                sum += a[i];
            }
        }
    }
    sum += a[index];
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n,a,b;
  cin>>n>>a>>b;
  cout << min(a,b) << " " << max(0,a+b-n)<<endl;
  return 0;
}


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

vector<int> v;

struct LazySegmentTree {
  int n;
  vector<int> node,delay;

  // 元配列 v をセグメント木で表現する
  void init(){
    n = 1; while(n < v.size()) n *= 2;
    node.resize(2*n-1,0);
    delay.resize(2*n-1,0);

    for(int i = 0; i < v.size(); i++) node[i+n-1] = v[i];
    for(int i = n-2; i >= 0; i--) node[i] = node[2*i+1] + node[2*i+2];
  }

  //k番目のノードの遅延評価
  void eval(int k,int l,int r){
    if(delay[k] != 0){
      node[k] += delay[k];
      if(r-l > 1){ //最下段でない場合
        // 子ノードは親ノードの1/2の範囲
        delay[2*k+1] += delay[k] / 2;
        delay[2*k+2] += delay[k] / 2;
      }
    }
    //遅延評価終わり
    delay[k] = 0;
  }

  void add(int a,int b,int x){ add(a,b,x,0,0,n); }
  void add(int a,int b,int x,int k,int l,int r){
    eval(k,l,r);
    if(b <= l || r <= a) return;
    if(a <= l && r <= b){
      delay[k] += (r-l) * x;
      eval(k,l,r);
    }
    else {
      add(a,b,x,2*k+1,l,(l+r)/2);
      add(a,b,x,2*k+2,(l+r)/2,r);
      node[k] = node[2*k+1] + node[2*k+2];
    }
  }

  int getsum(int a,int b) { return getsum(a,b,0,0,n); }
  int getsum(int a,int b,int k ,int l,int r){
    eval(k,l,r);
    if(b <= l || r <= a) return 0;
    if(a <= l && r <= b) return node[k];
    int vl = getsum(a,b,2*k+1,l,(l+r)/2);
    int vr = getsum(a,b,2*k+2,(l+r)/2,r);
    return vl + vr;
  }
}seg;

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

  int n,q; cin >> n >> q;
  v.resize(n,0);
  seg.init();
  for(int i = 0; i < q; i++){
    int query,s,t,x; cin >> query;
    if(query){
      cin >> s >> t;
      cout << seg.getsum(s-1,t) << endl;
    }
    else {
      cin >> s >> t >> x;
      seg.add(s-1,t,x);
    }
  }

  return 0;
}



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

int main()
{
	int N;
	cin >> N;
	int a = N % 10;
	int b = ((N - a) % 100) / 10;
	int c = ((N - a - b))/100;
	int revN = a * 100 + b * 10 + c;

	if (N == revN)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 256
s=int(input())
a=[0]*2001
x=(10**9)+7
if s<3:
    print(0)
    exit()

    
else:

    for i in range(3,6):
        a[i]=1

    for i in range(6,2001):
        a[i]=(sum(a[3:i-2])+1)%(x)

print(a[s])
  





Measured memory_bytes: 9144
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL V<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM emptm()
#define V vector
#define Q queue
#define DQ deque
#define PQ prioritm_queue
#define ST stack
#define FI first
#define MAn 1e18
#define MIN -1e18
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v;
map<LL,LL>u;
void Y()
{
    cout<<"Yes"<<endl;
}
void N()
{
    cout<<"No"<<endl;
}
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z=0,r;
    string a,b,c;
    cin>>a;
    for(i=0;a[i];i++)
    {
        u[a[i]-'A']++;
    }
    if(u.SZ==2)
    {
        Y();
    }
    else
    {
        N();
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int n;
ll k;
bool mat[51][51];
void add_self(int &a, int b){
    a += b;
    if(a >= MOD){
        a -= MOD;
    }
}
int mul(int a, int b){
    return (ll)a * b % MOD;
}
struct matrix{
    vector<vector<int> > v;
    matrix(){
        v.resize(n, vector<int>(n));
    }
    matrix operator* (const matrix& tmp) const{
        matrix ret = matrix();
        for(int i = 0; i < n; i ++){
            for(int j = 0; j < n; j ++){
                for(int k = 0; k < n; k ++){
                    add_self(ret.v[i][k], mul(v[i][j], tmp.v[j][k]));
                }
            }
        }
        return ret;
    }
};
int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n >> k;
    for(int i = 0; i < n; i ++){
        for(int j = 0; j < n; j ++){
            cin >> mat[i][j];
        }
    }
    matrix ret = matrix();
    for(int i = 0; i < n; i ++){
        ret.v[i][i] = 1;
    }
    matrix b = matrix();
    for(int i = 0; i < n; i ++){
        for(int j = 0; j < n; j ++){
            b.v[i][j] = mat[i][j];
        }
    }
    while(k){
        if(k % 2 == 1){
            ret = (ret * b);
        }
        b = (b * b);
        k /= 2;
    }
    int ans = 0;
    for(int i = 0; i < n; i ++){
        for(int j = 0; j < n; j ++){
            add_self(ans, ret.v[i][j]);
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

const int block = 4;
const int floor = 3;
const int room = 10;

int main() {
  int n, m;
  cin >> n >> m;
  int A[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> A[i][j];
    }
  }
  int b[m];
  for (int k = 0; k < m; k++) {
    cin >> b[k];
  }

  for (int l = 0; l < n; l++) {
    int c = 0;
    for (int o = 0; o < m; o++) {
      c += A[l][o] * b[o];
    }
    cout << c << endl;
  }
  return 0;
}

Measured memory_bytes: 3120
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        final int N = in.i();
        char[] c = in.s(N);
        int x = 0;
        int y = 0;
        for (int i = 0; i < c.length; i++) {
            if (c[i] == 'R') {
                y++;
            }
        }
        for (int i = 0; x != y && i < c.length; i++) {
            if (c[i] == 'W') {
                x++;
            } else {
                y--;
            }
        }
        out.println(y);
    }

    static class MyReader extends BufferedReader {
        char[] cbuf = new char[1024];
        int head = 0;
        int tail = 0;

        MyReader() {
            super(new InputStreamReader(System.in));
        }

        char next() {
            if (head == tail) {
                try {
                    tail = read(cbuf, 0, cbuf.length);
                } catch (IOException e) {}
                head = 0;
            }
            return cbuf[head++];
        }

        void back() {
            head--;
        }

        boolean minus() {
            boolean minus;
            while (true) {
                char c = next();
                if (c != ' ' && c != '\n' && c != '\r') {
                    if (!(minus = c == '-')) back();
                    return minus;
                }
            }
        }

        void skip() {
            while (true) {
                char c = next();
                if (c != ' ' && c != '\n' && c != '\r') {
                    back();
                    break;
                }
            }
        }

        char[] s(final int N) {
            skip();
            char[] s = new char[N];
            for (int i = 0; i < s.length; i++) {
                s[i] = next();
            }
            return s;
        }

        int i() {
            boolean minus = minus();
            int n = 0;
            while (true) {
                int k = next() - '0';
                if (k < 0 || 9 < k) break;
                n = 10 * n + k;
            }
            return minus ? -n : n;
        }

        int[] ii(final int N) {
            int[] a = new int[N];
            for (int j = 0; j < a.length; j++) a[j] = i();
            return a;
        }

        long l() {
            boolean minus = minus();
            long n = 0;
            while (true) {
                int k = next() - '0';
                if (k < 0 || 9 < k) break;
                n = 10 * n + k;
            }
            return minus ? -n : n;
        }
    }
}


Measured memory_bytes: 35656
a,b = map(int,input().split())
sum = 1
if ((b > 1) and (b < a)):
    print(1)
elif b == 1:
    print(0)
else:
    b = b - a
    while 0 < b:
        b = b - (a-1)
        sum=sum+1
    print(sum)

Measured memory_bytes: 3060
// Problem : D - Chat in a Circle
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Muallif: Azimjon Mehmonali o'g'li

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define F first
#define S second
#define pb push_back
#define endl "\n"

#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SORT(a) sort(ALL(a))
#define rSORT(a) sort(rALL(a))
#define REV(a) reverse(ALL(a))
#define sqr(x) ((x) * (x))

//===========================================================

int recur_depth = 0;
#ifdef DEBUG
#define xtp(x)                                                           \
	{                                                                    \
		++recur_depth;                                                   \
		auto x_ = x;                                                     \
		--recur_depth;                                                   \
		cerr << string(recur_depth, '\t') << __func__ << ":" << __LINE__ \
			 << "\t" << #x << " = " << x_ << endl;                       \
	}
#else
#define xtp(x)
#endif
template <typename Ostream, typename Cont>
typename enable_if<is_same<Ostream, ostream>::value, Ostream&>::type operator<<(
	Ostream& os, const Cont& v) {
	os << "[";
	for (auto& x : v) {
		os << x << ", ";
	}
	return os << "]";
}
template <typename Ostream, typename... Ts>
Ostream& operator<<(Ostream& os, const pair<Ts...>& p) {
	return os << "{" << p.first << ", " << p.second << "}";
}

//===========================================================

#define TEZ                  \
	ios::sync_with_stdio(0); \
	cin.tie(0);

const long double PI = 3.1415926535897932384626433832795;
const ll mod = 1000000007LL;
const int INF = 1000000000;

int main() {
	TEZ;

	int n;
	cin >> n;

	vi a(n);
	for (int& i : a)
		cin >> i;

	if (n == 1) {
		cout << 0 << endl;
		return 0;
	}

	rSORT(a);
	xtp(a);
	ll jv = a[0];
	int t = n / 2;
	for (int i = 1; i <= t - 1; i++)
		jv += 2ll * a[i];

	xtp(t);
	xtp(jv);
	if (n & 1) jv += a[t];

	cout << jv << endl;

	return 0;
}


Measured memory_bytes: 3984
#include<bits/stdc++.h>
#define fi                first
#define se                 second
#define ll               long long
#define mod              1000000007LL
#define endl              "\n"
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb                push_back
#define all(v)             v.begin(),v.end()
#define inp(V,n)      for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)     {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define pll              pair<long long,long long>
using namespace std;
//queue<ll> q;
ll cnt=0;
//vector<ll> adj[3000005];
//vector<ll> a(1000005),b(100005);
//vector<bool> vis(3000005,false);
//ll ed,ve;
ll timer =0;
set<ll> s;
vector<pll> vp;
ll factorial(ll n)
{
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
ll gcd(ll a, ll b)
{
    if (a == 0)
      return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
   return (a*b)/gcd(a, b);
}
bool sortByVal(const pair<double,double> &a,
              const pair<double,double> &b)
{
    if(a.fi==b.fi)
    {
    return (a.se >b.se);
    }
    else
        return (a.fi<b.fi);
}
ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}
/*ll  dfs(ll node)
{
   vis[node]=true;
   ll c=1;
   //ll c=adj[node].size();
   for(auto x:adj[node])
   {
       if(vis[x]==false)
       {
           c+=dfs(x);
       }
   }
   a[node]=c;
   return c;
}
void bfs(ll node)
{
    vis[node]=true;
    for(auto x:adj[node])
    {
        if(vis[x]==false)
        {
            bfs(x);
        }
    }
}*/
int main()
{
 fast;
     int t=1;
     //cin>>t;
     while(t--)
     {
       ll k,n,i=0,j=0,c=0,d=0,e=0,f=0,g=0,h=0,sum=0,maxi=0,to=0;
       cin>>n;
       for(i=1;i<=n;i++)
       {
           for(j=1;j<=n && (i*j<n);j++)
           {
              c=i*j;
              d=n-c;
              if(d>=1 && d<=n)
              {
                  //cout<<i<<" "<<j<<" "<<d<<endl;
                  sum++;
              }
           }
       }
       cout<<sum<<endl;
     }
}


Measured memory_bytes: 3656
#include <iostream>

using namespace std;

int main(void) {
	int A, B, C, D, P;
	int X, Y;
	
	cin >> A;
	cin >> B;
	cin >> C;
	cin >> D;
	cin >> P;
	
	X = A * P;
	Y = B;
	if(C < P) Y += D * (P - C);
	
	if(X < Y) cout << X << endl;
	else cout << Y << endl;
	return 0;
}

Measured memory_bytes: 1164
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
ll count_div(ll n, ll m) {
    if (n%m != 0) return 0;
    else return 1 + count_div(n/m, m);
}
#endif


int main_C() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    vi A(N); REP(i, N) cin >> A[i];
    
    vi B(N); REP(i, N) B[i] = A[i] - (i + 1);
    sort(B.begin(), B.end());
    int b = B[N / 2];
    
    ll ans = 0;
    REP(i, N) ans += abs(B[i] - b);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
// URL: https://atcoder.jp/contests/abc173/tasks/abc173_d

import std.algorithm, std.array, std.bitmanip, std.container, std.conv, std.format,
       std.functional, std.math, std.range, std.traits, std.typecons, std.stdio, std.string;

version(unittest) {} else
void main()
{
  int N; io.getV(N);
  int[] A; io.getA(N, A);

  A.sort!"a>b"();

  auto q = DList!int(A[0]), r = 0L;
  foreach (Ai; A[1..$]) {
    auto a = q.front; q.removeFront();
    r += a;
    q.insertBack(Ai);
    q.insertBack(Ai);
  }

  io.put(r);
}

auto io = IO!()();
import std.stdio;
struct IO(alias IN = stdin, alias OUT = stdout)
{
  import std.meta : allSatisfy;
  import core.stdc.stdlib : exit;

  void getV(T...)(ref T v)
  {
    foreach (ref w; v) get(w);
  }
  void getA(T)(size_t n, ref T v)
    if (hasAssignableElements!T)
  {
    v = new T(n);
    foreach (ref w; v) get(w);
  }
  void getC(T...)(size_t n, ref T v)
    if (allSatisfy!(hasAssignableElements, T))
  {
    foreach (ref w; v) w = new typeof(w)(n);
    foreach (i; 0..n) foreach (ref w; v) get(w[i]);
  }
  void getM(T)(size_t r, size_t c, ref T v)
    if (hasAssignableElements!T && hasAssignableElements!(ElementType!T))
  {
    v = new T(r);
    foreach (ref w; v) getA(c, w);
  }
  template getS(E...)
  {
    void getS(T)(size_t n, ref T v)
    {
      v = new T(n);
      foreach (ref w; v) foreach (e; E) mixin("get(w."~e~");");
    }
  }

  const struct PutConf
  {
    bool newline = true, flush, exit;
    string floatFormat = "%.10f", delimiter = " ";
  }

  void put(alias conf = "{}", T...)(T v)
  {
    mixin("const PutConf c = "~conf~"; putMain!c(v);");
  }
  void putB(alias conf = "{}", S, T)(bool c, S t, T f)
  {
    if (c) put!conf(t);
    else put!conf(f);
  }
  void putRaw(T...)(T v)
  {
    OUT.write(v);
    OUT.writeln;
  }

  private
  {
    dchar[] buf;
    auto sp = (new dchar[](0)).splitter;

    void nextLine()
    {
      IN.readln(buf);
      sp = buf.splitter;
    }
    void get(T)(ref T v)
    {
      if (sp.empty) nextLine();
      v = sp.front.to!T;
      sp.popFront();
    }

    void putMain(PutConf c, T...)(T v)
    {
      foreach (i, w; v) {
        putOne!c(w);
        if (i+1 < v.length) OUT.write(c.delimiter);
      }
      static if (c.newline) OUT.writeln;
      static if (c.flush) OUT.flush();
      static if (c.exit) exit(0);
    }
    void putOne(PutConf c, T)(T v)
    {
      static if (isInputRange!T && !isSomeString!T) putRange!c(v);
      else static if (isFloatingPoint!T) OUT.write(format(c.floatFormat, v));
      else static if (hasMember!(T, "fprint")) v.fprint(OUT);
      else OUT.write(v);
    }
    void putRange(PutConf c, T)(T v)
    {
      auto w = v;
      while (!w.empty) {
        putOne!c(w.front); w.popFront();
        if (!w.empty) OUT.write(c.delimiter);
      }
    }
  }
}


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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, M;
  cin >> N >> M;

  string S, T;
  cin >> S >> T;

  int L = N*M / __gcd(N, M);
  map<int, char> s;  
  for ( int i = 0; i < N; i++ ) {
    s[i*(L/N)] = S[i];    
  }

  for ( int i = 0; i < M; i++ ) {
    if ( s.count(i*(L/M)) == 0 ) continue;    
    if ( T[i] != s[i*(L/M)] ) {
      cout << -1 << endl;
      return 0;
    }
  }

  cout << L << endl;
  
  return 0;
}


Measured memory_bytes: 6144
#include <cstdio>
#include <cctype>
#include <utility>
#include <array>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int,in,){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_DEF(bool, scan, int &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);} _OUT(const char *s){while(*s)pcu(*s++);} _OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

struct P {
	int n;
	char c;
};

bool up (P &a, P &b) {
	if (a.n < b.n) {
		swap(a, b);
		return true;
	}
	return false;
}

int main() {
	for (int n; (n = in());) {
		array<int, 26> a {};
		P r1 {0, -1}, r2 {0, -1};
		int r {};
		for (int i: range(1, n + 1)) {
			char c = gcu(); gcu();
			P t{++a[c - 'A'], c};
			up(r2, t) && up(r1, r2) && up(t, r2);
			if (!r) {
				if (r1.n > n / 2)
					r = i;
				else if (r1.n > r2.n + n - i)
					r = i;
			}
		}
		if (r)
			outl(r1.c, ' ', r);
		else
			outl("TIE");
	}
}


Measured memory_bytes: 2444
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int a[2*maxn];
int32_t main(){
	fastio();
	int n;
	cin >> n;
	for(int i = 2; i <= n; i++){
		int x;
		cin >> x;
		a[x]++;
	}
	for(int i = 1; i <= n; i++) cout << a[i] <<"\n";
}

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

using namespace std;

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

typedef complex<double> P;

#define EPS (1e-7)

bool operator < (P const& a, P const& b) {
  return (a.real() != a.real()) ? a.real() < b.real() : a.imag() < b.imag();
}

double dot(P const& a, P const& b) {
  return real(conj(a)*b);
}

double cross(P const& a, P const& b) {
  return imag(conj(a)*b);
}

int ccw(P a, P b, P c) {
  b -= a, c -= a;
  if(cross(b, c) > 0) return +1; // counter clockwise
  if(cross(b, c) < 0) return -1;  // clockwise
  if(dot(b, c) < 0) return +2;    // c-a-b
  if(norm(b) < norm(c)) return -2;  // a-b-c
  return 0; // on segment
}

int main () {
  
  P p0, p1; cin >> p0.real() >> p0.imag() >> p1.real() >> p1.imag();
  int q; cin >> q;
  rep(i,q) {
    P p3; cin >> p3.real() >> p3.imag();
    int ret = ccw(p0, p1, p3);
    if(ret == +1) cout << "COUNTER_CLOCKWISE\n";
    if(ret == -1) cout << "CLOCKWISE\n";
    if(ret == +2) cout << "ONLINE_BACK\n";
    if(ret == -2) cout << "ONLINE_FRONT\n";
    if(ret == 0) cout << "ON_SEGMENT\n";
  }
  
  return 0;
}

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

int main(){
    int n;  cin >> n;
    ll k;   cin >> k;
    vector<int>a(n);
    vector<int>f(n);
    rep(i, n)   cin >> a[i];
    rep(i, n)   cin >> f[i];
    //sovle
    sort(a.begin(), a.end());   //昇順
    sort(f.rbegin(), f.rend()); //降順
    ll l = -1, r = 1e12;
    while(l+1<r){
        ll m = (l+r)/2;
        bool ok = [&]{
            ll s = 0;
            rep(i, n){
                s += max(0ll, a[i]-m/f[i]);
            }
            return s <= k;
        }();
        if(ok) r = m;   else l = m;
    }
    cout << r << endl;
}


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

using namespace std;

#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int N, A, B;
int h[100000];

bool C(int c) {
    int cnt = 0;
    rep(i, N) if(h[i] - B * c > 0) {
        cnt += (h[i] - B * c) / (A - B) + (((h[i] - B * c) % (A - B)) ? 1 : 0);
    }
    return (c >= cnt);
}

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

    cin >> N >> A >> B;
    rep(i, N) cin >> h[i];
    int lb = 0, ub = 1000000000;
    while(ub - lb > 1) {
        int mid = (ub + lb) / 2;
        if(C(mid)) ub = mid;
        else lb = mid;
    }
    cout << ub << endl;
    return 0;
}

Measured memory_bytes: 1024
N,M,X = map(int,input().split())

L,R = [],[]
for i in range(M):
    l,r = map(int,input().split())
    L.append(l-1)
    R.append(r-1)
P,Q = [],[]
for i in range(X):
    p,q = map(int,input().split())
    P.append(p-1)
    Q.append(q-1)

A = [[0 for _ in range(N+1)] for _ in range(N+1)]
for i in range(M):
    l,r = L[i],R[i]
    A[r][0] += 1
    A[r][l+1] -= 1
    A[N][0] -= 1 
    A[N][l+1] += 1

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

for i in range(X):
    p,q = P[i],Q[i]
    print(A[q][p])

Measured memory_bytes: 23936
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int n;
  scanf("%d", &n);
  long l[87];
  l[0] = 2;
  l[1] = 1;
  for (int i=2; i<n+1; i++)
    l[i] = l[i-1] + l[i-2];
  printf("%ld\n", l[n]);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    string s[n];
    for(int i=0;i<n;i++)cin >> s[i];
    int a[4];
    a[0] = 0;
    a[1] = 0;
    a[2] = 0;
    a[3] = 0;
    
    for(int i=0;i<n;i++){
        if(s[i]=="AC")a[0]++;
        else if(s[i]=="WA")a[1]++;
        else if(s[i]=="TLE")a[2]++;
        else a[3]++;
    }
    cout<<"AC x "<<a[0]<<endl;
    cout<<"WA x "<<a[1]<<endl;
    cout<<"TLE x "<<a[2]<<endl;
    cout<<"RE x "<<a[3]<<endl;

}

Measured memory_bytes: 6712
import scala.collection.mutable

//object D {
object Main {
  import InOut._
  def main(args: Array[String]): Unit = {

    val n, k = nextInt
    val ps = nextInts(n).map(_ - 1)
    val cs = nextInts(n)
    val visited = Array.fill(n){ false }
    var res: Long = cs.max

    for (i <- 0 until n) {
      if (!visited(i) && res > 0) {
        val builder = new mutable.ArrayBuilder.ofInt
        var p = i
        while (!visited(p)) {
          visited(p) = true
          builder += p
          p = ps(p)
        }
        val cycle = builder.result()
        val cycleSum = cycle.map(p => cs(p).toLong).sum
        var cycleSubRes, cycleSubRes2 = 0L
        var j = 0
        val kk = Math.min(k, cycle.length - 1)
        val kMod = k % cycle.length
        while (j < cycle.length) {
          var sum = 0L
          var len = 0
          while (len < kk) {
            sum += cs(cycle((j + len) % cycle.length))
            if (sum > cycleSubRes) {
              cycleSubRes = sum
            }
            if (sum > cycleSubRes2 && len < kMod) {
              cycleSubRes2 = sum
            }
            len += 1
          }
          j += 1
        }
        if (cycleSum > 0 && k > cycle.length) {
          cycleSubRes += cycleSum * (k / cycle.length - 1)
        }
        if (cycleSum > 0) {
          cycleSubRes2 += cycleSum * (k / cycle.length)
        }
        val cycleRes = Math.max(cycleSubRes, cycleSubRes2)
        if (cycleRes > res) {
          res = cycleRes
        }
      }
    }

    out.println(res)

    out.flush()
  }
 
  final object InOut {
    val in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))
    val out = new java.io.PrintWriter(System.out, false)
    private[this] var tokenizer: java.util.StringTokenizer = _
    def nextToken: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new java.util.StringTokenizer(in.readLine)
      tokenizer.nextToken
    }
    def nextInt = Integer.parseInt(nextToken)
    def nextLong = java.lang.Long.parseLong(nextToken)
    def nextBig = BigInt(nextToken)
    def nextInts(n: Int) = Array.fill(n) { nextInt }
    def nextLongs(n: Int) = Array.fill(n) { nextLong }
    def nextBigs(n: Int) = Array.fill(n) { nextBig }
    def nextLine = in.readLine
  }
}


Measured memory_bytes: 55532