akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
int mod=1000000007;
int32_t main()
{
   fastio
   int n,m;
   cin>>n>>m;
   unordered_map<int,int>mp;
   while(m--)
   {
     int a;
     cin>>a;
     mp[a]=1;
   }
   int dp[n+1]={0};
   dp[0]=1;
   for(int i=1;i<=n;i++)
   {
     if(mp[i]==1)continue;
     else
     {
       if(i==1)dp[i]=dp[i-1]%mod;
       else dp[i]=((dp[i-1]%mod)+(dp[i-2]%mod))%mod;
     }
   }
   cout<<dp[n]%mod<<endl;
   return 0;
}

Measured memory_bytes: 5156
def lotate(dic, dire):
    if dire == 'N':
        x,y,z,w = dic['up'], dic['back'], dic['bottom'], dic['front']
        dic['back'], dic['bottom'], dic['front'], dic['up'] = x,y,z,w
    elif dire == 'S':
        x, y, z, w = dic['up'], dic['back'], dic['bottom'], dic['front']
        dic['front'], dic['up'], dic['back'], dic['bottom'] = x, y, z, w
    elif dire == 'W':
        x, y, z, w = dic['up'], dic['left'], dic['bottom'], dic['right']
        dic['left'], dic['bottom'], dic['right'], dic['up'] = x, y, z, w
    elif dire == 'E':
        x, y, z, w = dic['up'], dic['left'], dic['bottom'], dic['right']
        dic['right'], dic['up'], dic['left'], dic['bottom'] = x, y, z, w
    return dic


a,b,c,d,e,f = map(int, input().split())
n = int(input())
for _ in range(n):
    dic = {'up': a, 'front': b, 'right': c, 'left': d, 'back': e, 'bottom': f}
    x, y = map(int, input().split())
    s = 'EEENEEENEEESEEESEEENEEEN'
    for i in s:
        if dic['up'] == x and dic['front'] == y:
            print(dic['right'])
            break
        dic = lotate(dic, i)


Measured memory_bytes: 5608
import scala.io.StdIn._
object Main extends App {
  val read = readLine().split(' ').map(_.toInt)
  val alpha = math.Pi * read(3) * 6 / 180
  val beta = (math.Pi * (read(2) * 30 + read(3) * 0.5)) / 180
  val Ax = read(0) * math.cos(alpha)
  val Ay = read(0) * math.sin(alpha)
  val Bx = read(1) * math.cos(beta)
  val By = read(1) * math.sin(beta)
  val cos = (Ax * Bx + Ay * By) / (read(0) * read(1))
  val AB2 = read(0) * read(0) + read(1) * read(1) - 2 * read(0) * read(1) * cos
  val AB = math.sqrt(AB2)
  println(AB)
}


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

""" 逆順使わないでDPでやる版 """

S = input()

dp = [False] * (len(S)+1)
# 0文字地点は遡る用にTrueにしておく
dp[0] = True

for i in range(1, len(dp)):
    if i-5 >= 0:
        if S[i-5:i] == "dream" or S[i-5:i] == "erase":
            # 条件に当てはまったら、文字数分遡って有効な文字列が続いているか確認
            if dp[i-5]:
                dp[i] = True
    if i-6 >= 0:
        if S[i-6:i] == "eraser":
            if dp[i-6]:
                dp[i] = True
    if i-7 >= 0:
        if S[i-7:i] == "dreamer":
            if dp[i-7]:
                dp[i] = True

if dp[len(S)]:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3956
use std::collections::HashMap;
use std::collections::VecDeque;
use std::io::{self, Read};
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
type Point = (usize, usize);
type Graph = HashMap<Point, Vec<Point>>;
type Todo = VecDeque<Point>;

fn dijkstra(g: &Graph, v0: Point, v1: Point) -> i64 {
    let mut pot: HashMap<Point, i64> = HashMap::new();
    pot.insert(v0, 0);
    let mut todo: Todo = VecDeque::new();
    todo.push_back(v0);
    while !todo.is_empty() {
        let cur = todo.front().unwrap().clone();
        todo.pop_front();
        // eprintln!("cur:{},{}, pot:{}", cur.0, cur.1, *pot.get(&cur).unwrap());
        match g.get(&cur) {
            Some(ws) =>
                for w in ws {
                    if !pot.contains_key(w) {
                        let dist = pot.get(&cur).unwrap() + 1;
                        pot.insert(*w, dist);
                        todo.push_back(*w);
                        if *w == v1 {
                            return dist / 3;
                        }
                    }
                },
            None => (),
        }
    }
    -1
}

fn main() {
    let _: usize = read();
    let m: usize = read();
    let mut g: Graph = HashMap::new();
    for _ in 0..m {
        let p: usize = read::<usize>() - 1;
        let q: usize = read::<usize>() - 1;
        for i in 0..3 {
            g.entry((p, i)).or_insert(Vec::new()).push((q, (i + 1) % 3));
        }
    }
    let s: usize = read::<usize>() - 1;
    let t: usize = read::<usize>() - 1;
    let ans = dijkstra(&g, (s, 0), (t, 0));
    println!("{}", ans);
}

Measured memory_bytes: 78056
#include <iostream>
using namespace std;
int main(void){
    long long N,i,j;
    cin>>N;
    for(i=1;i<10;i++){
        for(j=1;j<10;j++){
            if(N==i*j){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
typedef long long ll;
using namespace std;

int main()
{
	int A, B;
	cin >> A;
	cin >> B;
	if (A==1)
	{
		A = 14;
	}
	if (B == 1)
	{
		B = 14;
	}
	if (A>B)
	{
		cout << "Alice";
	}
	else if (A<B)
	{
		cout << "Bob";
	}
	else
	{
		cout << "Draw";
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    int aPlusB = a + b;
    
    if (aPlusB % 2 == 0) {
      System.out.println(aPlusB / 2);
    } else {
      System.out.println("IMPOSSIBLE");
    }
  }
}

Measured memory_bytes: 23764
// 2011/01/09 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int seg[11][7] = {{0,1,1,1,1,1,1},
	                  {0,0,0,0,1,1,0},
	                  {1,0,1,1,0,1,1},
	                  {1,0,0,1,1,1,1},
	                  {1,1,0,0,1,1,0},
	                  {1,1,0,1,1,0,1},
	                  {1,1,1,1,1,0,1},
	                  {0,1,0,0,1,1,1},
	                  {1,1,1,1,1,1,1},
	                  {1,1,0,1,1,1,1},
	                  {0,0,0,0,0,0,0}};

	while(true){
		int n;
		cin >> n;
		if(n==-1)
			break;

		int pst = 10;
		int now;
		for(int i=0; i<n; i++){
			cin >> now;
			for(int j=0; j<7; j++)
				cout << (seg[pst][j]+seg[now][j])%2;
			cout << endl;
			pst = now;
		}
	}

	return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    int t=1,b=n-1;
    ll l=a[0],r=a[0],ans1=0,ans2=0;
    while(1){
        if(t>b) break;
        ans1+=abs(a[b]-l);
        l=a[b];
        --b;
        if(t>b) break;
        ans1+=abs(a[b]-r);
        r=a[b];
        --b;
        if(t>b) break;
        ans1+=abs(a[t]-l);
        l=a[t];
        ++t;
        if(t>b) break;
        ans1+=abs(a[t]-r);
        r=a[t];
        ++t;
    }
    b=0,t=n-2;
    l=a[n-1],r=a[n-1];
    while(1){
        if(b>t) break;
        ans2+=abs(a[b]-l);
        l=a[b];
        ++b;
        if(b>t) break;
        ans2+=abs(a[b]-r);
        r=a[b];
        ++b;
        if(b>t) break;
        ans2+=abs(a[t]-l);
        l=a[t];
        --t;
        if(b>t) break;
        ans2+=abs(a[t]-r);
        r=a[t];
        --t;
    }
    cout << max(ans1,ans2) << "\n";
    return 0;
}   

Measured memory_bytes: 3992
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N;
	cin >> N;
	if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8)cout << "pon\n";
	else if (N % 10 == 2 || N % 10 == 4 || N % 10 == 5 || N % 10 == 7 || N % 10 == 9)cout << "hon\n";
	else cout << "bon\n";
	return 0;
}

Measured memory_bytes: 3136
N = int(input())
L = list(map(int,input().split()))

L.sort()
#print(L)

count = 0
for i in range(N):
	for j in range(N):
		for k in range(N):
			if (i <j and j<k ) and (L[i] != L[j] and L[j] != L[k] and L[k] !=L[i]) and (L[i] +L[j] > L[k]):
				count = count + 1
#				print(i,j,k,"/",L[i],L[j],L[k])
print(count)

Measured memory_bytes: 9136
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

class Program
{

    static void Main()
    {
        var sc = new Scanner();
        string a = Console.ReadLine();
        string[] b = a.Split(' ');
        string c = b[1];
        char d = c[0];
        Console.WriteLine("A"+d+"C");
    }
}
static class Extentions
{
    public static IEnumerable<T> Outpuut<T>(this IEnumerable<T> source)
    {
        foreach (var item in source)
        {
            Console.WriteLine(item);
        }
        return source;
    }
    public static T Print<T>(this T obj)
    {
        Console.WriteLine(obj);
        return obj;
    }
}
public class Scanner
{
    public Scanner()
    {
        byte[] inputBuffer = new byte[1024];
        System.IO.Stream inputStream = Console.OpenStandardInput(inputBuffer.Length);
        Console.SetIn(new System.IO.StreamReader(inputStream, Console.InputEncoding, false, inputBuffer.Length));
    }
    string[] buffer = new string[0];
    int index = 0;
    public char[] SplitChars { get; set; }
    public string String()
    {
        if (index < buffer.Length) return buffer[index++];
        string line = "";
        while (line == "") line = Console.ReadLine();
        if (line == null) return null;
        buffer = line.Split(SplitChars, StringSplitOptions.RemoveEmptyEntries);
        index = 0;
        return buffer[index++];
    }
    public string[] StringArray(int count) { return NextArray(count, x => x); }
    public void Skip(int count) { for (int i = 0; i < count; i++) String(); }
    public T Next<T>(Func<string, T> parser) { return parser(String()); }
    public T[] NextArray<T>(int count, Func<string, T> parser)
    {
        var arr = new T[count];
        for (int i = 0; i < count; i++) arr[i] = Next(parser);
        return arr;
    }
    public int Int() { return Next(int.Parse); }
    public int[] IntArray(int count) { return NextArray(count, int.Parse); }
    public double Double() { return Next(double.Parse); }
    public double[] DoubleArray(int count) { return NextArray(count, double.Parse); }
}


Measured memory_bytes: 2648
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

char str[200005];

int main(int argc, char* argv[])
{
    scanf("%s", str);
    long len=strlen(str);
    long i;
    ll   sum=0;
    long cnt=0;
    for(i=0; i<len; i++) {
        if(str[i]=='B') cnt++;
        else {
            sum += cnt;
        }
    }
    printf("%lld\n", sum);

    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
// https://atcoder.jp/contests/abc125/tasks/abc125_d
void Solve02()
{
    int n;
    cin >> n;
    long long a[n + 1], dp[n + 1][2];
    dp[0][0] = 0, dp[0][1] = -1e10;
    for (int i = 1; i < n + 1; i++)
        cin >> a[i];
    for (int i = 1; i < n + 1; i++)
    {
        dp[i][0] = max((dp[i - 1][0] + a[i]), (dp[i - 1][1] - a[i]));
        dp[i][1] = max((dp[i - 1][0] - a[i]), (dp[i - 1][1] + a[i]));
        // cout << dp[i][0] << " " << dp[i][1] << endl;
    }
    cout << dp[n][0];
}
 
int main()
{
    Solve02();
}

Measured memory_bytes: 2560
import java.util.Comparator;
import java.util.Scanner;

class Main{




	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] count = new int[n+1];
		for(int i = 0;i < 2*m;i++){
			int x = sc.nextInt();
			count[x]++;
		}
		for(int i = 1;i <= n;i++){
			System.out.println(count[i]);
		}
	}

}

class MyComparator implements Comparator {
	 
    public int compare(Object obj1, Object obj2) {
         
        int num1 = (int)obj1;
        int num2 = (int)obj2;
         
        if(num1 < num2) {
            return 1;
        } else if(num1 > num2) {
            return -1;
        } else{
            return 0;
        }
    }
}




Measured memory_bytes: 22996
#include <bits/stdc++.h>
#include <cstdlib>
using namespace std;
string a;
int s,i,n;
int main()
{
    cin>>a;
    n=a.length();
    for(i=0;i<n;i++)
    {
        if(a[i]=='1')
        s++;
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int n;
    cin>>n;
    int v[n];
    map<int,int> g;
    map<int,int> k;
    rep(i,n) {
        cin>>v[i];
        if(i%2==0) g[v[i]]++;
        else k[v[i]]++;
    }
    int cg=0,ck=0,cga,cka,cgs=0,cks=0;
    bool zg=false,zs=false;
    for(auto p:g){
        cg=max(cg,p.second);

        if(cg==p.second) cga=p.first;
    }
    for(auto p:k){
        ck=max(ck,p.second);
        if(ck==p.second) cka=p.first;
    }
    if(cga!=cka) cout << n-cg-ck << endl;
    else{
        for(auto p:g){
            if(p.first==cga) continue;
            cgs=max(cgs,p.second);

        }
        for(auto p:k){
            if(p.first==cga) continue;
            cks=max(cks,p.second);
        }
        if(ck-cks>=cg-cgs) cout << n-ck-cgs << endl;
        else cout << n-cg-cks << endl;
    }



}


Measured memory_bytes: 7296
package main

import (
	"fmt"
)

func main() {
	var n,k int
  	fmt.Scan(&n,&k)
  	n++
  
  ans := 1
  for i := 1; i < n; i++ {
    if ans * 2 < ans + k {
    	ans = ans * 2
    } else {
    	ans = ans + k
    }
    
  }
  fmt.Println(ans)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
long long x1,x2,x3;
string s;
int main()
{
  cin>>s;
  for(int i=0;i<s.length();i++){
    if(s[i]=='a')x1=1;
    if(s[i]=='b')x2=1;
    if(s[i]=='c')x3=1;
  }
  if(x1==0 || x2==0 || x3==0)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;

int N, X;
int L;
int length;
int main(void){
    cin >> N >> X;
    int count = 1;
    REP(i,N){
        cin >> L;
        length += L;
        if (length <= X) count++;
        else break;
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 256
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
front = [0]
back = [0]
for i in range(len(A)):
    front.append(gcd(A[i], front[i]))
    back.append(gcd(A[len(A) - i - 1], back[i]))
ans = 0
for i in range(len(A)):
    ans = max(gcd(front[i], back[len(A) - i - 1]), ans)
print(ans)


Measured memory_bytes: 16144
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
    string a = rstr();
    string b = rstr();
    string ans = "Yes";
    
    // aで先頭文字と同じ文字が見つかったときbも同様か確認
    // 先頭文字と同じ文字を消去
    // 計算量 O(26|S|)くらい
    while(a.Length > 0){
        
        if(a.Length != b.Length){
            ans = "No";
            break;
        }
        
        for(int i=1;i<a.Length;i++){
            
            if(a[i] == a[0]){
                if(b[i] != b[0]){
                    ans = "No";
                    break;
                }
            }
            
        }

        a = a.Replace(a[0].ToString(),"");
        b = b.Replace(b[0].ToString(),"");
    }
    if(b.Length >0){
        ans = "No";
    }
    WriteLine(ans);
    
    
    
    
    }
    //各種読取
    static string rstr(){
        return ReadLine();
    }
    static int rint(){
        return int.Parse(ReadLine());
    }
    static string[] stra(){
        return ReadLine().Split(' ');
    }
    static int[] inta(){
        string[] read_str_array = ReadLine().Split(' ');
        int[] return_int_array = new int[read_str_array.Length];
        for(int countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
        }
        return return_int_array;
    }
    static int[,] inta2(int num_array,int in_array){
        int[,] int_array2 = new int[num_array,in_array];
        for(int i=0;i<num_array;i++){
            int[] temp_array = inta();
            for(int j=0;j<in_array;j++){
                int_array2[i,j] = temp_array[j];
            }
        }
        return int_array2;
    }
}

Measured memory_bytes: 26328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[200010],f[200010];
ll n,k;
inline bool check(ll x){
	 ll m=k;
	 for(int i=1;i<=n;i++){
	 	if(f[i]*a[i]>x){
			ll now=a[i]-x/f[i];
			if(m>=now) m-=now;
			else return 0;
		}
  }
  return 1;
}
int main(){
	//ll n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) cin>>f[i];
	ll l=0,r=1e12;
	sort(a+1,a+1+n);
	sort(f+1,f+1+n,greater<ll>());
	while(l<r){
		ll mid=(l+r)>>1;
		if(check(mid)) r=mid;
		else l=mid+1;
	}
	cout<<l<<'\n';
}


Measured memory_bytes: 3328
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"

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

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

//動的計画法で役に立つ関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int R, G, B, N;cin >> R >> G >> B>> N;
    int c=0;
    for (int r=0; r*R<=N; r++)
    {
        for (int g=0; r*R+g*G<=N; g++)
        {
            int b=(N-r*R-g*G)%B;
            if (b>=0 && b==0) c++;
        }
    }
    cout << c << endl;
  
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		System.out.println(Integer.max(Integer.max(A + B, A - B), A * B));
	}
}

Measured memory_bytes: 23764
import Control.Applicative
import Control.Monad
import Data.List

solve :: String -> Int
solve ss = minimum . fmap (flip go ss) . nub $ ss
  where
    ln = length ss
    go c xs
        | all (== c) xs = ln - length xs
        | otherwise     = go c (fmap f (zip xs (tail xs)))
      where
        f (a, b)
            | a == c || b == c = c
            | otherwise        = a

main :: IO ()
main = do
    ss <- getLine
    print $ solve ss

Measured memory_bytes: 1020
N,M=[int(x) for x in input().split()]
X=[0,2,5,5,4,5,6,3,7,6]
#    1,2,3,4,5,6,7,8,9

A=[int(x) for x in input().split()]



ANS=[0]
for i in range(1,N+1):
	ans=0
	for j in A:
		if i==X[j]:
			ans=max(j,ans)
		elif i>=X[j]:
			temp=ANS[i-X[j]]
			if temp!=0:

				ans=max(ans,10*temp+j)
		
		#print(ans)
	ANS.append(ans)
print(ANS[-1])
	


Measured memory_bytes: 51420
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

// inf
constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n - 1);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        --a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    for (int i = 0; i < n - 1; ++i) {
        cin >> c[i];
    }

    int ans = b[a[0]];
    for (int i = 1; i < n; ++i) {
        ans += b[a[i]];
        if (a[i - 1] + 1 == a[i]) {
            ans += c[a[i - 1]];
        }
    }

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

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

#define FOR(i, n) for(int i = 0; i < n; i++) 

#define pow CHANGETHENAMESTUPID

using namespace std;

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

bool load() {
	char s[7];
	scanf("%s", s);
	return s[2] == s[3] && s[4] == s[5];
}

void solve() {

}

int main() {
	printf("%s\n", load() ? "Yes" : "No");
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <set>

class union_find {
  std::vector<intmax_t> tree;

public:
  union_find(size_t n): tree(n, -1) {}

  size_t find(size_t v) {
    if (tree[v] < 0)
      return v;

    return (tree[v] = find(tree[v]));
  }

  bool unite(size_t u, size_t v) {
    u = find(u);
    v = find(v);
    if (u == v)
      return false;

    if (-tree[u] >= -tree[v])
      std::swap(u, v);

    tree[v] += tree[u];
    tree[u] = v;
    return true;
  }

  bool connected(size_t u, size_t v) {
    return (find(u) == find(v));
  }

  size_t size(size_t v) {
    return -tree[find(v)];
  }
};

template <class Weight>
struct edge {
  using value_type = Weight;
  size_t src, dst;
  value_type cost;

  edge(size_t src, size_t dst, value_type cost=1):
    src(src), dst(dst), cost(cost)
  {}

  bool operator <(const edge<value_type> &rhs) const {
    if (cost != rhs.cost) return cost < rhs.cost;
    if (src != rhs.src) return src < rhs.src;
    return dst < rhs.dst;
  }
};

template <class ForwardIt>
auto min_spanning_tree(size_t v, ForwardIt first, ForwardIt last) {
  // return type: std::pair<Weight, std::set<edge<Weight>>
  // based on Kruskal algorithm
  using Weight = typename ForwardIt::value_type::value_type;
  union_find uf(v);
  Weight cost = Weight();
  std::set<edge<Weight>> mst;
  while (first != last) {
    const auto& e = *first++;
    if (uf.connected(e.src, e.dst)) continue;
    cost += e.cost;
    mst.insert(e);
    uf.unite(e.src, e.dst);
  }
  return std::make_pair(cost, mst);
}

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

  std::vector<std::pair<intmax_t, size_t>> x(N), y(N);
  for (size_t i = 0; i < N; ++i) {
    scanf("%jd %jd", &x[i].first, &y[i].first);
    x[i].second = y[i].second = i;
  }

  std::sort(x.begin(), x.end());
  std::sort(y.begin(), y.end());

  std::vector<edge<intmax_t>> es;
  for (size_t i = 1; i < N; ++i) {
    intmax_t dx = std::abs(x[i].first-x[i-1].first);
    intmax_t dy = std::abs(y[i].first-y[i-1].first);
    es.emplace_back(x[i].second, x[i-1].second, dx);
    es.emplace_back(x[i-1].second, x[i].second, dx);
    es.emplace_back(y[i].second, y[i-1].second, dy);
    es.emplace_back(y[i-1].second, y[i].second, dy);
  }

  std::sort(es.begin(), es.end());
  printf("%jd\n", min_spanning_tree(N, es.begin(), es.end()).first);
}


Measured memory_bytes: 28008
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#define For(N) for (int i = 0; i < N; i++)

using namespace std;
using ll = long long int;

void say(string);

int main() {
	ll X, Y;
	int ans = 0;
	cin >> X >> Y;
	for (ll i = X; i <= Y; i *= 2)ans++;
	say(to_string(ans));
	return 0;
}

void say(string s) {
	cout << s << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
public class Main{
	static BufferedReader br;
	static int cin() throws Exception
	{
		return Integer.valueOf(br.readLine());
	}
	static int[] split() throws Exception
	{
		String[] cmd=br.readLine().split(" ");
		int[] ans=new int[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Integer.valueOf(cmd[i]);
		}                                              
		return ans;
	} 
	static long mod=1000000007;
	static long power(long x,long y) 
    { 
        long res = 1; 
        x = x % mod; 
        while (y > 0) { 
            if (y % 2 == 1) 
                res = (res * x) % mod; 
            y = y >> 1;
            x = (x * x) % mod; 
        } 
        return res%mod; 
    } 
    static long modInverse(long n) 
    { 
        return power(n, mod-2); 
    } 
    static int digits(int n)
    {
    	int ans=0;
    	while(n!=0)
    	{
    		ans++;
    		n=n/10;
    	}
    	return ans;
    }
    static int[][] dp;
    static int max(int[][]arr,int ind,int prev)
    {
    	if(ind==arr.length)
    		return 0;
    	if(prev!=-1 && dp[ind][prev]!=-1)
    		return dp[ind][prev];
    	int res=-1000000000;
    	for(int i=0;i<3;i++)
    	{
    		if(i!=prev)
    			res=Math.max(res,arr[ind][i]+max(arr,ind+1,i));
    	}
    	if(prev!=-1)
    	dp[ind][prev]=res;
    	return res;
    }
    public static void main(String[] args) throws Exception {
        br = new BufferedReader(new InputStreamReader(System.in));
        int n=cin();
        int[][]arr=new int[n][3];
        for(int i=0;i<n;i++)
        {
        	int[]ar=split();
        	arr[i][0]=ar[0];
        	arr[i][1]=ar[1];
        	arr[i][2]=ar[2];
        }
        dp=new int[n+1][3];
        for(int i=0;i<=n;i++)
        {
        	Arrays.fill(dp[i], -1);
        }
        System.out.println(max(arr,0,-1));
    }
}

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

using namespace std;

using ll = long long;

int main() {

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

  ll ans = upper_bound(sum1, sum1 + m, k) - sum1;
  for(ll i = 0; i < n; ++i){
    if(sum[i] > k)break;
    ll br = upper_bound(sum1, sum1 + m, k - sum[i]) - sum1;
    ans = max(ans, i + br + 1);
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 9864
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (ll r = a % b)
		a = b, b = r;
	return b;
}

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

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

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

int main()
{
	map<long, bool> m;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		long in;
		cin >> in;
		if (m.find(in) == m.end())
			m[in] = true;
		else
		{
			printf("NO");
			return 0;
		}
	}

	printf("YES");
	return 0;

}


Measured memory_bytes: 12800
#include <stdio.h>

#define MOD_BY 1000000007

int add(int a, int b) {
	return a + b - MOD_BY * (a + b >= MOD_BY);
}

char S[114514];

int memo[114514][13];

int murakawarie(int idx, int amari) {
	int subete_no_nswer = 0; /* ∀NSWER */
	if (S[idx] == '\0') return amari == 5;
	if (memo[idx][amari]) return ~memo[idx][amari];
	if (S[idx] == '?') {
		int i;
		for (i = 0; i <= 9; i++) {
			subete_no_nswer = add(subete_no_nswer, murakawarie(idx + 1, (amari * 10 + i) % 13));
		}
	} else {
		subete_no_nswer = murakawarie(idx + 1, (amari * 10 + (S[idx] - '0')) % 13);
	}
	return ~(memo[idx][amari] = ~subete_no_nswer);
}

int main(void) {
	if (scanf("%114513s", S) != 1) return 1;
	printf("%d\n", murakawarie(0, 0));
	return 0;
}


Measured memory_bytes: 13184
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Sat Jan  5 16:18:20 2019
//
package main

import (
	"fmt"
	"sort"
)

func max(slice ...int) int {
	sort.Ints(slice)
	return slice[len(slice)-1]
}

func main() {
	var N int
	fmt.Scan(&N)
	f := make([][]int, N)
	for i := range f {
		f[i] = make([]int, 10)
		for j := range f[i] {
			fmt.Scan(&f[i][j])
		}
	}

	p := make([][]int, N)
	for i := range p {
		p[i] = make([]int, 11)
		for j := range p[i] {
			fmt.Scan(&p[i][j])
		}
	}

	ans := -1 << 60
	for i := 1; i < 1<<10; i++ {
		profit := 0
		for n := 0; n < N; n++ {
			same := 0
			for j := 0; j < 10; j++ {
				if i&(1<<uint8(j)) != 0 {
					same += f[n][j]
				}
			}
			profit += p[n][same]
		}
		ans = max(ans, profit)
	}

	fmt.Println(ans)
}


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

using namespace std;

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

    vector <int> height(no_of_stones + 1, 0);
    for(int i = 1; i <= no_of_stones; i++)
        cin >> height[i];

    vector <int> minimum_cost(no_of_stones + 1);
    minimum_cost[2] = abs(height[2] - height[1]);
    for(int i = 3; i <= no_of_stones; i++)
        minimum_cost[i] = min(minimum_cost[i - 1] + abs(height[i] - height[i - 1]),
                              minimum_cost[i - 2] + abs(height[i] - height[i - 2]));

    cout << minimum_cost[no_of_stones];
    return 0;
}

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

int main(void) {
    string str;
    char check;
    char number;
    int start, end;
    int last;
    long n[100] = {};
    
    getline(cin, str);
    
    start = -1;
    last = -1;
    end = -1;
    for(int i = 0; i < str.length(); ++i) {
        check = str[i];
        if(check == ' ') {
            end = i - 1;
            check = str[end];
            switch(check) {
                case '+' : n[last - 1] += n[last];    n[last] = 0;   --last;    start = i;    break;
                case '-' : n[last - 1] -= n[last];    n[last] = 0;   --last;    start = i;    break;
                case '*' : n[last - 1] *= n[last];    n[last] = 0;   --last;    start = i;    break;
                default  : {
                    int up = 1;
                    ++last;
                    for(int j = end; j > start; -- j) {
                        number = str[j];
                        n[last] += (number - '0') * up;
                        up *= 10;
                    }
                    start = i;
                }
            }
        }
    }
    check = str[str.length() - 1];
    switch(check) {
    	case '+' : n[0] += n[1];   break;
    	case '-' : n[0] -= n[1];   break;
    	case '*' : n[0] *= n[1];   break;
    }
    cout << n[0] << endl;
    return 0;
}





Measured memory_bytes: 3228
table = { "R": 0, "G": 1, "B": 2 }

N = int(input())
S = [table[c] for c in input().strip()]

counts = [0, 0, 0]

for c in S:
	counts[c] += 1

count_diff = counts[0] * counts[1] * counts[2]

count_diff_si = 0
for i in range(0, N - 2):
	ci = S[i]
	for j in range(i + 1, N - 1):
		k = j + j - i
		if k >= N:
			break
		cj = S[j]
		ck = S[k]
		if ci != cj and ci != ck and cj != ck:
			count_diff_si += 1
print(count_diff - count_diff_si)


Measured memory_bytes: 68288
from heapq import *
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

class UnionFind:
    def __init__(self, n):
        self.state = [-1] * n
        # self.size_table = [1] * n
        # cntはグループ数
        # self.cnt = n

    def root(self, u):
        v = self.state[u]
        if v < 0: return u
        self.state[u] = res = self.root(v)
        return res

    def merge(self, u, v):
        ru = self.root(u)
        rv = self.root(v)
        if ru == rv: return
        du = self.state[ru]
        dv = self.state[rv]
        if du > dv: ru, rv = rv, ru
        if du == dv: self.state[ru] -= 1
        self.state[rv] = ru
        # self.cnt -= 1
        # self.size_table[ru] += self.size_table[rv]
        return

def main():
    n=int(input())
    xx=[]
    yy=[]
    for i in range(n):
        x,y=MI()
        heappush(xx,[x,i])
        heappush(yy,[y,i])
    #print(xx,yy)
    ee=[]
    px,pi=heappop(xx)
    while xx:
        x,i=heappop(xx)
        heappush(ee,[x-px,pi,i])
        pi,px=i,x
    py,pi=heappop(yy)
    while yy:
        y,i=heappop(yy)
        heappush(ee,[y-py,pi,i])
        pi,py=i,y
    #print(ee)
    uf=UnionFind(n)
    cnt=0
    ans=0
    while ee:
        d,u,v=heappop(ee)
        if uf.root(u)==uf.root(v):continue
        uf.merge(u,v)
        ans+=d
        cnt+=1
        if cnt==n-1:break
    print(ans)

main()

Measured memory_bytes: 35404
#include<stdio.h>
int main(){
	int N, a, c, b = 0, d = 0, e = 0, f = 0, z, aa;
	int o = 0;
	scanf("%d", &N);
	int A[N], B[N], C[N];
	for (int i = 0; i < N; i++)
		scanf("%d", &A[i]);
	for (int j = 0; j < N; j++)
		scanf("%d", &B[j]);
	for (int k = 0; k < N; k++){
      d = 0; b = 0;
		for (int l = 0; l <= k; l++){
			a = A[l];
			b += a;
		}
      aa = k;
		for (int m = aa; m < N; m++){
			c = B[m];
			d += c;
		}
		z = b + d;
		if (f < z) f = z;
	}
	printf("%d", f);
}

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

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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int N, K;
int dfs(int u, int p, VVI& G, int& res){
  int d = 0;
  for(int to: G[u]){
	if(to == p) continue;
	d = max(d, dfs(to, u, G, res));
  }

  if(d == K-1 && p != 0){
	++res;
	return 0;
  }
  return d+1;
}

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

  cin >> N >> K;
  VI xs(N);
  REP(i,N){
	cin >> xs[i];
	--xs[i];
  }
  int ans = 0;
  if(xs[0] != 0) ++ans;
  xs[0] = 0;

  VVI rev(N);
  REP(i,N) rev[xs[i]].PB(i);
  dfs(0, 0, rev, ans);
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 13952
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        p,q = LI()
        if p == 0:
            break

        a = [S() for _ in range(p)]
        b = [S() for _ in range(q)]
        aa = [[0,0,0,0]]
        mc = 0
        for c in a:
            d = collections.Counter(c)
            t = aa[-1][:]
            t[0] += d['(']
            t[0] -= d[')']
            t[1] += d['{']
            t[1] -= d['}']
            t[2] += d['[']
            t[2] -= d[']']
            t[3] = 0
            for ct in c:
                if ct != '.':
                    break
                t[3] += 1
                if mc < t[3]:
                    mc = t[3]
            aa.append(t)
        k = []
        for c1,c2,c3 in itertools.product(range(1,min(mc+1,21)), repeat=3):
            f = True
            for ci in range(p):
                c = aa[ci]
                if c[0] * c1 + c[1] * c2 + c[2] * c3 != aa[ci+1][3]:
                    f = False
                    break
            if f:
                k.append((c1,c2,c3))
        bb = [[0,0,0]]
        for c in b:
            d = collections.Counter(c)
            t = bb[-1][:]
            t[0] += d['(']
            t[0] -= d[')']
            t[1] += d['{']
            t[1] -= d['}']
            t[2] += d['[']
            t[2] -= d[']']
            bb.append(t)

        r = [0]
        for c in bb[1:-1]:
            s = set()
            for c1,c2,c3 in k:
                s.add(c[0]*c1+c[1]*c2+c[2]*c3)
            if len(s) == 1:
                r.append(list(s)[0])
            elif sum(c) == 0:
                r.append(0)
            else:
                r.append(-1)

        rr.append(' '.join(map(str,r)))


    return '\n'.join(map(str,rr))


print(main())




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

int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    int nums[n];
    
    for(int i=0;i<n;i++){
        
        cin >> nums[i];
    }
    int flag = 0;
    for(int i=0;i<n;i++){
        if(nums[i]%2 != 0){
            continue;
        }
        else{
            
            if(nums[i]%3 == 0 || nums[i]%5 == 0){
                continue;
            }
            else{
                flag = 1;
                break;
            }
        }
    }
    if(flag){
        cout<<"DENIED"<<" ";
    }
    else{
        cout<<"APPROVED"<<" ";
    }
    return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	ll a, b;
	cin >> a >> b;
	ll ans=(a%2==0)? 0: a;
	if(a%2==1) a++;
	for(int i=0; i<=(b-a)%4; i++) ans^=b-i;
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

int A[2][MAX_N];
int S[2][MAX_N];

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

  CIN(N);
  REP(i, 2) {
    REP(j, N) {
      cin >> A[i][j];
      S[i][j + 1] += A[i][j];
    }
  }

  REP(i, 2) {
    REP(j, N) {
      S[i][j + 1] += S[i][j];
    }
  }

  int ans = 0;
  REP(i, N) {
    ans = max(ans, S[0][i + 1] + S[1][N] - S[1][i]);
    // debug(i);
    // debug(ans);
  }

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



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

#define int long long
const int MOD=1e9+7;
int pw(int n,int k){
  assert(k>=0);
  int res=1;
  while(k){
    if(k&1)(res*=n)%=MOD;
    (n*=n)%=MOD;
    k>>=1;
  }
  return res;
}
typedef pair<int,int> P;
int n;
vector<int> A,B;
int solve(){
  map<P,int> m;
  int f=0;
  for(int i=0;i<n;i++){
    int a=A[i],b=B[i];
    if(a==0&&b==0){f++;continue;}
    int g=__gcd(a,b);
    a/=g;b/=g;
    if(a<0)a*=-1,b*=-1;
    if(!a)b=1;
    if(!b)a=1;
    m[P(a,b)]++;
  }
  int ans=1;
  for(auto p:m){
    int a=p.first.first,b=p.first.second;
    int c=-b,d=a;
    if(c<0)c*=-1,d*=-1;
    if(m.count(P(c,d))){
      if(b>0)(ans*=pw(2,m[P(a,b)])+pw(2,m[P(c,d)])-1)%=MOD;
    }
    else (ans*=pw(2,m[P(a,b)]))%=MOD;
  }
  return (ans+f-1+MOD)%MOD;
}
int solve2(){
  int res=0;
  for(int i=1;i<(1<<n);i++){
    int out=0;
    for(int j=0;j<n;j++){
      if(((i>>j)&1)==0)continue;
      for(int k=0;k<j;k++){
        if(((i>>k)&1)==0)continue;
        if(A[j]*A[k]+B[j]*B[k]==0)out=1;
      }
    }
    if(!out)res++;
  }
  return res;
}

signed main(){
  cin>>n;
  for(int i=0;i<n;i++){
    int a,b;cin>>a>>b;
    A.push_back(a);
    B.push_back(b);
  }
  cout<<solve()<<endl;return 0;
  for(int i=0;i<100;i++){
    n=rand()%20+1;
    A.clear();B.clear();
    for(int i=0;i<n;i++){
      int a=rand()%3;
      int b=rand()%3;
      if(rand()&1)a*=-1;
      if(rand()&1)b*=-1;
      A.push_back(a);
      B.push_back(b);
    }
    if(solve()!=solve2()){
      cout<<n<<endl;
      for(int i=0;i<n;i++)cout<<A[i]<<" "<<B[i]<<endl;
      cout<<solve()<<endl;
      cout<<solve2()<<endl;
    }
  }
}


Measured memory_bytes: 18792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			long[] nk = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
			long n = nk[0];
			long k = nk[1];

			if (n < k / 2) {
				Console.WriteLine(0);
				return;
			}

			// (k/2, k/2, k/2)
			long ans = 0;
			if (k % 2 == 0) {
				ans += n / (k / 2);
				long count = 1 + ((n - (k / 2)) / k);
				ans += count * count * count - count;
			} else {
				ans += n / k;
			}

			long cc = n / k;
			ans += cc* cc * cc - cc;

			Console.WriteLine(ans);
		}
	}
}


Measured memory_bytes: 13268
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
#include <functional>																							   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra																													   																				   list<int>::iterator it;																								   
																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////


///////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
	int a, b;
	cin >> a >> b;
	int ans = max((a + a-1), max((a + b), (b + b-1)));
	cout << ans << endl;
	
	
	
	
	
	
	
	
	
	
	
    
	return 0;
}


Measured memory_bytes: 256