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

typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second
#define P pair<ll,ll>


ll n,ans,cnt;
vector<P> vec[15];
ll type[15];

int main(){
    ll n;
    cin >> n;
    ll a[n] = {};
    rep(i,0,n) cin >> a[i];

    sort(a,a+n);

    double ans = a[0];
    rep(i,1,n){
        ans = (a[i] + ans) / 2.0;
    }

    cout << setprecision(10) << ans << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 25
#define NIL -1

struct Node{
  int p, l, r;
};

struct Node T[N];
int n, D[N], H[N];

int getDepth(int);
void print(int);
int getSibling(int);

int main(){
  int i, v, l, r;

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    T[i].p = NIL;
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if ( l != NIL ) T[l].p = v;
    if ( r != NIL ) T[r].p = v;
  }

  for ( i = 0; i < n; i++ ){
    D[i] = getDepth(i);
    H[i] = 0;
  }

  for ( i = 0; i < n; i++ ){
    if ( T[i].l == NIL && T[i].r == NIL ) { 
      H[i] = 0;
      int p = T[i].p;
      int c = 1;
      while(1){
	if ( p == NIL ) break;
	if ( H[p] < c ) H[p] = c;
	c++;
	p = T[p].p;
      }
    }
  }

  for ( i = 0; i < n; i++ ) print(i);
  return 0;
}

int getDepth(int u){
  int d = 0;
  while(1){
    u = T[u].p;
    if ( u == NIL ) break;
    d++;
  }
  return d;
}

int getSibling(int u){
  if ( T[u].p == NIL ) return NIL;
  if ( T[T[u].p].l != u && T[T[u].p].l != NIL ) return T[T[u].p].l;
  if ( T[T[u].p].r != u && T[T[u].p].r != NIL ) return T[T[u].p].r;
  return NIL;
}

void print(int u){
  int deg = 0;
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].p);
  printf("sibling = %d, ", getSibling(u));
  
  if ( T[u].l != NIL ) deg++;
  if ( T[u].r != NIL ) deg++;
  
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if ( T[u].p == NIL ){
    printf("root\n");
  } else if ( T[u].l == NIL && T[u].r == NIL ){
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}

Measured memory_bytes: 612
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
ll s,k,x,y,a,b;
int main(){
    cin>>s;
    while((k+1000ll)*(k+1000ll)<=s)k+=1000;
    while((k+1)*(k+1)<=s)++k;
    if(k*k==s)x=y=k;
    else if(s<=k*(k+1))x=k+1,y=k,a=x*y-s,b=1;
    else x=y=k+1,a=1,b=x*y-s;
    printf("0 0 %lld %lld %lld %lld\n",a,y,x,b);
    //system("pause");
    return 0;
}


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

class union_find
{
private:
        int par[MAX_N];
public:
    void init(int n)
    {
        for(int i=0;i<n;i++)
        {
            par[i]=i;
        }
    }

    int FIND(int x)
    {
        if(par[x]==x)
        {
            return x;
        }
        else
        {
            int j=x;
            while(par[j]!=j)
            {
                j=par[j];
            }
            int r=par[j];
            while(par[x]!=r)
            {
                j=x;
                x=par[x];
                par[j]=r;
            }
            return r;
        }
    }

    void unite(int x,int y)
    {
        x=FIND(x);
        y=FIND(y);
        if(x==y)
        {
            return ;
        }
        else
        {
            par[x]=y;
        }
    }

    bool same(int x,int y)
    {
        return FIND(x)==FIND(y);//怎么判断两个元素是否是同一个集合,是判断传进来两个
        //参数的根是否相同
    }
};

map<pair<int,int>,int>m;
int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    union_find u1;
    union_find u2;
    int N,K,L;
    cin>>N>>K>>L;
    u1.init(N+1);
    u2.init(N+1);
    int a,b;
    for(int i=0;i<K;i++)
    {
        cin>>a>>b;
        u1.unite(a,b);
    }
    for(int i=0;i<L;i++)
    {
        cin>>a>>b;
        u2.unite(a,b);
    }

    for(int i=1;i<=N;i++)
    {
        m[make_pair(u1.FIND(i),u2.FIND(i))]++;
    }
    cout <<m[make_pair(u1.FIND(1),u2.FIND(1))];
    for(int i=2;i<=N;i++)
    {
       cout <<" "<< m[make_pair(u1.FIND(i),u2.FIND(i))];
    }
    cout <<endl;
    return 0;
}


Measured memory_bytes: 13568
#include <stdio.h>

int main(){
	int a,b,p,m,k;
	scanf("%d %d",&a,&b);
	p=a+b;
	m=a-b;
	k=a*b;
	if(p<m){
		if(m<k){
			printf("%d\n",k);
		}else{
			printf("%d\n",m);
		}
	}else{
		if(p<k){
			printf("%d\n",k);
		}else{
			printf("%d\n",p);
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> L(N);
    for (auto& l : L) {
        cin >> l;
    }
    int ans = 0;
    rep(i, 0, N) rep(j, i + 1, N) rep(k, j + 1, N) {
        if (L[i] != L[j] && L[j] != L[k] && L[k] != L[i] && L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[k] + L[i] > L[j]) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

  int ans=0;
  for(int i=0; i<s.length(); i++){
    if(s[i] == 'g' && i%2 == 1){
      ans ++;
    }
    if(s[i] == 'p' && i%2 == 0){
      ans--;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = (ll)1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int main(){
  int a, b;
  cin >> a >> b;
  int g = __gcd(a, b);
  a /= g;
  b /= g;
  int res = 1;
  int i = 2;
  int t = b;
  while (i * i <= t){
    if (b % i == 0){
      res *= i;
      while (b % i == 0) b /= i;
    }
    i++;
  }
  res *= b;
  cout << res << endl;
}

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

int co=0;
vector<int> s;

int main(){
  int i,j;
  for(i=0;i<3;i++){
    cin >> j;
    s.push_back(j);
  }
  sort(s.begin(),s.end());
  if(s[0]%2!=s[1]%2&&s[0]%2!=s[2]%2){
    s[1]++;
    s[2]++;
    co++;
  }
  if(s[1]%2!=s[0]%2&&s[1]%2!=s[2]%2){
    s[0]++;
    s[2]++;
    co++;
  }
  if(s[2]%2!=s[0]%2&&s[2]%2!=s[1]%2){
    s[1]++;
    s[0]++;
    co++;
  }
  sort(s.begin(),s.end());
  co += (s[2]-s[0])/2;
  co += (s[2]-s[1])/2;

  cout << co << endl;

  return 0;
}


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

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

  // N要素の配列
  vector<int> A(N);

  // 入力処理
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  // 合計点
  int max = A.at(0);
  int min = A.at(0);
  int difference;

  // max,minを求める
  for (int i = 0; i < N; i++) {
    if (max < A.at(i)) max = A.at(i);
    if (min >= A.at(i)) min = A.at(i);
    
  }

  // 差の絶対値
  difference = max - min;
  cout << difference;
    
  
}



Measured memory_bytes: 256
#pragma optimize("unroll-loops,no-stack-protector")
#include <bits/stdc++.h>
using namespace std;
// using namespace __gnu_pbds;
// #include <ext/pb_ds/assoc_container.hpp>
// typedef tree<int,null_type,less<int>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define Max(a,b,c) max(a,max(b,c))
#define Min(a,b,c) min(a,min(b,c))
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define pc(x)  __builtin_popcount (x)
#define vl vector< ll >
#define sorts(v) sort(v.begin(),v.end())
#define sortg(v) sort(v.begin(),v.end(),greater<ll>())
#define ss second
#define ff first
#define ll long long
#define ld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1e18)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod 1000000007
#define mem(x,y) memset(x,y,sizeof(x))
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define gcd __gcd
#define primeDEN 727999983
#define nx_pe next_permutation(s.begin(),s.end())
#define cl cout<<"\n"
#define sp(x) setprecision(x)



void solve()
{
   ll n;
   cin>>n;
   ll a[n];
   rep(i,n)cin>>a[i];
   ll pre[n]={0};
   ll ans=0;
   ll sum=0;
   rep(i,n)sum+=a[i],pre[i]=sum;
   rep(i,n)
   {
       ans=((ans%mod)+(a[i]%mod)*(pre[n-1]%mod-pre[i]%mod+mod)%mod)%mod;
   }
   cout<<ans<<"\n";
}


    
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("ouput.txt", "w", stdout) ;
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    std::ios::sync_with_stdio(false);
    ll te=1;
    // cin>>te;
    while(te--){
        solve();
    }
    
}


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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

int main() {
    int N; vector<int> ps, qs;
    cin >> N;
    vector<int> ns;
    for (int i = 0; i < N; ++i) {
        ns.push_back(i + 1);
        int p;
        cin >> p;
        ps.push_back(p);
    }
    for (int i = 0; i < N; ++i) {
        int q;
        cin >> q;
        qs.push_back(q);
    }

    int i = 0, pi = -1, qi = -1;
    do {
        if (ns == ps) {pi = i;}
        if (ns == qs) {qi = i;}
        i++;
    } while(next_permutation(ns.begin(), ns.end()));
    assert(pi >= 0 && qi >= 0);
    cout << abs(pi - qi) << endl;
}

Measured memory_bytes: 256
s = input()
n = len(s)
def dfs(i: int, t: str):
  if i == n-1: #i = n - 1に到達したら終了
    # + で区切った数字をint型に変換して足し算
    return sum(list(map(int, t.split('+'))))
  # 文字列で次の数字をそのまま連結するパターンと、+で区切るパターン
  return dfs(i+1, t+s[i+1]) + dfs(i+1, t + '+' + s[i+1])
# 初期値でsの一文字目を入れておく
print(dfs(0, s[0]))

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

namespace Test
{
  public class Program
  {
    public static void Main()
    {
      var inputs = Console.ReadLine().Split(' ');
      var n = int.Parse(inputs[0]);
      var k = int.Parse(inputs[1]);
      Console.WriteLine(n % k == 0 ? 0 : 1);
    }
  }
}


Measured memory_bytes: 11092
#include <cstdio>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

int main() {
    vector<int> d(5);
    int m = 0;
    for (int i = 0; i < 5; ++i) {
        scanf("%d", d.begin() + i);
        if (d.at(i) % 10) m = max(m, 10 - d.at(i) % 10);
        d.at(i) = ((d.at(i) - 1) / 10 + 1) * 10;
    }
    printf("%d\n", accumulate(d.begin(), d.end(), 0) - m);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);++i)
#define REP(i,n) for (int i=0;i<=(n);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int INF = 10000000;

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

int main(){
    while(true){
        int n, x;
        cin >> n >> x;

        if(n == 0 && x == 0) return 0;
        int ans = 0;
        for(int i = 1; i <= n; ++i){
            for(int j = i+1; j <= n; ++j){
                for(int k = j+1; k <= n; ++k){
                    if(i+j+k == x){
                        ++ans;
                    }
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3084
import java.util.Scanner;

/**
 * https://abc060.contest.atcoder.jp/tasks/arc073_a
 */
public class Main {
	 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		final int T = sc.nextInt();
		int[] t = new int[N];
		for(int i=0; i<N; i++){
			t[i] = sc.nextInt();
		}
		sc.close();
		
		int ans = 0;
		for(int i=1; i<N; i++){
			ans += Math.min(t[i]-t[i-1], T);
		}
		ans += T;
 
		System.out.println(ans);
 
	}
 
}

Measured memory_bytes: 64332
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

double dot(P a, P b) {
    return (a.X * b.X + a.Y * b.Y);
}
double cross(P a, P b) {
    return (a.X * b.Y - a.Y * b.X);
}

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

// 2??´?????????????????? (?????????0??§???????????¨)
bool is_parallel(P a1, P a2, P b1, P b2) {
    return EQ( cross(a1-a2, b1-b2), 0.0);
}

P crossp_ll(P a1, P a2, P b1, P b2) {
    double d1 = cross(b2-b1, b1-a1);
    double d2 = cross(b2-b1, a2-a1);
    if( EQ(d1,0) && EQ(d2,0) ) return a1; // same line
    if( EQ(d2,0) ) assert(false); // precondition not satisfied
    return a1 + d1 / d2 * (a2 - a1);
}

int N;

signed main() {
    while(cin >> N, N) {
        vector<L> ls;
        rep(i,0,N) {
            int a, b, c, d; cin >> a >> b >> c >> d;
            ls.push_back(make_pair(P(a, b), P(c, d)));
        }

        int ans = 1;
        rep(i,0,N) {
            set<pii> s;
            rep(j,0,i) {
                if(is_parallel(ls[i].first, ls[i].second,
                               ls[j].first, ls[j].second)) continue;
                P cp = crossp_ll(ls[i].first, ls[i].second,
                                 ls[j].first, ls[j].second);
                if(-100.0 + EPS < cp.X && cp.X + EPS < 100.0
                && -100.0 + EPS < cp.Y && cp.Y + EPS < 100.0) {
                    // printf("point: %lf %lf\n", cp.X, cp.Y);
                    int x = floorl(cp.X * pow(10, 10));
                    int y = floorl(cp.Y * pow(10, 10));
                    s.insert(pii(x, y));
                }
            }
            // printf("size = %lld\n", s.size());
            ans += (s.size() + 1);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3056
N,D = map(int, input().split())
X = [[int(i) for i in input().split()] for i in range(N)]
ans = 0
def dis2(x,y):
    T = []
    for i in range(len(x)):
        T.append((x[i]-y[i])**2)
    return sum(T)
for i in range(N):
    for j in range(i+1,N):
        R = dis2(X[i],X[j])
        for k in range(R+1):
            if k**2 == R:
                ans +=1
print(ans)

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

using namespace std;
using ll = long long;

#define all(x) x.begin(),x.end()

const ll MOD = 1e9 + 7;

inline void normal(ll &a) { if (a >= MOD) a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) {normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) {normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) {normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; } //if MOD is prime, modPow(b, p % (MOD-1))
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

    int a[n];
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);

    auto b = vector <int> (a, a + n);
    sort(b.begin(), b.end());

    vector <int> c;

    ll ans = 0;

    for (int i = n - 1; i >= 0; i--) {
        auto it = lower_bound(all(c), a[i]);
        ll x = it - c.begin();
        
        auto jt = lower_bound(all(b), a[i]);
        ll y = jt - b.begin();


        ans = modAdd(ans, modMul(k, x));

        ll kmul = modMul(k, k - 1);
        kmul = modDiv(kmul, 2);

        ans = modAdd(ans, modMul(y, kmul));

        c.push_back(a[i]);
        sort(all(c));
    }

    printf("%lld\n", ans);
}

Measured memory_bytes: 3812
def main():
    A, B = map(int, input().split())
    bin_B = bin(B)[2:]
    if A != 0:
        A -= 1
    bin_A = bin(A)[2:]
    cnt = [0] * len(bin_B)
    for i in range(len(bin_B)):
        loop = 2 ** (i+1)
        mod = B % loop
        if mod >= loop // 2:
            mod -= loop // 2
            mod += 1
        else:
            mod = 0
        cnt[i] = mod
        cnt[i] += (B // loop) * (loop // 2)
    for i in range(len(bin_A)):
        loop = 2 ** (i+1)
        mod = (A) % loop
        if mod >= loop // 2:
            mod -= loop // 2
            mod += 1
        else:
            mod = 0
        cnt[i] -= mod
        cnt[i] -= ((A) // loop) * (loop // 2)


    ans = 0
    for i in range(len(bin_B)):
        if cnt[i] % 2 == 1:
            ans += 2 ** i

    print(ans)


    



if __name__ == "__main__":
    main()

Measured memory_bytes: 62140
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vl a(n); cin>>a;
    ll ans=0, v=LINF;
    rep(i,n){
        if(chmin(v,a[i]))ans++;
    }
    puta(ans);
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(){
  long n,a[200000]={0},i,all=0;
  
  scanf("%ld",&n);
  for(i=0;i<n;i++){
    scanf("%ld",&a[i]);
    all=all^a[i];
  }
  
  //printout
  for(i=0;i<n;i++){
    printf("%ld ",all^a[i]);
  }
}

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

using namespace std; 

int main(){ 
  string n;
  cin>>n;
  if(n[n.size()-1]=='3'){
    cout<<"bon";
  }
  else if(n[n.size()-1]=='0'||n[n.size()-1]=='1'||n[n.size()-1]=='6'||n[n.size()-1]=='8'){
    cout<<"pon";
  }
  else {
    cout<<"hon";
  }
}
  

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define All(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
#define Graph vector<vector<int>>
using namespace std;

Graph G;
vl cnt;
set<int> s;

void dfs(int v)
{
        s.insert(v);
        for(auto next_v : G[v])
        {
                if(s.count(next_v))continue;
                cnt[next_v]+=cnt[v];
                dfs(next_v);
        }
}

main()
{
        int N,Q; cin>>N>>Q;
        G.resize(N);
        int a,b;
        rep(i,N-1)
        {
                cin>>a>>b;
                a--; b--;
                G[a].push_back(b);
                G[b].push_back(a);
        }

        cnt.assign(N,0);
        int p,x;
        rep(i,Q)
        {
                cin>>p>>x;
                p--;
                cnt[p]+=x;
        }

        dfs(0);

        each(it,cnt)cout<<it<<" ";
        cout<<endl;
}


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

int main(){
  cout<<fixed<<setprecision(12);
  double a,b,C;
  cin>>a>>b>>C;
  double PI=acos(-1.0);
  C=C*PI/180.0;
  double S=a*b*sin(C)/2;
  double c=sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(C));
  double L=a+b+c;
  double h=b*sin(C);
  cout<<S<<endl<<L<<endl<<h<<endl;
  return 0;
}
  



Measured memory_bytes: 3472
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
  long long int t,a[10000],i,c;
  cin>>t;
  for(i=0;i<t;i++)
  {
    cin>>a[i];
  }
  sort(a,a+i);
  c=a[t-1]-a[0];
  cout<<c<<endl;


    return 0;

}








Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]

fn main() {
    let x: i64 = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };

    // 6, 5, 6, 5, ... となるようにサイコロを転がせばよい
    let ans = 2 * (x / 11) + (x % 11 + 5) / 6;

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数
static FILE *szpFpI;											// 入力

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// りんご数 - 取得
	int liACnt;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &liACnt);

	// りんご - 取得
	for (i = 0; i < liACnt; i++) {
		int liApple;
		fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
		sscanf(lc1Buf, "%d", &liApple);

		// 奇数
		if (liApple % 2) {
			return 0;
		}
	}

	return -1;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	if (liRet == 0) {
		sprintf(lc1Buf, "first\n");
	}
	else {
		sprintf(lc1Buf, "second\n");
	}
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n;
    cin>>n;
    VL arr(n+1,0);
    ll ct=0;
    fr(i,1,n+1)
    {
        cin>>arr[i];
        if(i%2==1&&arr[i]%2==1)
            ct++;
    }
    cout<<ct<<endl;
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 3656
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> ppl;
#define ain(a,n) for(ll i=0;i<(n);++i)	cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define mp make_pair
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
#define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 100005
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 200005;
const long double epsilon = 1e-9;
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

signed main() {

	fast
	ll n, k;
	cin >> n >> k;
	vl a(n + 2), ans(n + 2, 0);
	FOR(i, 1, n)	cin >> a[i];
	bool done = 1;
	while (k > 0 && done)
	{
		ans = vl(n + 2, 0);
		FOR(i, 1, n)
		{
			++ans[max(1LL, i - a[i])];
			--ans[min(n, i + a[i]) + 1];
		}
		FOR(i, 1, n)	ans[i] += ans[i - 1];
		FOR(i, 1, n)	a[i] = ans[i];
		bool ok = 1;
		FOR(i, 1, n)
		{
			if (ans[i] < n)
			{
				ok = 0;
				break;
			}
		}
		done = ok ^ 1;
		--k;
	}
	FOR(i, 1, n)	cout << ans[i] << " ";
	cout << END;


// #ifndef ONLINE_JUDGE
// 	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
	return 0;
}


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

Measured memory_bytes: 256
using System;

namespace AOJ0069
{
    class Program
    {
        int[] lots;
        int width;
        int height;
        int init;
        int goal;
        int[,] bar;
        int[,] barInit;

        public void Proc()
        {
            while(true)
            {
                
width = int.Parse(Console.ReadLine());
                if (width == 0) break;
                init = int.Parse(Console.ReadLine());
                goal = int.Parse(Console.ReadLine());
                height = int.Parse(Console.ReadLine());

                width += 2;
                lots = new int[width];
                setInitLots();

                setBar();

                doLots();

                if (lots[goal] == init)
                {
                    Console.WriteLine(0);
                    continue;
                }

                for (int i = 1; i <= height; i++)
                {
                    for (int j = 1; j < width - 2; j++)
                    {
                        bar = (int[,])barInit.Clone();
                        if ((bar[i, j] == 0) && (bar[i,j - 1] == 0 && bar[i,j + 1] == 0))
                        {
                            bar[i, j] = 1;

                            setInitLots();

                            doLots();

                            if (lots[goal] == init)
                            {
                                Console.WriteLine("{0} {1}", i, j);
                                break;
                            }
                        }
                        if (lots[goal] == init) break;
                    }
                    if (lots[goal] == init) break;
                }

                if (lots[goal] != init) Console.WriteLine(1);
            }
        }

        static void Main(string[] args)
        {
            Program prg = new Program();
            prg.Proc();
        }

        public void setInitLots()
        {
            for (int i = 1; i < width - 1; i++)
            {
                lots[i] = i;
            }
        }

        public void setBar()
        {
            string input;
            bar = new int[height + 1, width - 1];
            for (int i = 1; i <= height; i++)
            {
                input = Console.ReadLine();
                for (int j = 1; j < width - 2; j++)
                {
                    bar[i, j] = int.Parse(input.Substring(j - 1, 1));
                }
            }
            barInit = (int[,])bar.Clone();
        }

        public void doLots()
        {
            for (int i = 1; i <= height; i++)
            {
                for (int j = 1; j < width - 2; j++)
                {
                    if (bar[i,j] == 1)
                    {
                        swap(j, j + 1);
                    }
                }
            }
        }

        public void swap(int x, int y)
        {
            int tmp = lots[x];
            lots[x] = lots[y];
            lots[y] = tmp;
            return;
        }
    }
}

Measured memory_bytes: 9244
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt(),k=sc.nextInt();
		int inf=400000000;
		int[] dp=new int[n],h=new int[n];
		for(int i=0;i<n;i++) {
			h[i]=sc.nextInt();
			dp[i]=inf;
		}
		dp[0]=0;
		for(int i=1;i<n;i++) {
			dp[i]=dp[i-1]+Math.abs(h[i]-h[i-1]);
			for(int j=1;j<=i&&j<=k;j++) {
				int cost=dp[i-j]+Math.abs(h[i]-h[i-j]);
				dp[i]=Math.min(dp[i],cost);
			}
		}
		System.out.println(dp[n-1]);
		sc.close();
	}
}

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

#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define VPII vector<PII>
#define LD long double

int pow(int n1, int n2, int m){
    int ret = 1;
    FOR(i,1,n2){
        ret=(ret*n1)%m;
    }
    return ret;
}
int mod(int n,int m){
    n%=m;
    n=(n < 0) ? n + m : n;
    return n;
}
int n;
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed << setprecision(11);
    cerr << fixed << setprecision(6);
    cin >> n;
    int m = (int)pow(10,9) + 7;

    cout << to_string( mod(pow(10,n,m) - (2*pow(9,n,m) - pow(8,n,m)),m) ) << endl;
}


Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<
typedef struct {
	int h;
	int w;
}Point;

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n,m;
	cin>>n>>m;
	int A[n];
	int B[n];
	long long dp[m+1];
	priority_queue<int>que[m+1];
	priority_queue<int>q;
	for(int i=0;i<n;i++){
		cin>>A[i]>>B[i];
		if(A[i]<=m)que[A[i]].push(B[i]);
	}
	dp[0]=0;
	for(int i=1;i<=m;i++){
		while(!que[i].empty()){
			q.push(que[i].top());
			que[i].pop();
		}
		if(!q.empty()){
			dp[i]=q.top()+dp[i-1];
			q.pop();
		}else dp[i]=dp[i-1];
	}
	//for(int i=0;i<=m;i++)
	cout<<dp[m]<<endl;
	
}
	


Measured memory_bytes: 7936
#include<stdio.h>
int main() {

	int N, M, X, Y;

	scanf("%d %d %d %d", &N, &M, &X, &Y);

	int x[N], y[M], i, j;

	for (i = 0; i < N; i++) {
		scanf("%d", &x[i]);
	}

	for (j = 0; j < M; j++) {
		scanf("%d", &y[j]);
	}

	int flag = 1;

	if (X < Y) {
		flag = flag * 1;
	}
	else {
		flag = flag * 0;
	}

	int maxx = X;

	for (i = 0; i < N; i++) {
		if (x[i] >= maxx) {
			maxx = x[i];
		}
	}


	int miny = Y;

	for (i = 0; i < M; i++) {
		if (y[i] <= miny) {
			miny = y[i];
		}
	}

	if (maxx < miny) {
		flag = flag * 1;
	}else{
      	flag = 0;
    }

	if (flag == 1) {
		printf("No War");
	}
	else {
		printf("War");
	}

	return 0;

}

Measured memory_bytes: 128
#include<stdio.h>
char c[206][103];
int h,w;
int main(){
	scanf("%d %d",&h,&w);
	for(int y=1;y<=h;y++){
		scanf("%s",&c[y*2]);
		for(int x=0;x<w;x++){
		c[y*2-1][x]=c[y*2][x];
		}	
	}
	for(int y=1;y<=2*h;y++){
		for(int x=0;x<w;x++){
			printf("%c",c[y][x]);
		}
		printf("\n");
	}

}


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

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

  vector<int> A(N);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    while (A.at(i) % 2 == 0){
      A.at(i) /= 2;
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
S = input()
T = S[::-1]
count = 0
N = len(S)
if N % 2 == 0:
    A = int(N / 2)
else:
    A = int((N-1) / 2)

for i in range(A):
    if S[i] == T[i]:
        pass
    else:
        count += 1

print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.1415926
#define coutdb cout<<fixed<<setprecision(15)

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

// typedef int_fast64_t ll;
#define int int_fast64_t

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int N, K, A[200000], F[200000];
  cin >> N >> K;
  REP(i, N) cin >> A[i];
  REP(i, N) cin >> F[i];
  sort(A, A+N); sort(F, F+N); reverse(F, F+N);
  int left = -1, right = 1e12 + 1;
  while(right-left > 1){
    int mid = (left+right) / 2;
    int cnt = 0;
    REP(i, N){
      int h = mid / F[i];
      cnt += max(int(0), A[i]-h);
    }
    if(cnt <= K) right = mid;
    else left = mid;
  }
  cout << right << endl;
}

Measured memory_bytes: 3328
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=350;
//↑templete
signed main(){
	int N;
	cin>>N;
	ll ans=0, sum=0;
	for(int i=0;i<N;i++){
		ll c, d;
		cin>>c>>d;
		sum+=c*d;
		ans+=d;
	}
	cout<<ans-1+(sum-1)/9<<endl;

	return 0;
}

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

long int MOD = 998244353;
long long int dp[300][90001], sum = 0, ans = 0;
long long powmod(long long a, long long b) {
	a %= MOD;
	long long res = 1;
	while (b > 0) {
		if (b % 2 == 1)res = res * a % MOD;
		a = a * a % MOD;
		b /= 2;
	}
	return res;
}
int main() {
	int N, A[300], i, j;


	cin >> N;
	for (i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
	}
	for (i = 0; i < 90001; i++)dp[0][i] = (long long)0;
	dp[0][0] = (long long)2;
	dp[0][A[0]] = (long long)1;
	for (i = 1; i < N; i++) {
		for (j = 0; j < 90001; j++) {
			dp[i][j] = dp[i - 1][j] * 2;
			if (A[i] <= j)dp[i][j] += dp[i - 1][j - A[i]];
			dp[i][j] %= MOD;
		}
	}
	for (i = (sum + 1) / 2; i < 90001; i++) {
		ans += dp[N - 1][i];
		ans %= MOD;
	}
	for (i = 0; i < 90001; i++)dp[0][i] = 0;
	dp[0][0] = 1;
	dp[0][A[0]] = 1;
	for (i = 1; i < N; i++) {
		for (j = 0; j < 90001; j++) {
			dp[i][j] = dp[i - 1][j];
			if (A[i] <= j)dp[i][j] += dp[i - 1][j - A[i]];
			dp[i][j] %= MOD;
		}
	}
	if (sum % 2 == 0)ans -= dp[N - 1][sum / 2];
	printf("%lld", (((long long)powmod(3.0, N - 1) - ans + MOD) * 3) % MOD);
}


Measured memory_bytes: 211200
H = int(input())
W = int(input())
N = int(input())

A = N % H
B = N % W
if H > W and A != 0:
	print(N // H + 1)
elif H > W and A == 0:
	print(N // H)
elif H < W and B != 0:
  print(N // W + 1)
elif H < W and B == 0:
  print(N // W)
else:
  print(N // W)


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

using namespace std;

using ll = long long;
using Pii = pair<int, int>;


int main() {
    ll a, b, x;

    cin >> a >> b >> x;

    cout << b/x - max(0ll,(a-1))/x + (a == 0) << endl;
    
    return 0;
}


Measured memory_bytes: 256
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : August 22, 2020 6:00 PM
 *    Problem Name  : C - Step
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc176/tasks/abc176_c
 *    @genarated by : ai-virtual-assistant
**/

#include<bits/stdc++.h>
#define ll long long int 
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);

    ll n;
    cin >> n;

    ll arr[n+1], sum=0;
    for(ll i=0; i<n; i++){
        cin >> arr[i];
    }

    for(ll i=0, j=1; i<n-1 && j<n; i++,j++){
        if(arr[i] <= arr[j]) continue;
        else {
            ll temp = arr[i] - arr[j];
            //cout << "Temp = " << temp << endl; 
            sum += temp;
            arr[j] = arr[j] + temp;
            //cout << "Sum = " << sum << endl; 
        }
    }

    cout << sum << endl;

    return 0 ;
}


Measured memory_bytes: 5164
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cctype>
#include <map>
#include <functional>
using namespace std;

typedef vector<int> vint;

int ans;
const char *ptr;
char buf[256];
map<string,int> mp;

size_t cmp(const vint &v1, const vint &v2){
	return v1.size() < v2.size();
}

vint block(bool brace, string varname = string()){
	vector<vint> freqs;
	map<string,int>::iterator it;
	
	vector<string> varlist;
	if(!varname.empty()){
		varlist.push_back(varname);
		mp.insert(make_pair(varname, 1));
	}

	if(brace) ++ptr;
	while(*ptr != '}'){
		if(*ptr == '{'){
			freqs.push_back(block(true));
		}
		else if(*ptr == 'V'){	//VAR
			ptr += 3;
			ans += 3;

			int dif = 0;
			sscanf(ptr, " %[a-z]%n", buf, &dif);
			varname = buf;
			ptr += dif;

			freqs.push_back(block(false, varname));
		}
		else if(islower(*ptr)){
			sscanf(ptr, "%[a-z]", buf);
			varname = buf;
			ptr += varname.size();
			++mp[varname];
		}
		else if(!isspace(*ptr++)){
			++ans;
		}
	}
	if(brace){
		++ptr;
		ans += 2;
	}

	vint res;
	if(freqs.size() == 1){
		res.swap(freqs[0]);
	}
	else if(freqs.size() > 1){
		int maxsize = max_element(freqs.begin(), freqs.end(), cmp)->size();
		for(int i = 0; i < maxsize; ++i){
			int s = 0;
			for(int j = 0; j < freqs.size(); ++j){
				if(i < freqs[j].size()){
					s += freqs[j][i];
				}
			}
			res.push_back(s);
		}
	}

	for(int i = 0; i < varlist.size(); ++i){
		it = mp.find(varlist[i]);
		res.push_back(it->second);
		mp.erase(it);
	}
	sort(res.begin(), res.end(), greater<int>());

	return res;
}

int main(){
	string s, lines;
	int n;
	while(cin >> n, n){
		cin.ignore();
		lines = "{";
		for(int i = 0; i < n; ++i){
			getline(cin, s);
			lines += s;
		}
		lines += '}';
		
		ans = -2;
		mp.clear();
		ptr = lines.c_str();
		vint v = block(true);
		
		v.resize(1024, 0);
		vint::iterator it1 = v.begin(), it2;
		for(int i = 1; i <= 9; ++i){
			it2 = it1 + (1 << i);
			ans += accumulate(it1, it2, 0) * i;
			it1 = it2;
		}
		
		cout << ans << '\n';
	}
}

Measured memory_bytes: 1824
use std::fmt::Debug;
use std::str::FromStr;

fn main() {
    let x: Vec<u32> = read_line();
    let num1 = x[0];
    let num2 = x[1];
    let product = num1 * num2;
    match product {
        product if product % 2 == 0 => println!("Even"),
        _ => println!("Odd")
    }
}


fn read_line<T>() -> Vec<T>
    where T: FromStr, <T as FromStr>::Err: Debug {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

Measured memory_bytes: 4352