akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 10000;
const int K = 250;
int q[N], t[N], nxt[N][K], dif[N][K], b[N][K], c[N][K];
int sum (int r)
{
	int result = 0;
	for (; r >= 0; r = (r & (r+1)) - 1)
		result += t[r];
	return result;
}

void inc (int i, int delta)
{
	for (; i < N; i = (i | (i+1)))
		t[i] += delta;
}

main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   // freopen("input.txt", "r", stdin);
    int n, m;
    cin >> n >> m;
    for (int i = 2; i <= n; i++){
        int l;
        cin >> l;
        q[i] = q[i - 1] + l;
    }
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= m; j++){
            cin >> b[i][j];
        }
        nxt[i][0] = 1;
        dif[i][0] = b[i][1];
    }
    for (int i = 1; i <= m; i++){
        stack < pair < int, int > > s;
        s.push({1e12, n + 1});
        for (int j = n; j >= 0; j--){
            auto x = s.top();
            while(x.F <= b[j][i]){
                s.pop();
                x = s.top();
            }
            nxt[j][i] = x.S;
            dif[j][i] = x.F - b[j][i];
            s.push({b[j][i], j});
        }
    }
    for (int i = 1; i <= m; i++){
        int j = 0;
        while(j != n + 1){
            int x = dif[j][i];
            j = nxt[j][i];
            c[j][i] = x;
            inc(j, x);
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= m; j++){
            int l = nxt[i][j];
            int z = dif[i][j];
            inc(i, -c[i][j]);
            inc(i, b[i][j]);
          //  inc(i, b[i][j]);
            while(z != c[l][j]){
                inc(l, -c[l][j]);
                inc(l, z);
                c[l][j] = z;
                z = dif[l][j];
                l = nxt[l][j];
            }
        }
        for (int j = i; j <= n; j++){
            ans = max(ans, q[i] - q[j] + sum(j) - sum(i - 1));
        }
    }
    cout << ans;
}


Measured memory_bytes: 45440
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

int main(){
  ll n,p;
  cin>>n>>p;
  int size = (int)sqrt(p)+2;
  ll v[size];
  ll i = 2;
  ll a = p;
  // cout<<a<<endl;
  for(int j = 0; j < size; j++) v[j]=0;

  while(p>1&&i<size){
    // cout<<i<<endl;
    if(p%i==0){
      p/=i;
      v[i]++;
    }
    else i++;
  }
  // cout<<i<<endl;
  ll ans = 1;
  if(n!=1){
    for(int j = 1; j < size; j++){
      // cout<<i<<" "<<v[i]<<endl;
      ans*=pow(j,v[j]/n);
    }
  }
  if(n==1) ans*=a;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 8064
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

int compare_array(vector<int> a1, vector<int>a2) {
  if (a1.size() != a2.size()) {
    return a1.size() - a2.size();
  }
  for (int i=0; i<a1.size(); i++) {
    if (a1.at(i) != a2.at(i)) {
      return a1.at(i) - a2.at(i);
    }
  }
  return 0;
}

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

char int_to_char(int a) {
  if (a == -1) {
    return 'z';
  }
  else {
    return 'a' + a;
  }
}

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int divide_count(int a, int divider) {
  int r = 0;
  while(a % divider == 0) {
    a /= divider;
    r++;
  }
  return r;
}

bool is_prime(int a) {
  int i = 2;
  while(i * i <= a) {
    if(a % i == 0) {
      return false;
    }
    i++;
  }
  return true;
}

int main() {
  std::cout << std::setprecision(9);
  int n, m;
  cin >> n >> m;

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

  vector<bool> ans(n, true);
  for(int i=0; i<m; i++) {
    int a, b;
    cin >> a >> b;
    if(h[a-1] <= h[b-1]) {
      ans[a-1] = false;
    }
    if(h[a-1] >= h[b-1]) {
      ans[b-1] = false;
    }
  }

  int count = 0;
  for(int i=0; i<n; i++) {
    if(ans[i]) {
      count++;
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 3780
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX=200000;

int main(){
    int R[MAX],n;
    
    cin >> n;
    for(int i=0;i<n;i++) cin >> R[i];
    
    int maxv=-2000000000;
    int minv=R[0];
    
    for (int i =1; i < n;i++){
        maxv=max(maxv,R[i]-minv);
        minv=min(minv,R[i]);
    }
    
    cout << maxv << endl;
    return 0;
}

Measured memory_bytes: 3872
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9

int main(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    if (k % 2 == 0) {
        cout << a - b << endl;
    }
    else{
        cout << b - a << endl;
    }
}

Measured memory_bytes: 3588
def f(a,k):
    p=0
    while a<k:
        a*=2
        p+=1
    return p

n,k=map(int,input().split())
a=float()
for i in range(1,n+1):
    a+=1/(2**f(i,k))
print('{:.18f}'.format(a/n))

Measured memory_bytes: 3188
#include<iostream>
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
  int a,b ;
  cin >> a >> b  ;
  
  if(a&2 != 0 && b&2 != 0)
    cout << "Yes" << endl ;
  else 
    cout << "No" << endl ;    
  return 0 ;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
class Main {
 
    private static Scanner sc = new Scanner(System.in);
 
    public static void main(String[] args) {
        String s = sc.next();
        String s2 = sc.next();
        System.out.println((s + s).contains(s2) ? "Yes" : "No");
    }
}


Measured memory_bytes: 22868
N = gets.to_i
H = gets.chomp.split(" ")
H.map!{|x| x.to_i}

max_count = 0  #最大数カウント
i = 0
while i < H.length - 1
  count = 0 #移動回数カウント
  while i < H.length - 1
    if H[i] >= H[i+1]
      i += 1
      count += 1
    else
      i += 1
      break
    end
  end
  max_count = count if max_count < count
end

p max_count


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

using lint = long long;
using Time = pair< lint, int >;

struct Customer {
	lint a, b, c;
	bool operator > (const Customer& obj) const { return a == obj.a ? c > obj.c : a > obj.a; }
};

lint N, M, K, D, S, last[100005];

int main() {
	cin >> N >> M >> K >> D >> S;
	
	if (N > M) {
		cout << K * D << endl;
		return 0;
	}
	
	priority_queue< Customer, vector< Customer >, greater< Customer > > que;
	for (int i=0; i<M; ++i) {
		lint a, b, c;
		cin >> a >> b >> c;
		--c;
		que.push(Customer{a, b, c});
	}
	que.push(Customer{S+D, 0, N});
	
	set< Time > reg;
	for (int i=0; i<N; ++i) reg.insert(Time(0, i));
	memset(last, 0, sizeof(last));
	
	lint ans = K * D;
	while (!que.empty() && K > 0) {
		Customer cust = que.top(); que.pop();
		if (cust.c == N) { // sazoe
			lint fast = (*reg.begin()).first;
			ans += max(0LL, fast - cust.a);
			que.push(Customer{max(fast, cust.a)+D, 0, N});
			--K;
		}
		else { // others
			int i = cust.c;
			reg.erase(Time(last[i], i));
			last[i] = max(last[i], cust.a) + cust.b;
			reg.insert(Time(last[i], i));
		}
	}
	cout << ans << endl;
}


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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount

const int INF = 1e9;

bool str_cmp(string x, string y){ // x<y ?
    int sx = sz(x), sy = sz(y);
    if(sx!=sy) return sx < sy;
    else return x < y;
}

int cost[11]={-1, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

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

    vector<string> dp(N+1, "-");
    dp[0]="";

    for(int i=1;i<=N;i++){
        for(int j=0;j<M;j++){
            if(i-cost[A[j]]>=0){
                if(dp[i-cost[A[j]]]!="-" && str_cmp(dp[i], dp[i-cost[A[j]]]+to_string(A[j]))){
                    dp[i] = dp[i-cost[A[j]]]+to_string(A[j]);
                }
            } 
        }
    }

    cout<<dp[N]<<endl;

    return 0;
}

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

ll GCD(ll a, ll b)
{
	if (b == 0) return a;
	else return GCD(b, a%b);
}

int main(int argc, char **argv)
{
	ll n; cin >> n;
	vector<ll> v(n); for (int i = 0; i < n; ++i) cin >> v[i];
	ll res{0};
	for (int i = 0; i < n; ++i)
	{
		res = GCD(v[i], res);
	}
	std::cout << res<< std::endl;
}

Measured memory_bytes: 1024
n;main(r,i){
scanf("%d",&n);r=n;
for(i=2;i*i<=n;i++)if(n%i==0)for(r=1LL*r*(i-1)/i;n%i==0;n/=i);
if(--n)r=1LL*r*n/(++n);
n=!printf("%d\n",r);
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
#define MAX 100
char s[MAX],t[MAX];
int main()
{
    int i,n;
    char c;
    for(i=0;;i++)
    {
        scanf("%c",&c);
        if(!(c>='a'&&c<='z')) break;
        s[i]=c;
    }
    n=i;
    for(i=0;i<=n;i++)
    {
        scanf("%c",&t[i]);
    }
    bool f=true;
    for(i=0;i<n;i++)
    {
        f=f&&(s[i]==t[i]);
    }
    if(f)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 3832
N,M,C=map(int,input().split())
B=map(int,input().split())
b=list(B)
X=0
Y=C
Z=0
def mul(x,y):
  return(x*y)

for i in range(N):
  A=map(int,input().split())
  a=list(A)
  for j in range(M):
    Y=Y+a[j]*b[j]
  if Y<=0:
    Y=C
  else:
    Z=Z+1
    Y=C

print(Z)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
#define rep(i,x) for(long long i=0;i<x; i++)
#define INF 1000100
typedef long long  ll;
using namespace std;


int main(){
	string N;
  bool check=false;
  cin>>N;
  rep(i,3){
  	if(N[i]=='7') check=true;
  }
  if(check){
  	cout<<"Yes";
  }else{
  	cout<<"No";
  }
}


Measured memory_bytes: 3600
n,k=map(int,input().split())
A=list(map(int,input().split()))
V=[0]*n
V[0]=0
a=0
c=0
for i in range(k):
  a=A[a]-1
  if V[a]!=0:
    break
  V[a]=i+1
if i==k-1:
  print(a+1)
  exit()
else:
  k=(k-V[a])%(i+1-V[a])
  for i in range(k):
    a=A[a]-1
  if k==0:
    print(a+1)
  else:
    print(a+1)


Measured memory_bytes: 100092
#!/usr/bin/env python3
# n,m = map(int,sys.stdin.readline().split())
# a = list(map(int,sys.stdin.readline().split()))
# a = [sys.stdin.readline() for _ in range(n)]
# s = sys.stdin.readline().rstrip()
# n = int(sys.stdin.readline())
INF = float("inf")
import sys,bisect
sys.setrecursionlimit(15000)

n = int(sys.stdin.readline())
a = [int(sys.stdin.readline()) for _ in range(n)]

# naive O(n**2)
# dp = [0]*n
# for i in range(n):
#   m = 0
#   for j in range(0,i):
#     if a[j] < a[i] and m <= dp[j]:
#       m = dp[j]
#   dp[i] = m+1
# print(max(dp))
import bisect
dp = [float("inf")]*n
dp[0] = a[0]
l = 0
for i in range(1,n):
  if dp[l] < a[i]:
    l += 1
    dp[l] = a[i]
  else:
    j = bisect.bisect_left(dp,a[i])
    dp[j] = a[i]
print(bisect.bisect_left(dp,float("inf")))


Measured memory_bytes: 10476
#include <bits/stdc++.h>
//#define int long long
#define square(x) x*x
using namespace std;
int mod = 1000000007;
int inf = INT_MAX;
int m_inf = INT_MIN;
int dp[100001][2];

int32_t main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	std::cout.unsetf ( std::ios::floatfield );
	std::cout.precision(6);
	string str;
	cin>>str;
	string s;
	int q;
	cin>>q;
	int t,f;
	char c;
	int count = 0;
	while(q--)
	{
		cin>>t;
		if(t == 1)
		{
			count++;
		}
		else
		{
			cin>>f>>c;
			if((f == 1 && count%2) || (f == 2 && count%2 == 0))
			{
				str +=c;
			}
			else
			{
				s += c;
			}
		}
	}
	reverse(s.begin(),s.end());
	str=s+str;
	if(count%2)
		reverse(str.begin(),str.end());
	cout<<str;

}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#define N 100005
#define ll long long
using namespace std;
int n;
int a[N],b[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)cin>>b[i];
	ll n1=0,n2=0;
	for(int i=1;i<=n;i++)
	{
		if(b[i]>a[i])
		{
			n2+=(b[i]-a[i])/2;
		}
		else
		{
			n1+=(a[i]-b[i]);
		}
	}
	if(n1<=n2)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 384
import Data.Array

foldl_trace::(a->b->a)-> a -> [b] -> [a]
foldl_trace f initial []     = []
foldl_trace f initial (x:xs) = (f initial x):(foldl_trace f (f initial x) xs)

gcd_still::[Int]->[Int]
gcd_still (x:xs) = x:(foldl_trace gcd x xs)

solver::Int->[Int]->Int
solver n ls = let ar_1 = listArray (1,n) (gcd_still ls) in
              let ar_2 = listArray (1,n) (reverse (gcd_still (reverse ls))) in
              maximum ([gcd (ar_1!(i-1)) (ar_2!(i+1)) |i<-[2..(n-1)]]++[ar_1!(n-1) , ar_2!(2)])


main::IO()
main=do
  n<-return.read=<<getLine
  ls<-return.map read.words=<<getLine
  print (solver n ls)

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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


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

void solve(ll n, ll s) {
    ll b = 1e18;
    if (n == s) {
        b = n + 1;
    }

    for (int i = 2; i <= 1000000; i++) {
        if (sum(n, i) == s) {
            b = min(b, 1ll * i);
        }
    }

    for (int i = 1; i <= 1000000; i++) {
        if ((i + n - s) % i == 0) {
            if( (i + n - s) / i > 1) {
                if (sum(n, (i + n - s) / i) == s) {
                    b = min(b, (i + n - s) / i);
                }
            }
        }
    }


    if (b == 1e18) {
        cout << -1 << endl;
    } else {
        cout << b << endl;
    }
}


void main_(istream &cin) {
    ll s;
    ll n;
    cin >> n;
    cin >> s;
    solve(n, s);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 256
/*
...........__________                                                                           ___  __
.............|       |                                                                           |   /
.............|       |                                                                           |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
...........__|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int                 long long
#define ull                 unsigned long long int
#define ld                  long double
#define vi                  vector<int>
#define vii                 vector<pair<int,int>>
#define vvi                 vector<vector<int>>
#define pii                 pair<int,int>
#define prec(x)             fixed<<setprecision(15)<<x
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define rev(x)              reverse(x.begin(),x.end())
#define mset(a,b)           memset(a,b,sizeof(a))
#define mcpy(a,b)           memcpy(a,b,sizeof(a))
#define fo0(i,n)            for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n)            for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b)           for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)            for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)            for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
const int inf=1e18;const int mod=1e9+7;const int N=2e5+9;
void read_And_write(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}

void raushan_kumar(){
    int d=0,e=0,f=0,g=0,p=0,w=0,flag=0,ans=0,res=0,cnt=0,sum=0;double f1=0.0,f2=0.0,f3=0.0;
    int a,b,n;cin>>a>>b>>n;
    if(b==n){
    	int x=b-1;
    	cout<<(a*x)/b;
    }
    else{
    	int x=min(b-1,n);
    	cout<<(a*x)/b;
    }
}

int32_t main()
{
    read_And_write();fast;int t=1;
    // cin>>t;
    while(t--){raushan_kumar();}
}

Measured memory_bytes: 3692
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;

enum INF = long.max/3;
enum MOD = 10L^^9+7;

//辞書順順列はiota(1,N),nextPermituionを使う


void end(T)(T v)
if(isIntegral!T||isSomeString!T||isSomeChar!T)
{
    import core.stdc.stdlib;
    writeln(v);
    exit(0);
}

T[] scanArray(T = long)()
{
    static char[] scanBuf;
    readln(scanBuf);
    return scanBuf.split.to!(T[]);
}

dchar scanChar()
{
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    return cast(dchar)c;
}

T scanElem(T = long)()
{
    import core.stdc.stdlib;
    static auto scanBuf = appender!(char[])([]);

    scanBuf.clear;

    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        scanBuf ~= cast(char) c;
        c = getchar;
    }
    return scanBuf.data.to!T;
}

dchar[] scanString(){
    return scanElem!(dchar[]);
}


void main()
{
  auto a=scanString;
  auto b=scanString;
  auto c=scanString;
  write(dchar(a[0]-'a'+'A'));
  write(dchar(b[0]-'a'+'A'));
  write(dchar(c[0]-'a'+'A'));
  writeln();
}


Measured memory_bytes: 256
def factorial(n):
    a = 1
    for i in range(1, n + 1):
        a *= i
    return a

def nCr(n,r):
    if r > n:
        return 0
    return factorial(n) // factorial(r) // factorial(n - r)

def normal(d, k):
    #print("normal d,k ", d, k)
    return nCr(d, k) * (9**k)

def main():
    tmp = input()
    N = [int(c) for c in tmp]
    D = len(N)
    K = int(input())
    #print(D, K)

    x = 0
    ans1, ans2, ans3, ans4, ans5, ans6 = 0, 0, 0, 0, 0, 0
    if K == 1:
        ans1 = normal(D-1, K)
        ans2 = N[0]
    elif K == 2:
        ans1 = normal(D-1, K)
        ans2 = (N[0] - 1) * normal(D-1, K-1)
        x = 1
        found = False
        for i in range(x, D):
            if N[i] != 0:
                x = i
                found = True
                break
        if found:
            if x == D - 1:
                ans4 = N[x]
            else:
                ans3 = normal(D-(x+1), K-1)
                ans4 = N[x]
    elif K == 3:
        ans1 = normal(D-1, K)
        ans2 = (N[0] - 1) * normal(D-1, K-1)
        x = 1
        found = False
        for i in range(x, D):
            if N[i] != 0:
                x = i
                found = True
                break
        if found:
            if x == D - 1:
                pass
            else:
                ans3 = normal(D-(x+1), K-1)
                ans4 = (N[x] - 1) * normal(D-(x+1), K-2)
                x = x + 1
                found = False
                for i in range(x, D):
                    if N[i] != 0:
                        x = i
                        found = True
                        break
                if found:
                    if x == D - 1:
                        ans6 = N[x]
                    else:
                        ans5 = normal(D-(x+1), K-2)
                        ans6 = N[x]

    #print("ans1", ans1)
    #print("ans2", ans2)
    #print("ans3", ans3)
    #print("ans4", ans4)
    #print("ans5", ans5)
    #print("ans6", ans6)

    ans = ans1+ans2+ans3+ans4+ans5+ans6
    #print("ans", ans)
    print(ans)

main()

Measured memory_bytes: 3192
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;

signed main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b && b == c){
        cout << "Yes" << endl;

    }else cout << "No" << endl;
    

    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_d
// rm -r -f test;oj dl http://exawizards2019.contest.atcoder.jp/tasks/exawizards2019_a

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a==b)
    {
         printf("a == b\n");
    }else if(a<b)
          {
             printf("a < b\n");
          }else{
             printf("a > b\n");
          }

    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        int cnt = 0;
        for (int j = 1; j * j <= i; j++)
        {
            for (int k = j; k * k <= i; k++)
            {
                for (int l = k; l * l <= i; l++)
                {
                    if (j * j + k * k + l * l + j * k + k * l + l * j == i)
                    {
                        if (l == j && j == k && k == l)
                        {
                            cnt++;
                        }
                        else if (l == j || j == k || l == k)
                        {
                            cnt += 3;
                        }
                        else
                        {
                            cnt += 6;
                        }
                    }
                }
            }
        }

        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 3560
#include <iostream>

using namespace std;

int main()
{
	int n;
	cin>>n;
	long long sum=0;
	for(int i=1;i<=n;i++){
		if(i%3==0 && i%5==0) continue;
		else if(i%3==0 && i%5!=0) continue;
		else if(i%5==0 && i%3!=0) continue;
		else sum = sum + i;
	}
	cout<<sum;
	return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (c >= a && c <= b)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3612
<?php
fscanf(STDIN,"%d",$n);

$cnt=0;
if($n<10){
	$cnt=$n;
}elseif($n<100){
	$cnt=9;
}elseif($n<1000){
	$cnt=9+$n-99;
}elseif($n<10000){
	$cnt=9+900;
}elseif($n<100000){
	$cnt=9+900+$n-9999;
}else{
	$cnt=90909;
}

echo $cnt;
?>

Measured memory_bytes: 4856
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>

const int NUMBER = 10;

long min(long a,long b)
{
    if (a > b){
        return b;
    }
    else {
        return a;
    }
}

int main(void)
{
    int d,g;
    int p[NUMBER];
    int c[NUMBER];
    int i;
    
    std::cin >> d >> g;
    for (i = 0;i < d;i++){
        std::cin >> p[i] >> c[i];
    }
    
    long long res = 1<<29;
    for (int bit = 0;bit < (1<<d);++bit){
        long long sum = 0;
        long long num = 0;
        for (int i = 0;i < d;i++){
            if (bit & (1<<i)){
                sum += c[i] + p[i]*100*(i+1); num += p[i];
            }
        }
        if (sum >= g){
            res = min(res,num);
        }
        else {
            for (int i = d-1;i >= 0;--i){
                if (bit & (1<<i)) continue;
                for (int j = 0;j < p[i];++j){
                    if (sum >= g) break;
                    sum += 100*(i+1);
                    ++num;
                }
            }
            res = min(res,num);
        }
    }
    std::cout << res << "\n";
}

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

int n,a,b;
int f(int a,int b)
{
	a-=b;
	return a<0 ?-a:a;
}

int main()
{
	cin>>n>>a>>b;
	if(f(a,b)%2==0) cout<<"Alice"<<endl;
	else cout<<"Borys"<<endl;
	return 0;
}

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



int main(){
  
  int n,m,k;
  cin >> n >> m >> k;
  if(k == 0){
    cout << "Yes" << endl;
    return 0;
  }
  vector<vector<int>> dp(n+1,vector<int>(m+1));
  rep(i,n+1){
    rep(j,m+1){
      if(dp[i][j] == k){
        cout << "Yes" << endl;
        return 0;
      }
      if(i==n || j==m) continue;
      dp[i+1][j] = dp[i][j]+m-j*2;
      dp[i][j+1] = dp[i][j]+n-i*2;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 7560
#include <iostream>
#include <string>

using namespace std;

int n;
string s;
int a[3005], b[3005];
int order[6005];

string calc(int l, int r, string &ans)
{
	string ret;
	if(s[l] == 'a'){
		if(ans.size() && ans[0] == 'b') return ans;
		int x = l;
		while(x <= r){
			ret += "ab";
			x = b[order[x]];
			while(x <= r && s[x] != 'a') x++;
		}
		ret += ans;
		return ret;
	}
	
	ret = ans;
	for(int i = l; i <= r; i++){
		if(s[i] == 'a') continue;
		int p = a[order[i]];
		string tmp;
		for(int j = i; j <= r; j++){
			if(s[j] == 'b') tmp += "b";
			else if(j >= p) tmp += "a";
		}
		ret = max(ret, tmp + ans);
	}
	return ret;
}

int main(void)
{
	cin >> n;
	cin >> s;
	s = "#" + s;
	n *= 2;
	
	int aid = 1, bid = 1;
	for(int i = 1; i <= n; i++){
		if(s[i] == 'a') a[aid] = i, order[i] = aid++;
		if(s[i] == 'b') b[bid] = i, order[i] = bid++;
	}
	
	string ans; int l = n+1, r = n;
	for(int i = n; i >= 1; i--){
		if(s[i] == 'a') l = min(l, b[order[i]]);
		if(s[i] == 'b') l = min(l, a[order[i]]);
		if(i == l){
			ans = calc(l, r, ans);
			r = l-1;
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 384
n = int(input())

list1 = []
list1.append(input())
for i in range(n-1):
    s = input()
    if s in list1:
        print("No")
        exit()
    elif s[0] != list1[-1][-1]:
        print("No")
        exit()
    list1.append(s)
print("Yes")

Measured memory_bytes: 38256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

#define POS(i,j) ((i)*w+(j))

int func(int i,int j,char *board,int h,int w){
  int k;
  for(k=0;k<h;k++){
    if(board[POS(k,i)]!=board[POS(h-1-k,j)]) return 0;
  }
  return 1;
}

int calcCol(char *board,int h,int w){
  int flag[16];
  int i,j;
  for(i=0;i<w;i++) flag[i]=0;
  int useCenter=0;
  for(i=0;i<w;i++){
    if(flag[i]) continue;
    for(j=i+1;j<w;j++){
      if(flag[j]) continue;
      if(func(i,j,board,h,w)){
	flag[i]=1;
	flag[j]=1;
	break;
      }
    }
    if(flag[i]==0){
      if(w%2==0 || useCenter) return 0;
      for(j=0;j<h-1-j;j++){
	if(board[POS(j,i)]!=board[POS(h-1-j,i)]) return 0;
      }
      useCenter=1;
      flag[i]=1;
    }
  }
  return 1;
}

void swapRow(int a,int b,char *board,int h,int w){
  int i;
  for(i=0;i<w;i++){
    char t=board[POS(a,i)];
    board[POS(a,i)]=board[POS(b,i)];
    board[POS(b,i)]=t;
  }
  return;
}

int loopRow(int d,char *board,int h,int w){
  if(d>=h-d-1) return calcCol(board,h,w);
  int i,j;
  for(i=d;i<h-d;i++){
    for(j=i+1;j<h-d;j++){
      swapRow(d,i,board,h,w);
      swapRow(h-d-1,j,board,h,w);
      if(loopRow(d+1,board,h,w)) return 1;
      swapRow(d,i,board,h,w);
      swapRow(h-d-1,j,board,h,w);
    }
  }
  return 0;
}

int calc(char *board,int h,int w){
  return loopRow(0,board,h,w);
}

void run(void){
  int h,w;
  scanf("%d%d",&h,&w);
  char *board=(char *)malloc(sizeof(char)*(h*w+1));
  int i;
  for(i=0;i<h;i++) scanf("%s",board+POS(i,0));
  printf("%s\n",calc(board,h,w)?"YES":"NO");
  free(board);
}

int main(void){
  run();
  return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    string s;
    cin>>s;
    set<char> x;
    for(auto l : s)
    {
        x.insert(l);
    }
    if(x.size()==1) cout<<"No";
    else cout<<"Yes";
}



Measured memory_bytes: 256
// Created by new_sm
//
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
s.find_by_order(x) xth element in set
x.order_of_key(x) number of elements <x*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
int a;
cin>>a;
cout<<a+a*a+a*a*a;

}
int main()
{
//code

fastio
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}



Measured memory_bytes: 3536
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

typedef long long LL;
static LL INF = (1LL<<62);

int isPrime(LL p){
	if(p<=1) return 0;
	if(p==2 || p==3 || p==5 || p==7) return 1;
	if(p==4 || p==6 || p==8 || p==9) return 0;

	LL i;
	int ret = 1;
	for(i=2; i*i<=p; i++){
		if(p%i==0 && i!=p){
			ret = 0;
			break;
		}
	}
	return ret;
}

vector<LL> P55;
vector<LL> A;

void init(){
	LL i = 0;
	for(i = 2; i<=55555; i++){
		if(isPrime(i) == 1){
			P55.push_back(i);
		}
	}
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	LL N;
	cin >> N;
	init();
	for(int i=0; i<P55.size(); i++){
		if((P55[i] % 5) == 1){
			A.push_back(P55[i]);
		}
	}

	for(int i=0; i<N; i++){
		printf("%lld", A[i]);
		if(i<N-1){
			printf(" ");
		}
	}
	printf("\n");
	return 0;
}



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

typedef long long ll;

int a,sum = 0;

void answer(){
	cin >> a;
	for (int i = 1; i <=3 ; i++){
		sum += pow(a,i);
		}
	cout << sum ;
 	}

int main (){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	answer(); 
return 0 ;
}



Measured memory_bytes: 4040
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            WriteLine(ReadLine().Replace(',', ' '));
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}



Measured memory_bytes: 11092
//  SMOKE SHISHA PLAY FIFA  // 
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i,start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main()
{
	fastio
	ll t=1;
	//cin >> t;
	while(t--)
	{
		string s,t;
		cin>>s>>t;
		ll n,m;
		n=s.size();
		m=t.size();
		//cout<<n<<m<<endl;
		ll dp[n+1][m+1];
		//dp[0][0]=0;
		for(ll i=0; i<=n; i++){
			for(ll j=0; j<=m; j++){
				if(i==0 || j==0)
					dp[i][j]=0;
				else if(s[i-1]==t[j-1])
					dp[i][j]=1+dp[i-1][j-1];
				else
					dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
		ll tot=dp[n][m];
		char lcs[tot+1];
		lcs[tot]='\0';
		ll i=n, j=m;
		while(i>0 && j>0){
			if(s[i-1]==t[j-1]){
				lcs[tot-1]=s[i-1];
				i--;
				j--;
				tot--;
			}
			else if(dp[i][j-1]>dp[i-1][j])
				j--;
			else
				i--;
		}
		cout<<lcs<<endl;
	}
	return 0;	
}


Measured memory_bytes: 70656
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cinttypes>
#include <cstdint>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <forward_list>
#include <initializer_list>
#include <random>
#include <regex>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;

using Field = vector<vector<ll>>;
using Graph = vector<vector<ll>>;
using VI = vector<int>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VC = vector<char>;
using PI = pair<int, int>;

#define FOR(i, s, n) for (int i = s; i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) x.begin(), x.end()

const long long INF = 1LL<<60;
const int mod = 1000000007;

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

ll N , M;
Graph G;

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

    cin >> N >> M;
    G.assign(N + 1, vector<ll>());

    REP(i, M) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    queue<pair<ll, ll>> que;

    vector<ll> ans(N + 1, -1);

    que.push(make_pair(0, -1));

    while (!que.empty()) {
        pair<ll, ll> p = que.front();
        que.pop();
        ll cur = p.first;
        ll par = p.second;
        if (ans[cur] != -1) continue;
        ans[cur] = par;
        for (int i = 0; i < G[cur].size(); i++) {
            ll next = G[cur][i];
            pair<ll, ll> nextp = make_pair(next, cur);
            que.push(nextp);
        }
    }

    bool flag = true;

    for (int i = 1; i < N; i++) {
        if (ans[i] == -1) {
            flag = false;
            break;
        }
    }

    if (flag) {
        cout << "Yes" << endl;
        for (int i = 1; i < N; i++) {
            cout << ans[i] + 1 << endl;
        }
    }else {
        cout << "No" << endl;
    }
    
    return 0;
}

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

using namespace std;
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	
	int n; cin >>n;
	VI a(n);
	rep(i,n) cin >>a[i];
	rep(i,10000){
		rep(j,n){
			if(a[j]%2 ){
				cout << i <<"\n";
				return 0;
			}
			a[j] /=2;
		}
	}
	puts("0");
	return 0;
	
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) < (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pii Dir[8] = { //移動
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x^(x << 11));
	x = y; y = z; z = w;
	return (w = (w^(w >> 19))^(t^(t >> 8)));
}

int main(void) {
	int n;
	cin >> n;
	vector<int> a(n);
	REP(i, n)
		cin >> a[i];

	int ans = 0;
	int cur = 0;

	sort(ALL(a));

	REP(i, n) {
		if ((a[i] - cur) % 2) {
			ans ^= n - i;
		}

		cur = a[i];

	}

	if (ans) cout << "first" << endl;
	else cout << "second" << endl;

	return 0;
}


Measured memory_bytes: 640
#include<cstdio>
using namespace std;
int a,b,c;
int main(void){
	scanf("%d%d%d",&a,&b,&c);
	if(a==b&&c!=a)
		printf("%d",c);
	if(a==c&&b!=a)
		printf("%d",b);
	if(b==c&&c!=a)
		printf("%d",a);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int flag=1;
    while(1)
    {
        if(flag)
        {
            c-=b;
            if(c<=0)
            {
                cout<<"Yes"<<endl;
                break;
            }
            flag=0;
        }
        else
        {
            a-=d;
            if(a<=0)
            {
                cout<<"No"<<endl;
                break;
            }
            flag=1;
        }
    }
    return 0;
}


Measured memory_bytes: 3620
N = int(input())
A = list(map(int, input().split()))

if __name__ == '__main__':
    cnt = 0
    for i in range(N):
        for j in range(N-1, i, -1):
            if j > 0 and A[j-1] > A[j]:
                A[j-1], A[j] = A[j], A[j-1]
                cnt += 1
    print(" ".join(map(str, A)))
    print(cnt)


Measured memory_bytes: 5596
h, w = map(int, input().split())

f = (h-h%2)*(w-w%2)//4
t = 0
one = 0
if h%2==1:
    t += w//2
if w%2==1:
    t += h//2
if h%2==1 and w%2==1:
    one = 1

dic = {}
for i in range(h):
    a = list(input())
    for j in a:
        if j in dic:
            dic[j] += 1
        else:
            dic[j] = 1

result = True
for i, j in dic.items():
    if j%2==1:
        if one == 1:
            j -= 1
            one -= 1
        else:
            result = False
    if j==0:
        continue
    while f > 0 and j>=4:
        j -= 4
        f -= 1
        if j==0:
            break
    if j==0:
        continue
    while t > 0 and j>=2:
        j -= 2
        t -= 1
        if j==0:
            break
    if j==0:
        continue
    else:
        result = False

    if result == False:
        break

if result:
    print("Yes")
else:
    print("No")

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

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int a, b, c, k;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> b >> c >> k;
	int cnt = 0;
	if(k >= a) k -= a, cnt += a;
	else{
		cout << cnt + k << "\n";
		return 0;
	}
	if(k >= b) k -= b;
	else{
		cout << cnt << "\n";
		return 0;
	}
	cout << cnt - k << "\n";
	return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long int ll;
int main()
{
  //ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  ll t;
  //cin >> t;
  t=1;
  while(t--)
  {
    ll a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    if(((a[2]-a[0])&1) && ((a[2]-a[1])&1))
    {
      cout << (a[2]-a[0]-1)/2 + (a[2]-a[1]-1)/2 +1<<endl;
    }
    else if((a[2]-a[0])&1)
    {
      cout << (a[2]-a[0]+1)/2 + (a[2]-a[1])/2 + 1<<endl;
    }
    else if((a[2]-a[1])&1)
    {
      cout << (a[2]-a[1]+1)/2 + (a[2]-a[0])/2 + 1<<endl;
    }
    else
    {
      cout << (a[2]-a[0])/2 + (a[2]-a[1])/2  <<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
H = [int(input()) for _ in range(n)]
H.sort()
d = []
for i in range(1,n):
  d.append(abs(H[i]-H[i-1]))
S = [0]
for i in d:
  S.append(S[-1]+i)
min_num = 10**9
for i in range(k-1,n):
  min_num = min(min_num, abs(S[i]-S[i-k+1]))
print(min_num)

Measured memory_bytes: 15568
#include <string>
#include <vector>
#include <cstring>
#include <algorithm>
#include <iostream> 
#include <cmath>
 
using namespace std;
typedef long long ll;
typedef long double ld;

const ll MOD=ll(1e9+7);

//repetition
#define REP(i,n)  for(ll i=0;i<n;i++)

ll P_POW(ll i, ll n) {
  if(n==0) return 1;

  n--;
  ll rep = i;

  while(n) {
    rep = rep * i;
    n--;
  }
  return rep;
} 

unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
 
unsigned binarySearch(ll target, ll max, ll min) {
  while((max - min) > 1) {
      if((max + min)/2 > target) {
        max = (max + min)/2;
        min = min;
      } else {
        max = max;
        min = (max + min)/2;
      }
    }
}

ll n;


long long solve2(long long N) {
    if (N % 2 == 1) return 0;

    long long res = 0;
    N /= 2;
    while (N) {
        res += N / 5;
        cout << "N/5: " << N/5 <<  endl;
        cout << "res1: " << res <<  endl;
        N /= 5;
    }
    return res;
}


ll solve(ll n) {
    if (n % 2 == 1) return 0;

    ll res = 0;
    n /= 2;
    int c = 1;

    while ((ll) n/((ll)pow(5,c))) {
      res += n/P_POW(5,c);
      c++;
    }
    return res;
}

void f(int rest, string s) {
  char abc[] = "abc";
  if(rest == 0) {
    cout << s << endl;
  } else {
    for(int i=0; i < 3; i++) {
      f(rest - 1, s+abc[i]);
    }
  }
}

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a;

  REP(i, n) {
    ll ai;
    cin >> ai;
    a.push_back(ai);
  }

  ll t1 = 0;

  REP(i, a.size()) {
    vector<ll> ai;
    ai = vector<ll>(a.begin() + i, a.end());
    sort(ai.begin(), ai.end());
    int pos = lower_bound(ai.begin(), ai.end(), a[i]) - ai.begin();
    t1 += pos;
  }

  ll t2 = 0;

  REP(i, a.size()) {
    sort(a.begin(), a.end());
    int pos = lower_bound(a.begin(), a.end(), a[i]) - a.begin();
    t2 += pos;
  }

  ll s1 = t1 * k %MOD;
  ll s2 =  k * (k-1) / 2 % MOD * t2 % MOD;

  cout << (s1 + s2)%MOD << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define P(x) cout << x << endl
#define D(x) P(#x << ": " << x)
#define F(i,n) for (int i=0; i<(int)(n); i++)
#define DEC(i,n) for (int i=(int)(n); --i>=0;)
#define S(s) (int)((s).size())
#define ALL(v) v.begin(), v.end()
#define V vector
#define pb push_back
#define double long double
using namespace std;
void MI(int &a, int v) {a = min(a,v);}
void MA(int &a, int v) {a = max(a,v);}
const double EPS=1e-7;

struct water{double t,v;};
const water WARM_VOID={2e9,0};
water operator+(water w1, water w2) {
    double v = w1.v + w2.v;
    return {(w1.t*w1.v + w2.t*w2.v) / v, v};
}
water operator-(water w1, water w2) {
    double v = w1.v - w2.v;
    return {(w1.t*w1.v - w2.t*w2.v) / v, v};
}

signed main() {
    //P("long double");
    int n; double l; cin>>n>>l;
    //water a[n];
    //F(i,n) cin>>a[i].t>>a[i].v;
    water total=WARM_VOID;
    deque<water> d;
    
    F(i,n) {
        water cur; cin>>cur.t>>cur.v;
        total = total + cur;
        //D(rest.t), D(rest.v);
        while (total.v - l > EPS) {
            water torem = {d.front().t, min(d.front().v, total.v - l)};
            //P("remove "<<torem<<" at "<<suff.t);
            d.front() = d.front() - torem;
            total = total - torem;
            if (d.front().v < EPS)
                d.pop_front();
        }
        printf("%.7Lf\n", total.t);
        
        while (S(d) && cur.t < d.back().t) {
            cur = cur + d.back();
            d.pop_back();
        }
        d.pb(cur);
    }
}

Measured memory_bytes: 25396