akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include<stack>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>
int main(void)
{
    string s;
    string t;

    cin>>s>>t;
    int ans = 2000;

    for(int i =0;i<s.size()-t.size()+1;i++)
    {
        int rew =0;
        for(int j =0;j<t.size();j++)
        {
            if(s[j+i]!=t[j]) rew++;

        }
        ans = min(ans,rew);

    }

    cout<<ans<<endl;
}

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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  int n;
  cin >> n;
  unordered_map<ll, int> ad, su;

  ll cnt = 0;

  for (int i = 1; i <= n; i++) {
    ll h;
    cin >> h;

    cnt += ad[i - h];
    ++ad[h + i];
  }

  cout << cnt << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


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

#include <iostream>
//#include <cmath>
//#include <vector>

using namespace std;

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

}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int l,r;
    cin>>l>>r;

    ll ans=2019;

    for(ll i=l;i<r;i++)
    {
        for(ll j=i+1;j<=r;j++)
        {
            ans=min(ans,((i%2019)*(j%2019))%2019);
            if(ans==0)
            {
                cout<<"0\n";
                return 0;
            }
        }
    }
    cout<<ans<<"\n";
 return 0;
}


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

main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    int ti=1;
    for(int i=0;i<m;i++)
        ti*=2;
    printf("%d\n",ti*(m*1900+(n-m)*100));
}


Measured memory_bytes: 3784
#include <iostream>

int main()
{
    std::cout.sync_with_stdio(false);

    int n;
    std::cin >> n;
    int h[n];
    int count = 0;
    int maxcount = 0;
    std::cin >> h[0];
    for (int i = 1; i < n; i++)
    {
        std::cin >> h[i];
        if (h[i] <= h[i-1])
        {
            count++;
            if (count > maxcount)
                maxcount = count;
        }
        else
        {
            count = 0;
        }
    }
    std::cout << maxcount;

    return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, p = LI()
    def fact(x):
        res = 1
        for i in range(2, int(sqrt(x)) + 3):
            t = 0
            while x % i == 0:
                t += 1
                x //= i
            while t >= n:
                res *= i
                t -= n
        return res
    if n == 1:
        print(p)
        return
    print(fact(p))

    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 40688
let input = readLine()!.split(separator: " ").map { Int($0)! }

let N = input[0]
let M = input[1]
let X = input[2]

struct Book {
  var price: Int
  var contents: [Int]
}

var books = [Book]()

for _ in 0 ..< N {
    let book = readLine()!.split(separator: " ").map { Int($0)! }
    books.append(Book(price: book[0], contents: Array(book[1 ... M])))
}

var result = Int.max
var all = 1 << N
var mask = 0

while mask < all {
    var level = Array(repeating: 0, count: M)
    var price = 0
    for i in 0 ..< N {
        if mask >> i & 1 == 1 {
            price += books[i].price
            for j in 0 ..< M {
                level[j] += books[i].contents[j]
            }
        }
        if level.first(where: { $0 < X }) == nil {
            result = min(result, price)
        }
    }
    mask += 1
}

print(result == Int.max ? "-1" : result)


Measured memory_bytes: 8292
#include <iostream>
#include <string>

int main() {
  std::string s; std::cin >> s;
  bool ok = true;
  for (int i = 0; i < s.size(); ++i) {
    if (i%2 == 0 && s[i] == 'L') ok = false;
    if (i%2 == 1 && s[i] == 'R') ok = false;
  }
  if (ok) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <utility> 
#include <tuple>
#include <iterator>
#include <functional>
using namespace std;
#define rep(i,n) for(long i=0; i<n; i++)





void solve(){
  int n,l;
  cin >> n >> l;
  int m=max(l,-l);
  int pointer = 1;
  int sum = 0;
  for(int i=1;i<=n;i++){
     int tmp = l+i-1;
     if(m > max(tmp, -tmp)) {
       m = max(tmp,-tmp);
       pointer = i;
     }
     sum += tmp;
  }
  cout << sum-(l+pointer-1) << endl;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
x,k,d=map(int,input().split())
x=abs(x)
if x>d:
  if x<k*d:
    q=x//d
    if (k-q)%2==0:
      print(x%d)
    else:
      print(d-x%d)
  else:
    print(x-k*d)
else:
  if k%2==0:
    print(x)
  else:
    print(d-x)

Measured memory_bytes: 9192
#include <stdio.h>
#include <set>
#include <string>

int main()
{
    std::multiset<std::string> set;
    for (int i = 0; i < 3; ++ i) {
        int x;
        scanf("%d", &x);
        for (int j = 0; j < x; ++ j)
            set.emplace(1, 'a' + i);
    }
    while (set.size() > 1) {
        auto it = -- set.end();
        std::string s = *set.begin() + *it;
        set.erase(set.begin());
        set.erase(it);
        set.emplace(s);
    }
    printf("%s\n", set.begin()->c_str());
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

INT = list(map(int,input().split()))
A,B = INT[0],INT[1]

if A >= 13:
    COST = B
elif A>=6 and A <= 12:
    COST = int(B/2)
elif A<= 5:
    COST = 0
    
print(COST)

Measured memory_bytes: 3060
import Control.Applicative
import Control.Monad
import System.IO

main :: IO ()
main = do
  s <- getLine
  putStrLn (haiku s)

haiku :: String -> String
haiku (a1:a2:a3:a4:a5:s1:b1:b2:b3:b4:b5:b6:b7:s2:c1:c2:c3:c4:c5)
 = (a1:a2:a3:a4:a5:' ':b1:b2:b3:b4:b5:b6:b7:' ':c1:c2:c3:c4:c5)

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll T[200005];
ll N, K;

ll modpow(ll n, ll r) {
    ll ret = 1;
    ll p = n;
    while (r > 0) {
        if (r & 1)
            ret = (ret * p) % MOD;
        p = (p * p) % MOD;
        r /= 2;
    }
    return ret;
}

ll solve() {
    vector<ll> A, B;
    bool z = false;
    REP(i, N) {
        if (T[i] == 0)
            z = true;
        else if (T[i] < 0)
            B.push_back(T[i]);
        else if (T[i] > 0)
            A.push_back(T[i]);
    }
    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end());

    if (A.size() + B.size() < K)
        return 0;
    if (A.size() == 0) {
        if (K % 2 == 1) {
            if (z)
                return 0;
            ll ret = 1;
            ll index = B.size() - 1;
            REP(i, K) {
                ret = (ret * (MOD + B[index - i])) % MOD;
            }
            return ret;
        }
        {
            ll ret = 1;
            REP(i, K) {
                ret = (ret * (MOD + B[i])) % MOD;
            }
            return ret;
        }
    }

    if (A.size() + B.size() == K && B.size() % 2 == 1) {
        if (z)
            return 0;
        ll ret = 1;
        REP(i, A.size()) {
            ret = (ret * (A[i])) % MOD;
        }
        REP(i, B.size()) {
            ret = (ret * (MOD + B[i])) % MOD;
        }
        return ret;
    }

    //! プラスのやつからK個とる
    {
        ll ret = 1;
        stack<ll> s;
        ll num = K;
        if (A.size() < K) {
            num = A.size();
            //! マイナスが偶数個になるように
            if ((K - num) % 2 == 1)
                num--;
        }
        REP(i, num) {
            ret = (ret * A[i]) % MOD;
            s.push(A[i]);
        }

        ll index = K - num;
        REP(i, index) {
            ret = (ret * (MOD + B[i])) % MOD;
        }

        while (s.size() >= 2 && index + 1 < B.size()) {
            ll t0 = s.top();
            s.pop();
            ll t1 = s.top();
            s.pop();

            ll s0 = B[index++];
            ll s1 = B[index++];

            if (t0 * t1 > s0 * s1)
                break;
            ret = (ret * modpow((t0 * t1) % MOD, MOD - 2)) % MOD;
            ret = (ret * ((s0 * s1) % MOD)) % MOD;
        }
        return ret;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    REP(i, N) {
        cin >> T[i];
    }
    cout << solve() << endl;
    return 0;
}

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

int main(void) {
    int a,sum;
    int frac,minfrac = 10;    
    sum = 0;
    for(int i=0;i<5;i++) {
        cin >>a;
        if(a%10) {
            sum += (((a/10)+1)*10);
            frac = a %10;
            if(minfrac > frac) {
                minfrac = frac;
            }
        } else {
            sum += ((a/10)*10);
        }
    }

    if(minfrac % 10){
        sum  = sum - 10 + minfrac;
    }

    cout << sum << endl;
    return 0;
}


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

using namespace std;

int main()
{
    int a[3];
    for(int i = 0; i < 3; i++) cin >> a[i];
    sort(a, a+3);
    if(a[2] == a[0] + a[1]){
        cout << "Yes";
    }
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
def main():
    n,x,y = map(int,input().split())

    def dist(s,g):
        return min(abs(g-s), abs(g-y) + 1 + abs(x-s), abs(g-x) + 1 + abs(s-y))

    array = [0] * (n-1)
    for i in range(1,n+1):
        for j in range(1,i):
            array[dist(i,j)-1] += 1

    [print(i) for i in array]

if __name__ == '__main__':
    main()

Measured memory_bytes: 46684
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < int(n); ++i)
#define REPE(i, a, b) for (int i = (a); i <= int(b); ++i)
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
#define PB push_back
#define EB emplace_back
using LL = long long;
using PII = pair<int, int>;
#define F first
#define S second

int ans = 0;
int dp[1 << 26];
char s[200010];
int main() {
  memset(dp, 0x7f, sizeof dp);
  dp[0] = 0;
  scanf("%s", s);
  int m = 0;
  for (int i = 0; s[i]; ++i) {
    m ^= 1 << (s[i] - 'a');
    ans = dp[m] + 1;
    REP(j, 26) {
      ans = min(ans, dp[m ^ (1 << j)] + 1);
    }
    dp[m] = min(dp[m], ans);
  }
  printf("%d\n", ans);
  return 0;
}



Measured memory_bytes: 262656
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 1100000000000000000LL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if((abs(a-b)<=d && abs(b-c)<=d) || abs(a-c)<=d){
		cout<<"Yes"<<endl;
	}
	else
		cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	x, y := r.nextInt(), r.nextInt()
	ok := false
	for i := 0; i <= 50; i++ {
		for j := 0; j <= 50; j++ {
			if i*4+j*2 == y && i+j == x {
				ok = true
				break
			}
		}
	}
	fmt.Fprintln(stdout, []string{"No", "Yes"}[b2i(ok)])
}


Measured memory_bytes: 1728
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn get_order(n: usize) -> usize {
    let mut m = n;
    let mut order = 1;
    while m/10 > 0 {
        order += 1;
        m /= 10;
    }
    order
}

fn get_count(n: usize) -> Option<(bool,bool,bool)> {
    let mut a = false;
    let mut b = false;
    let mut c = false;

    let mut m = n;

    while m > 0 {
        let p = m%10;
        if p==3 {
            a = true;
        } else if p==5 {
            b = true;
        } else if p==7 {
            c = true;
        } else {
            return None;
        }
        m /= 10
    }

    Some((a,b,c))
}

fn func(n: usize, a: bool, b: bool, c: bool) -> usize {
    let mut ans = 0;

    let mut tmp = 1;
    while n >= tmp {
        tmp *= 10;
    }
    tmp /= 10;

    for i in tmp..n+1 {
        match get_count(i) {
            Some((a2, b2, c2)) => {
                if (!a || a2) && (!b || b2) && (!c || c2) {
                    ans += 1
                }
            },
            None => {},
        }
    }

    ans
}

fn func2(n: usize, a: bool, b: bool, c: bool) -> usize{
    let mut ans = 0;

    for i in 0..n+1 {
        match get_count(i) {
            Some((a2, b2, c2)) => {
                if (a == a2) && (b == b2) && (c == c2) {
                    ans += 1
                }
            },
            None => {},
        }
    }

    ans
}

fn main() {
    let n: usize = read_line().trim().parse().unwrap();
    
    let order = get_order(n);

    if order < 3 {
        println!("{}", 0);
    } else {
        let mut ans = 0;
        let higher = n / 1000;
        let lower = n % 1000;

        match get_count(higher) {
            Some((a,b,c)) => {
                ans += func(lower, !a, !b, !c);
            }
            _ => {}
        }

        if higher > 0 {
            ans += func(999, true, true, true);
            ans += func2(higher - 1, false, false, true) * func(999, true, true, false);
            ans += func2(higher - 1, false, true, false) * func(999, true, false, true);
            ans += func2(higher - 1, false, true, true) * func(999, true, false, false);
            ans += func2(higher - 1, true, false, false) * func(999, false, true, true);
            ans += func2(higher - 1, true, false, true) * func(999, false, true, false);
            ans += func2(higher - 1, true, true, false) * func(999, false, false, true);
            ans += func2(higher - 1, true, true, true) * func(999, false, false, false);
        }
        println!("{}", ans);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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 const INF = 1001001001;


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

int x,y,z;
cin >> x >> y >> z;
cout << z  << ' ' << x << ' ' << y << endl;

return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
            long num = Long.parseLong(reader.readLine());
            System.out.println(num * num * num);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 24352
n, m, l = map(int, input().split())
A = []
B = []
C = [[0 for j in range(l)] for i in range(n)]
for i in range(n):
    tmplist = []
    tmplist = list(map(int, input().split()))
    A.append(tmplist)
for i in range(m):
    tmplist = []
    tmplist = list(map(int, input().split()))
    B.append(tmplist)
for i in range(n):
    for j in range(l):
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]
    print(" ".join(map(str, C[i])))


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

int main(){
    int n,m; cin >> n >> m;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    //sort(a.begin(),a.end());
    ll ans=0;
    while(m>0){
        sort(a.begin(),a.end());
        int left=0;
        int right=n-1;
        a[right]/=2;
        m--;
        while(left!=right){
            int mi=(right+left)/2;
            if(a[mi]<a[n-1]) left=mi+1;
            else right=mi;
        }
        for(int i=n-2; i>=left; i--){
            if(!m) break;
            a[i]/=2;
            m--;
        }
    }

    rep(i,n) ans+=a[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
def resolve():
    N,K = map(int,input().split())
    children=[False for i in range(N)]
    for i in range(K):
        d= int(input())      
        for i in map(int,input().split()):
            children[i-1]=True
    
    ans = 0
    for i in children:
        if not i:
            ans +=1
    
    print(ans)

        

    


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9196
import fractions
from functools import reduce
def lcm1(x,y):
    return (x*y)//fractions.gcd(x,y)
def lcm2(*numbers):
    return reduce(lcm1,numbers,1)
n,m = map(int,input().split())
a = set(map(lambda x: int(x)//2,input().split()))
l = lcm2(*a)
for i in a:
    if l // i % 2 == 0:
        print(0)
        exit()
print(((m // l) + 1) // 2)



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

int main() {
    double N;
    cin >> N;
    for (double i = 1; i <= 3600; i++) {
        for (double j = 1; j <= 3600; j++) {
            double sum = (4 * i * j - N * j - N * i) / (N * i * j);
            if (sum == 0) continue;
            double k = 1 / sum;
            if (1 <= k && k <= 1e9 && ceil(k) == floor(k)) {
                cout << int(i) << " " << int(j) << " " << int(k) << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <map>
#include <set>
#include <list>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <iomanip>
#include <functional>

#define SIZE 300005
#define INF 1000000000
#define FD(d) fixed << setprecision(d)
#define MOD 1000000007
#define ll long long

using namespace std;

typedef pair<ll, ll> P;

int main()
{
	string w;
	int F[30];

	cin >> w;
	
	for (int i = 0; i < 30; i++) {
		F[i] = 0;
	}
	for (int i = 0; i < w.size(); i++) {
		F[w[i] - 'a']++;
	}
	for (int i = 0; i < 26; i++) {
		if (F[i] % 2 != 0) {
			cout << "No" << endl;
			return(0);
		}
	}
	cout << "Yes" << endl;

	return(0);

}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  string col;
  cin >> col;
  string foo = "AABB";
  vector<vector<int>> g(4 * n);
  vector<pair<int, int>> ed;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    for (int it : {0, 1}) {
      for (int x = 0; x < 4; x++) {
        int y = (x + 1) % 4;
        if (col[a] != foo[x] || col[b] != foo[y]) continue;
        g[4 * a + x].push_back(4 * b + y);
        ed.emplace_back(4 * a + x, 4 * b + y);
      }
      swap(a, b);
    }
  }
  vector<int> ord;
  vector<int> id(4 * n);
  vector<bool> mark(4 * n);
  function<void(int)> Dfs = [&](int v) {
    mark[v] = 1;
    for (int to : g[v]) {
      if (!mark[to]) {
        Dfs(to);
      }
    }
    id[v] = (int) ord.size();
    ord.push_back(v);
  };
  for (int i = 0; i < 4 * n; i++) {
    if (!mark[i]) {
      Dfs(i);
    }
  }
  bool found = false;
  for (auto e : ed) {
    found |= (id[e.first] < id[e.second]);
  }
  cout << (found ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 46596
#include <bits/stdc++.h>
#define ll long long int
#define db double
#define pb push_back
#define mpr make_pair
#define andl "\n"
#define f first
#define s second
#define mset(x,y) memset(x,y,sizeof(x))
#define fr(i,n) for(long long int i=0;i<n;i++)
#define trace(it,x) for(auto it = (x).begin(); it != (x).end(); it++)
#define mod 1000000007
#define fastio ios::sync_with_stdio (false); cin.tie (0); cout.tie (0);
#define runtime cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
using namespace std;
 
// convert number to string to_string(x);
// convert string to number stoi();
 
// ll mulmod(ll x,ll y)
// {
//     return ((x%mod)*(y%mod))%mod;
// }
 
// ll binpow(ll x, ll y)
// {
//     ll z = 1;
//     while(y > 0)
//     {
//         if(y % 2 == 1)
//             z = mulmod(z, x);
//         x = mulmod(x, x);
//         y /= 2;
//     }
//     return z;
// }
 
// ll ncr(ll n,ll r)
// {
//     return mulmod(fact[n],binpow(mulmod(fact[n-r],fact[r]),mod-2));
// }
 
// ll pwr(ll n,ll m)
// {
//   if(n==1 || m==0)
//     return 1;
 
//   ll x=pwr(n,m/2);
//   if(m%2==0)
//     return x*x;
//   else
//     return n*x*x;
// }
 
// ll pwr(ll n,ll m,ll b)
// {
//   if(n==1 || m==0)
//     return 1;
 
//   ll x=pwr(n,m/2,b);
//   if(m%2==0)
//     return ((x%b)*(x%b))%b;
//   else
//     return ((n%b)*(((x%b)*(x%b))%b))%b;
// }
 
void solve(ll n)
{
    ll x=0,a,b;
    fr(i,n)
    {
        cin >> a >> b;
        if(a==b)
            x++;
        else
            x=0;
        if(x==3)
        {
            cout << "Yes";
            return ;
        }

    }
    cout << "No";
  return ;
}
 
int main()
{
  fastio
  
  ll t;
  cin >> t;
  solve(t);
  runtime
}

Measured memory_bytes: 3792
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    vector<int> A(3);
    rep(i, 3) cin >> A[i];
    int K;
    cin >> K;
    
    sort(A.rbegin(), A.rend());
    rep(i, K) A[0] *= 2;
    cout << A[0] + A[1] + A[2] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int n,y,i,j,k;
  cin >> n >> y;
  for(i=0;i<=n;i++){
  	for(j=0;j<=n;j++){
      k=n-i-j;
        if(k>=0 && 1000*i+5000*j+10000*k==y){
        	printf("%d %d %d\n",k,j,i);
       	  	 return 0;	
        }
  	}
  }
  printf("-1 -1 -1\n");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define ll long long int
#define d 1000000007
using namespace std;
int main()
{
    int t;
    t=1;
    while(t--)
    {
        int n;
        cin >> n;
        ll total=0;
        for(int i=1;i<n;i++)
        {
            for(int j=1;j*i<n;j++)
            {
                total++;
            }
        }
        cout << total;
    }
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main(){
  long int n;
  cin >> n;
  vector<long int> a(3*n);
  for(int i = 0;i < 3*n;i++) cin >> a.at(i);
  sort(a.begin(), a.end(), greater<int>());
  long int sum = 0;
  for(int i = 1;i < 2*n;i += 2){
    sum += a.at(i);
  }
  cout << sum << endl;
}


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

int main() {
  string s;
  cin >> s;
  int cnt = 0;
  if (s[0] == '1') ++cnt;
  if (s[1] == '1') ++cnt;
  if (s[2] == '1') ++cnt;
  cout << cnt << endl;
}

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

public class Main implements Runnable {
	public static void main (String[] args) {new Thread(null, new Main(), "_cf", 1 << 28).start();}

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		char[] s = fs.next().toCharArray();
		Arrays.sort(s);
		System.out.println(s[0] == s[1] && s[2] == s[3] && s[0] != s[2] ? "Yes" : "No");
		
		out.close();
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}                
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
		
		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}
		
	}

}

Measured memory_bytes: 23252
//Never stop chasing!-MdSourav.
#include <bits/stdc++.h>

#define yes            cout<<"YES"<<endl
#define no             cout<<"NO"<<endl
#define sz(x)          x.size()
#define ll                    long long int
#define ls             long int
#define start          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test           int t;cin>>t;while(t--)
#define f(i, a, n)     for(int i=a; i<n;i++)
#define gcd(a,b)7           __gcd(a,b)
#define lcd(a,b)       (a*b)/gcd(a,b)
#define pb             push_back
#define mp(x,y)        make_pair(x,y)
#define rsrt(v)        sort(v.begin(),v.end(),greater<int>())
#define srt(v)         sort(v.begin(),v.end())
#define basrt(a,n)     sort(a,a+n,greater<int>())
#define asrt(a,n)      sort(a,a+n)
#define fact(n)        ll x=1;for(ll i=1;i<=n;i++){x=(x*i);}
#define F              first
#define S              second
#define deb(x)         cout << #x << ": " << x << endl;
#define enter(v,n)     for(ll i=0;i<n;i++){ll x;cin>>x;v.pb(x);}
#define INF 	       1000000007
#define unique(v)      v.erase(unique(v.begin(),v.end()),v.end())
using namespace std;

double pi=3.14159265358979323846;
typedef vector<ll> vll ;
typedef vector<int> vii ;

template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    for (const auto &x : v) os << " " << x;
        return os << '}';
}
void solve()
{
      int n;cin>>n;
      vector<ll>v;
      enter(v,n);
      if(v[0]==1000000000 && v[1]==1000000000)
      {
          cout << "1000000000000000000" << endl;
          return;
      }
      for(int i=0;i<n;i++)
      {
          if(v[i]==0)
          {
              cout << "0" << endl;
              return;
          }
      }
      ll ans=v[0];
      ll sup=v[0];
      for(ll i=1;i<n;i++)
      {
         long double x=1000000000000000000.0/v[i]*(1.0);
         //cout << fixed << setprecision(20) << x << endl;
        //deb(sup);
         if(x<=sup)
         {
             cout << "-1" << endl;
             return;
         }
         ans=ans*(v[i]);
         sup=ans;


      }
      cout << ans << endl;

}

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

	return 0;
}

Measured memory_bytes: 4264
// Created by PRATEEK RANJAN
#include <bits/stdc++.h>
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define int long long
const int mod = 1e9+7;

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int w,a,b;
    cin>>w>>a>>b;
    if((b>=a and b<=a+w) or (a>=b and a<=b+w)){
        cout<<0;
    }
    else
        cout<<abs(min({a+w-b, b+w-a}));
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>

using namespace std;

void b_papers_please(void) {
	int n;
	cin >> n;
	vector<int> a(n);
	int a_buf;
	string judge = "APPROVED";

	for (int i = 0; i < n; i++) {
		cin >> a_buf;
		if ((a_buf & 0x1) == 0x0) {
			if ((a_buf % 3 != 0)&&(a_buf % 5 != 0)) judge = "DENIED";
		}
	}

	cout << judge << endl;
}

int main()
{
    b_papers_please();

    return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cmath>

int gcd(int x,int y)
{
    if(y==0)
        return x;
    else 
        return gcd(y,x%y);
}



int main(void)
{
    int i,N,X,dist;
    int *a;
    scanf("%d%d",&N,&X);
    a=new int [N];
    for(i=0;i<N;i++)
        scanf("%d",a+i);
    dist=std::abs(a[0]-X);
    for(i=1;i<N;i++){
        dist=gcd(dist,std::abs(a[i]-X));
    }
    printf("%d\n",dist);
    delete [] a;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(r<=x&&x<=W-r&&r<=y&&y<=H-r)
	{
			printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 580
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]
# @lru_cache(None)

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x
n=l()[0]
LCM=1
for i  in range(n):
    t=int(input())
    g=gcd(LCM,t)
    LCM=(LCM*t)//g
print(LCM)



Measured memory_bytes: 5632
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int N, M;
    cin >> N >> M;
    int A[M];
    rep(i, M) cin >> A[i];
    int sum = 0;
    rep(i, M) sum += A[i];
    if(sum > N) cout << -1 << endl;
    else cout << N - sum << endl;
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    vector<ll> cnt(4000001);
    bitset<4000001> dp;
    bitset<4000001> dp_shifted;
    dp.set(0);
    rep(i,N){
        dp_shifted = dp << A[i];
        dp |= dp_shifted;
    }

    double sum =0;
    rep(i,N){
        sum+=A[i];
    }
    
    rep2(i,(int)((sum+1)/2),4000001){
        if(dp.test(i)){
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 33024
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m;i>n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
   lli A,B,L,R,N,M,K,sum=0,num=0,flag=0;
   string S;
   cin >> S;
   if(S=="Sunny")Out("Cloudy");
   else if(S=="Cloudy")Out("Rainy");
   else Out("Sunny");
}

Measured memory_bytes: 256
let f (_, x) (_, y) = x-y
let () =
  Scanf.scanf "%d" @@ fun n ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d %d" (fun a b -> a, b)) in
  Array.sort f a;
  a |> Array.fold_left (fun (msg, t) (a, b) ->
    if msg = "Yes" && t+a <= b then ("Yes", t+a) else ("No", -1)) ("Yes", 0)
  |> fst |> print_endline


Measured memory_bytes: 9472
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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 long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    for(int i = 0; i < N; i++) cin >> p[i];
    sort(p.begin(), p.end());
    int ans = 0;
    for(int i = 0; i < K; i++) ans += p[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n:usize , d:usize, xy: [[i128; 2];n]};
    let xy: Vec<Vec<i128>> = xy;

    let mut count = 0;

    for i in xy.iter() {
        let result = ((i[0] * i[0] + i[1] * i[1]) as f64).sqrt();

        if result <= d as f64 {
            count += 1;
        }
    }

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


Measured memory_bytes: 18916
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 55 + 10;
#define fi first
#define se second
#define pb push_back
int n,m;
struct uzi{
  int s,t,i;
}p[N];
vector<int>v[N];
vector<int>g[N][N];
int b[51][51],pre[N];
void dfs(int x,int y){
  pre[x]=y;
  for(auto k:v[x])if(k!=y){
      dfs(k,x);
    }
}
bitset<50>li[N];
int main() {
  ios::sync_with_stdio(false);
  cin>>n;
  for(int i=1;i<n;i++){
    int s,t;
    cin>>s>>t;
    v[s].pb(t);
    v[t].pb(s);
    b[s][t]=b[t][s]=i;
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++)pre[j]=0;
    dfs(i,0);
    for(int j=1;j<=n;j++){
      int now=pre[j];
      while(now){
        g[i][j].pb(now);
        now=pre[now];
      }
    }
  }
  cin>>m;
  LL ans=1ll<<n-1;
  // cout<<ans<<endl;
  for(int i=0;i<m;i++){
    cin>>p[i].s>>p[i].t;
    int S=p[i].s,t=p[i].t;
    for(auto z:g[S][t]){
      li[i].set(b[t][z]-1);
      //if(i==2)cout<<t<<' '<<z<<endl;
      t=z;
    }
  }
  for(int i=1;i<1<<m;i++){
    vector<int>x;
    for(int j=0;j<m;j++){
      if(1<<j&i) {
        x.pb(j);
      }
    }
    int y=__builtin_popcount(i)&1?-1:1;
    bitset<50>ggx;ggx.reset();
    for(auto k:x){
      ggx|=li[k];
    }
    ans+=y*(1ll<<(n-1-ggx.count()));
  }
  cout<<ans<<'\n';
  return 0;
}


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

int f[4],ans;

inline int read(){
  	int X=0,w=0; 
	char ch=0;
  	while (ch<'0' || ch>'9'){
		w|=ch=='-';
		ch=getchar();
	}
  	while (ch>='0' && ch<='9') 
	    X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
  	return w?-X:X;
}

int main(){
	scanf("%d%d%d",&f[1],&f[2],&f[3]);
	sort(f+1,f+4);
	ans=f[3]-f[1];
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Solve is
   A : Integer;
   B : Integer;
   score : Integer;
begin
   Get (A);
   Get (B);
   for I in 1 .. 2 loop
      if A >= B then
         score := score+A;
         A := A-1;
      else
         score := score+B;
         B := B-1;
      end if;
   end loop;
   Put_Line (Integer'Image (score));
end Solve;

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

typedef long long ll;

const int N = 100010;

int n, W;
ll f[N], w[N], v[N];

int main() {
	scanf("%d%d", &n, &W);
	ll ans = 0;
	for(int i = 1; i <= n; ++i) scanf("%lld%lld", &w[i], &v[i]);
	for(int i = 1; i <= n; ++i) {
		for(int j = W; j >= w[i]; --j) {
			f[j] = max(f[j], f[j - w[i]] + v[i]);
		}
	}
	for(int i = 1; i <= W; ++i) ans = max(ans, f[i]);
	printf("%lld\n", ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
  
int main(){
int a,b,c,d;
  cin >> a>>b>>c>>d;
  if(a+b<c+d){
    cout<<"Right"<<endl;
  }else if(a+b>c+d){
    cout<<"Left"<<endl;
  }else{
    cout<<"Balanced"<<endl;
  }
}


Measured memory_bytes: 256
#include <cstdint>
#include <cmath>
#include <iostream>
#include <string>
#include <boost/lexical_cast.hpp>

using Number = int64_t;

Number getWidth(Number num) {
    return 1 + static_cast<Number>(std::floor(std::log10(num)));
}

int main(int argc, char* argv[]) {
    std::string line;
    std::getline(std::cin, line);
    Number num = boost::lexical_cast<decltype(num)>(line);
    const Number nearRoot = static_cast<decltype(num)>(std::floor(std::sqrt(num) + 0.5));

    Number digits = 100;
    for(Number i = nearRoot; i > 0; --i) {
        auto d = num / i;
        if ((d * i) == num) {
            digits = std::min(digits, std::max(getWidth(i), getWidth(d)));
        }
    }

    std::cout << digits;
    return 0;
}


Measured memory_bytes: 256
N, M =map(int, input().split())

def divisor(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse =True)
    return divisors

d = divisor(M)

for i in d:
  if M//i >= N:
    print(i)
    break

Measured memory_bytes: 3060
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        s: Bytes
    }
    let m = 1000000007usize;

    let mut dp = vec![vec![0usize; 13]; s.len()+1];
    dp[0][0] = 1;
    for i in 0..s.len() {
        for prev in 0..13 {
            if s[i] != b'?' {
                let v = prev * 10 + (s[i] - b'0') as usize;
                let r = v % 13;
                dp[i+1][r as usize] += dp[i][prev];
                dp[i+1][r as usize] %= m;
                continue;
            }
            for d in 0..=9 {
                let v = prev * 10 + d;
                let r = v % 13;
                dp[i+1][r as usize] += dp[i][prev];
                dp[i+1][r as usize] %= m;
            }
        }
    }
    let ans = dp[s.len()][5];
    println!("{}", ans);
}


Measured memory_bytes: 15524
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
const int nmax=100005;
int a[nmax];
int n,i,x,d1,d2;
bool decomp(int a,int b)
{
    return a>b;
}
bool marg()
{
    return (i>=a[i+1]);
}
int main()
{
   // freopen("data.in","r",stdin);
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1,decomp);
    a[0]=a[1];
    for(i=0;!marg();i++);
    x=i-1;
    d1=1-(a[x+1]-x)%2;
    for(i=x;i<=n&&a[i+1]>x;i++);
    i--;
    d2=(i-x)%2;
    if(d1||d2) cout<<"First";
    else cout<<"Second";
    return 0;
}


Measured memory_bytes: 640
import sys
 
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


from collections import deque

def main():

  n,q=map(int,input().split())

  li=[[] for i in range(n+1)]
  ans=[0]*(n+1)

  for i in range(n-1):
    a,b=map(int,input().split())
    li[a].append(b)
    li[b].append(a)

  for i in range(q):
    p,x=map(int,input().split())
    ans[p]+=x

  Q=deque([1])
  sumi=set([1])

  while Q:
  #  print(Q)
    now=Q.pop()
    for i in li[now]:
      if i in sumi:
        continue
      else:
        sumi.add(i)
        Q.append(i)
        ans[i]+=ans[now]
  print(*ans[1:])
      
if __name__ == "__main__":
  main()     

Measured memory_bytes: 64220
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        double w = stdIn.nextDouble();
        double h = stdIn.nextDouble();
        double x = stdIn.nextDouble();
        double y = stdIn.nextDouble();

        System.out.println(w * h / 2);
        
        if(x == w / 2 && y == h / 2)  {
            System.out.println(1);
        } else {
            System.out.println(0);
        }
    }
}

Measured memory_bytes: 25044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

bool f = 1;
string s;

int main(){
	int co = 0;
	cin >> s;
	REP(i, s.size()){
		if (f){
			if (s[i] == 'A')f = 0;
		}
		else{
			if (s[i] == 'Z'){
				co++;
				f = 1;
			}
		}
	}
	if (co == 0){
		cout << -1 << endl;
		return 0;
	}
	REP(i, co){
		cout << "AZ";
	}
	cout << endl;
}

Measured memory_bytes: 1180
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
from collections import defaultdict

N,K = map(int,input().split())
A = [int(x) for x in input().split()]

AA = A + A # 2周分
next_same = [None] * (2*N)
last_pos = defaultdict(lambda: None)

for i,a in enumerate(AA):
    j = last_pos[a]
    if j is None:
        last_pos[a] = i
    else:
        next_same[j] = i
        last_pos[a] = i

# Xの添字で、最後にvisitしたときを持つ。visit = （そこからスタート！）

NK = N * K
visited = [None] * N
x = 0
visited[0] = 0
while True:
    y = next_same[x % N] + (x//N) * N + 1
    if y >= NK:
        break
    if visited[y % N] is not None:
        # 周期が見つかった！
        P = y - visited[y % N]
        y += (NK - y) // P * P
        x = y
        break
    else:
        visited[y % N] = y
        x = y

answer = []
while x < NK:
    y = next_same[x % N] + (x//N) * N + 1
    if y > NK:
        answer.append(A[x%N])
        x += 1
        continue
    x = y

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

Measured memory_bytes: 57304