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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

string f(int dig, ll num) {
   string ret = "";
   while (num > 0) {
      char c = '0' + num % 2;
      ret += c;
      num /= 2;
   }
   int nn = dig - ret.size();
   rep (i, nn) {
      ret += "0";
   }
   reverse(all(ret));
   return ret;
}

string rem(string s) {
   rep (i, s.size()) {
      if (s[i] == '1') {
         return s.substr(i, 100);
      }
   }
}

using pll = pair<ll, ll>;

ll N;

int main() {
   cin >> N;
   if (N == 0) {
      cout << 0 << endl;
      return 0;
   }

   vec<ll> v;
   ll val = 1;
   rep (i, 35) {
      v.push_back(val);
      val *= -2;
   }
   reverse(all(v));

   vec<ll> a, b;
   rep (i, 18) {
      a.push_back(v[i]);
   }
   repp (i, 18, 36) {
      b.push_back(v[i]);
   }

   map<ll, ll> candA;
   for (int mask = 0; mask < (1 << a.size()); mask++) {
      ll sum = 0;
      for (int i = 0; i < a.size(); i++) {
         if (mask & (1 << i)) sum += a[i];
      }
      candA[sum] = mask;
   }

   for (int mask = 0; mask < (1 << b.size()); mask++) {
      ll sum = 0;
      for (int i = 0; i < b.size(); i++) {
         if (mask & (1 << i)) sum += b[i];
      }
      ll p = N - sum;
      if (candA.find(p) != candA.end()) {
         string a = f(18, candA[p]), b = f(18, mask);
         // cout << a + b << endl;
         reverse(all(a));
         reverse(all(b));
         b.pop_back();
         if (count(all(a), '0') == 18) {
            cout << rem(b) << endl;
         } else {
            cout << rem(a) + b << endl;
         }
         return 0;
      }
   }

   return 0;
}

Measured memory_bytes: 16768
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define ld long double
#define mp make_pair

void print(auto &a)
{
    for (auto s: a) cout<<s<<' ';
    cout<<endl;
}

void get(vector<auto> &a)
{
    for (int i = 0; i<a.size(); i++) cin>>a[i];
}

int p;


int mul(int a, int b) {
    return (1LL * a%p * b%p) % p;
}

int add(int a, int b) {
    ll s = (a+b);
    s = s%p;
    if (s<0) s+=p; 
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}



vector<int> Z(string s)
{
int n = s.length();
vector<int> z(n);
int L = 0, R = 0;
for (int i = 1; i < n; i++) {
  if (i > R) {
    L = R = i;
    while (R < n && s[R-L] == s[R]) R++;
    z[i] = R-L; R--;
  } else {
    int k = i-L;
    if (z[k] < R-i+1) z[i] = z[k];
    else {
      L = i;
      while (R < n && s[R-L] == s[R]) R++;
      z[i] = R-L; R--;
    }
  }
}
return z;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);

    int n;
    cin>>n;
    string s;
    cin>>s;
    int red = 0;
    int blue = 0;
    for (int i = 0; i<n; i++) if (s[i]=='R') red++; else blue++;
    if (red>blue) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
#n = int(input())
#=map(int,input().split()) #横並び
#x=[int(input()) for i in range(3)] #縦に並んだのを配列に
x=list(map(int,input().split())) #横に並んだのを配列に
#print(n)
print('YNEOS'[not(x.count(1)and x.count(9) and x.count(7) and x.count(4))::2])


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a=0,b=0;
  cin>>n;
  int arr[n],brr[n],crr[n],drr[n];
  for(int i=0;i<n;i++) {crr[i]=i+1;drr[i]=crr[i];}
  for(int i=0;i<n;i++) cin>>arr[i];
  for(int i=0;i<n;i++) cin>>brr[i];
  do{
    int t=1;
    for(int i=0;i<n;i++) if(arr[i]!=crr[i]) t=0;
    if(t) break;
     a++;
  }while(next_permutation(crr,crr+n));
         do{
    int t=1;
    for(int i=0;i<n;i++) if(brr[i]!=drr[i]) t=0;
    if(t) break;
    b++;
  }while(next_permutation(drr,drr+n));

	cout<<abs(a-b);
         }

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

const ll M = 1e9 + 7;

ll mod(ll a){return ((a % M) + M) % M;}

int main(){
	ll ways[2010] = {};
	ways[0] = 1;
	ll n;
	cin >> n;
	for(int i = 3; i <= n; i++){
		for(int j = 3; j <= i; j++){
			ways[i] = mod(ways[i] + ways[i-j]);
		}
	}
	cout << ways[n] << endl;
}


Measured memory_bytes: 3604
// [AT1381 エンド・オブ・ビギニング] https://www.luogu.org/problem/AT1381
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
    int ans = 1;
    int n, k;
    cin >> n >> k;

    for (int i = 0; i < n; i++)
    {
        ans += min(ans, k);
    }

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

Measured memory_bytes: 256
using System;
using System.Linq;

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

            int[] buckets = new int[110];
            for (int i = 0; i < N; ++i)
            {
                buckets[d[i]]++;
            }

            int result = 0;
            for (int i = 0; i <= 100; ++i)
            {
                if (buckets[i] > 0)
                {
                    ++result;
                }
            }

            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
using namespace std;
int main(){
  int N;
  int K;
  cin>>N>>K;
  int X[N]={};
  int i;
  for(i=0;i<=N-1;i++){
  cin>>X[i];
  }
  int ans=0;
  int adis=0;
  int bdis=0;
  for(i=0;i<=N-1;i++){
  adis=X[i];
  bdis=K-X[i];
  if(adis<=bdis){
  ans+=adis*2;
  }
  else{
  ans+=bdis*2;
  }  
  }
  cout<<ans;
}

Measured memory_bytes: 3548
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    ll n, k;
    cin >> n >> k;
    set<ll> st;
    FOR(x,k,k+2*n-1) st.insert(x);
    VL aa, ab, ac;
    ll a = k + 2 * n - 1;
    ll b = max(n, k);
    if (b >= a || a + b > k + 3 * n - 1){
        cout << -1 << endl;
        return 0;
    }
    bool f = true;
    REP(i,n){
        ll c = k + 3 * n - i - 1;
        if (f){
            aa.push_back(a);
            ab.push_back(b);
            ac.push_back(c);
            st.erase(a);
            st.erase(b);
            a -= 2;
            b++;
            if (a <= b){
                f = false;
                a = k + 2 * n - 1;
            }
        }else{
            while (!st.count(a)){
                a--;
                if (a < k){
                    cout << -1 << endl;
                    return 0;
                }
            }
            st.erase(a);
            ll bma = c - a;
            auto itr = st.upper_bound(bma);
            if (itr == st.begin()){
                cout << -1 << endl;
                return 0;
            }
            itr--;
            ll b = *itr;
            st.erase(b);

            aa.push_back(a);
            ab.push_back(b);
            ac.push_back(c);
        }
    }
    REP(i,n){
        printf("%lld %lld %lld\n", aa[i], ab[i], ac[i]);
    }

    return 0;
}


Measured memory_bytes: 12504
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

const int MAX_SQRT_B = 320; // 約sqrt(1e5);
bool is_prime_small[MAX_SQRT_B];
bool is_prime[3*MAX_SQRT_B+100]; // is_prime[0] := Xが素数かどうか

int main()
{
    int X;
    cin >> X;
    for(int i = 0; i*i <= X; ++i) is_prime_small[i] = true;
    for(int i = 0; i < 3*MAX_SQRT_B; ++i) is_prime[i] = true;

    for(int i = 2; i*i <= X; ++i) {
        if(is_prime_small[i]) {
            for(int j = 2*i; j*j <= X; j += i) is_prime_small[j] = false;
            for(int j = (X%i)? (X/i+1)*i - X : 0; j < 3*MAX_SQRT_B; j += i) is_prime[j] = false;
        }
    }

    for(int i = 0; i < 3*MAX_SQRT_B; ++i) if(is_prime[i]) {
        cout << (i+X) << endl; break;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, a, b = 0, sum = 0;
	for (int h = 0; h < 100; h++) {
		cin >> n;
		if (n == 0) {
			cin >> n; return 0;
		}
		for (int i = 0; i < n; i++) {
			cin >> a;
			if (a >= 2) {
				b = 1;
			}
			if (a != 0) {
				sum++;
			}
		}
		if (b == 0) {
			cout << "NA" << endl;
		}
		else {
			cout << sum + 1 << endl;
		}
		b = 0; sum = 0;
	}
	cin >> n;
}


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

int main() {
  string s;
  cin>>s;
  int kotae=0;
  int ichi=0;
  int zero=0;
  int n=s.size();
  for(int i=0;i<n;i++){
    if(s[i]=='0')zero++;
    else ichi++;
  }
  kotae=min(ichi,zero)*2;
  cout<<kotae<<endl;
  return 0;
}

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

int main(){
  int N, Y;
  cin >> N >> Y;
  
  for(int x = 0; x <= N; x++){
    for(int y = 0; y <= N-x; y++){
      int z = N - x - y;
      if(10000*x + 5000*y + 1000*z == Y){
        cout << x << ' ' << y << ' ' << z << endl;
        return 0;
      }
    }
  }
  cout << -1 << ' ' << -1 << ' ' << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>

using namespace std;

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

struct T{
    long a, b, c;
};

set<P> s;

int main(){
    int X, Y, Z, K;
    long A[100000], B[100000], C[100000];
    cin >> X >> Y >> Z >> K;
    for(int i = 0; i < X; i++){
        cin >> A[i];
    }
    for(int i = 0; i < Y; i++){
        cin >> B[i];
    }
    for(int i = 0; i < Z; i++){
        cin >> C[i];
    }
    sort(A, A+X, greater<long>());
    sort(B, B+X, greater<long>());
    sort(C, C+Z, greater<long>());
    
    int cnt = 1;
    priority_queue<P> que;
    que.push(P(P_(A[0]+B[0]+C[0], 0), P_(0, 0)));
    s.insert(P(P_(0, 0), P_(0, 0)));
    while(cnt <= K){
        P top = que.top();
        que.pop();
        cout << top.first.first << endl;
        cnt++;
        //cout << 'H' << endl;
        long a = top.first.second;
        long b = top.second.first;
        long c = top.second.second;
        //cout << a << ' ' << b << ' ' << c << endl;
        if(a+1 < X && s.count(P(P_(0, a+1), P_(b, c))) == 0){
            long tmp = A[a+1]+B[b]+C[c];
            que.push(P(P_(tmp, a+1), P_(b, c)));
            s.insert(P(P_(0, a+1), P_(b, c)));
        }
        if(b+1 < Y && s.count(P(P_(0, a), P_(b+1, c))) == 0){
            long tmp = A[a]+B[b+1]+C[c];
            que.push(P(P_(tmp, a), P_(b+1, c)));            
            s.insert(P(P_(0, a), P_(b+1, c)));
        }
        if(c+1 < Z && s.count(P(P_(0, a), P_(b, c+1))) == 0){
            long tmp = A[a]+B[b]+C[c+1];
            que.push(P(P_(tmp, a), P_(b, c+1)));            
            s.insert(P(P_(0, a), P_(b, c+1)));
        }
    }
}

Measured memory_bytes: 2944
package main

import (
	"fmt"
)

func main() {
	var h, w, n int
	fmt.Scan(&h)
	fmt.Scan(&w)
	fmt.Scan(&n)

	if h > w {
		fmt.Println((n + h - 1) / h)
	} else {
		fmt.Println((n + w - 1) / w)
	}
}


Measured memory_bytes: 512
main=do
 getLine;s<-getLine
 print(minimum(map(\(a,b)->a+b)(zip(w s 0)(reverse(e(reverse s)0)))))
  where w [] _ = []
        w ('W':s) i = i:(w s (i+1))
        w ('E':s) i = i:(w s i)
        e [] _ = []
        e ('W':s) i = i:(e s i)
        e ('E':s) i = i:(e s (i+1))

Measured memory_bytes: 56700
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  string s;
  cin >> s;
  int cnt = 0;
  for(char t : s){
    cnt += int(t - '0');
  }
  if(cnt % 9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

#ifdef NeverBeRed
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ld> point;
#define F first
#define S second



int main()
{
	#ifdef TurnRed
		//freopen("a.in", "r", stdin);
		//freopen("a.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	string s;
	cin >> s;
	cout << s.substr(0, 3) << "\n";

	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }


void solve(long long N, long long L){
	ll res = 0;
	ll min = 1e18;
	REPR(i, N) {
		res += L+i;
		if (min > abs(L+i)) min = L+i;
	}
	res -= min;
	cout << res << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long L;
    scanf("%lld",&L);
    solve(N, L);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7, N = 5e5 + 10;
const int LINF = LLONG_MAX;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << setprecision(14) << fixed ;
    double r;
    cin >> r;
    double rr = 2*acos(-1)*r;
    cout << rr << "\n";
    return 0;
}
 

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

int main() {
  int A, B;
  cin >> A >> B;
  
  if (A > 12){
    cout << B << endl;
  }
  else if (6 <= A && A <= 12){
    cout << B / 2 << endl;
  }
  else if (A < 6){
    cout << 0 << endl;
  }
}

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


int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for (int i=0; i<N; i++) {
    cin >> a.at(i);
  }
  
  int cnt = 0, p = 1;
  while(1) {
    p = a.at(p-1);
    cnt++;
    if (p==2) break;
    if (cnt==N) {
      cnt = -1;
      break;
    }
  }
  
  cout << cnt << endl;
  
  return 0;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
#define Rep(i, N) for(int i = 0; i < N; i++)
int main()
{
  int N, T, S;
  vector<int> dp(3005, 0);
  int A, B;
  cin >> N >> T >> S;
  Rep(p, N) {
    cin >> A >> B;
    for(int i = T; i >= 0; i--) {
      int now = i - B;
      if(now < 0 || now < S && S < i) continue;
      dp[i] = max(dp[i], dp[now] + A);
    }
  }
  cout << *max_element(dp.begin(), dp.end()) << endl;
  return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
vector <ll> v;
void solve(){
    ll a,b;
    cin >> a >> b;
    int cnt = 0; 
    for(int i = a; i <= b; ++i){
        v.pb(i );
        cnt ++;
        if(cnt >= 1010)
            break;
    }
    ll mn = INF;
    for(int i = 0; i < v.size(); ++i) {
        for(int j = 0; j < v.size(); ++j){
            if(i == j)
                continue;
            if(v[i] * v[j] % 2019 < mn){
                mn = min(mn,(v[i] * v[j])%2019);
                // cout << v[i] << " " << v[j] << "\n";
            }
        }
    }
    cout << mn;
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 256
//0029 English Sentence
//pêÌ¶ÍÅo»·éPêðÇÝæèAo»pxªÅà¢PêÆAàÁÆà·¢PêðoÍµÄI¹¹æ
//üÍf[^ÍAAt@xbgÆXy[XÌÝªÜÜêé
//¶ÍÌ¶Í1000¶ÈºÅA1PêÌ·³Í32¶ÈºÅ·
//Ü½Ao»pxªÅà¢PêÆÅà·¢PêÍA»ê¼ê¶ÉêÂµ©¶ÝµÈ¢

#include<iostream>
#include<string>
#include<map>
#include<limits>
#include<algorithm>
using namespace std;

int main(void)
{
	typedef map<string, int> Map;
	Map m;
	string str;
	Map::iterator s;
	int maxSize = numeric_limits<int>::min();
	while( cin >> str)
	{
		m[str]++;
		if( maxSize < (int)str.size())
		{
			maxSize = str.size();
			s = m.find(str);
		}
	}
	
	Map::iterator mode = m.begin();
	for(map<string, int>::iterator ite = m.begin();
		ite != m.end();
		++ite)
	{
		if(mode->second < ite->second)
			mode = ite;
	}
	cout << mode->first << ' ' << s->first << endl;
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

int main(){
  int N;
  scanf("%d", &N);
  std::vector<long long > A(N);
  int zerocount=0;
  for (int i=0; i<N; i++){
    scanf("%lld", &A[i]);
    if (A[i]==0) zerocount++;
  }
  if (zerocount>0){
    printf("0\n");
  } else {
    long double ans = 1.0;
    long long ans2 = 1;
    for (int i=0; i<N; i++){
      ans2*=A[i];
      ans*=A[i];
      if (ans>1e18){
	printf("-1\n");
	return 0;
      }
    }
    printf("%lld\n", ans2);
  }


    
  
  return 0;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		String result = "";
		
		if(a < b){
			if(b < c){
				result = "Yes";
			}else{
				result = "No";
			}
		}else{
			result = "No";
		}
		
		System.out.println(result);
	}
}

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

const int limit=8;
vector<int>to[limit];
vector<bool>visited(limit,false);

int dfs(int v, int n){
  bool all = true;
  int res = 0;
  visited[v]=true;
  for(int i=0; i<n; i++){
   if(visited[i]==false) all=false; 
   //cout << v << " " << visited[i] << endl;
  }
  
  if(all){
    visited[v]=false;
    return 1;
  }
  
  for(int i=0; i<to[v].size(); i++){
    if(visited[to[v][i]])continue;
    //cout << i << "  "  << to[v][i] << endl;
    res+=dfs(to[v][i],n);
  }
  visited[v]=false;
  return res;
}

int main(){
  int n,m;
  cin >> n >> m;
  for(int i=0; i<m; i++){
    int x,y;
    cin >> x >> y;
    x--; y--;
    to[x].push_back(y);
    to[y].push_back(x);
  }
  cout << dfs(0,n) << endl;
  return 0;
  
}

Measured memory_bytes: 256
while True:
    n=int(input())
    x=[]
    if n==0:
        break
    else:
        for i in range(n):
            s=int(input())
            x.append(s)
        
        a=min(x)
        b=max(x)
        
        ave=(sum(x)-a-b)/(n-2)
        print(int(ave))
     


Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
char umi[100][100],a;
int ans;
void solve(int x,int y);

int main(){

    while(cin>>umi[1][1]){
    for(int i=1;i<=12;i++){
        for(int j=1;j<=12;j++){
            if(!(i==1&&j==1))cin >> umi[j][i];
        }
    }
    for(int i=1;i<=12;i++){
        for(int j=1;j<=12;j++){
            if(umi[j][i]=='1'){
                ans++;
                umi[j][i]='0';
                solve(j,i);
            }
        }
    }
    cout << ans << endl;
    ans=0;
    fill(umi[0],umi[12],'0');

    }

return 0;
}

void solve(int x,int y){
    if(umi[x+1][y]=='1'){
     umi[x+1][y]='0';
     solve(x+1,y);
    }
    if(umi[x-1][y]=='1'){
     umi[x-1][y]='0';
     solve(x-1,y);
    }
    if(umi[x][y+1]=='1'){
     umi[x][y+1]='0';
     solve(x,y+1);
    }
    if(umi[x][y-1]=='1'){
     umi[x][y-1]='0';
     solve(x,y-1);
    }
}

Measured memory_bytes: 1148
use proconio::{input,fastout};

#[fastout]
fn main() {
    input!{
        n: usize,
        ss: [String ; n],
    }

    let mut ac = 0;
    let mut wa = 0;
    let mut tle = 0;
    let mut re = 0;

    for s in ss {
        match s.as_str() {
            "AC" => ac += 1,
            "WA" => wa += 1,
            "TLE" => tle += 1,
            "RE" => re += 1,
            _ => {}
        }
    }
    println!("AC x {}", ac);
    println!("WA x {}", wa);
    println!("TLE x {}", tle);
    println!("RE x {}", re);

}


Measured memory_bytes: 7820
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>

#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;
constexpr Int mod = 1e9 + 7;


void calc() {

	Int N; std::cin >> N;
	std::queue<std::pair<Int, std::array<bool, 3>>> q; q.push(std::make_pair < Int, std::array<bool, 3>>(0, { false, false, false }));
	Int cnt = 0;
	while (!q.empty()) {
		auto val = q.front(); q.pop();

		if (val.second[0] && val.second[1] && val.second[2]) {
			cnt++;
			if (val.first > N)break;
		}

		val.first *= 10;

		auto tmp1 = val;
		tmp1.first += 3;
		tmp1.second[0] = true;
		q.push(tmp1);

		auto tmp2 = val;
		tmp2.first += 5;
		tmp2.second[1] = true;
		q.push(tmp2);

		auto tmp3 = val;
		tmp3.first += 7;
		tmp3.second[2] = true;
		q.push(tmp3);
	}

	std::cout << cnt - 1;

}


int main() {

	calc();

	return 0;
}

Measured memory_bytes: 1280
abc = list(map(int,input().split()))
maxnum = max(abc)
parity = maxnum%2
ans = 0
for i in abc:
    if i%2==parity:
        ans+=(maxnum-i)//2+1
    else:
        ans+=(maxnum-1-i)//2
if abc[0]%2==abc[1]%2 and abc[1]%2==abc[2]%2:
    ans-=3
print(ans)

Measured memory_bytes: 9192
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

class Data
{
public:
    int y, x, b;
    vector<int> history;
    Data(int y0, int x0, int b0, int k)
    {
        y = y0;
        x = x0;
        b = b0;
        history.clear();
        for(int i=0; i<5; ++i){
            history.push_back(k % 4);
            k /= 4;
        }
    }
    bool move(int d)
    {
        int y2 = y;
        int x2 = x;
        y += dy[d];
        x += dx[d];
        b -= d / 2;

        bool ret = false;
        for(int i=4; i>=0; --i){
            y2 -= dy[history[i]];
            x2 -= dx[history[i]];
            if(y2 == y && x2 == x)
                ret = true;
        }

        history.erase(history.begin());
        history.push_back(d);

        return ret;
    }
    int toInt(){
        int ret = 0;
        for(int i=4; i>=0; --i){
            ret *= 4;
            ret += history[i];
        }
        return y + 50 * (x + 50 * (b + 4 * ret));
    }
};

int main()
{
    int h, w, n;
    cin >> h >> w >> n;

    vector<string> s(h);
    for(int i=0; i<h; ++i)
        cin >> s[i];

    vector<int> dp(50*50*4*1024, -1);
    dp[Data(0, 0, n, 0).toInt()] = 0;

    for(int b=n; b>=0; --b){
        for(int y=0; y<h; ++y){
            for(int x=0; x<w; ++x){
                for(int k=0; k<1024; ++k){
                    Data d(y, x, b, k);
                    if(dp[d.toInt()] == -1)
                        continue;

                    for(int i=0; i<4; ++i){
                        Data d2 = d;
                        bool use = d2.move(i);
                        if(d2.y < 0 || d2.y >= h || d2.x < 0 || d2.x >= w || s[d2.y][d2.x] == '#' || d2.b < 0)
                            continue;

                        int next = dp[d.toInt()];
                        if(!use && isdigit(s[d2.y][d2.x]))
                            next += s[d2.y][d2.x] - '0';

                        dp[d2.toInt()] = max(dp[d2.toInt()], next);
                    }
                }
            }
        }
    }

    int ret = 0;
    for(int i=0; i<=n; ++i){
        for(int j=0; j<1024; ++j){
            ret = max(ret, dp[Data(h-1, w-1, i, j).toInt()]);
        }
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 41232
#include<cstdio>
#include<iostream>
#include<algorithm>

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

using namespace std;

char cell[1001][1001];
int J[1001][1001];
int O[1001][1001];
int I[1001][1001];

int main(void){
	
	int n,m, k;
	
	scanf("%d%d", &m, &n);
	scanf("%d", &k);
	
	rep(i,m)scanf("%s", cell[i]);
	
	reps(i,1,m+1)reps(j,1,n+1){
		J[i][j] = J[i-1][j]+J[i][j-1]-J[i-1][j-1]+(cell[i-1][j-1]=='J');
		O[i][j] = O[i-1][j]+O[i][j-1]-O[i-1][j-1]+(cell[i-1][j-1]=='O');
		I[i][j] = I[i-1][j]+I[i][j-1]-I[i-1][j-1]+(cell[i-1][j-1]=='I');
	}
	
	/*
	reps(i,1,m+1){
		reps(j,1,n+1){
			printf("(%d %d %d)", J[i][j], O[i][j], I[i][j]);
		}puts("");
	}
	*/
	int a,b,c,d;
	
	rep(i,k){
		scanf("%d %d %d %d", &a, &b, &c, &d);
		int jt = J[c][d] + J[a-1][b-1];
		int ot = O[c][d] + O[a-1][b-1];
		int it = I[c][d] + I[a-1][b-1];
		
		jt =jt-(J[a-1][d]+J[c][b-1]);
		ot =ot-(O[a-1][d]+O[c][b-1]);
		it =it-(I[a-1][d]+I[c][b-1]);
		printf("%d %d %d\n", jt, ot, it);
	}
	
	return 0;
	
}

Measured memory_bytes: 13900
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           ((ll)x.size())
#define hell            (1000000007)
#define inf             ((ll)5e18 + 5)
#define PI              ((double)3.14159265358979323844)
#define DECIMAL(n)      cout << fixed << setprecision(n);
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define bitcount(a)     (ll)__builtin_popcount(a)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

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

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

void solve() {
    ll n,k;
    cin>>n>>k;
    ll arr[n];
    rep(i,0,n){
        cin>>arr[i];
    }
    ll supp[n];
    rep(i,0,min(k,100LL)){
        memset(supp,0,sizeof supp);
        rep(j,0,n){
            supp[max(0LL,j-arr[j])]++;
            if (j+arr[j]+1<n)supp[j+arr[j]+1]--;
        }
        rep(i,1,n){
            supp[i]+=supp[i-1];
        }
        rep(i,0,n){
            arr[i]=supp[i];
        }
    }
    rep(i,0,n){
        cout<<arr[i]<<" ";
    }
    cout<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 6732
/*
 * ITP1_6_A.cpp
 *
 *  Created on: 2016/05/15
 *      Author: suna
 */

#include <iostream>
#include <vector>

using namespace std;

int main(void)
{
	//????´???°
	int n_element;

	//????´???°?????\???
	cin >> n_element;

	vector<int> array(n_element);

	//?????????????????\?????????
	for(int i = 0; i < n_element; i++)
	{
		cin >> array[i];
	}

	//??\??????????????????????????????????????????
	for(int i = 1; i <= n_element; i++)
	{
		if( (n_element-i) != 0)
		{
			cout << array[n_element-i] << " ";
		}
		else
		{
			cout << array[n_element-i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1196
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<int, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 1000010;
const int MAXM = 30010;
const int MAXK = 16;
const int MAXQ = 200010;

int k;
string s;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> k >> s;
    FOR(i,0,SZ(s)-1) {
        int g = s[i] - 'A';
        g = (g + k) % 26;
        cout << char(g + 'A');
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define maxn 200005
using namespace std;
ll arr[maxn];
int SZ,bit[maxn];
inline int lowbit(int x) {
	return x&-x;
}
void add(int pos) {
	while(pos <= SZ) {
		bit[pos]++;
		pos += lowbit(pos);
	}
}
int sum(int pos) {
	int ret = 0;
	while(pos > 0) {
		ret += bit[pos];
		pos -= lowbit(pos);
	}
	return ret;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,k;
	cin >> n >> k;
	vector<ll> dct = {0};
	for(int i=1,val;i<=n;i++) {
		cin >> val;
		arr[i] = arr[i-1] + val - k;
		dct.push_back(arr[i]);
	}
	sort(dct.begin(),dct.end());
	dct.resize(unique(dct.begin(),dct.end())-dct.begin());
	SZ = (int)dct.size();
	ll ans = 0;
	for(int i=0;i<=n;i++) {
		int idx = lower_bound(dct.begin(),dct.end(),arr[i])-dct.begin() + 1;
		ans += sum(idx);
		add(idx);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4336
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
string s;
ll ans=0;
int leftblacknum[200005];
int main(int argc,char const* argv[])
{
  memset(leftblacknum,0,sizeof(leftblacknum));
  cin >> s;
  for(int i=0;i<int(s.size());i++)
    {
      if(s[i]=='B') leftblacknum[i]++;
    }
  for(int i=1;i<int(s.size());i++)
    {
      leftblacknum[i]+=leftblacknum[i-1];
    }
  for(int i=0;i<int(s.size());i++)
    {
      if(s[i]=='W')
	{
	  ans+=leftblacknum[i];
	}
    }
  cout << ans << endl;
  return 0;
}


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

#define mod 998244353


int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	string s; cin>>s;
	ll res = 0;
	for(int i = 0; i < s.size()/2; i++){
		if(s[i] != s[s.size() -1 -i]){
			res++;
		}
	}
	cout<<res;
	return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

int main(void){
    int n,m;
    cin >> n >> m;
    vector<int> num(n,0);
    if(n>1)
        num[0] = 1;
    vector<bool> f(n,false);
    int s,c;
    rep(_,m){
        cin >> s >> c;
        if(n > 1 && s == 1 && c == 0){
            cout << -1 << endl;
            return 0;
        }
        if(f[s-1] && num[s-1] != c){
            cout << -1 << endl;
            return 0;
        }
        num[s-1] = c;
        f[s-1] = true;
    }
    rep(i,n){
        cout << num[i];
    }
    cout << endl;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,a[200001],m[200001];

signed main () {
    cin >> n >> a[0];
    m[0] = a[0];
    rep11(i,n) {
        cin >> a[i];
        m[i] = max(m[i-1], a[i]);
    }
    for(int i=n-2;i>=0;--i) a[i] = max(a[i], a[i+1]);
    rep(i,n) {
        if (!i) cout << a[1] << endl;
        else cout << max(a[i+1], m[i-1]) << endl;
    }
}


Measured memory_bytes: 4736
h = int(input())
w = int(input())
n = int(input())

cell_cnt=0
x=0

for x in range(h):
	cell_cnt+=w
	if cell_cnt>=n:
		break

cell_cnt = 0
for y in range(w):
	cell_cnt+=h
	if cell_cnt>=n:
		break

print(min(x+1,y+1))


Measured memory_bytes: 3060
#pragma region template
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a) \
    REP(i, (a).size()) { cout << (a[i]) << (i == (a).size() - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
    vector<vi> A(3, vi(3));
    REP(i, 3)
    {
        REP(j, 3) { cin >> A[i][j]; }
    }
    ll N;
    cin >> N;
    vi b(N);
    REP(i, N) { cin >> b[i]; }

    vector<vector<bool>> c(3, vector<bool>(3));
    REP(i, 3)
    {
        REP(j, 3)
        {
            REP(k, N)
            {
                if (A[i][j] == b[k])
                {
                    c[i][j] = true;
                }
            }
        }
    }

    bool ok = false;
    REP(i, 3)
    {
        ok |= c[i][0] and c[i][1] and c[i][2];
        ok |= c[0][i] and c[1][i] and c[2][i];
    }
    ok |= c[0][0] and c[1][1] and c[2][2];
    ok |= c[0][2] and c[1][1] and c[2][0];
    if (ok)
    {
        OUT("Yes");
    }
    else
    {
        OUT("No");
    }
}
#pragma endregion template

Measured memory_bytes: 256
def main():
    s = input()
    k = int(input())

    m = 0
    ans = ""

    for i in range(len(s)):
        if s[i] != "1":
            m = i+1
            ans = s[i]
            break
    
    if k < m:
        print(1)
    elif m == 0:
        print(1)
    else:
        print(int(ans))



if __name__ == "__main__":
    main()

Measured memory_bytes: 9116
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define ANTHRO(x...) cerr << "[" << #x << "] = [", _print(x)
#else
#define ANTHRO(x...)
#endif


#define ll long long
#define MOD 1000000007
#define INF (int)1e9
#define EPS 1e-9
/*
    This is my attempt
*/
void aE(vector<ll> adj[],ll x,ll y){
    adj[x].push_back(y);
}
void d(vector<ll> adj[],vector<ll>& dp,vector<bool>& v,ll i){
    v[i]=true;
    for(ll j=0;j<adj[i].size();j++){
        //dp[adj[i][j]]=max(dp[adj[i][j]],1+dp[i]);
        //ANTHRO(i,dp[i],adj[i][j],dp[adj[i][j]]);
        if(!v[adj[i][j]]){
            //ANTHRO(i,adj[i][j]);
            d(adj,dp,v,adj[i][j]);
        }

        dp[i]=max(dp[i],1+dp[adj[i][j]]);
    }
}
ll lP(vector<ll> adj[],ll n){
    vector<ll> dp(n+1,0);
    vector<bool> v(n+1,false);
    for(ll i=1;i<=n;i++){
        if(!v[i]){
            v[i]=true;
            d(adj,dp,v,i);
        }
    }
    //ANTHRO(dp);
    ll b=-INF;
    for(auto x: dp){
        b=max(b,x);
    }
    return b;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m; cin>>n>>m;
    vector<ll> adj[n+1];
    for(ll i=0;i<m;i++){
        ll x,y; cin>>x>>y;
        aE(adj,x,y);
    }//This is base of the program
    cout<<lP(adj,n);
    return 0;
}



Measured memory_bytes: 9984
n,a,b=map(int,input().split())
a-=1
b-=1
while 1:
  if a+1==b:
    if a==0:
      print("Borys")
      break 
    a-=1
  else:
    a+=1
  
  if b-1==a:
    if b==n-1:
      print("Alice")
      break
    b+=1
  else:
    b-=1

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <map>
using namespace std;

int main()
{
	int64_t H, W, N;
	cin >> H >> W >> N;

	map<pair<int32_t, int32_t>, int32_t> black_cnt;
	for (int32_t i = 0; i < N; i++) {
		int32_t y, x;
		cin >> y >> x;
		y--;
		x--;

		for (int32_t dx = -2; dx < 1; dx++) {
			for (int32_t dy = -2; dy < 1; dy++) {
				if (x + dx < 0 || x + dx >= W - 2 ||
				    y + dy < 0 || y + dy >= H - 2)
					continue;

				pair<int32_t, int32_t> p = make_pair(y + dy, x + dx);
				if (black_cnt.count(p) == 0) {
					black_cnt[p] = 1;
				} else {
					black_cnt[p]++;
				}
			}
		}
	}

	vector<int64_t> res(10, 0);
	for (auto iter = black_cnt.begin(); iter != black_cnt.end(); iter++) {
		res[iter->second]++;
	}

	int64_t total = 0;
	for (int32_t i = 0; i < 10; i++) {
		total += res[i];
	}
	res[0] = (H - 2) * (W - 2) - total;

	for (int32_t i = 0; i < 10; i++) {
		cout << res[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 56448
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

int dp[11000];

int main(){
  int x;
  cin>>x;
  if(x<1200) cout<<"ABC"<<endl;
  else cout<<"ARC"<<endl;
}


Measured memory_bytes: 256
N,M,K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A_accumulate_cost = [0]
lastCost = 0
for i in range(N):
    lastCost += A[i]
    A_accumulate_cost.append(lastCost)

B_accumulate_cost = [0]
lastCost = 0
for i in range(M):
    lastCost += B[i]
    B_accumulate_cost.append(lastCost)

max_num = 0
p = M
for i in range(N+1):
    A_cost = A_accumulate_cost[i]
    if A_cost > K:
        break

    for j in range(p, -1, -1):
        if A_cost + B_accumulate_cost[j] <= K:
            p = j
            if i + j > max_num:
                max_num = i+j
            break

print(max_num)

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

// why am I so weak

int n;
long long a[100055], b[100055];

int main() {
	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		scanf("%lld %lld", &a[i], &b[i]);
	}

	long long res = 0;

	for (int i = n - 1; i >= 0; i--) {
		a[i] += res;

		long long cool = (a[i] +  b[i] - 1) / b[i] * b[i];

		res += cool - a[i];
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 1792
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
bool DEBUG = 0; void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void main(string[] args){ args ~= ["", ""]; string cmd = args[1]; if(cmd == "-debug") DEBUG = 1;
if(cmd == "-gen") gen; else if(cmd == "-jury") jury; else solve; } 
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ std.stdio.write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string picture(bool[] xs){ return xs.array.map!(x => x? '#': '.').array; } string picture(bool[][] xf){ return xf.map!(xs => xs.picture).array.join("\n"); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //
void gen(){
}
void jury(){
}
void solve(){
    int k = scan!int;
    foreach(i; 0 .. k) "ACL".write;
    "".writeln;
}

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

double D(vector<double> a, vector<double> b) {
  double r = sqrt((a.at(0)-b.at(0))*(a.at(0)-b.at(0)) + (a.at(1)-b.at(1))*(a.at(1)-b.at(1)));
  return r;
}

int main() {
  int N;
  cin >> N;
  vector<vector<double>> point(N, vector<double>(2,0));
  for (int i=0; i<N; i++) {
    cin >> point.at(i).at(0);
    cin >> point.at(i).at(1);
  }
  
  double ans = 0;
  for (int i=1; i<=N; i++) {
    for (int j=i+1; j<=N; j++) {
      ans += D(point.at(i-1), point.at(j-1));
    }
  }
  ans *= 2;
  ans /= N;
  cout << fixed << setprecision(8);
  cout << ans << endl;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<P> cb(m);
    rep(i, m){
        int b, c;
        cin >> b >> c;
        cb[i].first = c;
        cb[i].second = b;
    }
    sort(cb.rbegin(), cb.rend());
    int k = n;
    for(auto i: cb){
        vector<int> x(i.second, i.first);
        a.insert(a.end(), x.begin(), x.end());
        k -= i.second;
        if(k < 0) break;
    }
    sort(a.rbegin(), a.rend());
    ll ans = 0;
    rep(i, n) ans += a[i];
    cout << ans << endl;
}

Measured memory_bytes: 3312
#include <bits/stdc++.h>
struct data{ double v,t; }st[500005];
double v,t,s;
int n,w,L;
inline int gi(){
  int x=0,q=1; char ch=getchar();
  while ((ch<'0' || ch>'9') && ch!='-') ch=getchar();
  if (ch=='-') q=-1,ch=getchar();
  while (ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
  return q*x;
}
int main(){
  n=gi(),L=gi();
  for (int i=1,l=1,r=0,p;i<=n;++i){
    t=gi(),p=v=gi(),s+=v*t,L-=v;
    while (w>L){
      if (w-st[l].v>=L) s-=st[l].t*st[l].v,w-=st[l++].v;
      else s+=st[l].t*(L-w),st[l].v+=L-w,w=L;
    }
    while (l<=r && t<st[r].t)
      t=(t*v+st[r].t*st[r].v)/(v+st[r].v),v+=st[r--].v;
    st[++r]=(data){v,t},w=(L+=p),printf("%0.7lf\n",s/L);
  }
  return 0;
}


Measured memory_bytes: 16896