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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  ll N; cin >> N;
  vector<ll> A(N), B(N); REP(i, N) cin >> A[i] >> B[i];
  ll ans = 0;
  for(int i = N - 1; i >= 0; --i) {
    A[i] += ans;
    if(A[i] > B[i]) {
      ll tmp = 0;
      if(B[i] != 1) {
        if((A[i] % B[i]) == 0) {
        } else {
          tmp = B[i] - (A[i] % B[i]);
        }
      }
      A[i] = A[i] + tmp;
      ans += tmp;
    } else {
      ll tmp = 0;
      if(B[i] != 1) {
        if((A[i] % B[i]) == 0) {
        } else {
          tmp = B[i] - A[i];
        }
      }
      A[i] = A[i] + tmp;
      ans += tmp;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

ll f(ll x,ll c,ll d){
    ll res =x;
    res -=x/c;
    res -=x/d;
    res+= x/lcm(c,d);
    return res;
}

int main(){
   ll n,k;
   cin>>n>>k;
   vector<ll>v(n);
   rep(i,n){
       v[i]=i+1;
   }
   double sum=0;
   ll tmp;
   rep(i,n){
       bool ok=1;
       tmp=v[i];
       ll m=0;
       while(ok){
           if(k<=tmp)break;
           m+=1;
           tmp*=2;
       }
       sum+=1.0/(n*pow(2.0,m));
   }
   cout<< fixed << setprecision(13)<< sum<<endl;
}


Measured memory_bytes: 4124
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in1(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in1(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
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; }


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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int N;
    in1(N);

    vll h(N);
    inN(h, N);

    ll ans = 0;
    int start = 0;

    while (true)
    {
        //開始位置のチェック
        if (start >= N) break;

        if (h[start] == 0)
        {
            start++;
            continue;
        }

        //0でない範囲はまとめて引く
        ll minh = INF;
        int end;

        for (end = start; end < N; end++)
        {
            if (h[end] == 0) break;
            chmin(minh, h[end]);
        }

        reps(j, start, end) h[j] -= minh;

        ans += minh;
    }

    outl(ans);

    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int a, b, c; scanf("%d%d%d", &a, &b, &c);
	
	if(b - a == c - b) printf("YES\n");
	else printf("NO\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  cin >> N;
  long long ans = 1;
  for (long long i = 1; i <= N; i++) {
    ans *= i;
    ans = ans % (1000000007);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>

using namespace std;

int main() {
    size_t N;
    scanf("%zu", &N);

    int parity[2]={};
    for (size_t i=0; i<N; ++i) {
        int A;
        scanf("%d", &A);
        ++parity[A&1];
    }

    parity[0] += parity[1] >> 1;
    parity[1] &= 1;

    parity[0] = !!parity[0];

    printf("%s\n", parity[0]+parity[1]==1? "YES":"NO");
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>

int main(void){

  int d,n;
  scanf("%d %d", &d, &n);
  int answer = pow(100,d);
  if (n < 100) {
    answer *= n;
  } else {
    answer *= 101;
  }
  printf("%d\n", answer);

  return 0;
}

Measured memory_bytes: 128
#include<iostream>//不是我想抄题解，只是参考了那位红名大佬，不过正好和某题解差不多
using namespace std;
int main()
{
    long long n,a,b;
    cin>>n>>a>>b;
    if(n>1&&b>=a||n==1&&a==b)
        cout<<(b-a)*(n-2)+1<<endl;
    else
        cout<<0<<endl; 
    return 0;
 } 

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int n; cin >> n;
	vector<int> v(n);

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

	vector<int> c(n);

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

	int ans = 0;
	for (int bit = 0; bit < (1 << n); ++bit) {
		int tmp = 0;
		for (int j = 0; j < n; j++) {
			if (bit&(1 << j)) {
				tmp += (v[j] - c[j]);
			}
		}

		ans = max(ans, tmp);
	}

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

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc065/tasks/abc065_b


N = gets.to_i
as = Array.new(N) { gets.to_i }

k = 0
ans = 0
used = Array.new(N, false)

loop do
  used[k] = true
  k = as[k] - 1
  ans += 1
  if used[k]
    ans = -1
    break
  elsif k == 1
    break
  end
end

puts ans


Measured memory_bytes: 3580
#include<iostream>

using namespace std;

int main ()
{
	int n,day[99],i;
	cin >> n;
	for( i =0;i<n;i++){
	cin >> day[i];
	}

	for( i =1;i<n;i++){
    	cout << day[n - i] << " ";

    }cout <<day[0]<< endl;


}

Measured memory_bytes: 3048
N = int(input())
L = list(map(int,input().split()))
cnt = [0]*(3*10**3+1)
for i in range(N):
    cnt[L[i]] += 1
cum = [0]*(3*10**3+1)
for i in range(3*10**3):
    cum[i+1] = cum[i]+cnt[i+1]

ans = 0
for a in range(1,10**3+1):
    if cnt[a] == 0:
        continue
    for b in range(a+1,10**3+1):
        if cnt[b] == 0:
            continue
        ans  += (cum[a+b-1]-cum[b])*cnt[a]*cnt[b]

for a in range(10**3+1):
    if cnt[a] < 2:
        continue
    ans += ((cum[2*a-1]-cnt[a])*cnt[a]*(cnt[a]-1))//2

for a in range(10**3+1):
    if cnt[a] < 3:
        continue
    ans += (cnt[a]*(cnt[a]-1)*(cnt[a]-2))//6

print(ans)

Measured memory_bytes: 3188
A, B, K = map(int, input().split())

ans = set([])

for i in range(A, A + K):
        if i > B:
                break
        ans.add(i)

for i in range(B - K + 1, B + 1):
        if i < A:
                continue
        ans.add(i)


for i in sorted(ans):
        print(i)

Measured memory_bytes: 38256
def pop_count(n):
    return sum(n >> i & 1 for i in range(n.bit_length()))


def f(n):
    if n == 0:
        return 0
    return f(n % pop_count(n)) + 1


N = int(input())
X = input()
p = X.count("1")
rem_plus = 0
rem_minus = 0
for i in range(N):
    k = N - i - 1
    if X[i] == "0":
        continue
    elif p > 1:
        rem_minus = (rem_minus + pow(2, k, p - 1)) % (p - 1)
    rem_plus = (rem_plus + pow(2, k, p + 1)) % (p + 1)
for i in range(N):
    k = N - i - 1
    if X[i] == "0":
        print(f((rem_plus + pow(2, k, p + 1)) % (p + 1)) + 1)
    elif p > 1:
        print(f((rem_minus - pow(2, k, p - 1)) % (p - 1)) + 1)
    else:
        print(0)


Measured memory_bytes: 9520
#include <bits/stdc++.h>
    using namespace std;
    
    typedef long long ll;
    
    int main(){
        ll n;
        vector<ll> v;
        
        cin >> n;
        ll c;
        ll ans = 0;
        for(ll i = 0; i < n ; i++){
            cin >> c;
            v.push_back(c);
        }
        sort(v.begin() , v.end());
        ll d = n / 2;
        if(v[d - 1] == v[d]){
            
        }else{
            ans = v[d] - v[d - 1];
        }
        
        cout << ans << endl;
        
        return 0;
        
    }

Measured memory_bytes: 1528
from collections import deque
input_list = list(input())

left_idx_stack = deque()
puddle_stack = deque()

for idx, s in enumerate(input_list):
    if s == "\\":
        left_idx_stack.append(idx)
    
    elif s == '/':
        if left_idx_stack:
            latest_left_idx = left_idx_stack.pop()
            area = idx - latest_left_idx
        
            if not puddle_stack:
                puddle_stack.append((latest_left_idx, area))
            
            elif latest_left_idx > puddle_stack[-1][0]:
                puddle_stack.append((latest_left_idx, area))
            else:
                
                while len(puddle_stack) != 0 and (latest_left_idx < puddle_stack[-1][0]):
                    latest_puddle = puddle_stack.pop()
                    area += latest_puddle[1]
                    
                puddle_stack.append((latest_left_idx, area))
        else:
            pass
areas = [p[1] for p in puddle_stack]
print(sum(areas))
print(len(areas), *areas)



Measured memory_bytes: 6916
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define INF (int)1e9+1
#define INFLL (int)1e18+1
#define sz(bb) (int)bb.size()
#define all(qq) qq.begin(), qq.end() 
#define Max(a, b, c) max(a, max(b, c))
#define Min(a, b, c) min(a, min(b, c))
const double PI=acos(-1);
// #define int unsigned long long int//used when x<=2^64-1 && x>0
#define int long long//used when x<=2^63-1
//bool cmp if returns true it keeps 1st as first else swaps
typedef long long  ll;

void solve()
{
    int n;
    cin>>n;
    double prob[n];
    for(int i=0;i<n;i++)
        cin>>prob[i];
    double dp[n+1][n+1];// dp[i][j] means till toss 'i' times having 'j' heads 
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        dp[i][0]=(1-prob[i-1])*dp[i-1][0];
        dp[0][i]=0;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            dp[i][j]=prob[i-1]*(dp[i-1][j-1]); //heads
            dp[i][j]+=(1-prob[i-1])*(dp[i-1][j]);
        }
    }
    double ans=0;
    for(int i=n/2+1;i<=n;i++)
    {
        ans+=dp[n][i];
    }
    cout<<fixed<<setprecision(10)<<ans<<"\n";
}
int32_t main()
{
    IOS;
    int t;
    // cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 74112
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

vector<ll> digitsSums;

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

    int N; cin >> N;
    digitsSums.resize(N);

    rep(i, 0, N) {
        int num = i;
        ll digitsSum = 0;

        while (num > 0) {
            digitsSum += num % 10;
            num /= 10;
        }

        digitsSums[i] = digitsSum;
    }

    ll res = 2000000000;
    rep(A, 1, N) {
        ll B = N - A;
        ll sum = digitsSums[A] + digitsSums[B];
        res = min(res, sum);
    }

    cout << res << "\n";
}

Measured memory_bytes: 1024
#include "iostream"
#include "vector"
#include "array"
#include "string"
#include "algorithm"
#include "functional"
#include <math.h>
#include "tuple"


using namespace std;
#define rep(p,q) for(int i = p;i < q;i++)

//C
int main(void) {
	long long int k, a, b;
	cin >> k >> a >> b;
	if (b - a < 2 || k <= a) {
		cout << k + 1 << endl;
	}
	else {
		int hoge = (k - (a - 1)) / 2;
		switch ((k - (a-1))%2)
		{
		case 0:
			
			cout << (b-a)*(k - (a - 1)) / 2 + a << endl;
			break;
		case 1:
			cout << 1 + a + (b-a)*(k - (a - 1) - 1) / 2 << endl;
			break;
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < n; i ++)
#define for1(i, n) for (int i = 1; i <= n; i ++)
#define repn(i, n) for (int i = n-1; i >= 0; i --)
#define rep1(i, n) for (int i = n; i >= 1; i --)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define f first
#define s second
using namespace std;
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
typedef long long ll;
const int INF = 1e9;
const ll INFl = 1e18;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<ll> vll;
typedef queue<int> qi;
typedef queue<pii> qpii;

void test_case() {
	int n, k; cin >> n >> k;
	vi a(n);
	forn (i, n) {
		cin >> a[i];
	}
	sort(all(a));
	int sum = 0;
	for (int i = 0; i < k; i ++) sum += a[i];
	cout << sum << '\n';
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int q = 1; 
	//cin >> q;
	while (q--) {
		test_case();
	}
	return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[100]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << a[k-1] << endl;
}

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

using namespace std;

struct ang {
	const long *x, *y;
	int m;
	ang(const long *x, const long *y, int m) :x(x), y(y), m(m) {}
	bool operator()(int i, int j) const {
		auto t = (x[i] - x[m])*(y[j] - y[m]) - (x[j] - x[m])*(y[i] - y[m]);
		if (t) return t < 0;
		if (x[i] == x[j])
			return y[i] < y[j];
		return x[i] < x[j];
	}
};

int main()
{
	int n;
	cin >> n;
	long x[111], y[111];
	for (int i = 0; i < n; i++)
		cin >> x[i] >> y[i];
	int s = 0;
	for (int i = 0; i < n; i++) {
		if (x[i] > x[s])
			continue;
		if (x[i] < x[s] || y[i] < y[s])
			s = i;
	}
	vector<int> v, w(n);
	for (int i = 0; i < n; i++)
		w[i] = i;
	sort(w.begin(), w.end(), ang(x, y, s));
	for (auto s : w) {
		while (v.size() > 1 && (x[s] - x[v.rbegin()[1]])*(y[s] - y[v.back()]) >= (x[s] - x[v.back()])*(y[s] - y[v.rbegin()[1]]))
			v.pop_back();
		v.push_back(s);
	}
	v.push_back(v[0]);
	v.push_back(v[1]);
	double res[111] = {};
	for (int i = 0; i < v.size() - 2; i++) {
		long a = (x[v[i + 1]] - x[v[i]])*(x[v[i + 2]] - x[v[i + 1]]) + (y[v[i + 1]] - y[v[i]])*(y[v[i + 2]] - y[v[i + 1]]);
		long b = (x[v[i + 1]] - x[v[i]])*(x[v[i + 1]] - x[v[i]]) + (y[v[i + 1]] - y[v[i]])*(y[v[i + 1]] - y[v[i]]);
		long c = (x[v[i + 2]] - x[v[i + 1]])*(x[v[i + 2]] - x[v[i + 1]]) + (y[v[i + 2]] - y[v[i + 1]])*(y[v[i + 2]] - y[v[i + 1]]);
		assert(a < 0 || (a % 824982541 * (a % 824982541) - b % 824982541 * (c % 824982541)) % 824982541);
		double co = a;
		co /= sqrt(double(b)*c);
		res[v[i + 1]] = acos(co) / 2 / 3.14159265358979;
	}
	cout.precision(18);
	for (int i = 0; i < n; i++)
		cout << res[i] << '\n';
	cout << flush;
	return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <string>
#include <iostream>
int n;
std::string s, t;
int main()
{
	
	std::cin >> n >> s >> t;
	for (int i = 0; i < n; i++)
	{
		if (equal(s.begin() + i, s.end(), t.begin()))
		{
			printf("%d\n",n+i);
			return 0;
		}
	}
	printf("%d\n",n*2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//________
#define pb push_back
#define fi first
#define se second
#define mkp make_pair
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define show(x) cerr << #x << ':' << (x) << endl
#define outl(x) cout << (x) << '\n'
#define FAST() cin.tie(0), ios::sync_with_stdio(false)

typedef long long ll;
typedef pair<int,int> Pii;
template<class A, class B>inline bool chmax(A &a, B b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, B b){return b<a ? a=b,1 : 0;}
inline bool inside(int y, int x, int H, int W){return(y>=0 && x>=0 && y<H && x<W);}
const int INF = 1 << 29;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
#define Size 1000011
//________

map<int, int> cnt;

signed main()
{
    FAST();
    int N;
    int a[100005];
    cin >> N;
    rep(i,N){
        cin >> a[i];
        cnt[ a[i] ]++;
    }
    int sum = 0;

    for(map<int,int>::iterator it = cnt.begin(); it != cnt.end(); ++it){
        if(it -> se < it -> fi){
            sum += it -> se;
        }
        else{
            sum += (it-> se - it -> fi);
        }
    }
    outl( sum );
}



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

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define dbg(x) true
#endif

void solve(long long a, long long b, long long c, long long d) {
  cout << max(max(a * c, a * d), max(b * c, b * d)) << endl;
}

int main() {
  long long a;
  scanf("%lld", &a);
  long long b;
  scanf("%lld", &b);
  long long c;
  scanf("%lld", &c);
  long long d;
  scanf("%lld", &d);
  solve(a, b, c, d);
  return 0;
}


Measured memory_bytes: 3760
from collections import Counter
from operator import add, mul
from functools import reduce
import bisect


def nCr(n, r):
    r = min(r, n - r)
    num = reduce(mul, range(n, n - r, -1), 1)
    den = reduce(mul, range(1, r + 1), 1)
    return num // den


N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0


for i in range(1, N - 1):
    for j in range(i + 1, N):
        k = bisect.bisect_left(L, L[j] - L[i] + 1, 0, i)
        ans += i - k
print(ans)


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

int main(void){
    int n, a[205], b[205], c[205], d[205];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    for (int i = 0; i < n; i++) cin >> c[i] >> d[i];
    
    int xc[205], xy[205];
    for (int i = 0; i < 2 * n; i++) {
        for (int j = 0; j < n; j++) {
            if (a[j] == i) {
                xc[i] = 0;  xy[i] = b[j]; // 0:red, 1:blue
            }
        }
        for (int j = 0; j < n; j++) {
            if (c[j] == i) {
                xc[i] = 1;  xy[i] = d[j]; // 0:red, 1:blue
            }
        }
    }
    
    
    int blue[105], bluep = 0, ans = 0;
    for (int i = 0; i < 102; i++) blue[i] = 1000;
    for (int i = 2 * n - 1; i >= 0; i--) {
        if (xc[i] == 0) { // red
        int cand = 1000;
            for (int j = bluep - 1; j >= 0 && bluep != 0; j--) {
                if (blue[j] < xy[i]) {
                    cand = j + 1;  break;
                }
            }
          	if (blue[0] > xy[i]) cand = 0;
            if (cand != n && blue[cand] < 1000) {
                ans++;
                blue[cand] = 1000;
                bluep--;
            } 
        }
        else { // blue
            blue[bluep] = xy[i];
            bluep++;
        }
        sort(blue, blue + bluep + 1);
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 256
////*24-AUG-19*///
//Why do we fall?//
// So we can learn to pick ourself up!//
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define endl "\n"
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fr(a,b,c) for(int a=b; a<c; a++)
#define frr(a,b,c) for(int a=b;a>=c;a--)
#define pb push_back
#define pii pair<int,int>
#define R(a) ll a; cin >> a;
#define RA(a, n) ll a[(n) + 1] = {}; fr(i, 1, (n)+1) {cin >> a[i];}
#define RM(a, n, m) int a[n + 1][m + 1] = {}; fr(i, 1, n) {fr(j, 1, m) cin >> a[i][j];}
#define reset(X) memset(X, 0, sizeof(X))
const int inf = 1e18;
const int mod=1e9+7;
unsigned int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
bool isPrime(int n)
{   if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
    }

    //z function -  z[i] is the length of the longest common prefix between s and the suffix of s starting at i
vector<int>z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}
signed main()
{
    fastio;
    int n;
    cin>>n;
    int dp[3];
    reset(dp);
    fr(i,0,n)
    {
        int a[3];
        fr(j,0,3)
        {
            cin>>a[j];
        }
        int new_dp[3];
        reset(new_dp);
        fr(i,0,3)
        {
             int mx=0;
            fr(j,0,3)
            {

                if(i!=j)
                {
                  new_dp[j]=max(new_dp[j],dp[i]+a[j]);
                }
            }
        }
       fr(k,0,3)dp[k]=new_dp[k];
    }
    cout<<max({dp[0],dp[1],dp[2]});
}


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

int main()
{
    string s;
    cin >> s;

    string t;

    int alf[26] = {};
    for (auto x: s) alf[x - 'a']++;

    char c;
    bool f = true;
    string tt = s;
    for (int i = 0; i < 26; i++) {
        if (!alf[i]) {
            f = false;
            c = 'a' + i;
            tt += c;
            break;
        }
    }

    for (int i = s.size() - 1; i > 0; i--) {
        if (s[i] > s[i - 1]) {
            char cc = s[i - 1];
            for (int k = i; k < s.size(); k++) {
                alf[s[k] - 'a']--;
            }
            for (int j = 0; j < 26; j++) {
                if (!alf[j] && j > cc - 'a') {
                    cc = 'a' + j;
                    break;
                }
            }
            t = s.substr(0, i - 1);
            t += cc;
            break;
        }
    }

    if (f) {
        if (t == "") cout << -1;
        else cout << t;
    }
    else if (t == "") cout << tt << endl;
    else if (t < tt) cout << t;
    else cout << tt;
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

#include <stdlib.h>

using namespace std;

int main()
{
    bool IsRevd = false;
    char *S;
    int Q_Len;
    S = (char *)calloc(1, 100001);
    cin >> S;
    cin >> Q_Len;

    char *Top, *Last;
    int TopCount = 0, LastCount = 0;
    //0 ... 100000
    //S ... Top
    Top = (char *)calloc(1, Q_Len);
    //0 ... 100000
    //S ... Last
    Last = (char *)calloc(1, Q_Len);
    char cmdarr[6];
    int cmd = 0, F = 0;
    char C;
    for (int i = 1; i <= Q_Len; i++)
    {
        scanf("%d", &cmd);
        if (cmd == 2)
            cin >> F >> C;
        //cout << ">>>" << cmd << '|' << F << '|' << C << endl;

        if (cmd == 1)
            IsRevd = !IsRevd;
        else if ((F == 1 && IsRevd) || (F == 2 && !IsRevd))
        {
            Last[LastCount] = C;
            LastCount++;
        }
        else
        {
            Top[TopCount] = C;
            TopCount++;
        }
    }
    int i = 0;
    if (IsRevd)
    {
        for (i = LastCount - 1; i >= 0; i--)
            printf("%c", Last[i]);
        for (i = 100000; i >= 0; i--)
            if (S[i] != '\0')
                printf("%c", S[i]);
        for (i = 0; i < TopCount; i++)
            printf("%c", Top[i]);
    }
    else
    {
        for (i = TopCount - 1; i >= 0; i--)
            printf("%c", Top[i]);
        for (i = 0; S[i] != '\0'; i++)
            printf("%c", S[i]);
        for (i = 0; i < LastCount; i++)
            printf("%c", Last[i]);
    }
}

Measured memory_bytes: 896
/********** BiSmIlLaHiR rAhMaNiR rAhIm ***********\
*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*
*$*                                             *$*
*$*    ||||||||  ||||||||  ||||||||  ||||||||   *$*
*$*    ||    ||  ||           ||     ||         *$*
*$*    ||||||||  ||||||||     ||     ||||||     *$*
*$*    ||    ||        ||     ||     ||         *$*
*$*    ||    ||  ||||||||  ||||||||  ||         *$*
*$*                                             *$*
*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*
\*************** DIIT(17th batch) ****************/

#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define pf printf
#define sf scanf
#define endl "\n"
#define pb push_back
#define makep make_pair
#define MOD 1000000007
#define PI acos(-1.0)
#define PII pair<string , ll> 
#define SIZE 1000005
#define fio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
ll fx[]={1,0,-1,0,-1,-1,1,1};
ll fy[]={0,1,0,-1,-1,1,-1,1};

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    fio();
    ll n,b,r,p,q,ans;
    cin>>n>>b>>r;
    p=n/(b+r);
    q=n%(b+r);
    ans=(p*b)+min(q,b);
    cout<<ans<<endl;
    return 0;
}
// ! () &

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, n) for (ll i = (a); i < (n); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _per(i, n) peri(i, 0, n)
#define peri(i, a, n) for (ll i = (n) - 1; i >= (a); --i)
#define per(...) _overload3(__VA_ARGS__, peri, _per)(__VA_ARGS__)
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T> inline void chmax(T& a, const T& b) {if (a < b) a = b;}
template<typename T> inline void chmin(T& a, const T& b) {if (a > b) a = b;}
template<typename T> inline void print(const T& x) {cout << x << "\n";}
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p) {is >> p.fi >> p.se; return is;}
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) {os << p.fi << " " << p.se; return os;}
template<typename T> istream& operator>>(istream& is, vector<T>& v) {each(in, v) is >> in; return is;}
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {rep(i, sz(v)) {os << v[i] << (i + 1 != sz(v) ? " " : "");} return os;}
struct Init {Init() {ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(10);}} init;


int main() {
    ll n; cin >> n;
    string m; cin >> m;
    ll idx = find(all(m), '.') - m.begin();
    ll a = stoi(m.substr(0, idx));
    ll b = stoi(m.substr(idx + 1));
    ll mm = a * 100 + b;
    ll ans = n * mm;
    print(ans / 100);
    
}

Measured memory_bytes: 3656
#include <stdio.h>
int main () {
  char arr[4] ;

  for (int i = 0 ; i < 4 ; ++i){
    scanf ("%s",&arr[i]) ;
  }

  int n = 0  ;
  for (int j = 0 ; j < 4 ; ++j ){
    if ( arr[j] == '+'  ){
        n = n + 1 ;
    } else {
        n -= 1 ;
    }
  }
    printf ("%d", n) ;
}


Measured memory_bytes: 128
n = gets.to_i
s = gets.chomp
max = 0
1.upto(n - 1){|i|
    a = s[0, i].split("").to_a.uniq
    b = s[i..-1].split("").to_a.uniq
    x = (a - (a - b)).length
    max = x if max < x
}
puts max


Measured memory_bytes: 1916
N,M = map(int,input().split())
nums = []
for _ in range(M):
    nums.append(list(map(int,input().split())))
    
if N == 1 and M == 0:
    print(0)
    exit()
for i in range(0,1000):
    if len(str(i)) == N:
        for j in range(M):
            s = nums[j][0]
            c = nums[j][1]
            if int(str(i)[s-1]) != c:
                break
        else:
            print(i)
            exit()
print(-1)

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

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589

using namespace std;

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

void solve_A(){
    int n,r;
    cin >> n >> r;
    if(n >= 10) cout << r;
    else cout << r + 100 * (10-n);
}

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

Measured memory_bytes: 256
#include<stdio.h>

int main(){

  int a,b,c,x;
  int ans=0;
  scanf("%d %d %d",&a,&b,&c);
  for(x=a;x<=b;x++){
      if(c%x==0){
      ans++;
    }
  }
    printf("%d\n",ans);
  
  return 0 ;
  }


Measured memory_bytes: 2104
#include"bits/stdc++.h"


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PL pair<ll,int>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 1010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n;

int C[maxn][4];

map<ll,int> has;

ll ans=0;

int tmp[maxn];

ll ned[4];

PL calc(int *a){
	ll f=1e18;int g=0;
	REP(i,0,3){
		ll t=0;
		REP(j,0,3)t=t*1000+a[(i+j)&3];
		if(t<f)f=t,g=1;
		else if(t==f)g++;
	}
	return MP(f,g);
}

void Work(){
	REP(i,1,n)
		REP(j,i+1,n){
			has[calc(C[i]).fi]--;has[calc(C[j]).fi]--;
			REP(k,0,3){
				ll t=1;
				REP(l,0,3){
					tmp[0]=C[i][(l+1)&3];
					tmp[1]=C[i][l];
					tmp[2]=C[j][(k-l)&3];
					tmp[3]=C[j][(k-l-1)&3];
					PL res=calc(tmp);
					t*=res.se%mod;
					ned[l]=res.fi;
				}
				REP(l,0,3)t*=has[ned[l]]--;
				REP(l,0,3)has[ned[l]]++;
				ans+=t;
			}
			has[calc(C[i]).fi]++;has[calc(C[j]).fi]++;
		}
	cout<<ans/3<<endl;
}

void Init(){
	read(n);
	REP(i,1,n)REP(j,0,3)read(C[i][j]);
	REP(i,1,n)has[calc(C[i]).fi]++;
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 80128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define ld long double
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define getchar gc
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=100005;
int tong[N<<1],a[N],n,k;
ll check(int x){
	memset(tong,0,sizeof(tong));
	int dq=n,dd=1; ll ans=0;
	tong[n]=1; 
	for(int i=1;i<=n;i++){
		if(a[i]>=x){
			dq++; dd+=tong[dq];
		}else{
			dd-=tong[dq]; dq--;
		}
		ans+=dd; tong[dq]++; dd++;
	}
	return ans;
}
signed main(){
	n=read(); ll k=((ll)n*(n+1)/2+1)/2;
	for(int i=1;i<=n;i++)a[i]=read(); //cout<<check(30)<<endl; return 0;
	int l=1,r=1e9;
	while(l<r){
		int mid=(l+r)>>1; mid++;
		if(check(mid)>=k)l=mid; else r=mid-1;
	}
	cout<<l<<endl;
}

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

using ll = long long;

const ll INF = 4e18;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	array<ll, 2> dp = {0, -INF};
	for (int i = 0; i < N; i++) {
		ll v; cin >> v;
		array<ll, 2> ndp = {-INF, -INF};
		for (int a = 0; a < 2; a++) {
			for (int b = 0; b <= int(i < N-1); b++) {
				ndp[b] = max(ndp[b], dp[a] + v * ((a + b) % 2 ? -1 : 1));
			}
		}
		dp = move(ndp);
	}
	ll ans = dp[0];
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include<cstring>

using namespace std;

int h,w;
int c[10][10];

struct info{
  int from;
  int to;
  int passed;
  int cost;
  info(int a,int b,int c,int d){
    from = a;
    to = b;
    passed = c;
    cost = d;
  }
};

int solve(int n){
  queue<info> que;
  int Min = 111111111;
  for(int i = 0;i<10;i++){
    if(i == n)
      continue;

    int passed = 1<<i;
    que.push(info(n,i,passed,c[n][i]));
  }
  
  while(!que.empty()){
    auto q = que.front();
    que.pop();
    if(q.to == 1){
      Min = min(Min,q.cost);
      //cout<<Min<<endl;
    }else{
      for(int i = 0;i<10;i++){
	if(i == q.to){
	  continue;
	}else{
	  if((q.passed & (1<<i)) == 0){
	    que.push(info(q.to,i,(q.passed|1<<i),q.cost + c[q.to][i]));
	    auto b = que.back();
	    //cout<<"test:"<<b.from<<"\t"<<b.to<<"\t"<<b.passed<<"\t"<<b.cost<<endl;
	    
	  }
	}
      }
    }
  }
  return Min;
}

int main(){
  cin>>h>>w;
  for(int i = 0;i<10;i++){
    for(int j = 0;j<10;j++){
      cin>>c[i][j];
    }
  }
  int cost[10];
  cost[1] = 0;

  // cout<<solve(8)<<endl;
  
  for(int i = 0;i<10;i++){
    if(i == 1)
      continue;
    cost[i] = solve(i);
  }
  int ans = 0;
  for(int i = 0;i<h;i++){
    for(int j = 0;j<w;j++){
      int a;
      cin>>a;
      if(a!=-1)
	ans += cost[a];
    }
  }
  cout<<ans<<endl;
  
  
  return 0;
}


Measured memory_bytes: 10936
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    string s;
    int k;
    cin >> k;
    cin >> s;
    int n = s.size();
    if (n <= k) {
        cout << s << endl;
    } else {
        cout << string(s.begin(), s.begin() + k) << "..." << endl;
    }
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std; 
int main(){
  int N;
  cin >> N;
  int uns[N], sor[N]; 
  for (int i = 0; i < N; i++){
    cin >> uns[i];
    sor[i] = uns[i]; 
  }
  sort(sor,sor + N); 
  int count = 0; 
  for (int i = 0; i < N; i++){
    if (uns[i] != sor[i]){
      count++; 
    }
  }
  if (count == 0 || count == 2){
    cout << "YES";
  } else {
    cout << "NO"; 
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

ll c[51][51];
int main(){
    int N, A, B; cin >> N >> A >> B;
    
    vector<ll> v(N);
    rep(i,N) cin >> v[i];

    sort(v.rbegin(), v.rend());

    // パスカルの三角形により二項係数を求める
    c[0][0] = 1;
    for (int i = 1; i <= 50; i++){
        for (int j = 0; j <= i; j++){
            c[i][j] += c[i-1][j];
            if (j > 0) c[i][j] += c[i-1][j-1];
        }
    }

    // 平均値の最大を求める
    ll sum = 0;
    rep(i,A){
        sum += v[i];
    }
    double ave = (double)sum/A;

    // 降順でA個目の価値と同じ数字の数を求める
    int ath_count = 0;
    rep(i,N){
        if (v[i] == v[A-1]) ath_count++;
    }

    ll ans = 0;
    // 降順でA個目まですべて同じ数値の場合
    if (v[0] == v[A-1]){
        for (int i = A; i <= B;i++){
            if (v[0] != v[i-1]) break;
            ans += c[ath_count][i];
        }
    }
    else{
        // A個目まででA番目と同じ数字の数を求める
        int ath_count_till_A = 0;
        rep(i,A) {
            if (v[i] == v[A-1]) ath_count_till_A++;       
        }
        ans = c[ath_count][ath_count_till_A];
    }
    cout << fixed << setprecision(20) << ave << endl;
    cout << ans << endl;
}

Measured memory_bytes: 3764
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define INF 1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

int main(void) {
    while(1) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        VI time(60 * 60 * 24 + 1);
        for (int i = 0; i < n; i++) {
            int s_h;
            int s_m;
            int s_s;
            int e_h;
            int e_m;
            int e_s;
            scanf("%d:%d:%d %d:%d:%d", &s_h, &s_m, &s_s, &e_h, &e_m, &e_s);
            int start = 60 * 60 * s_h + 60 * s_m + s_s;
            int end = 60 * 60 * e_h + 60 * e_m + e_s;
            for (int j = start; j < end; j++) {
                time[j]++;
            }
        }
        int res = 0;
        for (int i = 0; i < (int)(time.size()); i++) {
            res = std::max(res, time[i]);
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)
typedef long long ll;
const ll mod = 1e9 + 7;
const ll N = 3e5 + 7;



int main() {
	fastIO;
	int n;
	cin >> n;
	cout << n / 2 + (n & 1);
}

Measured memory_bytes: 3616
# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    ans = 0
    endA = 0
    startB = 0
    ryouhou = 0
    # Aで終わるs1と、Bで始まるs2を連結させれば1個増える
    for i in range(N):
        s = input()
        if s[-1]=="A" and s[0]=="B":
            ryouhou += 1
        elif s[-1]=="A":
            endA += 1
        elif s[0]=="B":
            startB += 1
        
        ans += s.count("AB")
    

    if endA>=1 and startB>=1 and ryouhou>=1:
        ans += min(endA-1, startB-1)
        ans += ryouhou + 1
        print(ans)
        return
    elif ((endA>=1 and startB==0 and ryouhou>=1) or
          (endA==0 and startB>=1 and ryouhou>=1)):
        ans += ryouhou
        print(ans)
        return
    elif endA==0 and startB==0 and ryouhou>=1:
        ans += ryouhou-1
        print(ans)
        return
    else:
        # ryouhou==0のとき
        ans += min(endA, startB)
        rest = abs(max(endA, startB) - min(endA, startB))
        
        ans += min(rest, ryouhou)
        rest = ryouhou - rest
        if rest <= 0:
            print(ans)
            return
        else:
            ans += rest//2
            print(ans)
            return

if __name__ == "__main__":
    solve()


Measured memory_bytes: 3064
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BDistance {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N, D;
        cin >> N >> D;

        int res = 0;
        REP(i, N) {
            int x, y;
            cin >> x >> y;
            if (x * x + y * y <= D * D) {
                res++;
            }
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BDistance solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3572
"use strict";

main(require("fs").readFileSync("/dev/stdin", "UTF-8"));

function main(input) {
  let integer_num = parseInt(input.split("\n")[0]);

  let odd_count = 0; //奇数の時、カウントされる

  for (let i = 1; i <= integer_num; i++) {
    if (i % 2 === 1) {
      odd_count++;
    }
  }

  console.log(odd_count / integer_num);
}


Measured memory_bytes: 7372
#include<iostream>
#include<cstdio>
#include<cmath>
typedef long long int lli;
using namespace std;
int main()
{
    lli L,R,ans=1<<30,temp;
    cin >> L >> R;
	if(L/2019!=R/2019)
	{
		cout<<"0";
		return 0;
	}
    for (lli i=L;i<=R ;i++ )
    {
        for (lli j=i+1;j<=R ;j++ )
        {
            temp = ((i%2019)*(j%2019))%2019;
            if(temp < ans)
                ans= temp;
        }
    }
    cout << ans;
    return 0;

}


Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{   
    class Template
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var a = new long[s.Length + 1];
            var b = new long[s.Length + 1];
            a[s.Length] = 0L;
            b[s.Length] = 1L;
            for (int i = s.Length - 1; i >= 0; --i)
            {
                var v = 0L;
                for (int j = i + 1; j <= s.Length; ++j)
                {
                    v = v * 10L + (s[j - 1] - '0');
                    a[i] += a[j] + v * b[j];
                    b[i] += b[j];
                }
            }
            Console.WriteLine(a[0]);
        }
    }

    public class IO
    {
        public static string ReadStr() => Console.ReadLine();
        public static string[] ReadStrArr() => ReadStr().Split(' ');
        public static int ReadInt() => int.Parse(ReadStr());
        public static int[] ReadIntArr() => Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        public static double ReadDouble() => double.Parse(ReadStr());
        public static double[] ReadDoubleArr() => Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
        public static long ReadLong() => long.Parse(ReadStr());
        public static long[] ReadLongArr() => Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
    }
}


Measured memory_bytes: 11092
if __name__ == '__main__':
    f = lambda: map(int, input().split())
    A, B, K = f()
    c = 0
    for x in range(1, 1 + max(A, B))[::-1]:
        if (A % x == 0) and (B % x == 0):
            c += 1
        if c == K:
            print(x)
            exit()


Measured memory_bytes: 2940