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

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(int n);            // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {
  
  ll n;
  cin >> n;
  vector<ll> h(n,0);

  ll his = 0;
  rep(i,n)
  {
    ll buf;
    cin >> buf;
    if(his - buf < 2)
    {
      his = max(his,buf);
    }
    else
    {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 1)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

int main(){
    string s,t;
    cin>>s>>t;
    long long ans=s.size();
    rep(i,s.size()){
        if(s[i]==t[i])ans--;
    }
    cout<<ans<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 3848
#include <iostream>                                                                                                              
#include <string>
using namespace std;
int main(){
  int A,B,X;
  string message = "";
  cin >> A >> B >> X;
  if(X-A > B || X-A < 0){
    message = "NO";
  }else{
    message = "YES";
  }
  cout << message << endl;
   
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int mod = 1e9 + 7;
//const int mod = 998244353;

const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;


int main() {
  int k,m;
  cin >> k >> m;
  if(k*500>=m) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll ll_inf = ll(1e9) * ll(1e9);
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

int main() {
    ll h, w;
    cin >> h >> w;
    ll startX, startY, endX, endY;
    cin >> startX >> startY >> endX >> endY;
    startX--, startY--, endX--, endY--;

    vector<vector<char>> s(h, vector<char>(w));
    rep(i, h) rep(j, w) cin >> s[i][j];

    vector<vector<ll>> cnts(h, vector<ll>(w, ll_inf));  // 魔法使った回数
    queue<P> q, visited;
    q.push(P(startX, startY));
    cnts[startX][startY] = 0;

    while (!q.empty() || !visited.empty()) {
        ll nowX, nowY;
        if (!q.empty()) {
            nowX = q.front().first, nowY = q.front().second;
            visited.push(P(nowX, nowY));
            q.pop();
            rep(i, 4) {
                ll nextX = nowX + dx[i], nextY = nowY + dy[i];
                if (0 <= nextX && nextX <= h - 1 && 0 <= nextY && nextY <= w - 1) {
                    if (s[nextX][nextY] == '#') continue;
                    if (cnts[nowX][nowY] < cnts[nextX][nextY]) {
                        cnts[nextX][nextY] = cnts[nowX][nowY];
                        q.push(P(nextX, nextY));
                    }
                }
            }

        } else {  // 今まで通った道から魔法で行ける道を全て調べる
            nowX = visited.front().first, nowY = visited.front().second;
            visited.pop();
            for (ll ix = -2; ix <= 2; ++ix) {
                for (ll jy = -2; jy <= 2; ++jy) {
                    ll nextX = nowX + ix, nextY = nowY + jy;
                    if (0 <= nextX && nextX <= h - 1 && 0 <= nextY && nextY <= w - 1) {
                        if (s[nextX][nextY] == '#') continue;
                        if (cnts[nowX][nowY] + 1 < cnts[nextX][nextY]) {
                            cnts[nextX][nextY] = cnts[nowX][nowY] + 1;
                            q.push(P(nextX, nextY));
                        }
                    }
                }
            }
        }
    }
    if (cnts[endX][endY] == ll_inf) {
        cout << -1 << '\n';
    } else {
        cout << cnts[endX][endY] << '\n';
    }
    return 0;
}


Measured memory_bytes: 12524
op = [['+', '+', '+'], ['+', '+', '-'], ['+', '-', '+'], ['-', '+', '+'], ['+', '-', '-'], ['-', '+', '-'],
      ['-', '-', '+'], ['+', '-', '-']]

a = list(map(int, input()))

for i in range(8):
    s = a[0]
    for j in range(3):
        if op[i][j] == '+':
            s += a[j + 1]
        else:
            s -= a[j + 1]
    if s == 7:
        for k in range(3):
            print(a[k], end='')
            print(op[i][k], end='')
        print(str(a[-1])+'=7')
        exit()


Measured memory_bytes: 3064
class DayDream:

    def is_possible(self, S):

        S = S[::-1]

        candidates = ["dream"[::-1], "dreamer"[::-1], "erase"[::-1], "eraser"[::-1]]

        idx = 0
        while idx < len(S):
            
            if S[idx:idx+5] in candidates:
                idx += 5

            elif S[idx:idx+6] in candidates:
                idx += 6

            elif S[idx:idx+7] in candidates:
                idx += 7

            else:
                return "NO"

        return "YES"

if __name__ == "__main__":

    S = raw_input()

    abc = DayDream()
    print abc.is_possible(S)


Measured memory_bytes: 2948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define plint pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    ll n,m,ans=0;
    cin >> n >> m;
    vector<ll > a(m);
    REP(i,m) cin >> a[i];
    ans = accumulate(ALL(a),0);
    if(ans>n){
        cout << -1 << endl;
    }else{
        cout << n-ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3708
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));
  list($t, $a) = explode(" ", trim(fgets(STDIN)));
  $h = array_map('intval', explode(" ", trim(fgets(STDIN))));

  $ans = 0;
  $min = PHP_INT_MAX;
  for ($i=0; $i<$n; $i++) {
    $sa = abs($a - ($t-$h[$i]*0.006));
    if($min > $sa){
      $ans = $i;
      $min = $sa;
    }
  }
  
  echo $ans+1;

Measured memory_bytes: 16216
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> D(N);
    rep(i, N) cin >> D[i];
    map<int, int> pset;
    rep(i, N) { pset[D[i]]++; }
    int M;
    cin >> M;
    vector<int> T(M);
    rep(i, M) cin >> T[i];
    int ok = 1;
    rep(i, M) {
        if(pset[T[i]] == 0) {
            ok = 0;
            break;
        } else {
            pset[T[i]]--;
        }
    }
    cout << (ok ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 11264
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
   let X = 100;
   let Y = 0;
   let count = 0;
   while(xs[0]>X){
      Y = Math.floor(X + (X*0.01));   
      X = Y;
      count++
     //console.log(X);
   }
   console.log(count);

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

Measured memory_bytes: 29900
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		loop: while (true) {
			w = scanner.nextInt();
			h = scanner.nextInt();
			if ((w | h) == 0)
				break;
			count = 0;
			visited = new boolean[h][w];
			sx = -1;
			sy = -1;
			boolean isworstpatt = (w == 7 && h == 7);
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					int now = scanner.nextInt();
					if (now == 0) {
						count++;
						if (sx == -1) {
							sy = i;
							sx = j;
						}
					} else {
						isworstpatt = false;
						visited[i][j] = true;
					}
				}
			}
			if(count%2==1){
				System.out.println("No");
				continue;
			}
			if (isworstpatt) {
				System.out.println("No");
				continue;
			}
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (visited[i][j])
						continue;
					int count = 0;
					for (int k = 0; k < 4; k++) {
						int x = j + vx[k];
						int y = i + vy[k];
						if (!isOK(x, y))
							continue;
						if (!visited[y][x])
							count++;
					}
					if (count < 2) {
						System.out.println("No");
						continue loop;
					}
				}
			}

			System.out.println(dfs(sx, sy, 0) ? "Yes" : "No");
		}

	}

	private boolean dfs(int x, int y, int deep) {
		if (count - deep < Math.abs(x - sx) + Math.abs(y - sy))
			return false;

		for (int i = 0; i < 4; i++) {
			int nx = x + vx[i];
			int ny = y + vy[i];
			if (!isOK(nx, ny))
				continue;
			if (ny == sy && nx == sx && deep + 1 == count)
				return true;
			if (visited[ny][nx])
				continue;
			boolean res = check(nx, ny);
			if (!res)
				continue;
			visited[ny][nx] = true;
			if (dfs(nx, ny, deep + 1))
				return true;
			visited[ny][nx] = false;
		}
		return false;

	}

	private boolean check(int x, int y) {
		loop: for (int i = 4; i < vx.length; i++) {
			int nx = x + vx[i];
			int ny = y + vy[i];
			if (!isOK(nx, ny))
				continue;
			if (nx == sx && ny == sy)
				continue;
			if (visited[ny][nx])
				continue;
			int count = 0;
			for (int j = 0; j < 4; j++) {
				int nnx = nx + vx[j];
				int nny = ny + vy[j];
				if (!isOK(nnx, nny))
					continue;
				if (visited[nny][nnx])
					continue;
				count++;
				if (count == 2)
					continue loop;
			}
			return false;
		}
		return true;
	}

	private boolean isOK(int x, int y) {
		if (0 <= x && x < w && 0 <= y && y < h)
			return true;
		return false;
	}

	boolean[][] visited;
	boolean ans;
	int count, w, h, sx, sy;
	int[] vx = { 0, 1, 0, -1, 1, 1, -1, -1 };
	int[] vy = { -1, 0, 1, 0, -1, 1, 1, -1 };
}

Measured memory_bytes: 50768
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author parsa bahrami
 */

#pragma GCC optimize("O2")

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

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef pair<string, string> pss;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sz(x)                       (ll) x.size()
#define jjoin(x)                    for (auto i : x) cout << i << endl;
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define sep                         ' '
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define kill(x)                     return cout << x << endl , 0;
#define Hkill(x)                    cout << x << endl; exit(0);
#define endl                        '\n'

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 2e5 + 10;
const ll MAXA = 101;
const ll INF = 8e18;
const ll MOD = 998244353; //1e9 + 7
const ld PI = 4 * atan((ld) 1);
ll n, k, A[MAXN], F[MAXN];

bool chk(ll x) {
    ll sum = 0;
    for (ll i = 0; i < n; i++)
        sum += max(0LL, A[i] - x / F[i]);
    return sum <= k;
}

int main() {
    fast_io;
    set_random;
    cin >> n >> k;
    for (ll i = 0; i < n; i++)
        cin >> A[i];
    for (ll i = 0; i < n; i++)
        cin >> F[i];
    sort(A, A + n, greater<ll>());
    sort(F, F + n);
    ll l = -1, r = 1e12;
    while (r - l > 1) {
        ll mid = (l + r) >> 1;
        if (chk(mid))
            r = mid;
        else
            l = mid;
    }
    cout << r << endl;
    return 0;
}



Measured memory_bytes: 3328
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type ByStr []string

func (a ByStr) Len() int { return len(a) }
func (a ByStr) Less(i, j int) bool {
	return a[i] < a[j]
}
func (a ByStr) Swap(i, j int) { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	S := sc.nextStr()
	K := sc.nextInt()
	set := make(map[string]bool)
	for i := 0; i < len(S); i++ {
		set[string(S[i])] = true
		for j := i + 1; j <= len(S); j++ {
			if len(S[i:j]) <= K {
				set[S[i:j]] = true
			}
		}
	}
	arr := []string{}
	for key, _ := range set {
		arr = append(arr, key)
	}
	sort.Sort(ByStr(arr))

	fmt.Fprintln(wtr, arr[K-1])
	wtr.Flush()
}


Measured memory_bytes: 3200
#include <stdio.h>

int cup[3];

void swap( int* a, int* b )
{
	char buf;
	buf = *a;
	*a = *b;
	*b = buf;
}

int main(void)
{
	char a;
	char b;
	int i;
	
	cup[0] = 1;
	
	while( scanf("%c,%c\n", &a, &b) != EOF )
	{
		swap( &cup[a - 'A'], &cup[b - 'A'] );
	}
	
	for( i = 0; i < 3; i++ )
	{
		if( cup[i] != 0 )
		{
			printf( "%c\n", 'A' + i );
		}
	}
	
	return (0);
}

Measured memory_bytes: 548
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n;

llint gcd(llint a, llint b)
{
	if(b == 0) return a;
	return gcd(b, a%b);
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	
	llint ans = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			for(int k = 1; k <= n; k++){
				ans += gcd(i, gcd(j, k));
			}
		}
	}
	cout << ans << endl;
		
	return 0;
}

Measured memory_bytes: 3652
"""from collections import *
from heapq import *
from itertools import *
from fractions import gcd

from decimal import *
import copy
from bisect import *
import time"""
import sys
sys.setrecursionlimit(10**7)
input=lambda :sys.stdin.readline().rstrip()
N=int(input())
if 2<=N<=4:
    if N==2:
        print(1)
    if N==3:
        print(2)
    if N==4:
        print(2)
    exit()
count=2
visited=set()
for K in range(2,round(N**.5)+1):
    n=N
    while n%K==0:
        n//=K
    count+=n%K==1
    visited.add(K)

lst=[]
X=round(N**.5)+1
for i in range(2,round(N**.5)+1):
    if (N-1)%i==0:
        if not i in visited:
            lst.append(i)
        C=(N-1)//i
        if not C in visited:
            lst.append(C)



for K in lst:
    n=N
    while n%K==0:
        n//=K
    count+=n%K==1
    visited.add(K)
print(count)
"""
for K in C:
    n=N
    while n>=K:
        if n%K==0:
            n//=K
        else:
            n-=K
    if n==1:
        print(K,"KK")
"""


Measured memory_bytes: 74496
#include<bits/stdc++.h>
using namespace std;
#define test(a) cout << "*" << a << endl;
#define rep0(i,n) for(i=0;i<n;i++)
int main(){
  vector<int>vec(3);
  int i;
  
  rep0(i,3){
    cin >> vec[i];
  }
  sort(vec.begin(),vec.end());  
  //rep0(i,3) test(vec[i]);
  
  cout << (vec[2]-vec[1])+(vec[1]-vec[0]) <<endl;
 
  //test(a[0]);
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6+10 , OO = 0x3f3f3f3f ;
const int mod = 1e9 + 7;
 
#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 xloop(i,a,b) for(int i = int(a);i <= int(b);i++)
#define range(vec) for(auto &x : vec) cin >> x;
#define ALL(v) ((v).begin()) , ((v).end())
#define SZ(v)  ((int)((v).size()))
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

int n , c;

int main()
{
   // startTime = (double)clock();
    #ifndef ONLINE_JUDGE
        //freopen("in.in", "r", stdin);
        //freopen("out.in", "w", stdout);
    #endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    

    map < string , int > cnt;
    cin >> n;
    for(int i = 0 ; i < n ; ++i){
        string s;
        cin >> s;
        cnt[s]++;
    }
    cout << "AC x " << cnt["AC"] << "\n";
    cout << "WA x " << cnt["WA"] << "\n";
    cout << "TLE x " << cnt["TLE"] << "\n";
    cout << "RE x " << cnt["RE"] << "\n";
    

    return 0;
}

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

int main (){
  int64_t H,A=1,B=1;
  int S=0;
  
  cin >> H;
  for (int i=0;i<1000;i++){
    if (H==1){
      break;
    }
    else {
      H /=2;
      S ++;
    }
  }
  if (S == 0){
    cout << 1<< endl;
  }
  else {
    for (int i=0;i<S;i++){
      A*=2;
      B+=A;

      }
    cout << B<<endl;
  }
}
    
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x; 
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x; 
        return true;
    }
    return false;
}
template<typename Val>
bool bitcheck(Val bit, size_t idx) {
    return bit & (1 << idx);
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;

void solve() {
    int a, b, m; cin >> a >> b >> m;
    vector<int> avec(a), bvec(b), xvec(m), yvec(m), cvec(m);
    FOR(i, 0, a) cin >> avec[i];
    FOR(i, 0, b) cin >> bvec[i];
    FOR(i, 0, m) {
        cin >> xvec[i] >> yvec[i] >> cvec[i];
    }

    int cost = *std::min_element(avec.begin(), avec.end()) + *std::min_element(bvec.begin(), bvec.end());
    int cost2 = 1000010;
    FOR(i, 0, m) {
        int cand = avec[--xvec[i]] + bvec[--yvec[i]] - cvec[i];
        chmin(cost2, cand);
    }
    chmin(cost, cost2);
    cout << cost << endl;
}

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

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

using namespace std;

int main(void)
{
	int n;
	cin>>n;
	int a[n];
	for(int i = 0; i < n; i++) cin>>a[i];
	for(int i = 0; i < n; i++){
		if(a[i] % 2 == 0){
			if(a[i] % 3 != 0 && a[i] % 5 != 0){
				cout<<"DENIED"<<endl;
				return 0;
			}
		}
	}
	
	cout<<"APPROVED"<<endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	
	static boolean search(int[] S,int a,int b,int target){
		if(a<=b){
			if(S[(a+b)/2]==target){
				return true;
			}else if(S[(a+b)/2]<target){
				return search(S,((a+b)/2)+1,b,target);
			}else{
				return search(S,a,((a+b)/2)-1,target);
			}
		}else{
			return false;
		}
	}
	
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int S[]=new int[n];
		for(int i=0;i<n;i++){
			S[i]=scan.nextInt();
		}
		Arrays.sort(S);
		int q=scan.nextInt();
		int count=0;
		int x;
		for(int i=0;i<q;i++){
			x=scan.nextInt();
			if(search(S,0,n-1,x)){
				count++;
			}
		}
		System.out.println(count);
		scan.close();
	}

}

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

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

    int sum = 0;
    int tmp = n;
    while(tmp > 0) {
        sum += tmp % 10;
        tmp /= 10;
    }
    if (n % sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;

const int maxn = 2e5 + 10;
const int mod = 1e9 + 7;

int dp[maxn], a[maxn], last[maxn], pre[maxn];

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	memset(last, -1, sizeof last);
	dp[0] = 1;
	for (int i = 1; i <= n; i++){
		pre[i] = last[a[i]];
		last[a[i]] = i;
		dp[i] = dp[i - 1];		
		if (pre[i] == -1)
			continue;
		if (pre[i] != i - 1)
			dp[i] = (dp[i] + dp[pre[i]]) % mod;	
	}
	cout << dp[n] << endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define se second
#define mp make_pair
#define fi first
#define del(a,vec) vec.erase(std::remove(vec.begin(), vec.end(), a), vec.end());
#define search(f,l,v) binary_search(f,l,v)
#define iter(a,b) vector<int>::iterator a,b
#define lower(v,num) lower_bound (v.begin(), v.end(), num);
#define upper(v,num) upper_bound (v.begin(), v.end(), num); 
#define removecopy(a) unique(a.begin(), a.end()); 
#define ll long long int
namespace Rahul{
    bool isPrime(int n) 
    {if (n <= 1)  return false; if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; }
    ll pow (ll x, ll n,ll mod) {//calculate x^n
    if (n == 0) return 1;

    ll res = pow (x, n / 2,mod);

    res = (res * res) % mod;
    if (n % 2) res = (res * x ) % mod;

    return res;
    }
    ll _gcd(ll a,ll b)
    {
        if(a==0)
            return b;
        else    
            return _gcd(b%a,a);
    }
    //s.erase(s.find(2)) where s={1,2,3,3,2}; 
};
using namespace Rahul;
int main()
{
     ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
        // cout<<"hi\n";
    int a,b,c;
  cin>>a>>b>>c;
  if(a+b+c >=22)
    cout<<"bust";
  else
    cout<<"win";

}
     
     
     



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i, j) FOR(i, 0, j)
#define FOR(i, j, k) for(int i = j; i < k; ++i)

using namespace std;

int main(){
  int n;
  while(scanf("%d", &n) && n){
    int c = n / 4, res = 0, hit;
    while(c--){ 
      scanf("%d", &hit);
      res += hit;
    }
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    string s,t,u;
    cin>>s>>t>>u;
    cout<<(char)(s[0]+'A'-'a')<<(char)(t[0]+'A'-'a')<<(char)(u[0]+'A'-'a')<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int calc(int n)
{
  int s = 0;
  while (n != 0)
  {
    s += n % 10;
    n = (n - n % 10) / 10;
  }
  return s;
}
int main()
{
  int n, a, b;
  cin >> n >> a >> b;
  int ans = 0;
  for (int i = 1; i <= n; i++)
  {
    if (a <= calc(i) && calc(i) <= b)
      ans += i;
  }
  cout << ans << endl;
  return 0;
}

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

int h[13], cnt[5];
bool one = false, two = false, three = false, full = false, four = false, straight = false;

void init(){
  for(int i = 0; i < 13; i++){
    h[i] = 0;
  }
  one = false;
  two = false;
  three = false;
  full = false;
  four = false;
  straight = false;
}

void judge(){
  for(int i = 0; i < 13; i++){
    if(h[i] == 2) one = true;
  }
  
  for(int i = 0; i < 13; i++){
    if(h[i] == 3) three = true;
  }

  for(int i = 0; i < 13; i++){
    for(int j = 0; j < 13; j++){
      if(h[i] == 2 && h[j] == 2 && i != j)  two = true;
      if(h[i] == 3 && h[j] == 2 && i != j)  full = true;
    }
  }
    
  for(int i = 0; i < 13; i++){
    if(h[i] == 4) four = true;
  }
  
  for(int i = 0; i < 9; i++){
    if(h[i] != 0 && h[i+1] != 0 && h[i+2] != 0 && h[i+3] != 0 && h[i+4] != 0) straight = true;
  }
  
  if(h[0] != 0 && h[12] != 0 && h[11] != 0 && h[10] != 0 && h[9] != 0)  straight = true;
}

int main(void){
  while(scanf("%d,%d,%d,%d,%d", cnt, cnt+1, cnt+2, cnt+3, cnt+4) != EOF){
    init();
    for(int i = 0; i < 5; i++){
      h[cnt[i]-1]++;
    }
    
    for(int i = 0; i < 5; i++){
      cnt[i] = 0;
    }

    judge();
 
    if(straight){
      cout << "straight" << endl;
    }else if(four){
      cout << "four card" << endl;
    }else if(full){
      cout << "full house" << endl;
    }else if(three){
      cout << "three card" << endl;
    }else if(two){
      cout << "two pair" << endl;
    }else if(one){
      cout << "one pair" << endl;
    }else{
      cout << "null" << endl;
    }
  }
  return 0;
}

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	int c = count(all(s),'x');
	cout << (c>=8? "NO":"YES") <<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<string>
#include<cstdio>
#include<cstdlib>
#define MAX 1000000007

void path1(int a, int b, int c, int d) {
	int k,l;

	printf("D");
	k = c - a + 1;
	for (l = 0; l < k; l++) {
		printf("R");
	}
	k = d - b + 1;
	for (l = 0; l < k; l++) {
		printf("U");
	}
	printf("L");
}

void path2(int a, int b, int c, int d) {
	int k, l;

	k = d - b;
	for (l = 0; l < k; l++) {
		printf("D");
	}
	k = c - a;
	for (l = 0; l < k; l++) {
		printf("L");
	}
}

void path3(int a, int b, int c, int d) {

	int k, l;

	k = d - b;
	for (l = 0; l < k; l++) {
		printf("U");
	}
	k = c - a;
	for (l = 0; l < k; l++) {
		printf("R");
	}
}

void path4(int a, int b, int c, int d) {
	int k, l;

	printf("U");
	k = c - a + 1;
	for (l = 0; l < k; l++) {
		printf("L");
	}
	k = d - b + 1;
	for (l = 0; l < k; l++) {
		printf("D");
	}
	printf("R");
}

int main() {
	int sx, sy, tx, ty;

	scanf("%d%d%d%d", &sx, &sy, &tx, &ty);

	path1(sx, sy, tx, ty);
	path2(sx, sy, tx, ty);
	path3(sx, sy, tx, ty);
	path4(sx, sy, tx, ty);
	printf("\n");

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int R;
int main(){
	cin.tie(0);
	cin.sync_with_stdio(0);
	cin >> R;
	cout << fixed << setprecision(2) << 2*R*3.1415926 << '\n';
	return 0;
}

Measured memory_bytes: 3760
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>

using namespace std;
using ll = long long;


int main() {
	ll N, T;
	ll ans = 0;
	cin >> N >> T;
	vector<ll> t(N);
	for (ll i = 0; i < N; i++)
	{
		cin >> t[i];
	}
	for (ll i = 0; i < N - 1; i++)
	{
		ans += (t[i + 1] - t[i] > T) ? T : (t[i + 1] - t[i]);
	}
	cout << ans + T << endl;
	return 0;
}

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

int main() {
    long long a, b, c;
    cin >> a >> b >> c;

    if (4*a*b < (c-a-b)*(c-a-b)) {
        if (c-a-b > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    else cout << "No" << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program {
    internal static void Main(string[] args) {
        var N = int.Parse(ReadLine());
        var lst = new List<long>();
        lst.Add(2);
        lst.Add(1);

        for (int i = 2; i <= 86; i++) {
            lst.Add(lst[i - 1] + lst[i - 2]);
        }

        WriteLine(lst[N]);
     }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n; cin >> n;
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i];

    sort(all(a)); // 昇順
    rep(i, n) b[i] = a[i];
    reverse(all(b)); // 降順

    ll ans = 0, now = 0;
    int k = n / 2;
    if (n % 2 == 0) {
        rep(i, k-1) now += 2 * b[i];
        now += b[k-1];
        rep(i, k-1) now -= 2 * a[i];
        now -= a[k-1];
        chmax(ans, now);
    } else {
        rep(i, k-1) now += 2 * b[i];
        now += b[k-1] + b[k];
        rep(i, k) now -= 2 * a[i];
        chmax(ans, now);
        now = 0;
        rep(i, k) now += 2 * b[i];
        rep(i, k-1) now -= 2 * a[i];
        now -= a[k-1] + a[k];
        chmax(ans, now);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
/*ll modexpo(ll a,ll b)
{
     ll ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
int find(int a){
     if(par[a]==a)return a;
     return par[a]=find(par[a]);
}
void unite(int a,int b){
     a=find(a),b=find(b);if(a==b)return ;
     parent[b]=a;
}*/
 
 
 
 
 
 
 












int main(){
     ll h,w;
     cin>>h>>w;
     ll res=h*w;
     for(ll i=1;i<h;i++){
          ll t1=(h-i)/2,t2=(h-i+1)/2;
          ll ans1=min(t1,min(i,t2)),ans2=max(t1,max(t2,i));
          res=min(res,w*(ans2-ans1));
          t1=w/2,t2=(w+1)/2;
          ans1=t1*(h-i),ans2=t2*(h-i);
          ll ans3=i*w;
          res=min(res,max(ans1,max(ans2,ans3))-min(ans1,min(ans2,ans3)));
     }
     for(int i=1;i<w;i++){
          ll t1=(w-i)/2,t2=(w-i+1)/2;
          ll ans1=h*i,ans2=h*t1,ans3=h*t2;
          res=min(res,max(ans1,max(ans2,ans3))-min(ans1,min(ans2,ans3)));
          t1=h/2,t2=(h+1)/2;
          ans1=i*h,ans2=t1*(w-i),ans3=t2*(w-i);
          res=min(res,max(ans1,max(ans2,ans3))-min(ans1,min(ans2,ans3)));
     }
     cout<<res;
}


























Measured memory_bytes: 3652
from sys import stdin
import itertools

def main():

    input = stdin.readline

    N = int(input())
    L = map(int,input().split())

    ans = 0

    for i in list(itertools.combinations(sorted(L), 3)):
        if (i[0] + i[1] > i[2]) & (i[0] != i[1]) & (i[1] != i[2]) & (i[0] != i[2]):
            ans += 1

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 20532
#include <stdio.h>
int main(void){
	
	int n,x,i,j,k,cnt;
	while(1){
		cnt=0;
		scanf("%d%d",&n,&x);
		if(n==0 && x==0)break;
		for(i=1;i<=n-2;i++){
			for(j=i+1;j<=n-1;j++){
				for(k=j+1;k<=n;k++){
					if((i+j+k)==x)cnt++;
				}
			}
		}
		printf("%d\n",cnt);
	}
	
	return 0;
}


Measured memory_bytes: 1912
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int n;
    cin >> n;
    if(n == 1){
        cout << 1 << endl;
    }else if(2 <= n && n <= 3){
        cout << 2 << endl;
    }else if(4 <= n && n <= 7){
        cout << 4 << endl;
    }else if(8 <= n && n <= 15){
        cout << 8 << endl;
    }else if(16 <= n && n <= 31){
        cout << 16 << endl;
    }else if(32 <= n && n <= 63){
        cout << 32 << endl;
    }else{
        cout << 64 << endl;
    }
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, M;
	cin >> N >> M;
	vector<int> L(N), R(N);
	for (int i = 0; i < N; ++ i) cin >> L[i] >> R[i];

	vector<int> a(M+3);
	for (int i = 0; i < N; ++ i) {
		int n = 1;
		for (;;) {
			int x = (L[i]+n-1)/n;
			int y = R[i]/n;
			if (y < 2) break;
			if (x > y) {
				n = max(n+1, L[i]/y);
				continue;
			}

			int m = n;
			while (x > 2) {
				int m2 = R[i] / (x-1);
				if (m2 <= m) break;
				m = m2;
				x = (L[i] + m - 1) / m;
			}
			x = max(2, x);
			//cout << "n = " << n << endl;
			//cout << "m = " << m << endl;
			//cout << "[" << x << ", " << y << "]" << endl;
			a[x]++;
			a[y+1]--;
			
			if (x == 2) break;
			n = R[i]/x + 1;
		}
		//cout << endl;
	}

	cout << N << endl;
	int x = 0;
	for (int d = 2; d <= M; ++ d) {
		x += a[d];
		cout << x << endl;
	}
}


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

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i ,a, b) for (int i = a ; i <= b ; i++)
#define sz(a) int(a.size())
#define cuti(a) cout << a << endl;
#define cutii(a,b) cout << a << " " << b << endl;
#define cutiii(a,b,c) cout << a << " " << b << " " << c << endl;
#define vec(a) vector<int > a;

template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }

typedef long long LL;
typedef pair<int ,int > pii;
typedef pair<string ,int > psi;
typedef pair<string ,string > pss;
typedef pair<LL, LL> pLL;

const long long oo = 1e9 + 7;
const double PI = acos(-1.0);

double DEG_to_RAD(double d) { return d * PI / 180.0; }

int h,w;
int c[12][12];
int a[213][213];
int ans;

int main(){
//    freopen("test.txt","r",stdin);
    cin >> h >> w;
    for (int i =0 ;i <= 9 ; i++) {
        for (int j = 0 ; j <= 9; j++) {
            cin >> c[i][j];
        }
    }
    for (int k = 0 ; k <= 9 ; k++) {
        for(int i = 0 ; i <= 9 ; i++) {
            for (int j = 0; j <= 9 ; j++) {
                if ( c[i][j] > c[i][k] + c[k][j]) {
                    c[i][j] = c[i][k] + c[k][j];
                }
            }
        }
    }
    for (int i = 1 ; i <= h ; i++) {
        for (int j = 1 ; j<= w ; j++) {
            cin >> a[i][j];
            if ( a[i][j] >= 0 ) ans += c[a[i][j]][1] ;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

const ll INF = 100000000000000000;

int main()
{
    int n;
    cin >> n;
    ll a[100005];
    for(int i = 0; i <= n; i++) cin >> a[i];
    ll ans = 0;
    ll s = 0;
    ll b[100005];
    b[0] = 1;
    for(int i = 0; i <= n; i++){
        b[i] -= a[i];
        if(b[i] < 0){
            cout << -1 << endl;
            return 0;
        }
        b[i + 1] = min(INF, b[i] * 2);
    }
    for(int i = n; i >= 0; i--){
        s = min(b[i], s) + a[i];
        ans += s;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5200
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        
        String[] spline = line.split(" ");
        int a = Integer.parseInt(spline[0]);
        int b = Integer.parseInt(spline[1]);
        int space = a*b;
        int loop = 2*(a+b);
        System.out.println(space+" "+loop);
    }
}


Measured memory_bytes: 25992
N, A, B = map(int,input().split())

if (B-A) % 2 == 0:
    ans = (B-A) // 2
else:
    if (A-1) < (N-B):
        count = A
        a = 1
        b = B - count
        count += (b-a)//2
    else:
        count = (N-B) + 1
        a = A + count
        b = N
        count += (b-a)//2
    ans = count

print(ans)
        

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 178, task a, 2020/09/13
//ms,

/*
*/

int main(void){
  int x;
  cin >>x;
  if(x==1) cout <<0<<endl;
  else cout <<1<<endl;
  return 0;
}
/*
*/


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <climits>
#include <map>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iterator>
#include <deque>
#include <bitset>
#include <list>
#include <queue>
#include <set>
#include <stack>
#include <functional>
#include <iterator>
#include <locale>
#include <memory>
#include <stdexcept>
#include <utility>
#include <fstream>
#include <ios>
#include <iosfwd>
#include <iomanip>
#include <istream>
#include <sstream>
#include <streambuf>
#include <complex>
#include <numeric>
#include <valarray>
#include <exception>
#include <limits>
#include <new>
#include <typeinfo>
#include <bitset>
#include <queue>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

int main() {
	string a;
	cin >> a;
	if (a == "RRS")
		cout << 2;
	else if (a == "SSS")
		cout << 0;
	else if (a == "RRR")
		cout << 3;
	else if (a == "SRR")
		cout << 2;
	else
		cout << 1;
}

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
int main() {
	string s, t; cin >> s >> t;
	for(int i=2;i>=0;i--){
		if(s[2-i]!=t[i]){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,x;
    cin>>n>>x;
    ll a[n];
    for(int i=0;i<n;i++){
    	cin>>a[i];
    }
    ll ans=0;
    for(int i=1;i<n;i++){
    	if(a[i]+a[i-1]>x){
    		if(a[i-1]>x){
    			ans+=a[i];
    			a[i]=0;
    			ans+=a[i-1]-x;
    		}else{
    			ans+=(a[i-1]+a[i]-x);
    			a[i]=x-a[i-1];
    		}
    	}
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <numeric>
#include <utility>
#include <iomanip>

using namespace std;
using int64 = long long;
using TP = tuple<int, int, int>;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

int main() {
    int h, w, ch, cw, dh, dw;
    cin >> h >> w >> ch >> cw >> dh >> dw;
    ch--; cw--; dh--; dw--;
    vector<string> s(h);
    for (int i=0; i<h; i++) cin >> s[i];

    vector cnt(h, vector(w, INT_MAX));
    cnt[ch][cw] = 0;
    priority_queue<TP, vector<TP>, greater<>> que;
    que.emplace(0, ch, cw);

    vector vy = {-1, 1, 0, 0};
    vector vx = { 0, 0,-1, 1};
    while (!que.empty()) {
        auto [c, y, x] = que.top();
        que.pop();

        if (y == dh && x == dw) break;
        
        for (int i=0; i<4; i++) {
            int yy = y + vy[i];
            int xx = x + vx[i];
            if (yy<0 || h<=yy || xx<0 || w<=xx) continue;
            if (s[yy][xx] == '#') continue;
            if (cnt[yy][xx] <= c) continue;

            cnt[yy][xx] = c;
            que.emplace(c, yy, xx);
        }

        for (int i=-2; i<=2; i++) {
            for (int j=-2; j<=2; j++) {
                if (abs(i)+abs(j) <= 1) continue;
                int yy = y + i;
                int xx = x + j;
                if (yy<0 || h<=yy || xx<0 || w<=xx) continue;
                if (s[yy][xx] == '#') continue;
                if (cnt[yy][xx] <= c+1) continue;

                cnt[yy][xx] = c+1;
                que.emplace(c+1, yy, xx);
            }
        }
    }

    if (cnt[dh][dw] == INT_MAX)
        cout << -1 << endl;
    else
        cout << cnt[dh][dw] << endl;
}


Measured memory_bytes: 8684
from fractions import gcd
from functools import reduce
lcm=lambda x,y:x//gcd(x,y)*y
MOD=10**9+7

n=int(input())
A=list(map(int,input().split()))

c=sum(pow(a,MOD-2,MOD) for a in A)%MOD
l=reduce(lcm,A)%MOD

print(c*l%MOD)


Measured memory_bytes: 69880
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::*;
use std::ops::*;
use std::*;

// -----------------------------------------------
// Framework
// -----------------------------------------------

#[allow(unused)]
fn rl() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused)]
fn rw<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|word| T::from_str(word).unwrap())
        .collect()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

#[allow(unused)]
macro_rules! debug {
    ($($arg:expr),*) => {
        let entries = &[
            $((
                &stringify!($arg).to_string() as &fmt::Debug,
                &($arg) as &fmt::Debug,
            )),*
        ];
        eprintln!("{:?}", DebugMap(entries));
    };
}

#[allow(unused)]
struct DebugMap<'a>(&'a [(&'a fmt::Debug, &'a fmt::Debug)]);

impl<'a> std::fmt::Debug for DebugMap<'a> {
    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
        let mut m = fmt.debug_map();
        for &(key, value) in self.0.iter() {
            m.entry(key, value);
        }
        m.finish()
    }
}

// -----------------------------------------------
// Polyfill
// -----------------------------------------------

#[derive(PartialEq, Eq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

#[allow(unused)]
macro_rules! eprintln {
    ($($arg:expr),*) => { _eprintln(format_args!($($arg),*)) }
}

fn _eprintln(args: fmt::Arguments) {
    let err = std::io::stderr();
    let mut err = err.lock();
    err.write_fmt(args).unwrap();
    err.write(b"\n").unwrap();
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

pub fn main() {
    let S = rl();
    let A = S.chars().map(|c| (c as i32 - '0' as i32) as i64).vec();

    fn dfs(A: &[i64], i: usize, s: i64, l: i64) -> i64 {
        if i == A.len() {
            l + s
        } else {
            let plus = dfs(A, i + 1, s + l, A[i]);
            let cons = dfs(A, i + 1, s, l * 10 + A[i]);
            plus + cons
        }
    };

    let sum = dfs(&A, 1, 0, A[0]);
    println!("{}", sum);
    return;
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_ok() {
        assert_eq!(7, 1 + 2 * 3);
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <iomanip>
#include <vector>
typedef long long ll;
using namespace std;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

ll num;

ll calc_maxn(ll a)
{
    ll i = 1;
    ll count = 0;
    while (a >= i)
    {
        a = a - i;
        i++;
        count++;
    }
    return count;
}

template <typename T>
void PrimeFactors(T n, std::map<T, T> &out)
{
    while (n % 2 == 0)
    {
        ++out[2];
        n = n / 2;
    }

    for (T i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            ++out[i];
            n = n / i;
        }
    }

    if (n > 2)
        ++out[n];
}

void solve()
{
    ll ans = 0;
    map<ll, ll> m;
    PrimeFactors(num, m);

    for (const auto &a : m)
    {
        //cout << a.first << ' ' << a.second << endl;
        ans += calc_maxn(a.second);
    }
    cout << ans;
}

int main()
{
    cin >> num;

    solve();
}


Measured memory_bytes: 3724