akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

ll lcm(ll u, ll v) {
  return u*v/gcd(u,v);
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll n,a,b,c,d,qr,wr;
  string s;
  cin >> n >> a >> b >> c >> d;
  cin >> s;
  a--;
  b--;
  c--;
  d--;
  qr=n-1;
  wr=n-1;
  FOR(i,a,n-1){
    if(s[i]=='#'&&s[i+1]=='#'){
      qr=i-1;
      break;
    }
  }
  FOR(i,b,n-1){
    if(s[i]=='#'&&s[i+1]=='#'){
      wr=i-1;
      break;
    }
  }
  if(d<c){
    FOR(i,b-1,d){
      if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.')goto A;
    }
    printf("No");
    return 0;
    A:;
  }
  if(qr<c||wr<d){
    printf("No");
    return 0;
  }
  printf("Yes");
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <cstdio>
#include <cmath>
using namespace std;
int main() {
	int rate;
	cin >> rate;
	if (rate < 1200)cout << "ABC" << endl;
	else cout << "ARC" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

int main() {
	double q;
	while(cin >> q, q != -1) { 
		double x1, x2;
		x1 = q/2;
		
		while(!(abs(x1*x1*x1-q) < 0.00001*q)) {
			x2 = x1 - ((x1*x1*x1-q) / (3*x1*x1));
			x1 = x2;
		}

		printf("%.6f\n", x1);
	}
}

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

 int main(){
 	int N,A,B;
 	cin >> N >>  A >> B; 
 	if(N*A>B){
 		cout << B << endl;
 	}
 	else{
 		cout << N*A << endl;
 	}
 	 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
int main(){
  int X, Y; cin >> X >> Y;
  if((X+Y)%3!=0){
    cout << 0 << endl;
    return 0;
  }
  int A=(2*X-Y)/3;
  int B=(2*Y-X)/3;
  int p=A+B;
  int b=min(A,B);
  if(b<0){
    cout << 0 << endl;
    return 0;
  }
  if(b==0){
    cout << 1 << endl;
    return 0;
  }
  combination c(p);
  mint ans=c(p,b);
  cout << ans.x << endl;
  return 0;
}
    
  

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

int main() {
  int64_t w,h;
  int x,y;
  cin>>w>>h>>x>>y;

  double ans = w/2.0*h;
  bool only;
  if(x*2==w && y*2==h) {
    only = false;
  }
  else only = true;
 
  cout<<ans<<' '<<(!only)<<endl;
  // cout<<fixed<<setprecision(10)<<ans<<' '<<(!only)<<endl;


  return 0;
}

Measured memory_bytes: 3780
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL W, H, x, y;
	in >> W >> H >> x >> y;

	out << std::fixed << std::setprecision(10);
	out << (long double)W * H / 2 << " " << (W % 2 == 0 && H % 2 == 0 && W / 2 == x && H / 2 == y ? 1 : 0) << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

int N;

void dfs(string s, char mx) {
  if(s.length() == N) {
    cout << s.c_str() << endl;
  } else {
    for(char c = 'a'; c <= mx; c++) {
      if (c == mx) {
        dfs(s + c, mx + 1);
      } else {
        dfs(s + c, mx);
      }
    }
  }
}

void solve(istream& cin, ostream& cout) {
  cin >> N;
  dfs("", 'a');
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000001
#define MAXN        100005
#define mod         1000000007
using namespace std;



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,i,x,y,count=0,mx=0,p,j,sum=0;
    cin>>n>>m;
    ll a[n+1];
    for(i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    vector<pair<ll,ll> > vi;
    for(i=0;i<m;i++){
        cin>>x>>y;
        vi.pb({y,x});
    }
    sort(vi.begin(),vi.end());
    x=vi[m-1].ff;
    y=vi[m-1].se;
    j=m-1;
    priority_queue<ll> pq;
    for(i=n;i>=1;i--){
        if(a[i]<x){
            if(!pq.empty()){
                if(pq.top()>x){
                    p=a[i];
                    a[i]=pq.top();
                    pq.pop();
                    pq.push(p);
                }
                else{
                    if(j>=0 && y!=0){
                        pq.push(a[i]);
                        a[i]=x;
                        y--;
                        if(y==0 && j>=1){
                            j--;
                            x=vi[j].ff;
                            y=vi[j].se;
                        }    
                    }
                    else{
                        p=a[i];
                        a[i]=pq.top();
                        pq.pop();
                        pq.push(p);
                    }
                }
            }
            else{
                if(j>=0 && y!=0){
                    pq.push(a[i]);
                    a[i]=x;
                    y--;
                    if(y==0 && j>=1){
                        j--;
                        x=vi[j].ff;
                        y=vi[j].se;
                    }    
                }
            }
        }
    }
    for(i=n;i>=1;i--){
        sum+=a[i];
    }
    cout<<sum;
}

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

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


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

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

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

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

bool fn_is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

bool isOK(int index, int key, vector<ll>& a) {
    if (a[index] >= key) return true;
    else return false;
}

int binary_search(int key, vector<ll>& a) {
    int ng = -1;
    int ok = a.size();

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key, a)) ok = mid;
        else ng = mid;
    }
    return ok;
}

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


Measured memory_bytes: 3620
import Control.Applicative

main = do [w,h,x,y,r] <- (map read::[String]->[Int]) . words <$> getLine
          putStrLn $ if solve w h x y r then "Yes" else "No"

solve :: Int -> Int -> Int -> Int -> Int -> Bool
solve w h x y r | x-r>=0 && x+r<=w && y-r>=0 && y+r<=h = True
                | otherwise = False

Measured memory_bytes: 3664
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin


def walk(index, tm, L, d, f):
    tm += 1
    d[index] = tm
    for i in L[index]:
        if not d[i-1]:
            tm = walk(i-1, tm, L, d, f)
    tm += 1
    f[index] = tm
    return tm


def main():
    num = int(stdin.readline())

    L = []
    for _ in xrange(num):
        L.append([int(s) for s in stdin.readline().split()[2:]])

    d = [0] * num
    f = [0] * num
    tm = 0
    for i in xrange(num):
        if not d[i]:
            tm = walk(i, tm, L, d, f)

    for i in xrange(num):
        print(i+1, d[i], f[i])


main()

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

int main(){

  int cnt=0;
  string s;

  cin>>s;

  for(int i=1;i<s.length();i++){
    if(s[i-1]!=s[i]) cnt++;
  }

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define F(i,a,b) for(int i=a;i<b;i++)
#define RF(i,a,b) for(int i=a;i>b;i--)
#define mp(a,b) make_pair(int a,int b)
#define ll long long
const int mxn=1e3+10,mxm=4e5+10,modl=1e9+7;
int nm,n,m,p,t,ans,sum;
int a[mxn],b[mxn],h[mxn];
//string s[mxn];
//bool in[mxn][mxn];
//int tr[][2]={{0,-1},{-1,0},{0,+1}};
//struct pos{
//    int x,y;
//    bool operator < (const pos b)const{
//        return h[x][y]>h[b.x][b.y];
//    }
//};
bool cmp(string a,string b){
    return a+b<b+a;
}
int main(){
    ios_base::sync_with_stdio(false);
//    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
//    cin>>nm;
//    string s,s2;
    while(cin>>p>>t){
//        priority_queue<int,vector<int>,greater<int>>q;
        F(i,t*10,t*10+10){
            if(p==int(i*0.08)){
                cout<<i;
                return 0;
            }
        }
        cout<<"-1";
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
<?php
  function getKyori($x1, $y1, $x2, $y2){
    return sqrt(($x1-$x2)**2 + ($y1-$y2)**2);
  }

  $n = intval(fgets(STDIN));

  $positions = [];
  for($i=0; $i<$n; $i++){
    $positions[] = explode(" ", trim(fgets(STDIN)));
  }

  $kyoriArray = [];
  for($i=0; $i<$n-1; $i++){
    for($j=$i+1; $j<$n; $j++){
      $kyoriArray[] = getKyori($positions[$i][0], $positions[$i][1], $positions[$j][0], $positions[$j][1]);
    }
  }

  $average = array_sum($kyoriArray) / count($kyoriArray);

  echo $average * ($n-1);


Measured memory_bytes: 4728
S = int(input())
a = S
S_10 = 0

while a>=1 :
    a = a/10
    S_10 += 1

if S_10%2 ==0:
    S_10_2 = S_10//2
else:
    S_10_2 = (S_10+1)//2



x1 = 10**S_10_2
y2 = S//x1 +1
x2 = 1
y1 = x1 - S%x1


if S_10==19:
    print('0 0 1000000000 0 0 1000000000')
else:
    print('0 0'+' '+str(x1)+' '+str(y1)+' '+str(x2)+' '+str(y2))

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

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

  int len = sizeof(a) / sizeof(int);
  sort(a, a + len, std::greater<>());
  int alice = 0, bob = 0;
  for(int i=0; i<n; i++) {
    if(i % 2 == 0) alice += a[i];
    else bob += a[i];
  }

  cout << alice - bob << endl;
}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t n;
  cin >> n;
  int a;
  map<int,int> s;
  for(int i=0;i<n;i++){
    cin >> a;
    s[a] = i+1;
  }

  for(auto p:s){
    cout << p.second << " ";
  }
  cout << endl;
  return 0;
}




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

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

  int pos_c = 101;
  int pos_f = -1;
  for (int i = 0; i < s.size(); ++i) {
    if (pos_c == 101 && s[i] == 'C')
      pos_c = i;
    if (s[i] == 'F')
      pos_f = i;
  }

  if (pos_c < pos_f)
    puts("Yes");
  else
    puts("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define F first
#define S second
#define MP make_pair
#define PB push_back
 
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)
int main(){
	int a,b,h;
	cin>>a>>b>>h;
	int ans=0.5*(a+b)*h;
	wd(ans);
	return 0;
}

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

int n;
ll k, a[MAXN], f[MAXN];

bool check(ll u) {
    ll need = 0;
    FOR(i,1,n) {
        ll target = u / f[i];
        if (a[i] <= target) continue;
        need += a[i] - target;
    }
    return need <= k;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> k;
    FOR(i,1,n) cin >> a[i];
    FOR(i,1,n) cin >> f[i];
    sort(a+1, a+n+1);
    sort(f+1, f+n+1);
    FOR(i,1,n/2) swap(f[i], f[n-i+1]);
    ll dau = 0, cuoi = 1e13, mid;
    while (dau <= cuoi) {
        mid = (dau + cuoi) / 2;
        if (check(mid)) cuoi = mid-1;
        else dau = mid+1;
    }
    cout << dau;

    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
  int n,i,d[55],ans=1e9;
  vector<int> t;
  cin >> n;
  for (i=0;i<n;i++) cin >> d[i];
  sort(d,d+n);
  t.push_back(0);
  for (i=0;i<n;i++){
    if (i%2) t.push_back(d[i]);
    else t.push_back(-d[i]);
  }
  if ((n-1)%2) t.push_back(d[n-1]-24);
  else t.push_back(24-d[n-1]);
  sort(t.begin(),t.end());
  for (i=0;i<n+1;i++) if (ans > t[i+1]-t[i]) ans=t[i+1]-t[i];
  cout << ans << endl;
  return 0;
}

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

const int maxn = 2e5+5;
int n, a[maxn];

int main() 
{
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    map<int,int> mp; 
    ll ans = 0;
    for (int i = n-1; i >= 0; i--) {
        int target = -a[i]-i;
        ans += mp[target];
        ++mp[a[i]-i];
    }
    cout << ans << '\n';
}


Measured memory_bytes: 21332
#include <iostream>
using namespace std;
int main () {
    int x, a, b;
    cin >> x >> a >> b;

    int d_a, d_b;
    d_a = max(a-x, x-a);
    d_b = max(b-x, x-b);

    if (d_a < d_b) cout << "A" << endl;
    else cout << "B" << endl;

    return 0;
}

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

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

	int l=s.length();
	l--;

	while(1){
		bool flag=false;;
		if(l%2==0 && s[0]==s[l/2]){
			flag=true;

			for(int i=0;i<l/2;i++){
				if(s[0+i]!=s[i + l/2]){
					flag=false;
					break;
				}
			}
		}
		if(flag)break;
		else l--;

	}

	cout<<l<<endl;


	return 0;
}


Measured memory_bytes: 256
import java.util.*
import kotlin.comparisons.compareValuesBy

fun main(arg: Array<String>) {
    val k = readLine()!!.toInt()
    val edge = PriorityQueue<IntPair>()
    val score = Array<Int?>(k) { null }
    edge.add(IntPair(1, 1))
    while (edge.isNotEmpty()) {
        val pair = edge.poll()
        val next1 = (pair.second * 10) % k
        val next2 = (pair.second + 1) % k
        score[pair.second] = pair.first
        if (pair.second == 0) break
        if (score[next1] == null) edge.add(IntPair(pair.first, next1))
        if (score[next2] == null) edge.add(IntPair(pair.first + 1, next2))
    }
    println(score[0])
}

class IntPair(val first: Int, val second: Int) : Comparable<IntPair> {
    override fun compareTo(other: IntPair): Int = compareValuesBy(this, other, { it.first })
}


Measured memory_bytes: 40580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

ll f(ll x) {
    if (x==0) return 1;
    ll res = 1;
    rep(i, x) {
        res *= (ll)(i+1);
        res %= mod;
    }
    return res;
}


int main(){
    ll n, m;
    cin >> n >> m;
    if (abs(n-m)>1) {
        cout << 0 << endl;
        return 0;
    }
    if (n==m) {
        ll ans = 1;
        rep(i, 2) {
            ans *= f(n);
            ans %= mod;
        }
        ans *= 2;
        ans %= mod;
        cout << ans << endl;
        return 0;
    }
    ll ans = 1;
    ans *= f(n);
    ans %= mod;
    ans *= f(m);
    ans %= mod;
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
a, b, n = map(int, input().split())
ch = a*n//b
ans = 0
if ch < b:
  for i in range(1, min(ch + 1, n+1)):
    ans = max(ans, i-a*(i//a))
else:
  for i in range(min(b, n + 1)):
    ans = max(ans, (a*i//b) - a*(i//b))
print(ans)
    

Measured memory_bytes: 9004
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;


int main(){
  int A, B, C;
  cin >> A >> B >> C;
  int ans = 3;
  if(A == B && B == C) ans = 1;
  else if(A == B) ans = 2;
  else if(B == C) ans = 2;
  else if(A == C) ans = 2;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <queue>
#include <map>
#include <string>
const int INF = 99999999;
const int MIN = -0xffffff0;
using namespace std;

long long num[100];

int main(){
    num[0] = 2;
    num[1] = 1;
    for(int i=2;i<=86;i++) num[i] = num[i-1] + num[i-2];
    int n;
    while(cin >> n) cout << num[n] << endl;
    return 0;
}


Measured memory_bytes: 256
#n = int(input())
x1, y1, x2, y2 = map(int,input().split())
s = ''
a1 = 'R' * (x2 - x1)
b1 = 'U' * (y2 - y1)
a2 = 'L' * (x2 - x1)
b2 = 'D' * (y2 - y1)
a3 = 'D' + 'R' * (x2 - x1 + 1)
b3 = 'U' * (y2 - y1 + 1) + 'L'
a4 = 'U' + 'L' * (x2 - x1 + 1)
b4 = 'D' * (y2 - y1 + 1) + 'R'
s = a1 + b1 + a2 + b2 + a3 + b3 + a4 + b4
print(s)

Measured memory_bytes: 3064
def put_S(n, d) :
    global square
    if d == 0 :
        new_i = square[n][0] - 1
        new_j = square[n][1]
    elif d == 1 :
        new_i = square[n][0]
        new_j = square[n][1] - 1
    elif d == 2 :
        new_i = square[n][0] + 1
        new_j = square[n][1]
    elif d == 3 :
        new_i = square[n][0]
        new_j = square[n][1] + 1
        
    square.append([new_i, new_j])
    
while True :
    N = int(input())
    if N == 0 :
        break
    square = [[0, 0]]
    for i in range(N-1) :
        n, d = map(int, input().split())
        put_S(n, d) 
    
    sort_x_square = sorted(square)
    sort_y_square = sorted(square, key=lambda x:x[1])
    print(sort_x_square[-1][0] - sort_x_square[0][0]+1, sort_y_square[-1][1] - sort_y_square[0][1]+1)


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

const int D=365;
int csum;
int c[26];
int s[D][26];
int last[26];

int ans[D];

int score(){
	memset(last,-1,sizeof(last));
	int sum=0;
	int diff=0;
	rep(i,D){
		sum+=s[i][ans[i]];
		diff+=csum;
		diff-=(i-last[ans[i]])*c[ans[i]];
		sum-=diff;
		last[ans[i]]=i;
	}
	return sum;
}

int main(){
	scanf("%*d");
	rep(i,26)scanf("%d",&c[i]),csum+=c[i];
	rep(i,D)rep(j,26)scanf("%d",&s[i][j]);
	rep(i,D){
		ans[i]=max_element(s[i],s[i]+26)-s[i];
	}
	random_device rnd;
	mt19937 mt(rnd());
	uniform_real_distribution<double>Real(0,1);
	int Max=score();
	double stmp=10000,etmp=0;
	int update=0;
	int LOOP=3000000;
	rep(loop,LOOP){
		int pos=mt()%D,d=mt()%26;
		int old=ans[pos];
		ans[pos]=d;
		int nx=score();
		double tmp=stmp+(etmp-stmp)/LOOP*loop;
		double p=exp(-double(abs(Max-nx))/tmp);
		if(Max<nx||Real(mt)<p){
			Max=nx;update++;
		}
		else{
			ans[pos]=old;
		}
	}
	cerr<<update<<endl;
	rep(i,D){
		cout<<ans[i]+1<<endl;
	}
	cerr<<"score: "<<Max<<' '<<score()<<endl;
}

Measured memory_bytes: 4368
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let wab = read_vec::<i64>();
    let (w,a,b) = (wab[0],wab[1],wab[2]);
    let ans = if (a-b).abs() < w{
        0
    } else {
        (a-b).abs() - w
    };
    println!("{}",ans );
}

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

using namespace std;

int main()
{
    signed int A, B;
    cin >> A >> B;
    signed int plus, minus, cross, ans;
    plus = A + B;
    minus = A - B;
    cross = A * B;
    ans = max(plus, minus);
    ans = max(cross, ans);
    cout << ans << endl;

    return 0;
}

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

using namespace std;

string s;

int main(){
	cin >> s;
	for(int i = 1; i < 4; i++)
		if(s[i] == s[i-1]){
			cout << "Bad";
			return 0;
		}
	cout << "Good";
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

typedef long long ll;
using namespace std;

int n;

int main()
{
    string s; cin >> s;
    for (int i= 0; i < 19; i++){
        if(s[i] == ',') cout << " ";
        else cout << s[i];
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 256
/*
      author : nishi5451
      created: 11.08.2020 23:00:35
*/

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


int main(){
    int h,a;
    cin >> h >> a;
    int ans = h/a;
    if(h%a!=0) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
n=int(input())
H=list(map(int,input().split()))
INF=float('inf')

dp=[0]*(n+1)
dp[0]=INF
dp[1]=0
for i in range(2,n+1):
  if i-3<0:
    dp[i]=dp[i-1]+abs(H[i-1]-H[i-2])
  else:
    dp[i]=min(dp[i-1]+abs(H[i-1]-H[i-2]),dp[i-2]+abs(H[i-1]-H[i-3]))
    
print(dp[n])

Measured memory_bytes: 84832
/*
AizuOnline A0083
Title

pre-meiji
meiji	1868. 9. 8 〜 1912. 7.29
taisho	1912. 7.30 〜 1926.12.24
showa	1926.12.25 〜 1989. 1. 7
heisei	1989. 1. 8 〜
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
char dat[9];
int yyyy,mm,dd,yy;
char *nengo;
//
main()
{
  while(EOF != scanf("%d %d %d",&yyyy,&mm,&dd))
    {
      sprintf(dat,"%4d%02d%02d",yyyy,mm,dd);
      //printf("%s\n",dat);
      if(strcmp(dat,"18680908")==-1)
	{
	  printf("pre-meiji\n");
	  continue;
	}  
      else if(strcmp(dat,"19120730")==-1)
	{
	  nengo="meiji";
	  yy = yyyy - 1867;
	}
      else if(strcmp(dat,"19261225")==-1)
	{
	  nengo="taisho";
	  yy = yyyy -1911;
	}
      else if(strcmp(dat,"19890108")==-1)
	{
	  nengo="showa";
	  yy = yyyy - 1925;
	}
      else
	{
	  nengo="heisei";
      	  yy = yyyy - 1988;
	}
      printf("%s %d %d %d\n",nengo,yy,mm,dd); 
    }
return(0);
}

Measured memory_bytes: 624
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();

        var rights = new int[n];
        var digits = new HashSet<char>();
        for (int i = n - 1; i >= 0; i--)
        {
            rights[i] = digits.Count;
            digits.Add(s[i]);
        }

        var pattern = 0;
        var visit0 = new HashSet<char>();
        for (int i = 0; i < n; i++)
        {
            if (visit0.Contains(s[i]))
            {
                continue;
            }
            var visit1 = new HashSet<char>();
            for (int j = i + 1; j < n; j++)
            {
                if (visit1.Contains(s[j]))
                {
                    continue;
                }
                pattern += rights[j];
                visit1.Add(s[j]);
            }
            visit0.Add(s[i]);
        }

        Console.WriteLine(pattern);
    }
}

Measured memory_bytes: 13536
'use strict';

function main(stdin) {
  const input = stdin.split('\n');
  const temp = input.shift().split(' ').map(v => parseInt(v, 10));
  const N = temp[0];
  const X = temp[1];
  const L = input[0].split(' ').map(v => parseInt(v, 10));

  let d = 0;
  const bound = [0];

  L.forEach(l => {
    d += l;
    bound.push(d);
  });
  
  console.log(bound.filter(b => b <= X).length);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
 string s,t;
 cin>>s>>t;
 int n=s.size(),m=t.size();
 V<V<int>> ss(2,V<int>(n+1,0)),tt(2,V<int>(m+1,0));
 for(int i=0;i<n;i++){
     ss[s[i]-'A'][i+1]=ss[s[i]-'A'][i]+1;
     ss[(s[i]-'A')^1][i+1]=ss[(s[i]-'A')^1][i];
 }
  for(int i=0;i<m;i++){
     tt[t[i]-'A'][i+1]=tt[t[i]-'A'][i]+1;
     tt[(t[i]-'A')^1][i+1]=tt[(t[i]-'A')^1][i];
 }
 int q;
 cin>>q;
 while(q--){
     int w,x,y,z;
     cin>>w>>x>>y>>z;
     ll a1=(ss[0][x]-ss[0][w-1])%3,b1=(ss[1][x]-ss[1][w-1])%3;
     ll a2=(tt[0][z]-tt[0][y-1])%3,b2=(tt[1][z]-tt[1][y-1])%3;
     int d1=min(a1,b1),d2=min(a2,b2);
     a1-=d1;b1-=d1;
   //  cout<<a1<<" "<<b1<<" "<<a2<<" "<<b2<<"\n";
     if(a1&&a1%2==0){b1=1;a1=0;}
     else if(b1&&b1%2==0){a1=1;b1=0;}
     a2-=d2;b2-=d2;
     if(a2&&a2%2==0){b2=1;a2=0;}
     else if(b2&&b2%2==0){a2=1;b2=0;}
     //cout<<a1<<" "<<b1<<" "<<a2<<" "<<b2<<"\n";
     if(b1){
         if(b1==b2)cout<<"YES"<<"\n";
         else cout<<"NO"<<"\n";
     }else if(a1){
         if(a1==a2)cout<<"YES"<<"\n";
         else cout<<"NO"<<"\n";
     }else{
         if(a1==a2&&b1==b2)cout<<"YES"<<"\n";
         else cout<<"NO"<<"\n";
     }
 }
}

Measured memory_bytes: 2888
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

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

  int a, ans = 0;
  rep(i,0,N-1) {
    cin >> a;
    while (a % 2 == 0) {
      ans++;
      a /= 2;
    }
  }

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


Measured memory_bytes: 256
/** これを翻訳している間、あなたはあなたの人生のいくつかの貴重な瞬間を無駄にしました **/
#include<bits/stdc++.h>
using namespace std;

#define rep(i,x,y) for(int i=x;i<y;i++)
#define repr(i,x,y) for(int i=x;i>=y;i--) 
#define int long long
#define pb push_back
#define ff first
#define ss second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)

using pii = pair<int,int>;
using vi = vector<int>;
using vii = vector<pair<int,int>>;

constexpr int mod = 1000000007;
constexpr int N = 2e8 + 5;
constexpr int inf = 1e18 , eps = 1e-6; 


void Onigiri()
{
  string s;
  cin>>s;
  if(s.back()=='s')cout<<s<<"es";
  else cout<<s<<"s";
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifdef Zoro
   freopen("/home/pritish/Competitive/in", "r", stdin);
   freopen("/home/pritish/Competitive/out", "w", stdout);
   #endif  
 
   int t=1; 
   //cin>>t;
 
   while(t--)
   {Onigiri();cout<<"\n";}

   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;
   return 0;
}

Measured memory_bytes: 3816
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int x = s.nextInt();
        int n = x / 100;
        int ans;
        if(n*111 >= x){
            ans = n*111;
        }else {
            ans = (n+1)*111;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23892
import java.util.Scanner;
 
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t = sc.nextInt();
		int a = sc.nextInt();
		int[] h = new int[n];
		for(int i = 0;i < n;i++){
			h[i] = sc.nextInt();
		}
		double minAbs = Double.MAX_VALUE;
		int minNo = 1;
		
		for(int i = 0;i < n;i++){
			if(minAbs > Math.abs(a-(t-h[i]*0.006))){
				minAbs = Math.abs(a-(t-h[i]*0.006));
				minNo = i+1;
			}
		}
		
		System.out.println(minNo);
	}
}


Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int x = 1;
        while (x <= 1009) {
            if ((x * 8 / 100 == a) && (x * 10 / 100 == b)) {
                System.out.println(x);
                return;
            }
            x++;
        }
        System.out.println("-1");
    }
}

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


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int k,x;
    cin>>k>>x;
    for(int i=max(-1000000,x-k+1);i<=min(1000000,x+k-1);i++)
        cout<<i<<" ";
}


Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>

#define MAX_N 100
#define INF INT_MAX/2
#define min(a,b) (a < b ? a : b)

int prim(int,int[MAX_N][MAX_N]);

int main(){
  int n,i,j,a[MAX_N][MAX_N];
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++){
      scanf("%d",&a[i][j]);
    }
  }
  printf("%d\n",prim(n,a));
  return 0;
}

int prim(int n,int a[MAX_N][MAX_N]){
  int i,v,cost[MAX_N],used[MAX_N],res = 0;
  for(i = 0 ; i < n ; i++){
    cost[i] = INF;
    used[i] = 0;
  }
  
  cost[0] = 0;
  while(1){
    v = -1;
    for(i = 0 ; i < n ; i++){
      if(!used[i] && (v == -1 || cost[i] < cost[v])){
        v = i;
      }
    }
    if(v == -1){ break; }
    used[v] = 1;
    res += cost[v];
    for(i = 0 ; i < n ; i++){
      if(a[v][i] == -1){ continue; }
      cost[i] = min(cost[i],a[v][i]);
    }
  }
  return res;
}

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

void solve(int64_t x, vector<int64_t> &A)
{
  int64_t r = 0, s = 0, n = A.size(), ans = 0;
  for (int l = 0; l < n; l++)
  {
    while (r < n && s + A.at(r) <= x)
    {
      s += A.at(r);
      r++;
    }
    ans += (r - l);

    if (r == l)
      r++;
    else
      s -= A.at(l);
  }
  cout << ans << endl;
}

int main()
{
  int64_t N, Q, x;
  cin >> N >> Q;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }
  for (int i = 0; i < Q; i++)
  {
    cin >> x;
    solve(x, A);
  }
}


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

int main() {
	int a,b;
	cin >> a >> b;
	if(5*(a+1)<=4*b || 4*(b+1)<=5*a) cout << -1 << endl;
	else cout << max(10*b, (25*a+1)/2 ) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const long long inf = 1ll * 1000 * 1000 * 1000 * 1000 * 1000;
const int N = 1e5 + 10; 
int a[N], nxt[N], n, e, t;
long long val;
long long seg[N << 2], lazy[N << 2], dp[N];
vector<int> fnd[N];
//
void relax(int id) {
	int lc = id * 2, rc = lc + 1;
	seg[lc] += lazy[id], lazy[lc] += lazy[id];
	seg[rc] += lazy[id], lazy[rc] += lazy[id];
	lazy[id] = 0;
	return;
}
void add(int l, int r, int id = 1, int s = 0, int e = n) {
	if (e <= l || r <= s)
		return;
	if (l <= s && e <= r) {
		seg[id] += val;
		lazy[id] += val;
		return;
	}
	int mid = (s + e) / 2, lc = id * 2, rc = lc + 1;
	relax(id);
	add(l, r, lc, s, mid);
	add(l, r, rc, mid, e);
	seg[id] = min(seg[lc], seg[rc]);
//	cout << "s = " << s << " e = " << e << " : " << seg[id] << endl;
}
void upd(int p, int id = 1, int s = 0, int e = n) {
	if (e - s == 1) {
		seg[id] = val;
		lazy[id] = 0;
		return;
	}
	int mid = (s + e) / 2, lc = id * 2, rc = lc + 1;
	relax(id);
	if (p < mid)
		upd(p, lc, s, mid);
	else
		upd(p, rc, mid, e);
	seg[id] = min(seg[lc], seg[rc]);
	return;
}
void open(int id = 1, int s = 0, int e = n) {
	if (e - s == 1) {
		cout << "s = " << s << " : " << seg[id] << endl;
		return;
	}
	int mid = (s + e) / 2, lc = id * 2, rc = lc + 1;
	relax(id);
	open(lc, s, mid);
	open(rc, mid, e);
}
//
int32_t main() {
	ios_base::sync_with_stdio (false), cin.tie(0), cout.tie(0);
	cin >> n >> e >> t;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	int st = -1;
	n++;
	for (int i = 0; i < n; i++) {
		val = inf;
		upd(i);
		while ((a[i] - a[st + 1]) * 2 >= t)
			st++;
		if (st != -1)
			fnd[st].push_back(i);
	}
	st = n;
	for (int i = n - 1; i >= 0; i--) {
		while ((a[st - 1] - a[i]) * 2 >= t)
			st--;
		nxt[i] = st;
	}
//	cout << "HO" << endl;
	val = t;
	upd(n - 1);
	for (int i = n - 2; i >= 0; i--) {
//		cout << "i = " << i << endl;
		long long toall = a[i + 1] - a[i], tosome = a[i + 2] - a[i + 1];
		val = toall, add(i + 1, n);
		if (tosome > 0)
			val = 2 * tosome, add(nxt[i + 1], n);
		for (auto plc : fnd[i + 1]) {
			long long dis = 1ll * (a[plc] - a[i + 1]) * 3 + 1ll * toall;
			val = dis + dp[plc], upd(plc);
//			cout << "plc = " << plc << " : " << dis << " val = " << val << endl;
		}
//		cout << " open : " << endl;
//		open();
//		cout << endl;
		dp[i] = seg[1], val = dp[i] + t;
//		cout << "i = " << i << " a[i] =  " << a[i] << " dp = " << dp[i] << " toall = " << toall << " tosome = " << tosome << " nxt = " << nxt[i + 1] << endl;
		upd(i);
	}
	cout << dp[0] + e - a[n - 1];
//	cout << endl;
//	open();
	return 0;
}


Measured memory_bytes: 14336
import java.util.*;

public class Main{
  
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String input = sc.nextLine();
    String[] nums = input.split(" ");
    int N = Integer.parseInt(nums[0]);
    int A = Integer.parseInt(nums[1]);
    int B = Integer.parseInt(nums[2]);
    
    System.out.println(N * A < B ? N * A : B);
  }
}

Measured memory_bytes: 21844
from fractions import gcd
n = int(input())
A = list(map(int,input().split()))
left = [0]*(n+1)
right = [0]*(n+2)
for a,aa,i in zip(A,A[::-1],range(1,n+1)):
    left[i] = gcd(a,left[i-1])
    right[n+1-i] = gcd(aa,right[n-i+2])
ans = 1
for i in range(1,n+1):
    if i ==1:
        if ans < right[i+1]:
            ans = right[i+1]
    elif i == n:
        if ans < left[i-1]:
            ans = left[i-1]
    else:
        if ans < gcd(left[i-1],right[i+1]):
            ans = gcd(left[i-1],right[i+1])

print(ans)
    

Measured memory_bytes: 16116
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define endl '\n'
#define fastio ios::sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

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

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

	int arr[100005]{};
	for (int a, i = 0; i < N; ++i) {
		cin >> a;
		arr[a]++, arr[a + 1]++, arr[a + 2]++;
	}

	cout << *max_element(arr, arr + 100005);

	return 0;
}

Measured memory_bytes: 640
n=int(input())
test=[]
for i in range(n):
  a=int(input())
  testament=[list(map(int,input().split())) for i in range(a)]
  test.append(testament)
ans=0
for i in range(2**n):
  HorL=[0 for j in range(n)]
  success=True
  for j in range(n):
    if i&1==1:
      HorL[j]=1
    i>>=1
  for j in range(n):
    if HorL[j]==1:
      for x,y in test[j]:
        if y==HorL[x-1]:
          pass
        else:
          success=False
          break
    else:
      continue
  if success and ans < sum(HorL):
    ans=sum(HorL)
print(ans)

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

int main(){
	int n,m,a,w;
	cin>>n>>m;
	int* t=new int[m];
	int* s=new int[n];
	for(int i=0;i<m;i++){
		cin>>t[i];
	}
	for(int i=0;i<n;i++){
		s[i]=0;
	}
	for(int i=0;i<m;i++){
		w=0;
		for(int j=0;j<n;j++){
			cin>>a;
			if(a==t[i]) s[j]++;
			else w++;
		}
		s[t[i]-1]+=w;
	}
	for(int i=0;i<n;i++){
		cout<<s[i]<<endl;
	}
	delete[] t;
	delete[] s;
	return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include<vector>
#include<stack>
#include<cstdio>
using namespace std;

#define MAX (1<<21)

int n,M[101][101];
int vis[101],d[101],p[101];

int prim(){
    int u,minv,i,v,j;
    for( i = 0; i < n; i++ ){
        d[i] = MAX;
        p[i] = -1;
    }
    d[0] = 0;
    while(1){
        minv = MAX;
        u = -1;
        for( i = 0; i < n; i++ ){
            if( minv > d[i] && !vis[i] ){
                u = i;
                minv = d[i];
            }
        }
        if( u == -1 ) break;
        vis[u] = 1;
        for( v = 0; v < n; v++ ){
            if( !vis[v] && M[u][v] != MAX ){
                if( d[v] > M[u][v] ){
                    d[v] = M[u][v];
                    p[v] = u;
                }
            }
        }
    }
    int sum = 0;
    for( i = 0; i < n; i++ ){
        if( p[i] != -1 ) sum += M[i][p[i]];
    }
    return sum;
}


int main(){
    int i,j,k,m;
    cin >> n;
    for( i = 0; i < n; i++ ){
        for( j = 0; j < n; j++ ){
            cin >> k;
            M[i][j] = (k == -1) ? MAX : k;
        }
    }
    cout << prim() << endl;
}



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

int main() {
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(), a.end());
	if (a[0] == 5 && a[1] == 5 && a[2] == 7) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


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

#include <set>
#include <map>
#include <iomanip>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()

using ll = long long;

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

	cout << setprecision(20);
	if (N % 2 == 0)
	{
		cout << 0.5 << endl;
	}
	else
	{
		cout << (double)(N / 2 + 1) / N << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;


const int kN = 1000000;
void primeNumber(bool prime[kN]){
    rep(i,kN) prime[i] = 1;
    prime[0] = prime[1] = 0;
    rep(i,kN){
        if(prime[i]){
            for(int j = i + i; j < kN; j+=i){
                prime[j] = 0;
            }
        }
    }
}

int main(){
    bool p[kN];
    primeNumber(p);

    int a, d, n;
    while(cin >> a >> d >> n, a||d||n){
        vector<int> v;
        for(int i = a; i < kN; i+=d){
            if(p[i] == 1){
                v.emplace_back(i);
            }
        }
        cout << v[n - 1] << endl;
    }

}

Measured memory_bytes: 4584
using System;
class c
{
    static void Main()
    {
        int k = int.Parse(Console.ReadLine());
        int o = 0, e = 0;
        for (int i = 1; i <= k; i++)
        {
            if (i % 2 == 0) e++;
            else o++;
        }
        Console.WriteLine(e * o);
    }
}

Measured memory_bytes: 13140