akhauriyash/Code-Regression huggingface dataset:
N, K = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))

A.sort()
F.sort(reverse = True)

max_time = 0
for i in range(N):
    if A[i]*F[i] > max_time:
        max_time = A[i]*F[i]

#ans = 18
ans = max_time // 2
l, r = 0, max_time
#print(l,ans,r)
while r - l > 1:
    counta = 0
    for i in range(N):
        if A[i] * F[i] > ans:
            counta += (A[i] - ans // F[i])
#        print(counta)
    if counta <= K:
        ans, r = (l + ans)//2, ans
    else:
        ans, l = (ans + r)//2, ans
#    print(l,ans,r)

ans = l
counta = 0
for i in range(N):
    if A[i] * F[i] > ans:
        counta += (A[i] - ans // F[i])
if counta > K:
    print(r)
else:
    print(ans)

Measured memory_bytes: 119628
#include <iostream>
#include <cmath>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#include <bitset>
#include <iomanip>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

int main() {
    int n;
    cin >> n;
    std::multiset<int> S;
    rep(i, n) {
        int k;
        cin >> k;
        S.insert(k);
    }

    int q;
    cin >> q;

    int count = 0;
    rep(i, q) {
        int num;
        cin >> num;
        if (*(S.lower_bound(num)) == num) {
            count ++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 7772
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001000
#define mod 1000000007
#define pi 3.1415926535
using namespace std;


int main(void){
    string s,t;
    cin>>s>>t;
    sort(all(s));
    sort(all(t));
    reverse(all(t));
    if(s<t){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int N, A;

    scanf("%d%d", &N, &A);

    if(N % 500 <= A){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

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

int main(){
    
    while(true){
        int h,w;
        cin >> h >> w;
        if(h == 0 and w == 0) break;
        
        vector<vector<char> > board(h,vector<char>(w));
        rep(i,h){
            rep(j,w) board[i][j] = '#';
        }
        
        for(int i = 1; i < h - 1; i++){
            for(int j = 1; j < w - 1; j++){
                board[i][j] = '.';
            }
        }
        
        rep(i,h){
            rep(j,w){
                cout << board[i][j];
                if(j == w - 1) cout << endl;
            }
        }
        cout << endl;
    }
}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

int main(){
    int N;cin>>N;
    bool flag=false;
    for(int i=0;i<N;i++){
        int a;cin>>a;
        if(a%2==1) flag=true;
    }

    if(flag) cout<<"first"<<endl;
    else cout<<"second"<<endl;
}

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

n = int(input())

def gcd(a, b):
    if b==0:
        return a
    return gcd(b, a%b)

def lcm(a,b):
    return a//gcd(a,b)*b

ans = 1
for _ in range(n):
    t = int(input())
    ans = lcm(ans, t)

print(ans)


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

namespace ConsoleApp1
{
    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var ABT = ReadSplitInt();
            Console.WriteLine((int)Math.Floor((ABT[2] + 0.5)) / ABT[0] * ABT[1]);
        }

        static void B()
        {
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static IList<string> ReadSplit() => Read().Split().ToList();
        static IList<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
    }
}

Measured memory_bytes: 11220
import sys
a = [int(c) for c in input().split()]
N = a[0]
A = a[1]
B = a[2]
S = input()

cnt = 0
f = 0

for i in range(N):
    if S[i] == "a":
        if cnt < A+B:
           print("Yes")
           cnt+=1 
        else:
            print("No")
    elif S[i] == "b":
        if cnt < A+B and f+1 <= B:
            print("Yes")
            cnt+=1
            f+=1
        else:
            print("No")
        pass
    elif S[i] == "c":
        print("No")


Measured memory_bytes: 9276
X,Y=[int(x) for x in input().rstrip().split()]
y=float((Y-2*X)/2)
x=float(X-y)

if y.is_integer() and x.is_integer():
  if 0<=y and 0<=x:
    print("Yes")
  else:
    print("No")
else:
  print("No")

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int a,b;
  cin>>a>>b;
  puts(a<=8&&b<=8?"Yay!":":(");
  return 0;
}


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

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

	if(n%1000 == 0) {
		cout << "0" << endl;

	}else{
		cout << 1000* (n/1000 + 1)  - n << endl;	
	}
	return 0;
  
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
#define int ll
signed main() {
    int n;
    auto f = [](int x, int y, int z) {
        return x * x + y * y + z * z + x * y + y * z + z * x;
    };
    cin >> n;
    assert(f(1, 1, 1) == 6);
    for (int i = 1; i <= n; ++i) {
        int r = 0;
        for (int x = 1; f(x,1,1) <= i; ++x) {
            for (int y = 1; f(x,y,1) <= i; ++y) {
                int sq = 4 * i - (x + y) * (x + y) - 2 * (x * x + y * y);
                if (sq <= 0) continue;
                int rt = sqrt(sq);
                if (rt * rt != sq) continue;
                if (rt - x - y < 2) continue;
                int z = rt - x - y;
                if (z % 2) continue;
                z /= 2;
                ++r;
            }
        }
        cout << r << endl;
    }
}

Measured memory_bytes: 3576
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	int sum=0,temp;
	for(int i=0;i<5;i++){
		scanf("%d",&temp);
		if(temp<40)
		temp=40;
		sum+=temp;
	}
	printf("%d\n",sum/5);
}

Measured memory_bytes: 3228
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void debug(String str) {
        System.out.println(str);
    }

    public static void main(String[] args) {

        long result = 0;
        int N;
        String S;
        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            S = sc.next();
        }
        int[] iS = new int[N];
        char[] c = S.toCharArray();
        for(int i = 0;i < N;i++){
            iS[i] = c[i]-0x30;
        }

        int[] pre =new int[N];
        int[] post = new int[N];
        int[] count = new int[10];

        int[] preIndex = new int[10];
        for (int i = 0; i < 10; i++) {
            preIndex[i] = -1;
        }

        Set<Integer> set = new HashSet<>(10);
        for (int i = 0; i < N; i++) {
            set.add(iS[i]);
            pre[i] = set.size();
        }
        set = new HashSet<>(10);
        for (int i = N-1; i >= 0; i--) {
            set.add(iS[i]);
            post[i] = set.size();
        }
        for(int i = 1; i < N -1;i++){
            int num = iS[i];

            if (preIndex[num] ==-1){
                count[num] =pre[i -1] * post[i+1];
            }else{
                int q = post[i+1];
                int s = pre[preIndex[num]-1];
                int r = pre[i-1];
                count[num] += (r - s) * q;
            }
            preIndex[num] = i;
        }
        for(int i : count){
            result += i;
        }
        System.out.println(result);
        return;
    }
}


Measured memory_bytes: 24276
#include <bits/stdc++.h>
using namespace std;
int n, x;
long long sx, sn, zx, zn;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &x);
		sx += x;
		sn += x;
		if (sx < 1) {
			zx += 1 - sx;
			sx = 1;
		}
		if (sn > -1) {
			zn += sn + 1;
			sn = -1;
		}
		swap(sx, sn);
		swap(zx, zn);
	}
	printf("%lld\n", min(zx, zn));
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

var (
	n int
	s string
)

func main() {
	fmt.Scan(&n)
	fmt.Scan(&s)
	result := convert(s)
	fmt.Println(string(result))
}

func convert(s string) []byte {
	var result []byte = []byte(s)
	for i := 0; i < len(s); i++ {
		code := int(result[i])
		code += n
		if code > 90 {
			code -= 26
		}
		// fmt.Prin(code)
		result[i] = byte(code)
	}
	return result
}


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

namespace Atcoder
{

    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            
            string winner = "second";
            for (int i = 0; i < N; i++)
            {
                int a = int.Parse(Console.ReadLine());
                if (a % 2 == 1)
                {
                    winner = "first";
                }
            }
            Console.WriteLine(winner);
        }
    }
}


Measured memory_bytes: 15184
n=int(raw_input())
a=map(int,raw_input().split())
m4=0
m2=0
for x in a :
    if x%4==0 :
        m4 += 1
    elif x%2==0 :
        m2 += 1

if m2<=1:
    if m4+1>=n-m4:
        print 'Yes'
    else:
        print 'No'
else :
    n -= m2
    if m4>=n-m4:
        print 'Yes'
    else:
        print 'No'

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

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N;
	string s;
	vector<int> ans;
	
	cin>>s;
	
	N = s.size();
	ans.resize(s.size(),0);
	
	for(int i = 0, g = 0, k = 0; i < N; i++){
		if(s[i] == 'R'){
			if(i%2) k++;
			else g++;
		} else if(s[i] == 'L'){
			if(i%2){
				ans[i] += k;
				ans[i-1] += g;
				g = k = 0;
			} else {
				ans[i] += g;
				ans[i-1] += k;
				g = k = 0;
			}
		}
	}
	
	reverse(s.begin(), s.end());
	
	for(int i = 0, g = 0, k = 0; i < N; i++){
		if(s[i] == 'L'){
			if(i%2) k++;
			else g++;
		} else if(s[i] == 'R'){
			if(i%2 == 0){
				ans[N-i-1] += g;
				ans[N-(i-1)-1] += k;
				g = k = 0;
			} else {
				ans[N-(i-1)-1] += g;
				ans[N-i-1] += k;
				g = k = 0;
			}
		}
	}
	
	for(int i = 0; i < s.size(); i++){
		if(i) cout<<" ";
		cout<<ans[i];
	}
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 1488
const main = (input) => {
  const args = input.split(' ');
  const s = parseInt(args[0], 10);
  const w = parseInt(args[1], 10);

  if (s > w) {
      console.log('safe');
  } else {
      console.log('unsafe');
  }
}

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

Measured memory_bytes: 30164
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

vector<ll> lay;
vector<ll> p;
ll n, k;

//level n ,layer x

ll fun(ll n, ll x){
	if (n == 0)return (x <= 0 ? 0 : 1);
	if (x <= lay[n - 1] + 1)return fun(n - 1, x - 1);
	return p[n - 1] + 1 + fun(n - 1, x - 2 - lay[n - 1]);
	
}

int main()
{
	cin >> n >> k;
	lay.push_back(1), p.push_back(1);
	for (int i = 1; i <= n; i++){
		ll l = lay[i - 1] * 2 + 3;
		ll pp = p[i - 1] * 2 + 1;
		lay.push_back(l);
		p.push_back(pp);
	}
	cout << fun(n, k) << endl;
}

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

const int N = 1e5 + 10 , M = 5e5+10 ,  MOD = 1e9+7;
const int OO = 0x3f3f3f3f;
const double EPS = 1e-3;

#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define ALL(v) ((v).begin()) , ((v).end())
#define SZ(v)  ((int)((v).size()))
typedef pair <int,int> pii ;
typedef vector < pii > vii ;
typedef vector < int > vi;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
 


int n , m;



int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
	


    cin >> n >> m;

    if(n != m)
        cout << "No" << "\n";
    else 
        cout << "Yes" << "\n";



    
    return 0;
}

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

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    ll n;
    cin >> n;

    int ans = INF;
    for (int i = 1; i <= sqrt(n); i++) {
        if (n % i == 0) {
            ll num = n / i;
            int ans2 = max(log10(i) + 1, log10(num) + 1);
            ans = min(ans, ans2);
        }
    }

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

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 3872
import java.util.Scanner;
import java.util.function.Function;

public class Main {

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

    Scanner sc = new Scanner(System.in);

    void solve() {
        String str;
        while (true) {
            str = sc.nextLine();
            String[] sp = str.split(" ");
            int n = Integer.parseInt(sp[0]);
            int x = Integer.parseInt(sp[1]);
            if (isFin(n, x)) break;
            System.out.println(sim(n, x));
        }
    }

    int sim(int n, int x) {
        int cnt = 0;
        for (int i = 1; i <= n; ++i) {
            for (int j = i + 1; j <= n; ++j) {
                if (i == j) continue;
                int k = x - i - j;
                if (i == k || j == k) continue;
                if (j < k && k <= n) {
                    cnt++;
                }
            }
        }
        return cnt;
    }

    boolean isFin(int n, int x) {
        return n == 0 && x == 0;
    }

}


Measured memory_bytes: 26180
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;
U_MAP mp;

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

  cin >> n;
  rep(i, n) cin >> a[i], mp[a[i]]++;

  rep(i, ohara) { cnt += max(mp[i] - 1, 0LL); }
  ans = (cnt + 1) / 2;
  Cout(n - ans * 2);
  return 0;
}

Measured memory_bytes: 40592
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

def main():
    A = int(input())
    B = int(input())

    ans = [1, 2, 3]
    ans.remove(A)
    ans.remove(B)
    print(ans[0])
if __name__ == '__main__':
    main()

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

int main()
{
  int n, k;
  string s;
  
  cin >> n >> k;
  cin >> s;
  
  if(s.at(k-1) == 'A')
  {
    s.at(k-1) = 'a';
  }
  else if(s.at(k-1) == 'B')
  {
    s.at(k-1) = 'b';
  }
  else
  {
    s.at(k-1) = 'c';
  }
  
  cout << s << endl;
  
  return 0;
}

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

public class Playground
{
    private static List<string[]> item = new List<string[]>();

    public static void Main(string[] args)
    {
        Input();
        Method();
        System.Console.ReadLine();
    }

    private static void Input()
    {
        int num = int.Parse(Console.ReadLine());
        for (int i = 0; i < num; i++)
        {
            item.Add(Console.ReadLine().Split(' '));
        }
    }

    private static void Method()
    {
        //var dic = new Dictionary<int, string>();
        var dic = new HashSet<string>();
        foreach (var ope in item)
        {
            if (ope[0].Equals("insert"))
            {
                dic.Add(ope[1]);
            }
            else
            {
                if (dic.Contains(ope[1]))
                {
                    Console.WriteLine("yes");
                }
                else
                {
                    Console.WriteLine("no");
                }
            }
        }
    }
}

Measured memory_bytes: 176232
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int num = sc.nextInt();
    int array[] = new int[num];
    for(int i = 0;i < num;i++){
      array[i] = sc.nextInt();
    }
    long count = 0;
    int max = 0;
    for(int i = 0;i < num;i++){
      if(max < array[i]){
        max = array[i];
      }
      if(array[i] < max){
        count += max - array[i];
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 61920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll x,y;cin>>x>>y;
    ll n = x+y;
    ll a,b,c;cin>>a>>b>>c;
    ll p[a],q[b],r[c];
    for(ll i=0;i<a;i++)cin>>p[i];
    for(ll i=0;i<b;i++)cin>>q[i];
    for(ll i=0;i<c;i++)cin>>r[i];
    sort(p,p+a,greater<ll>() );
    sort(q,q+b,greater<ll>() );
    sort(r,r+c);
    priority_queue< ll , vector<ll> , greater<ll> > pqa , pqb;
    for(ll i=0;i<x;i++)pqa.push(p[i]);
    for(ll i=0;i<y;i++)pqb.push(q[i]);
    for(ll i=0;i<c;i++){
        ll v1 = pqa.top();
        ll v2 = pqb.top();
        if(v1>=r[i] && v2>=r[i])continue;

        if(v1<r[i] && v2<r[i]){
            if(v1<v2)pqa.pop(),pqa.push(r[i]);
            else pqb.pop(),pqb.push(r[i]);
        }
        else if(v1<r[i])pqa.pop(),pqa.push(r[i]);
        else pqb.pop(),pqb.push(r[i]);
    }

    ll ans =0;
    while(!pqa.empty())ans+=pqa.top(),pqa.pop();
    while(!pqb.empty())ans+=pqb.top(),pqb.pop();
    cout<<ans;
}


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

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while (true) {

			String str = br.readLine();
			StringTokenizer st = new StringTokenizer(str, " ");
			int x = Integer.parseInt(st.nextToken());
			int y = Integer.parseInt(st.nextToken());

			if (x == 0 && y == 0)
				break;
			if (x <= y) {
				System.out.println(x + " " + y);
			} else {
				System.out.println(y + " " + x);
			}
		}
	}

}

Measured memory_bytes: 26632
#include <stdio.h>
int main(){
    long k,i,a=50;
    scanf("%ld",&k);
    printf("50\n");
    for(i=0;i<a;i++){
        printf("%ld",i<k%a?(k/a-k%a+a*2):(k/a-k%a+49));
        printf(i==49?"\n":" ");
    }
  return 0;
}

Measured memory_bytes: 128
n,m = map(int,input().split())
#dic = {}
#for i in range(m):
#    a,b = map(int,input().split())
#    dic.setdefault(a,0)
#    dic[a] += 1
#    dic.setdefault(b,0)
#    dic[b] += 1
#for j in range(1,n+1):
#    print(dic[j])
ans = [int(0) for i in range(n+1)]
for i in range(m):
    a,b = map(int,input().split())
    ans[a] += 1
    ans[b] += 1
for i in range(1,n+1):
    print(ans[i])


Measured memory_bytes: 9128
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int h, w;
  readf("%s %s\n", &h, &w);
  auto c = new string[](h);
  foreach (i; 0..h) {
    c[i] = readln.chomp;
  }
  foreach (i; 0..h) {
    c[i].writeln;
    c[i].writeln;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <deque>
#include <iomanip>
#include <queue>
#include <stdio.h>
using namespace std;
#define rep(i,n) for (ll i=0;i<n;i++)
#define REP(i,n) for (ll i=1;i<=n;i++)
#define PI 3.1415926535897932384626433832795028841971693993751058209749445923078160628620899
typedef long long ll;
typedef pair<ll, ll> Pll;
const ll MOD = 1000000007;
const ll INF = 1000000000000000;

string S, T;
ll ans, sum, now, N, M, A;

int main() {
	cin >> S;
	ll N = S.size();
	M = (N - 1) / 2;
	A = (M + 1) / 2;
	bool ANS = true;
	rep(i, M) {
		if (S[i] != S[N - 1 - i]) ANS = false;
	}
	rep(i, A) {
		if (S[i] != S[M - 1 - i]) ANS = false;
	}
	cout << (ANS ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

using P=pair<long double,long double>;
void solve(){
  int n;
  cin>>n;
  vector<P>p(n);
  rep(i,n)cin>>p[i].first>>p[i].second;
  long double ans=0;
  long double cnt=0;
  sort(all(p));
  do{
    cnt+=1.0;
    rep(i,n-1){
      ans+=sqrtl((p[i].first-p[i+1].first)*(p[i].first-p[i+1].first)+(p[i].second-p[i+1].second)*(p[i].second-p[i+1].second));
    }
  }
  while(next_permutation(all(p)));
  cout<<ans/cnt;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 256
def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    ass.sort()
    return ass #sortされていない


def main():
    N = int(input())
    if N <= 2:
        print(0)
        exit()
    ans = 0
    for i in divisor(N):
        if i == 1:
            continue
        if N // (i-1) == N % (i-1):
            ans += (i-1)

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 66840
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <sstream> // std::stringstream
#include <bitset>  // std::bitset<N>

using namespace std;

int main(void){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    if(n%2==1){
        n++;
    }
    cout<<n/2;

    return 0;
}

Measured memory_bytes: 256
/*
 * atcoder/abc089/b.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }

vector<ll> dividers(ll n) {
  vector<ll> D;
  for (ll i=1; i*i<=n; i++) {
    if (n%i==0) {
      D.push_back(i);
    }
  }
  return D;
}

void solve() {
  ll n;
  cin >> n;
  auto D = dividers(n);
  ll min_ = 10000000000000;
  for (auto&&d1: D) {
    ll d2 = n / d1;
    min_ = min(min_, d2 - 1 + d1 - 1);
  }
  cout << min_ << endl;
}


Measured memory_bytes: 3624
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説どおりに作成したソースコード<br/>
 * https://atcoder.jp/contests/abc086/submissions/2279952 にも参照
 */
public class Main {

	/** 白の定数 */
	private static final String WHITE = "W";

	/** 四角の差分を計算用 */
	private static final int[] X_DIFFS = { 0, 0, 1, 1, 1, 1, 2, 2 };
	private static final int[] Y_DIFFS = { 0, 1, 0, 1, 1, 2, 1, 2 };
	private static final int[] COUNT_DIFFS = { 1, -1, -1, 1, 1, -1, -1, 1 };

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int k = scanner.nextInt();
			int w = 4 * k + 1;
			int k2 = 2 * k;
			int[][] count = new int[w][w];
			IntStream.range(0, n).forEach(i -> {
				int x = scanner.nextInt();
				int y = scanner.nextInt();
				if (WHITE.equals(scanner.next())) {
					y += k;
				}
				x %= 2 * k;
				y %= 2 * k;
				for (int j = 0; j < X_DIFFS.length; j++) {
					count[x + X_DIFFS[j] * k][y + Y_DIFFS[j] * k] += COUNT_DIFFS[j];
				}
			});
			// 横方向への累積和
			IntStream.range(0, w).forEach(i -> IntStream.range(1, w).forEach(j -> count[i][j] += count[i][j - 1]));
			// 縦方向への累積和
			IntStream.range(1, w).forEach(i -> IntStream.range(0, w).forEach(j -> count[i][j] += count[i - 1][j]));
			// 2k x 2k 範囲を超えたcountを2k x 2k範囲に加算
			IntStream.range(0, w).forEach(i -> IntStream.range(0, w).filter(j -> (i >= k2) || (j >= k2))
					.forEach(j -> count[i % k2][j % k2] += count[i][j]));
			// 2k x 2k 範囲の最大値を出力
			System.out.println(IntStream.range(0, k2)
					.map(i -> IntStream.range(0, k2).map(j -> count[i][j]).max().getAsInt()).max().getAsInt());
		}
	}
}


Measured memory_bytes: 133548
integer :: numSocket,a,b,numTap
      
      read*,a,b
      
      if(b==1)then
        print*,0;stop
      end if
      
      numSocket = 1
      do numTap = 1,300
        numSocket = numSocket - 1 + A
        if( numSocket>=B )then
          print*,numTap
          stop
        end if
      end do
      end

Measured memory_bytes: 2856
import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)

K = int(input())
mod = 10**9 + 7

N = 3

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

ans = 0

M = np.zeros(K+1, dtype=int)

for i in range(K, 0, -1):
#    print(i)
    M[i] += pow(K//i, N)
    
    for j in range(2,K//i+1):
        j *= i
        M[i] -= M[j]
    
    ans += M[i] * i
    
        
print(ans)

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

int main(){
	int n , x , count;
	while(1){
		count=0;
		cin >> n >> x;
		if(n==0 && x==0) break;
		for(int i=1 ; i<=n ; i++){
			for(int j=1 ; j<=i ; j++ ){
				for(int k=1 ; k<=j ; k++ ){
					if((i+j+k)==x && i!=j && i!=k && j!=k ){
						count++;
					}
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}

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

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;

  if (e - a > k) {
    cout << ":(" << endl;
  }
  else {
    cout << "Yay!" << endl;
  }
}


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

int main(){
    ll m, k; cin >> m >> k;
    if (1ll<<m <= k) { cout << -1 << "\n"; return 0; }
    if (m == 1 && k == 1) { cout << -1 << "\n"; return 0; }
  if(m == 1 && k == 0) { cout << "0 0 1 1" << "\n"; return 0; }
    for (ll i = 0; i < (1ll<<m); i++) if (i != k) cout << i << " ";
    cout << k << " ";
    for (ll i = (1ll<<m) - 1; i >= 0; i--) if (i != k) cout << i << " ";
    cout << k <<  "\n";
    return  0;
}

Measured memory_bytes: 3628
s = int(input())
front = s//100
bk = s%100
if 0 < front < 13:
    if 0 < bk < 13:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif 0 < bk < 13:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n;
int l[55],t[55],r[55],b[55];
ll ma[200][200];
int used [200][200];
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};


void dfs(int x,int y,ll k){
  if(x<0||200<=x||y<0||200<=y)return;
  if(used[x][y]||ma[x][y]!=k)return;
  used[x][y]=1;
  for(int i=0;i<4;i++)
    dfs(x+dx[i],y+dy[i],k);
}

int main(){
  int n;
  while(cin>>n,n){
    fill_n(*ma,200*200,0);
    fill_n(*used,200*200,0);
    vector<int> tx,ty;
    for(int i=0;i<n;i++){
      cin>>l[i]>>t[i]>>r[i]>>b[i];
      tx.push_back(l[i]);
      tx.push_back(r[i]);
      ty.push_back(t[i]);
      ty.push_back(b[i]);
    }
    sort(tx.begin(),tx.end());
    sort(ty.begin(),ty.end());

    map<int,int> mp[2];
    for(int i=0;i<tx.size();i++){
      mp[0][tx[i]]=i+1;
      mp[1][ty[i]]=i+1;
    }

    for(int i=0;i<n;i++){
      l[i]=mp[0][l[i]];
      r[i]=mp[0][r[i]];
      t[i]=mp[1][t[i]];
      b[i]=mp[1][b[i]];

      ll k=1LL<<i;
      ma[l[i]][b[i]]+=k;
      ma[l[i]][t[i]]-=k;
      ma[r[i]][b[i]]-=k;
      ma[r[i]][t[i]]+=k;
    }

    for(int i=0;i<200;i++)
      for(int j=1;j<200;j++)
	ma[i][j]+=ma[i][j-1];

    for(int i=0;i<200;i++)
      for(int j=1;j<200;j++)
	ma[j][i]+=ma[j-1][i];

    int ans=0;
    for(int i=0;i<200;i++)
      for(int j=0;j<200;j++){
	if(used[i][j])continue;
	ans++;
	dfs(i,j,ma[i][j]);
      }
    cout<<ans<<endl;
  }
  return 0;
}



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

int main() {
  string s, t;
  cin >> s >> t;
  bool isSame = true;
  rep(i, s.length()) {
    if (s[i] != t[i]) isSame = false;
  }
  if (isSame && s.length() == t.length() - 1)
    cout << "Yes" << endl;
  else
    cout << "No";
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#define  fi first
#define  se second
#define  mk make_pair
#define  fr(i,x,y) for(i=x;i<=y;i++)
using namespace std;
typedef pair < int ,int > PII;
const int maxn=1010;
int n,w,d,ans,m;
PII a[maxn],b[maxn];
int Get(int x,int y,int dir)
{
	if(dir==1){
		if(x<y)return y-x;//(0,y-x)
		else return d+w+d+w-(x-y);//(x-y,0)
	}else if(dir==2){
		if(x<d-y)return y+x;//(0,y+x)
		else return d+x-(d-y);//(x-(d-y),d)
	}else if(dir==3){
		if(w-x<d-y)return d+w+d-(y+(w-x));//(w,y+(w-x))
		else return d+x+(d-y);//(x+(d-y),d)
	}else{
		if(w-x<y)return d+w+d-(y-(w-x));//(w,y-(w-x))
		else return d+w+d+w-(x+y);//(x+y,0)
	}
}
PII Get(int x,int y,char ch)
{
	int ret1,ret2;
	if(ch=='W'){
		ret1=Get(x,y,1);
		ret2=Get(x,y,2);
	}else if(ch=='N'){
		ret1=Get(x,y,2);
		ret2=Get(x,y,3);
	}else if(ch=='E'){
		ret1=Get(x,y,3);
		ret2=Get(x,y,4);
	}else{
		ret1=Get(x,y,4);
		ret2=Get(x,y,1);
	}
	return mk(ret1,ret2);
}
void Read()
{
	int i,x,y;
	char ch;
	scanf("%d%d%d",&n,&w,&d);
	fr(i,1,n)
	{
		scanf("%d%d%c%c",&x,&y,&ch,&ch);
		a[i]=Get(x,y,ch);
	}
}
int Cal(int x)
{
	if(x>=0)return x;
	return x+2*(w+d);
}
bool Cmp(const PII &x,const PII &y){return x.se<y.se;}
void Minn(int &x,int y){if(y<x)x=y;}
void Update(int x)
{
	int i,sum,la;
	m=0;
	fr(i,1,n)
		if(a[i].fi<a[i].se)
			if(a[i].fi<=x&&x<=a[i].se);
			else b[++m]=mk(Cal(a[i].fi-x),Cal(a[i].se-x));
		else
			if(x>=a[i].fi||x<=a[i].se);
			else b[++m]=mk(Cal(a[i].fi-x),Cal(a[i].se-x));
	if(m==0){Minn(ans,1);return;}
	sort(b+1,b+m+1,Cmp);
	sum=2;
	la=b[1].se;
	fr(i,2,m)
	{
		if(b[i].fi<=la)continue;
		la=b[i].se;
		sum++;
	}
	Minn(ans,sum);
}
void Solve()
{
	int i;
	ans=n;
	fr(i,1,n)
	{
		Update(a[i].fi);
		Update(a[i].se);
	}
	printf("%d\n",ans);
}
int main()
{
	Read();
	Solve();
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsgned ll
#define db double
#define pint pair<int,int>
#define mk make_pair
#define pb push_back
#define eb emplace_back
#define ins insert
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=2e5+5;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
char s[MAXN];int n,cnt,last;
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	scanf("%s",s+1),n=strlen(s+1);
	Rep(i,1,n){
		if(s[i]=='T'){
			if(last)last--,cnt++;
		}else last++;
	}cout<<n-2*cnt<<'\n';
	return 0;
}





Measured memory_bytes: 3824
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int[] a=new int[n];
		for(int i=0; i<n; i++){
			a[i]=sc.nextInt();
		}
		boolean[] dp=new boolean[k+1];
		for(int i=1; i<=k; i++){
			for(int j=0; j<n; j++){
				if(i<a[j] || dp[i]) break;
				dp[i]|=!dp[i-a[j]];
			}
		}
		if(dp[k]){
			System.out.println("First");
		}else{
			System.out.println("Second");
		}
	}
}

Measured memory_bytes: 24148
/*@author Vipen Loka*/
#include <bits/stdc++.h>
#define endl '\n'
#define ff first
#define ss second
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define deb(x) cout << #x << ':' << x << '\n';

using namespace std;

void solve(){
	int i,j;
	int n;
	cin >> n;
	int mx=0,cnt=0;
	for (int i = 0; i < n; ++i)
	{
		int a,b;
		cin>> a >> b;
		if(a==b)cnt++;
		else cnt=0;
		mx=max(cnt,mx);

	}
	if(mx>2)puts("Yes");
	else puts("No");
	
}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    
	int T=1;
	// cin >> T;
	while (T--){
		solve();
	}
}


Measured memory_bytes: 3648
def main():
    n = int(input())
    arr = [int(e) for e in input().split()]
    t = [float('inf')] * (n + 1)
    t[0] = 0
    t[1] = 0 
    t[2] = abs(arr[1] - arr[0])
    for i in range(3, n + 1):
        l1 = t[i - 1] + abs(arr[i - 2] - arr[i - 1])
        l2 = t[i - 2] + abs(arr[i - 3] - arr[i - 1])
        t[i] = min(l1, l2)
    print(t[n])
    return 0


if __name__ == '__main__':
    main()

Measured memory_bytes: 52208
import itertools

N, M, Q = map(int, input().split())
A = list(itertools.combinations_with_replacement(range(1, M + 1), N))
B = []
# print(len(list(A)))
for a in A:
    for j in range(N - 1):
        flag = True
        if a[j] > a[j + 1]:
            flag = False
            break
    if flag:
        B.append(a)

a = []
b = []
c = []
d = []

for i in range(Q):
    o, p, q, r = map(int, input().split())
    o -= 1
    p -= 1
    a.append(o)
    b.append(p)
    c.append(q)
    d.append(r)

ans = 0
for li in B:
    tmp = 0
    for i in range(Q):
        if li[b[i]] - li[a[i]] == c[i]:
            tmp += d[i]
    ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 22236
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c, x, cnt = 0;
  cin >> a >> b >> c >> x;
  REP(i,a+1) {
    REP(j,b+1) {
      REP(k,c+1) {
        if(i * 500 + j * 100 + k * 50 == x) cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
//templete by private_yusuke

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

using namespace std;

int main()
{
  int h,w;
  cin >> h >> w;
  vector<string>path;
  string s;
  for(int i=0;i<h;++i){
    cin >> s;
    path.push_back(s);
  }
  vector<vector<long long int> >dp(h,vector<long long int>(w,0));
  long long int mod =1e9+7;
  dp[0][0]=1;
  for(int i=0;i<h;++i){
    for(int j=0;j<w;++j){
        if(path[i][j]!='#'){
            if(i!=0) dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
            if(j!=0) dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
        }
    }
  }
  cout << dp[h-1][w-1]<<endl;
  return 0;
}

Measured memory_bytes: 12236
#include<iostream>
#include<vector>
#include<algorithm>

#define ll long long int

using namespace std;
int N,M;

int main(){
    cin >> N >> M;
    if(N >= M) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> X(M);
    vector<int> dis(M-1);
    for(int i= 0; i< M;i++){
        cin >> X[i];
    }
    sort(X.begin(),X.end());
    for(int i=0;i<M-1;i++){
        dis[i] = X[i+1] - X[i];
    }
    sort(dis.begin(),dis.end(),greater<int>());
    ll sum = 0;
    for(int i = 0; i< N-1; i++){
        sum += dis[i];
    }
    cout << X[X.size()-1] - X[0] - sum << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  int H,W;
  cin >> H >> W;

  int b = 0;
  for(int i = 0;i < H;i++) {
    for(int j = 0;j < W;j++) {
      char A;
      cin >> A;
      if(A == '#') b++;
    }
  }

  if(b == H+W-1) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
#define NIL -1
   
typedef struct{
  int parent, left, right, depth;
} Node;
   
int set_depth(Node *tree, int id, int depth){
  tree[id].depth = depth;
  if(tree[id].right != NIL)
    set_depth(tree, tree[id].right, depth);
  if(tree[id].left != NIL)
    set_depth(tree, tree[id].left, depth+1);
  return 0;
}
   
int main(void){
  Node tree[MAX];
  int i, j, n, id, k, c, prev;
  char *kind[3] = {"root", "leaf", "internal node"};
   
  scanf("%d", &n);
  for(i=0; i<n; ++i)
    tree[i].parent = tree[i].left = tree[i].right = NIL;
  for(i=0; i<n; ++i){
    scanf("%d %d", &id, &k);
    for(j=0; j<k; ++j){
      scanf("%d", &c);
      tree[c].parent = id;
      if(j==0)
        tree[id].left = c;
      else
        tree[prev].right = c;
      prev = c;
    }
  }
   
  for(id=0; tree[id].parent!=NIL; id=tree[id].parent){}
  set_depth(tree, id, 0);
   
  for(i=0; i<n; ++i){
    printf("node %d: parent = %d, depth = %d, ", i, tree[i].parent, tree[i].depth);
    if(tree[i].parent == NIL)
      printf("%s, [", kind[0]);
    else if(tree[i].left == NIL)
      printf("%s, [", kind[1]);
    else
      printf("%s, [", kind[2]);
    id = tree[i].left;
    if(id == NIL){
      printf("]\n");
      continue;
    }
    printf("%d", id);
    for(id=tree[id].right; id != NIL; id=tree[id].right)
      printf(", %d", id);
    printf("]\n");
  }
   
  return 0;
}

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

using namespace std;

//#define int long long
#define FOR(i, j, k) for(int i = j; i < (int)k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

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

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
template <typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

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

    long double a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    long double res = 0;
    int total = 0, ans = 0;
    for(int i = 0; i * 100 <= f; i += a) {
        for(int j = 0; j * 100 <= f; j += b) {
            if(i == 0 && j == 0) continue;
            for(int k = 0; k <= f; k += c) {
                for(int l = 0; l <= f; l += d) {
                    if(i == 0 && j == 0 && k == 0 && l == 0) continue;
                    if((i + j) * e < k + l) continue;
                    if((i + j) * 100 + k + l > f) continue;
                    if(res <= (k + l) / ((i + j) * 100.)) {
                        res = (k + l) / ((i + j) * 100.);
                        total = (i + j) * 100 + k + l;
                        ans = k + l;
                    }
                }
            }
        }
    }
    cout << total << " " << ans << endl;
    return 0;
}


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

int main()
{
  int N;
  int p[11];
  int res=0;
  cin >> N;

  rep(i,N) {
    int pp;
    cin >> pp;
    p[i] = -pp;
  }

  sort(p,p+N);
  p[0] = p[0]/2;

  rep(i,N){
    res -= p[i];
  }
  cout << res << endl;
}

Measured memory_bytes: 256