akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, cos, radians, pi, sin
from operator import mul
from functools import reduce
from operator import mul
from decimal import Decimal

mod = 10 ** 9 + 7
INF = 10 ** 13
sys.setrecursionlimit(2147483647)
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]



a, b = LS()
a = Decimal(a)
b = Decimal(b)
print(int(a * b))



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

ll euclid(ll x,ll y){
    if(y==0){
        return x;
    }else{
        return euclid(y,x%y);
    }
}

int main(){
    ll a,b;
    cin >> a >> b;
    ll gcd = euclid(max(a,b),min(a,b));
    cout << a*b/gcd << endl;
    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ll t,i,j,ans=0,n,d;
	cin>>n>>d;
	for(i=0;i<n;i++)
	{
		ll x,y;
		cin>>x>>y;
		double z=sqrt((x*x)+(y*y));
		if(z<=(double)d)
		ans++;
	}
	cout<<ans;
	
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n - 1); i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

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

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

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

const int N = 1e5 + 10;
vector<int> e[N];

int dfs(int u, int p) {
    int ans = 0;
    for (int v : e[u]) {
        if (v == p) continue;
        ans ^= (1 + dfs(v, u));
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    forn(i, 1, n) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        e[u].eb(v);
        e[v].eb(u);
    }
    int res = dfs(0, -1);
    if (res) cout << "Alice\n";
    else cout << "Bob\n";
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(ll i = (ll)a; i <= (ll)b; i++)
#define DEC(i, a, b) for(ll i = (ll)a; i >= (ll)b; i--)
typedef pair<ll, ll> pi;
typedef pair<pi, ll> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (ll) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sandybridge __attribute__((optimize("Ofast"), target("arch=sandybridge")))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

ll n, q, l, r, d, one[200005], ten[200005], mod = 998244353;

struct node {
	ll s, e, m, v, conf;
	node *l, *r;
	node (ll S, ll E) {
		s = S, e = E, m = (s+e)/2, conf = -1;
		if (s == e) v = 1;
		else {
			l = new node(s, m);
			r = new node(m+1, e);
			v = (l->v * ten[e-m] + r->v) % mod;
		}
	}
	ll value() {
		if (conf != -1) { //set update
			v = (conf * one[e-s+1]) % mod;
			if (s != e) {
				l->conf = conf;
				r->conf = conf;
			}
			conf = -1;
		}
		return v;
	}
	void set(ll x, ll y, ll nv) {
		value(); //propagate previous updates to prevent conflicting
		if (s == x and e == y) {conf = nv; return;}
		else if (y <= m) l->set(x, y, nv);
		else if (x > m) r->set(x, y, nv);
		else l->set(x, m, nv), r->set(m+1, y, nv);
		v = (l->value() * ten[e-m] + r->value()) % mod;
	}
} *seg;

int main() {
	fastio; cin >> n >> q;
	FOR(i, 1, n) one[i] = (one[i-1] * 10 + 1) % mod;
	ten[0] = 1; FOR(i, 1, n) ten[i] = (ten[i-1] * 10) % mod;
	seg = new node(1, n);
	while (q--) {
		cin >> l >> r >> d;
		seg->set(l, r, d);
		cout << seg->value() << "\n";
	}
}


Measured memory_bytes: 31804
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()


int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size(), m = t.size();
  for (int i = 0; i < n+m; i++) {
    if (i%2 == 0) {
      cout << s[0];
      s.erase(s.begin());
    } else {
      cout << t[0];
      t.erase(t.begin());
    }
  }
  cout << endl;
  return 0;
}

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

int tot[100010];

int main()
{
    int n,k,q;
    scanf("%d%d%d",&n,&k,&q);
    for (int i=0;i<q;i++)
    {
        int tmp;scanf("%d",&tmp);
        tot[tmp]++;
    }
    for (int i=1;i<=n;i++)
        tot[i]=q-tot[i];
    for (int i=1;i<=n;i++)
    {
        if (k>tot[i])
            printf("Yes\n");
        else printf("No\n");
    }

}


Measured memory_bytes: 896
#include "bits/stdc++.h"
/* Properties of modulo:
	(a/b)%m ,where m is prime  = (a%m) * (b^(m-2))%m
*/
    /*ROLLING HASH
    Rabin-Karp algorithm for pattern matching in a string in O(n) time
    Calculating the number of different substrings of a string in O(n2logn)
    Calculating the number of palindromic substrings in a string.
    */
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define ll long long
#define pb push_back
#define gcd __gcd
#define nl cout<<"\n"
#define endl "\n"
#define all(c) (c).begin(),(c).end()
#define trav(a,x) for(auto a = x.begin() ; a != x.end() ; a++)
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
//template<typename T>
//#define o_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
// o_set(ll) name ; -- defining ordered set
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set - returns iterator
bool compare(ll a, ll b){
    return a > b;
}
ll power(ll x, ll ex , ll md) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}
void solve(){
    ll k , a , b;
    cin >> k >> a >> b;
    for(ll i = a  ; i <= b ; i++) if(i%k == 0){
        cout << "OK\n";
        return ;
    }
    cout << "NG\n";
}
int main(){
    IOS;
    ll T=1;
    //cin>>T;
    ll t=0;
    while(t++<T){
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 3804
from collections import defaultdict

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M, K = map(int, input().split())
friends = [set(map(int, input().split())) for _ in range(M)]
blocks = [set(map(int, input().split())) for _ in range(K)]

ans = [0] * N
uf = UnionFind(N)
for a, b in friends:
    uf.union(a - 1, b - 1)
    ans[a - 1] -= 1
    ans[b - 1] -= 1
    
for c, d in blocks:
    if uf.same(c - 1, d - 1):
        ans[c - 1] -= 1
        ans[d - 1] -= 1

for i in range(N):
    ans[i] += uf.size(i)-1
print(*ans)

Measured memory_bytes: 72392
from collections import Counter

N = int(input())
s = []
for i in range(N):
    s.append("".join(sorted(input())))
    
ans = 0
for i in Counter(s).values():
    if i != 1:
        n = i - 1
        ans += int(n / 2 * (n + 1))
print(ans)

Measured memory_bytes: 19760
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,sum=1,sum2=1;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    if(a%2==0)sum2*=2;
    sum*=3;
  }
  cout<<sum-sum2<<endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func check(s, t string) bool {
	r := map[byte]byte{}
	for i := 0; i < len(s); i++ {
		c := s[i]
		if v, ok := r[c]; ok {
			if v != t[i] {
				return false
			}
		} else {
			r[c] = t[i]
		}
	}
	return true
}

func main() {
	var s, t string
	fmt.Scan(&s, &t)
	if check(s, t) && check(t, s) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 2176
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll h;
    ll w;
    ll n;
    cin>>h>>w>>n;
    h=max(h,w);
    ll c=0;
    ll ans = 0;
    while(c<n)
    {
        c+=h;
        ans++;
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const int N = 100001;
bool like2017[N],sosu[N];
int q,l,r,ans[N];

void sosuhantei(){
	sosu[2]=true;
	sosu[3]=true;
	int a=0;
	FOR(i,5,N){
		a=0;
		FOR(j,2,sqrt(i)+1){
			if(i%j==0){a++;break;}
		}
		if(a==0){
			sosu[i]=true;
		}
	}
}
void cal(){
	int k;
	for(int i=3;i<N;i+=2){
		k=(i+1)/2;
		if(sosu[i]&&sosu[k])like2017[i]=true;
	}
}
void answ(){
	int a;
	ans[0]=0;
	for(int i=1;i<N;i++){
		a=0;
		if(like2017[i])a=1;
		ans[i]=ans[i-1]+a;
	}
}



int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	CLR(like2017);
	CLR(sosu);
	CLR(ans);
	sosuhantei();
	cal();
	answ();
	cin>>q;
	int a;
	FOR(i,0,q){
		a=0;
		cin>>l>>r;
		if(like2017[l])a++;
		cout<<ans[r]-ans[l]+a<<endl;
	}
	return 0;
}

Measured memory_bytes: 1280
a = int(input())
b = int(input())
c = int(input())
x = int(input()) /10
count =0

for ia in range(a,-1,-1):
    for ib in range(b,-1,-1):
        for ic in range(c,-1,-1):
            if ia*50 + ib*10 + ic*5 == x:
                count +=1
            elif ia*50 + ib*10 + ic*5 < x:
                break
        if ib >0 and ia*50 + (ib-1)*10 + c*5 < x:
            break
    if ia > 0 and (ia-1)*50 + b*10 + c*5< x:
        break
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int h, w;
    cin >> h >> w;
    
    vector<string> vec(h);
    
    for (int i = 0; i<h; i++) {
        string x = "#";
        string y;
        cin >> y;
        vec.at(i) = x + y + x;
    }
    
    string s = "";
    for (int i = 0; i<w+2; i++){
        s += "#";
    }
    
    cout << s << endl;
    for (int i = 0; i<h; i++) {
        cout << vec.at(i) << endl;
    }
    cout << s << endl;
}

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

int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    int sum=0;
    for(int i=0;i<k;i++) sum+=a[i];
    cout<<sum;



}


Measured memory_bytes: 3592
#include<stdio.h>
int main()
{
  int X;
  while(scanf("%d",&X)!=0)
  {
    for(long long A=0;A<120;A++)for(long long B=-120;B<A;B++)if(A*A*A*A*A-B*B*B*B*B==X)return printf("%lld %lld\n",A,B),0;
  }
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Mid ((l+r)>>1)
const int maxn=1e5+5,inf=0x3f3f3f3f,mod=1e9+7;
int n,m,Q,T,K;
int read(){
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return x*f;
}

int a,b,c;

int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	scanf("%d%d%d",&a,&b,&c);
	if(a+b+c>=22) puts("bust");
	else puts("win");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n, sol;

int main(){
cin >> n;
int maxi = 0;
for(int i = 0 ; i < n ; ++i){
	int x;
	cin >> x;
	if(x >= maxi){
		sol++;
	}
	maxi = max(x, maxi);
}
cout << sol << endl;

return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <set>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int A, B, H;
    cin >> A >> B >> H;
    cout << (A+B)*H/2 << "\n";
    
    return 0;
}


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

int main() {
	long long n, c, k;
	long long ans = 0;
	long long tstart;
	long long i = 0;
	vector<long long> arr;
	cin >> n >> c >> k;
	long long a;
	for (long long p = 0; p < n; p++) {
		cin >> a;
		arr.push_back(a);
	}
	sort(arr.begin(),arr.end());
	tstart = arr[0]; i = 1;
	while (i<=n) {
		if (i == n) { ans++; break; }
		ans++;
		long long tend = tstart + k;
		long long cnt = 1;
		while (true) {
			if (i == n) { i++; break; }
			if (cnt == c) {
				tstart = arr[i];				i++;
				break;
			}
			if (arr[i]> tend) {
				tstart = arr[i];				i++;
				break;
			}
			cnt++;
			i++;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,m,tot,d[N],head[N],nex[2*N],to[2*N],wi[2*N];
void add(int u,int v,int w)
{
    to[++tot]=v;
    nex[tot]=head[u];
    head[u]=tot;
    wi[tot]=w;
}
void dfs(int u,int fa)
{
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];
        if(v==fa) continue;
        d[v]=(d[u]+wi[i])%2;
        dfs(v,u);
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<n;i++)
    {
        int u,v,w;
        scanf("%d%d%d",&u,&v,&w);
        add(u,v,w%2);
        add(v,u,w%2);
    }
    dfs(1,0);
    for(int i=1;i<=n;i++)
        printf("%d\n",d[i]);
}


Measured memory_bytes: 5632
n,k = map(int,input().split())
okashi = [0 for i in range(n+1)]

for i in range(k):
    d = int(input())
    if(d==1):
        oka = int(input())
        okashi[oka] += 1
    else:
        oka = list(map(int,input().split()))
        
        for j in oka:
            okashi[j] += 1
c = 0
for i in okashi:
    if(i==0):
        c+=1
print(c-1)

Measured memory_bytes: 9208
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int nl[] = new int[n];

        for (int i = 0; i < n; i++) {
            nl[i] = sc.nextInt();
        }

        for (int j = nl.length-1; j >= 0; j--) {
            if (!(j == 0)) {
                System.out.print(nl[j] + " ");
            } else {
                System.out.println(nl[j]);
            }
        }
    }
}

Measured memory_bytes: 26508
#include <iostream>
#include <vector>

using namespace std;

int main(){
  long long int N, Y;
  cin >> N >> Y;
  long long int a, b, c;
  int f = 0;
  for(int i = 0; i <= N; i++){
    for(int j = 0; i + j <= N; j++){
      long long int k = N - i - j;
      if(i * 10000 + j * 5000 + k * 1000 == Y){
        a = i;
        b = j;
        c = k;
        f = 1;
        break;
      }
    }
  }
  if(f) cout << a << " " << b << " " << c;
  else cout << -1 << " " << -1 << " " << -1;
  
}


Measured memory_bytes: 256
abc=list(map(int, input().split()))
k=int(input())
a=abc[0]
b=abc[1]
c=abc[2]

num=0
if(a < b):
  if(b < c):
    print("Yes")
  else:
    while num<k:
      c=2*c
      num=num+1
      if(b<c):
        print("Yes")
        break
    if(b>=c):
      print("No")
else:
  while num<k:
    b=2*b
    num=num+1
    if(a<b):
      break
  if(a<b):
    while num<k:
      c=2*c
      num=num+1
      if(b<c):
        print("Yes")
        break
    if(b>=c):
      print("No")
  else:
    print("No")

Measured memory_bytes: 9060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    private static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(final String[] args) throws IOException {
        FastReader in = new FastReader();
        PrintWriter out = new PrintWriter(System.out, true);

        int n = in.nextInt();
        int m = in.nextInt();

        int nc2 = (n * (n - 1)) / 2;
        int mc2 = (m * (m - 1)) / 2;
        out.println(nc2 + mc2);
    }
}


Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
#define MOD 998244353
#define INF 1000000009
typedef long long ll;
typedef pair<int,int> P;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define rollcall cout<<"I'm Sucu."<<endl
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define int ll


signed main(void){
    int X,Y;
    cin >> X >> Y;
    int Ans=0;
    while(X<=Y){
        Ans++;
        X*=2;
    }
    cout << Ans << endl;
  return 0;
}


Measured memory_bytes: 256
import math

# input
N, M = map(int, input().split())
edge_lst = [list(map(int, input().split())) for _ in range(M)]

d_1 = []
d_N = []

for e in edge_lst:
    if e[0] == 1:
        d_1.append(e[1])
    if e[1] == N:
        d_N.append(e[0])

ans = list(set(d_1) & set(d_N))

if len(ans) == 0:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Measured memory_bytes: 61048
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
int main() {
  string s;
  cin >> s;
  for(int i=0; i<s.length(); i++) {
    if(s[i]=='C') {
      for(int j=i+1; j<s.length(); j++) {
        if(s[j]=='F') {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
<?php
  const DIRS = "RDLU";
  $p = array(1,0,0);
  $path = array('R');
  $stepx =  array(1,0,-1,0);
  $stepy = array(0,1,0,-1);

  function frontIsClear($x,$y,$d,$l) {
      return ($d == 0 && ($y>0 ? !$l[2*$y-1][$x] : 1)) || ($d == 1 && ($x<4 ? !$l[2*$y][$x] : 1))
          || ($d == 2 && ($y<4 ? !$l[2*$y+1][$x] : 1)) || ($d == 3 && ($x>0 ? !$l[2*$y][$x-1] : 1));
  }

  function canMove($x,$y,$d,$l) {
      return ($d==0 && $x!=4 && $l[2*$y][$x]) || ($d==1 && $y!=4 && $l[2*$y+1][$x])
          || ($d==2 && $x!=0 && $l[2*$y][$x-1]) || ($d==3 && $y!=0 && $l[2*$y-1][$x]);
  }

  function move(&$p,$stepx,$stepy) {
      if($p[2] == 0 || $p[2] == 2)
          $p[0] = $p[0] + $stepx[$p[2]];
      else
          $p[1] = $p[1] + $stepy[$p[2]];
  }

  for($i=0;$i<9;$i++)
      $l[] = trim(fgets(STDIN));

  while(true) {
       if(!frontIsClear($p[0],$p[1],$p[2],$l)){
          $p[2] = ($p[2]+3) % 4;
       } else {
           while(!canMove($p[0],$p[1],$p[2],$l))
              $p[2] = ($p[2]+1) % 4;
       }
       if($p == array(0,0,0))
           break;
       move($p,$stepx,$stepy);
       $path[] = DIRS[$p[2]];
  }

  echo implode('',$path).PHP_EOL;

Measured memory_bytes: 15228
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))

l = []
for i in range(n):
    for _ in range(a[i]):
        l.append(i+1)

ans = []
flag = True
for i in range(h):
    if flag:
        ans.append(l[w*i:w*(i+1)])
    else:
        ll = l[w*i:w*(i+1)]
        ll.reverse()
        ans.append(ll)
    flag = not flag

for i in ans:
    print(' '.join(map(str, i)))

Measured memory_bytes: 71492
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int R,G,B,N;
    cin >> R >> G >> B >> N;
    int cnt = 0;
    for(int i = 0;i <= N / R;i++) {
        for(int j = 0;j <= (N - i * R) / G;j++) {
            if((N - i * R - j * G) % B == 0) {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
n,l=map(int,input().split())
arr=list(map(int,input().split()))
psbl=False
pos=0
for i in range(n-1):
    if arr[i]+arr[i+1]>=l:
        psbl=True
        pos=i
        break
if psbl:
    print("Possible")
    for i in range(0,pos):
        print(i+1)
    for i in range(n-2,pos,-1):
        print(i+1)
    print(pos+1)
else:
    print("Impossible")


Measured memory_bytes: 14204
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

struct edge{int to; int cost;};
vector<vector<edge>> graph(0);
vector<int> d(0);
const int MAX_dist=1e9+7;

void init(int n){
    graph.resize(n);
    d.resize(n,MAX_dist);
}

void dijkstra(int s){
    if(d.size()==0){cout<<"You Should init"<<endl;return;}
    priority_queue<P, vector<P>, greater<P>> que;
    d[s]=0;
    que.emplace(0,s);
    while(!que.empty()){
        P p=que.top();
        que.pop();
        int v=p.second;
        if(d[v]<p.first) continue;
        rep(i,graph[v].size()){
            edge e=graph[v][i];
            if(d[e.to]>d[v]+e.cost){
            d[e.to]=d[v]+e.cost;
            que.emplace(d[e.to],e.to);
            }
        }
    }
}

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int h,w;
    cin>>h>>w;
    int x;
    init(10);
    rep(i,10)rep(j,10){
        cin>>x;
        graph[j].push_back({i,x});
    }
    map<int,int> a;
    rep(i,h)rep(j,w){
        cin>>x;
        a[x] ++;
    }
    dijkstra(1);
    int ans=0;
    rep(i,10) ans +=a[i]*d[i];
    cout<<ans<<endl;
}

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

int main() {

    int n;
    long long int x;

    cin >> n >> x;

    long long int a[n];

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

    long long int ans = 0;

    if(a[0] + a[1] > x){
        if(a[0] < x){
            ans += a[1] - (x-a[0]);
            a[1] = x-a[0];
        }
        else if(a[0] >= x){
            ans += a[1];
            a[1] = 0;
            ans += a[0] - x;
            a[0] = x;
        }
    }

    for(int i=1; i<n-1; i++){
        if(a[i] + a[i+1] > x){
            ans += a[i+1] - (x-a[i]);
            a[i+1] = x-a[i];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<x<<endl
#define all(v) v.begin(), v.end()
using namespace std;
//型エイリアス
using vi = vector<int>;
using ll = long long;
using P = pair<int,int>;
using Mat = vector<vector<int>>;
const ll inf = 1e18;
const int N = 2e5+10;

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

    sort(all(s));
    sort(all(t),greater<char>());

    if(s<t) cout("Yes");
    else cout("No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<vector<int>> G(N);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<bool> used(N);
  queue<int> f, s;
  f.push(0);
  s.push(N - 1);
  used[0] = used[N - 1] = true;
  int fennec = 0, snuke = 0;
  while (!f.empty() || !s.empty()) {
    queue<int> nf, ns;
    while (!f.empty()) {
      int v = f.front(); f.pop();
      for (int u: G[v]) {
        if (!used[u]) {
          ++fennec;
          used[u] = true;
          nf.push(u);
        }
      }
    }
    while (!s.empty()) {
      int v = s.front(); s.pop();
      for (int u: G[v]) {
        if (!used[u]) {
          ++snuke;
          used[u] = true;
          ns.push(u);
        }
      }
    }
    f = nf;
    s = ns;
  }
  cout << (fennec > snuke ? "Fennec" : "Snuke") << endl;
  return 0;
}


Measured memory_bytes: 5888
import java.io.*;
import java.util.*;


public class Main {
	public static void main(String[] args) {
		int[] n=new int[5];
		
		String s=null;
		InputStreamReader isr=new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try{
			s=br.readLine();
			StringTokenizer st=new StringTokenizer(s," ");
			for(int i=0;i<5;i++){
				n[i]=Integer.parseInt(st.nextToken());
			}
		}catch(IOException e){
			e.printStackTrace();
		}
		if((n[2]-n[4])>=0&&(n[2]+n[4])<=n[0]&&(n[3]-n[4])>=0&&(n[3]+n[4])<=n[1]){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
		
	}

}



Measured memory_bytes: 24464
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	h,w = readline() |> split |> parseMap
	a = ["" for i in 1:h]
	for i in 1:h
		a[i] = readline() |> chomp
	end
	c = 0
	r = 0
	for i in 1:h
		k = 0
		for j in 1:w
			if a[i][j]=='#'
				k += 1
			end
		end
		c += k-1
	end
	for i in 1:w
		k = 0
		for j in 1:h
			if a[j][i]=='#'
				k += 1
			end
		end
		r += k-1
	end
	println(r+1==h&&c+1==w?"Possible":"Impossible")
end
main()


Measured memory_bytes: 112780
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define mp make_pair

/// easy access -------------
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<int,int> pii;
///-------------------------

/// problem's variable---------------



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


int main()
{
    Phuong_;
    ll n,a,b;
    cin >> n >> a >> b;
    ll d = n/(a+b);
    n=(n%(a+b));
    d*=a;
    d+=min(n,a);
    cout << d;
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <cassert>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple

using namespace std;

typedef long long ll;
//typedef pair<int, int> P;
typedef unsigned long long ull;

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

int P[] = { 3, 2, 1, 0 };
int Q[] = { 1, 0, 3, 2 };

const int N = 110;
int dist[N][N][4][12];
int n, m, a;
vector<string> board;
priority_queue<tuple<int, int, int, int, int>> pq;

void enq(int r, int c, int dir, int p, int q){
	if (p > a || q > a) return;
	r += dy[dir], c += dx[dir];
	if (r < 0 || r >= n || c < 0 || c >= m) return;
	if (board[r][c] == '#') return;
	if (board[r][c] == 'S' && dir == 0) return;
	int d = p + q;
	if (dist[r][c][dir][p] <= d) return;
	dist[r][c][dir][p] = d;
	pq.emplace(-d, r, c, dir, p);
};


int main(){
	cin >> n >> m >> a;

	board.resize(n);
	rep(i, n) cin >> board[i];

	pair<int, int> start, goal;
	rep(i, n) rep(j, m){
		if (board[i][j] == 'S') start = MP(i, j);
		if (board[i][j] == 'G') goal = MP(i, j);
	}

	MEMSET(dist, 0x7f);
	dist[start.first][start.second][2][0] = 0;
	pq.push(MT(0, start.first, start.second, 2, 0));

	int ans = -1;
	while (!pq.empty()){
		auto state = pq.top();
		pq.pop();
		int d, r, c, dir, p, q;
		tie(d, r, c, dir, p) = state;
		d = -d;
		q = d - p;

		if (dist[r][c][dir][p] < d) continue;

		if (MP(r, c) == goal){
			ans = d;
			break;
		}
		
		if (board[r][c] != 'S'){
			enq(r, c, P[dir], p + 1, q);
			enq(r, c, Q[dir], p, q + 1);
		}
		enq(r, c, dir, p, q);
	}

	cout << ans << endl;


	return 0;
}

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

#define debug(x) cout << #x" = " << x;

#define st first
#define nd second

using namespace std;
using namespace placeholders;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

const int MAXM = 1E5 + 10;

int n, m;
int ans[MAXM];
vector<PII> E[MAXM];

int s[MAXM];

void update(int i, int c){
	for (; i <= m; i = (i | i - 1) + 1)
		s[i] += c;
}

int query(int i){
	int ret = 0;
	for (; i > 0; i &= i - 1)
		ret += s[i];
	return ret;
}

int main(){
	scanf("%d%d", &n, &m);
	for (int l, r, i = 0; i < n; ++i){
		scanf("%d%d", &l, &r);
		E[r - l + 1].push_back(PII(l, r));
	}
	for (int i = m; i >= 1; --i)
		ans[i] = ans[i + 1] + E[i].size();
	for (int i = 2; i <= m; ++i){
		for (int j = 0; j < E[i - 1].size(); ++j)
			update(E[i - 1][j].st, 1), update(E[i - 1][j].nd + 1, -1);
		for (int j = i; j <= m; j += i)
			ans[i] += query(j);
	}
	for (int i = 1; i <= m; ++i)
		printf("%d\n", ans[i]);
	return 0;
}


Measured memory_bytes: 8320
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

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

    ll n, k;
    cin >> n >> k;
    ll arr[n];
    for(int i = 0; i < n; i++) cin >> arr[i];
    sort(arr, arr + n);
    reverse(arr, arr + n);
    ll ans = 0;
    for(int i = k; i < n; i++) {
        ans += arr[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
typedef priority_queue<int> PQ;
typedef priority_queue<int,vector<int>,greater<int> > RPQ;
bool is_uruu(int y) {
        return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
const ll MOD=1e9+7;
const double PI=acos(-1.0);
//----------------------------------------------------------------------------------------------------------------------------------//
int n,bus,times;
int a[100000];
int maxtime[100000];
int main(){
        cin>>n>>bus>>times;
        for(int i=0; i<n; i++) {
                cin>>a[i];
        }
        sort(a,n);
        for(int i=0; i<n; i++) {
                maxtime[i]=a[i]+times;
        }
        int ans=0,i,j;
        for(i=0; i<n; ) {
                int nowmax=maxtime[i];
                //cout<<i<<" "<<nowmax<<endl;
                int overp=1;
                ans++;
                if(i>=n-1) break;
                for( j=i+1; j<n; ) {
                        if(a[j]<=nowmax && overp<bus) { overp++; j++;}
                        //cout<<j<<" "<<overp<<" "<<ans<<endl;
                        if(a[j]>nowmax || overp>=bus) {
                                i=j;
                                break;
                        }
                }
                if(j>=n) break;
        }
        cout<<ans<<endl;
}


Measured memory_bytes: 1024
#pragma warning (disable: 6031)
#pragma warning (disable: 26451)

#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <map>


const int mod = 1000000007;
//const int mod = 998244353;
int maximum(int a, int b) { return a < b ? b : a; }
int minimum(int a, int b) { return a > b ? b : a; }
int main() {
	int N, P;
	scanf("%d %d", &N, &P);
	auto S = new char[N + 1];
	scanf("%s", S);
	long long res = 0;
	if (P == 2 || P == 5) {
		for (int i = 0; i < N; i++) {
			if ((S[i] - '0') % P == 0) {
				res += i + 1;
			}
		}
	}
	else {
		int tenn = 1;
		auto cnt = new long long[P] {1};
		int sum = 0;
		for (int i = N - 1; i >= 0; i--) {
			sum = (sum + (S[i] - '0') * tenn) % P;
			cnt[sum]++;
			tenn = tenn * 10 % P;
		}
		for (int i = 0; i < P; i++) {
			res += cnt[i] * (cnt[i] - 1) / 2;
		}
	}
	printf("%lld", res);
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
	int k,s,x,y,z,i=0;
	cin >> k >> s;
	for(x=0;x<=k;x++){
		for(y=0;y<=k;y++){
            z=s-x-y;
			if(z>=0 && z<=k)
                i++;
		}
	}
	cout << i << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 


signed main(){
    FASTER;
    int n;cin>>n;
    vii v(n);cin>>v;
    sort(all(v),[](pii a,pii b){return a.second<b.second;});
    
    int t=0;
    for(pii p:v){
        if(t+p.first<=p.second){
            t+=p.first;
        }else{
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    
}


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

a = []; b = []

for i in range(n):
    x, y = map(int, input().split())

    a.append(x + y)
    b.append(x - y)

sm = a[0]; lr = a[0]; ans = float('-inf')

for i in range(1, n):
    ans = max(ans, lr - a[i])
    ans = max(ans, a[i] - sm)
    
    lr = max(lr, a[i])
    sm = min(sm, a[i])
sm = b[0]; lr = b[0]
for i in range(1, n):
    ans = max(ans, lr - b[i])
    ans = max(ans, b[i] - sm)
    
    lr = max(lr, b[i])
    sm = min(sm, b[i])
print(ans)


Measured memory_bytes: 96584
#include <bits/stdc++.h>
#include <math.h>
 
#define rep(i, n) for(int i = 0; (int)(i) < n; i++)
 
using namespace std;
 
int main() {
  int N, A;
  cin >> N;
  vector<int> sub(N);
  rep(i, N - 1){
    cin >> A;
    sub.at(A - 1)++;
  }
  rep(i, N) cout << sub.at(i) << endl;
}
  

Measured memory_bytes: 4004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a7=1000000007;
ll inf=100000000000000000;

int main()
{
  ll n;cin>>n;
  ll d[n];
  for(ll i=0;i<n;i++)cin>>d[i];
  ll ans=0;
  for(ll i=0;i<n;i++){
    for(ll j=i+1;j<n;j++){
      ans+=d[i]*d[j];
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

ll f(ll n, ll i) {
    return n/(1LL << i+1)*(1LL << i) + max((ll)0, n%(1LL << i+1) - ((1LL << i)-1));
}

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

  ll a, b;
  cin >> a >> b;
  ll ans = 0;
  a--;

  rep(i, 50) {
    ll ac = f(a, i);
    ll bc = f(b, i);
    if ((bc-ac)%2 == 1) {
      ans |= 1LL << i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int N;
    cin >> N;
    if (N <= 999) {
        cout << "ABC" << endl;
    } else {
        cout << "ABD" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/*
	Name: None
	Copyright: zhangjingcanËùÓÐ£¬Î´¾­ÔÊÐí²»µÃ×ªÔØ
	Author: zhangjingcan
	Date:
	Description: C++ÎÄ¼þ
*/
#include <bits/stdc++.h>
using namespace std;
const int A=27;
int n,m;
string s;
int main(int argc, char** argv) {
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>s;
			if(s=="snuke"){
				cout<<char(j+'A'-1)<<i<<"\n";
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
N=int(input())
A=[i for i in map(int,input().split())]

X=[0]*N
X[0]=sum(A[0::2])-sum(A[1::2])

for i in range(1, N):
    X[i]=2*A[i-1]-X[i-1]

print(' '.join(map(str,X)))


Measured memory_bytes: 19096
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
typedef long long ll;
using namespace std;
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
inline int rd(){
	int res=0,sign=1;char ch;
	while((ch=getchar())<'0'||ch>'9')if(ch=='-')sign=-1;res=res*10+ch-48;
	while((ch=getchar())>='0'&&ch<='9')res=res*10+ch-48;
	return res*sign;
}
int a,b,c;
int t=1;
int main(){
	a=rd(),b=rd(),c=rd();
	for(int i=1;i<=1000;i++){
		t=a*i;
		if(t%b==c){
			puts("YES");
			return 0;
		} 
	}
	puts("NO");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
    #include<algorithm>
    #include<functional>
     
    using namespace std;
     
    int main() {
    	long long n, a[100000];
    	cin >> n;
    	for (int i = 0; i < n; i++)cin >> a[i];
    	sort(a, a + n, greater<long long>());
    	long long j = 0, x = 0, y = 0;
    	while (!(x > 0 && y > 0) && j < n) {
    		if (a[j] == a[j + 1]) {
    			if (x == 0)x = a[j];
    			else if (y == 0) {
    				y = a[j];
    				break;
    			}
    			j += 2;
    		}
    		else j++;
    	}
    	cout << x*y << endl;
    	return 0;
    }

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define f first
#define s second
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
    int n;
    scanf("%d", &n);
    string s, t;
    cin >> s >> t;
    string r = "";
    for(int i = 0; i < 2*n; i++){
        if(i & 1){
            r += t[i/2];
        }else{
            r += s[i/2];
        }
    }
    cout << r << endl;
    return 0;
}

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

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

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

    int inp[n];
    for (int i = 0; i < n; i++)
        scanf("%d", &inp[i]);
    sort(inp, inp + n, greater<int>());

    ll ans = 0;
    /* WA
    int mx1 = inp[0];
    int mx2 = INT_MAX;
    for (int i = 1; i < n; i++) {
        ans += min(mx1, mx2);
        mx1 = mx2;
        mx2 = inp[i];
    }
    */

    for (int i = 1; i < n; i++) {
        ans += inp[i / 2];
    }

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

    return 0;
}


Measured memory_bytes: 4616
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::cmp::{min, max};

struct Scanner<R: Read> {
    reader: R,
    buffer: String,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader, buffer: String::new() }
    }

    // fn line(&mut self) -> String {
    //     self.buffer = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
    //         .skip_while(|&c| c == '\n' || c == '\r')
    //         .take_while(|&c| !(c == '\n' || c == '\r'))
    //         .collect::<String>();
    //     self.buffer.clone()
    // }

    fn read_buffer(&mut self) {
        self.buffer = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        self.read_buffer();
        if self.buffer.is_empty() {
            None
        } else {
            self.buffer.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            // writeln!(std::io::stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.read()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item=U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(104_857_600)
        .spawn(solve)
        .unwrap()
        .join()
        .unwrap();
}

fn solve() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n = sc.read();
    let k = sc.read();
    let w: Vec<u32> = sc.vec(n);

    let is_ok = |max_w: u32| {
        let mut i = 0;
        for _ in 0..k {
            let mut cur_w = 0;
            while i < n && cur_w + w[i] <= max_w {
                cur_w += w[i];
                i += 1;
            }
        }
        i == n
    };

    let mut ok = u32::max_value();
    let mut bad = 0;
    while ok - bad > 1 {
        let mid = (ok + bad) / 2;
        if is_ok(mid) {
            ok = mid;
        } else {
            bad = mid;
        }
    }

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



Measured memory_bytes: 9084
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
		
	void doIt() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k[] = new int[n];
		for(int i = 0; i < m; i++) {
			int knum = sc.nextInt();
			for(int j = 0; j < knum; j++) {
				k[sc.nextInt() - 1] += (1 << i);
			}
		}
		int p = 0;
		for(int i = 0; i < m; i++) {
			p += sc.nextInt() << i; 
		}
		int cnt = 0;
		for(int i = 0; i < (1 << n); i++) {
			int check = 0;
			for(int j = 0; j < n; j++){
				if(((i >> j) & 1) == 1) {
					check ^= k[j];
				}
			}
			if(check == p) cnt++;
		}
		System.out.println(cnt);
	}

	
	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 23892