akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long A, long long B, long long K){
    rep(_, K){
        if(!(_ & 1)){
            if(A&1){
                A--;
            }
            B+= A/2;
            A/=2;
        }
        else{
            if(B & 1){B--;
            }
            A += B/2;
            B/=2;

        }
    }
    cout << A << " " << B << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long K;
    scanf("%lld",&K);
    solve(A, B, K);
    return 0;
}


Measured memory_bytes: 256
array = gets.chomp.split('')

flag = "Yes\n"

array.each_with_index do |s, i|
  if (i+1) % 2 == 1
    if !'RUD'.include?(s)
      flag =  "No\n"
    end
  elsif (i+1) % 2 == 0
    if !'LUD'.include?(s)
      flag =  "No\n"
    end
  end
end

print flag


Measured memory_bytes: 1788
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;

#define ll long long
#define pal pair<ll,ll>
#define pad pair<double,double>
#define PB push_back
#define MP make_pair
#define F first
#define S second

const ll MOD = 1e9+7;
const ll INF = 1e18;
const double EPS = 1e-8;

long long pow(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


int main(){
	ll x,n;
	cin >> x >> n;
	if(n==0){
		cout << x << endl;
		return 0;
	}
	vector<bool> p(101,false);
	for(ll i=0;i<n;i++){
		ll tmp;
		cin >> tmp;
		p[tmp]=true;
	}
	for(ll i=0;i<100;i++){
		if(!p[x-i]){
			cout << x-i << endl;
			return 0;
		}
		if(!p[x+i]){
			cout << x+i << endl;
			return 0;
		}
		
	}
}

Measured memory_bytes: 3624
#import 
#=input()
n=int(input())
#=map(int,input().split())
a=list(map(int,input().split()))
#=[list(map(int,input().split())) for _ in range()]

if 0 in set(a):
    ans = 0
else:
    ans = 1
    for i in range(n):
        ans *= a[i]
        if ans > 10 ** 18:
            ans = -1
            break
print(ans)

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

int main()
{
  int A,B,C,D,E ;
  cin>>A>>B>>C>>D>>E ;
  
  int T[5]={A,B,C,D,E} ;
  int sum=0 ;
  int Max=(10-T[0]%10)%10 ;
  for(int i=0;i<5;i++){
    if(T[i]%10!=0) sum+=10-T[i]%10 ;
    if(10-T[i]%10>Max&&T[i]%10!=0)Max=10-T[i]%10 ;
  }

  cout<<A+B+C+D+E+sum-Max<<endl ;
  
  return 0 ;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
  if i * 500 == x:
    ans += 1
    break
  for j in range(b+1):
    if i * 500 + j * 100 == x:
      ans += 1
      break
    for k in range(c+1):
      if i * 500 + j * 100 + k * 50 == x:
        ans += 1
        break
print(ans)

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

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int a, b;

	cin >> a >> b;
	if (b/2 - a >= 0 && 2*a - b/2 >= 0 && b % 2 ==0)
		cout <<"Yes\n";
	else
		cout << "No\n";
	// a = m + n ; b/2 = m + 2n
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <math.h>
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> V(N), C(N);

	int ans = 0;
	for (int i = 0; i < N; ++i)
	{
		cin >> V[i];
	}
	for (int i = 0; i < N; ++i)
	{
		cin >> C[i];
	}
	for (int i = 0; i < N; ++i)
	{
		if (V[i] > C[i])
			ans += V[i] - C[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll h,w;
    cin>>h>>w;
    ll sum=0;
    if(h>=2 && w>=2) {
        sum+=(h-2)*(w-2);
        
    }else if((w==1 || h==1) && h!=w){
        sum+=max(h,w)-2;
    }else{
        cout<<1<<endl;
        return 0;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
n,a,b=list(map(int,input().split()))
x=list(map(int,input().split()))

cost=0
tp=n-1
for i in range(n-1):
    walk=(x[i+1]-x[i])*a
    if walk<b:
        cost+=walk
        tp-=1

cost+=tp*b
print(cost)

Measured memory_bytes: 14252
N = int(input())
A = list(map(int, input().split()))

check = 0
m = int(1e10)
ans = 0

for i in A:
    ans += abs(i)
    m = min(m, abs(i))
    if i < 0:
        check += 1

if check % 2 == 1:
    ans -= m * 2

print(ans)

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

int main(){
  int N; cin >> N;
  vector<int> A(N);
  for (int i=0; i<N; i++){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  int ans=0;
  for (int i=N-1; i>=0; i--){
    if ((N-1)%2 == (i)%2) ans += A[i];
    else ans -= A[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

type IntArray []int
func (p IntArray) Len() int           {return len(p);}
func (p IntArray) Less(i, j int) bool {return p[i] < p[j];}
func (p IntArray) Swap(i, j int)      {p[i], p[j] = p[j], p[i];}

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Scan()
                tmp := scanner.Text()
                arr := strings.Split(tmp, " ")
//              N, _ := strconv.Atoi(arr[0])
                K, _ := strconv.Atoi(arr[1])
    scanner.Scan()
                tmp2 := scanner.Text()
                arr2 := strings.Split(tmp2, " ")
                s := []int{}
                i := 0
                for value := range arr2 {
                        i, _ = strconv.Atoi(arr2[value])
                  s = append(s, i)
          }
                a := IntArray(s);
                sort.Sort(a);
//      fmt.Println(a)
                sum := 0
    for  ii := 0; ii < K; ii++  {
                        sum = sum + a[ii]
                }
        fmt.Println(sum)
}

Measured memory_bytes: 1828
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define ALL(x) begin(x), end(x)
using namespace std;

int solve(int n, int m, vector<int> const & p, vector<vector<int> > const & g) {
    vector<bool> used(n);
    vector<int> xs, pxs;
    function<void (int)> go = [&](int i) {
        used[i] = true;
        xs.push_back(i);
        pxs.push_back(p[i]);
        for (int j : g[i]) if (not used[j]) {
            go(j);
        }
    };
    int ans = 0;
    REP (i, n) if (not used[i]) {
        xs.clear();
        pxs.clear();
        go(i);
        sort(ALL(xs));
        sort(ALL(pxs));
        vector<int> ys;
        set_intersection(ALL(xs), ALL(pxs), back_inserter(ys));
        ans += ys.size();
    }
    return ans;
}

int main() {
    int n, m; cin >> n >> m;
    vector<int> p(n);
    REP (i, n) {
        cin >> p[i];
        -- p[i];
    }
    vector<vector<int> > g(n);
    REP (j, m) {
        int x, y; cin >> x >> y;
        -- x; -- y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    cout << solve(n, m, p, g) << endl;
    return 0;
}


Measured memory_bytes: 10660
#include <iostream>
#include <vector>
#define ll long long
#define ld long double
#define pb push_back
#define mk make_pair
using namespace std;

int main(){
    ll n, x, c = 1;
    cin >> n >> x;
    ll ar[n], li[n];
    for(ll i = 0;i<n;i++){
        cin >> li[i];
    }
    ar[0] = 0;
    ll i = 1;
    while(true){
        ar[i] = ar[i-1] + li[i-1];
        if(ar[i] > x)
            break;
        else{
            if(i == n){
                c++;
                break;
            }
            else if(i < n)
                c++;
        }
        i++;
    }
    cout << c;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<queue>
#include<bitset>

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;

int main() {
	int n, m, i, j, k, s, ans;
	vi a;

	cin >> n >> m;
	a.resize(m);
	ans = 0;
	rep(i, n) {
		cin >> k;
		rep(j, k) {
			cin >> s;
			a[s - 1]++;
			if (a[s - 1] == n) {
				ans++;
			}
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T binarysearch(vector<T> A, T key) {
	ll left = 0;ll right = 4;ll mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)//階乗
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

template<typename T>
T keta(T a) {
	ll kazu = 1;
	while (1) {
		if (a / 10 != 0) { a /= 10;kazu++; }
		else break;
	}
	return kazu;
}//桁数


template<typename T>
T nCr(ll n, T r) {
	ll ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*///map < string, ll> s;

/*i++ずつずらす
a[0] a[1] a[2]//a[1] a[2] a[3]
a[0] a[2] a[4]//a[1] a[3] a[5]
/*if (N % 2 != 0)a = N / 2;
else a = N / 2 - 1;
for (int i = 1;i <= a;i++) {
	for (int j = 0;j < N - (i * 2);j++) {
		if (S[j] != S[j + i] && S[j + i * 2] != S[j] && S[j + i] != S[j + i * 2]) sum--;
		if (sum == 0)break;
	}
}*/

//mapの使い方
/*map<int, int> mp;
for (int i = 0; i < N; i++)
	mp[a[i]]++;

int ans = 0;
for (auto p : mp) {
	int x = p.first;
	int n = p.second;
	if (n < x) ans += n;
	else ans += n - x;
}*/

int main() {
	string S;cin >> S;
	ll s;
	vector<ll> ans(26);
	for (int i = 0;i < 26;i++)ans[i] = 0;
	ll ok=100;
	for (int i = 0;i < S.size();i++) {
		 s = S[i] - 'a';
		 ans[s]++;
	}
	for (int i = 0;i < 26;i++) {
		if (ans[i] == 0) {
			ok = i;
			break;
		}
	}
	char an = 'a' + ok;
	if (ok < 100) cout << an << endl;
	else cout << "None" << endl;
}

Measured memory_bytes: 512
#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, K, C = getlist()
	S = list(input())
	D1 = defaultdict(int)
	D2 = defaultdict(int)
	var = - float("inf")
	cnt = 0
	for i in range(N):
		if S[i] == "o":
			if i - var >= C + 1:
				cnt += 1
				var = i
				D1[i] += 1

	if cnt >= K + 1:
		return

	#詰める
	var = float("inf")
	cnt = 0
	for i in range(N):
		if S[N - 1 - i] == "o":
			if var - (N - 1 - i) >= C + 1:
				cnt += 1
				var = N - 1 - i
				D2[N - 1 - i] += 1

	# print(D1)
	# print(D2)

	ans = []
	for i in D1:
		if D2[i] == 1:
			ans.append(i)

	ans = sorted(ans)
	for i in ans:
		print(i + 1)

if __name__ == '__main__':
	main()

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    ll A, B;
    cin >> A >> B;
    if(A == B) {
        printf("Draw\n");
        return 0;
    }
    if(A == 1) {
        printf("Alice\n");
        return 0;
    }
    if(B == 1) {
        printf("Bob\n");
        return 0;
    }
    if(A > B) {
        printf("Alice\n");
        return 0;
    }
    if(B > A) {
        printf("Bob\n");
        return 0;
    }
    assert(false);
    return 0;
}


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

using namespace std;
using lli = long long int;
using llu = long long unsigned int;

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

llu lcm(llu a, llu b) {
    return a/gcd(a, b)*b;
}

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

    llu lcm_v = 1;
    for(int i = 0; i < n; i++) {
        llu t;
        cin >> t;
        if (lcm_v == 1) {
            lcm_v = t;
        } else {
            lcm_v = lcm(lcm_v,t);
        }
    }
    cout << lcm_v << endl;
}


Measured memory_bytes: 256
{-# LANGUAGE RankNTypes, ViewPatterns, OverloadedStrings #-}
    
import Control.Monad.State
import Control.Monad.ST
import Data.Array.ST
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = inputs >>= putStrLn . uncurry solve
    where
        inputs = (,) <$> readLine <*> B.getLine 

solve :: [Int] -> B.ByteString -> String
solve [n, a, b, c, d] ss 
    | check0 a (B.drop a ss) = "No"
    | c < d = "Yes"
    | check1 (b - 2) (B.drop (b - 2) ss) = "Yes"
    | otherwise = "No"
    where
        check0 i s@(B.uncons -> Just (_, t))
            | i > max c d - 1 = False
            | "##" `B.isPrefixOf` s = True
            | otherwise = check0 (i + 1) t
        check0 _ _ = False

        check1 i s@(B.uncons -> Just (_, t))
            | i > d - 2 = False
            | "..." `B.isPrefixOf` s = True
            | otherwise = check1 (i + 1) t
        check1 _ _ = False


readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

type Table s a b = STArray s a (Maybe b)
type Memo s a b = a -> StateT (Table s a b) (ST s) b

evalMemo :: (Ix a) => (forall s. Memo s a b -> Memo s a b) -> a -> Table s a b -> ST s b
evalMemo f k = evalStateT (memoizeFix f k)

runMemo :: (Ix a) => (forall s. Memo s a b -> Memo s a b) -> a -> Table s a b -> ST s (b, Table s a b)
runMemo f k = runStateT (memoizeFix f k)

memoizeFix :: (Ix a) => (forall s. Memo s a b -> Memo s a b) -> forall s. Memo s a b
memoizeFix f k = get >>= (\arr -> lift (readArray arr k) >>= maybe (f (memoizeFix f) k >>= ((<$) <*> (lift . writeArray arr k . Just))) return)

Measured memory_bytes: 892
#include <stdio.h>
#include <string.h>

int main(){
 char s[1001];
 int c;
 scanf("%s", s);
 scanf("%d", &c);
 
 for(int i = 0; i < strlen(s); i += c){
  printf("%c", s[i]);
 }
 return 0;
}

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

int main(){
    double n,k;
    cin >> n >> k;

    double ans=0;

    for(int i=1; i<=n; i++){
        int tmp=i;
        double counti = 1.0/n;

        while(tmp < k){
            tmp *= 2;
            counti /= 2;
        }

        ans += counti;

    }

    cout << fixed << setprecision(15);
    cout << ans << endl;
}


Measured memory_bytes: 3720
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        x:i64,
        k:i64,
        d:i64,
    }
    let x = x.abs() as i64;

    // d*i >= k naruka?
    // i >= k/d
    // k/d
    if k < x / d {
        println!("{}", x - d * k);
        return;
    }
    let mut ans = INF;
    // d*k >= x のとき
    // 解の候補　d*k-x, x-d*k
    let c = x / d;
    if c % 2 == k % 2 {
        ans = x - c * d;
    } else {
        ans = (x - (c + 1) * d).abs();
    }
    println!("{}", ans);
}

const INF: i64 = 1 << 60;


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;

    i64 P,Q,R;
    cin >> P >> Q >> R;
    cout << min({P+Q,Q+R,P+R}) << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define TYPE int
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}

int main(void){
	int q=in(),h=in(),s=in(),d=in(),n=in();
	if(2*q<h)h=2*q;
	if(2*h<s)s=2*h;
	if(4*q<s)s=4*q;
	if(2*s<d)d=2*s;
	if(4*h<d)d=4*h;
	if(8*q<d)d=8*q;
	llprint((long long)d*(n/2)+s*(n%2));	
	return 0;
}

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

bool find(int wanted, std::vector<int> q) {
    for(int i = 0;i<q.size();i++) {
        if (q[i] == wanted) {
            return true;
        }
    }
    return false;
}

void solve(int X, int N, std::vector<int> p){
    if (N == 0) {
        cout << X << endl;
        return;
    }

    sort(p.begin(), p.end());
    std::vector<int> q;
    for(int i = -100;i<=200;i++) {
       if(!find(i, p)) {
           q.push_back(i);
       }
    }

    int min_diff = 1000;
    int close = 10000;
    for (int i = 0;i<q.size();i++) {
        int diff = std::abs(q[i]-X);
        if (diff < min_diff) {
            min_diff = diff;
            close = q[i];
        }
        if (diff == min_diff && close > q[i]) {
            close = q[i];
        }
    }

    cout << close << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    int X;
    scanf("%d",&X);
    int N;
    scanf("%d",&N);
    std::vector<int> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%d",&p[i]);
    }
    solve(X, N, std::move(p));
    return 0;
}


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

int main(){
    ll D;
    cin >> D;
    vector<ll> c(26), t(D), last(26, -1);
    vector< vector<ll> > s(365, vector<ll> (26));
    rep(i, 0, 26) cin >> c[i];
    rep(i, 0, D){
        rep(j, 0, 26) cin >> s[i][j];
    }
    srand((unsigned int)time(NULL));
    rep(i, 0, D){
        t[i] = (ll) (rand() % 26);
    }
    ll M = 1e6;
    vector<ll> rec(26, 0);
    /*
    vector<ll> d(M), q(M), rec(26, 0);
    rep(i, 0, M){
        d[i] = (ll) (rand() % D);
        q[i] = (ll) (rand() % 26);
    }
    */
    ll res = 0;
    rep(d, 0, D){
        res += s[d][t[d]];
        last[t[d]] = d;
        rep(j, 0, 26) {
            res -= c[j] * (d - last[j]);
            rec[j] += c[j] * (d - last[j]);
        }
    }
    vector<ll> median(D);
    rep(i, 0, D){
        auto cp = s[i];
        sort(cp.begin(), cp.end());
        median[i] = cp[20];
    }
    // t[d[m]] := 0 - 25
    rep(m, 0, M){
        ll prev_res = res;
        ll d = (ll) (rand() % D);
        // ll d = m % D;
        ll q = (ll) (rand() % 26);
        // ll q = m % 26;
        if(s[d][q] < median[min(23LL, 26 * m / M)]) continue;
        res -= s[d][t[d]];
        res += s[d][q];
        res += rec[t[d]];
        res += rec[q];
        ll tdrec = 0, qrec = 0;
        ll lst = -1;
        rep(i, 0, D){
            if(i != d && t[i] == t[d]){
                lst = i;
            }
            res -= c[t[d]] * (i - lst);
            // rec[t[d[m]]] +=  c[t[d[m]]] * (i - lst);
            tdrec +=  c[t[d]] * (i - lst);
        }
        lst = -1;
        rep(i, 0, D){
            if(i == d || t[i] == q){
                lst = i;
            }
            res -= c[q] * (i - lst);
            // rec[q[m]] += c[q[m]] * (i - lst);
            qrec += c[q] * (i - lst);
        }
        if(res > prev_res){
            rec[t[d]] = tdrec;
            rec[q] = qrec;
            t[d] = q;
        }else{
            res = prev_res;
        }
        // cout << res << endl;
    }
    rep(i, 0, D) cout << t[i]+1 << endl;
    return 0;
}

Measured memory_bytes: 3736
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <utility>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  set<string> S;
  string w; cin >> w;
  char e = w[w.length()-1];
  S.insert(w);
  for (int i = 1; i < N; i++) {
    cin >> w;
    if (S.count(w) || e != w[0]) {
      cout << "No" << endl;
      return 0;
    }
    S.insert(w);
    e = w[w.length()-1];
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
N,x=map(int,input().split())
a=[int(x)for x in input().split()]
count=0
for i in range(N-1):
    if a[i]+a[i+1]<=x:
        continue
    else:
        if a[i]<=x:
            d=a[i+1]-(x-a[i])
            a[i+1]-=d
            count+=d
        else:
            d=a[i+1]+a[i]-x
            a[i+1]=0
            count+=d
print(count)

Measured memory_bytes: 14252
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.14159265358979323846
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}

ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


string Toupper(string s){
  string ans="";
  rep(i,s.size()){
    if('a'<=s[i] && s[i]<='z') ans+=(char)s[i]-32;
    else ans+=s[i];
  }
  return ans;
}
string Tolower(string s){
  string ans="";
  rep(i,s.size()){
    if('A'<=s[i] && s[i]<='Z') ans+=(char)s[i]+32;
    else ans+=s[i];
  }
  return ans;
}


const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*bool cmp(pint a, pint b) { return a.second < b.second; }*/

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,k;
  cin>>n>>k;
  if(n>=10) cout<<k<<endl;
  else cout<<k+(100*(10-n))<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  char a[10];
  int i,j=0,count=0,max=0;
  scanf("%s",a);
  do{
for(i=j;i<=9;i++){
  j++;
if(a[i]=='A'||a[i]=='T'||a[i]=='G'||a[i]=='C')
  count++;
 else {
    if(count!=0){
      count=0;}
      break;} 
     if(max<count)
    max=count;
  }}while(i<=9);
  printf("%d",max);
  return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var N int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)

	var str string
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%s", &str)
	chars := strings.Split(str, "")

	ans := 0
	for i := 0; i < N; i++ {
		left := make(map[string]struct{})
		for j := 0; j < i; j++ {
			left[chars[j]] = struct{}{}
		}
		right := make(map[string]struct{})
		for j := i; j < N; j++ {
			right[chars[j]] = struct{}{}
		}
		cnt := 0
		for key, _ := range left {
			if _, e := right[key]; e {
				cnt++
			}
		}
		ans = max(ans, cnt)
	}
	fmt.Println(ans)
}

func max(ns ...int) int {
	ret := math.MinInt64
	for _, n := range ns {
		if n > ret {
			ret = n
		}
	}
	return ret
}


Measured memory_bytes: 768
import math

def inputToIntList():
	return list(map(int, input().split()))


x = inputToIntList()
count = x[0]
d0 = x[1]
result = []

for _ in range(count):
    point = inputToIntList()
    d1 = math.sqrt(point[0]**2 + point[1]**2)
    if d1 <= d0:
        result.append(d1)
        
print(len(result))

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

public class Main {

	public static void solve (int[] []map, int y, int x, int depth) {
		int[] moveX = {0,0,0,0,0,0,-1,-2,-3,1,2,3};
		int[] moveY = {-1,-2,-3,1,2,3,0,0,0,0,0,0};

		map[y][x] = 0;
		for (int i = 0; i < moveX.length; i++) {
			int nx = x + moveX[i];
			int ny = y + moveY[i];
			if (nx < 0 || nx >= map.length ||
					ny < 0 || ny >= map[0].length || map[ny][nx] == 0) continue;
			map[ny][nx] = 0;
			solve(map, ny, nx, depth + 1);
		}

		if (depth == 0) {
			for (int i = 0; i < map.length; i++) {
				for (int j = 0; j < map[i].length; j++)
					System.out.print(map[i][j]);
				System.out.println();
			}
		}

	}

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

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

		int n = Integer.parseInt(br.readLine());
		br.readLine();

		for (int i = 0; i < n; i++) {
			int[][] map = new int[8][8];
			for (int j = 0; j < map.length; j++) {
				char[] c = br.readLine().toCharArray();
				for (int k = 0; k < c.length; k++)
					map[j][k] = c[k] - '0';
			}
			int firstBombX = Integer.parseInt(br.readLine()) - 1;
			int firstBombY = Integer.parseInt(br.readLine()) - 1;
			System.out.println("Data " + (i + 1) + ":");
			solve(map, firstBombY, firstBombX, 0);
			if (i != n - 1) br.readLine();
		}

	}

}

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

using namespace std;

int main() {
	string s;
	cin >> s;
	if(s == "SUN") {
		cout << "7\n";
	}
	if(s == "MON") {
		cout << "6\n";
	}
	if(s == "TUE") {
		cout << "5\n";
	}
	if(s == "WED") {
		cout << "4\n";
	}
	if(s == "THU") {
		cout << "3\n";
	}
	if(s == "FRI") {
		cout << "2\n";
	}
	if(s == "SAT") {
		cout << "1\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<limits>
#include<algorithm>
#include<numeric>
#include<utility>

int main(){
    int A, P;

    std::cin >> A >> P;

    std::cout << (A*3+P)/2 <<  std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll n;cin>>n;
  vector<ll> a(n);
  rep(i,n){
    cin>>a[i];
  }
  sort(all(a),greater<ll>());

  if(n==2){
    cout<<a[0]<<" "<<a[1]<<endl;
  }else{
    ll left = 1,right=n-1,mid;
    while (right!=left+1) {
        mid =(right+left)/2;
        if(a[mid]>=a[0]/2){
          left=mid;
        }else right=mid;
    }
    double x=double(a[0])/2;
    cout<<a[0]<<" "<<((abs(x-a[left])<abs(x-a[right]))?a[left]:a[right])<<endl;
  }
  return 0;
}

Measured memory_bytes: 1024
"""
author : halo2halo
date : 29, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A, B = map(int, readline().split())

print('Possible' if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0 else 'Impossible')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 998244353;

int main() {
    Int r;
    cin >> r;
    dump(3 * r * r);
    return 0;
}

Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<cctype>
using namespace std;
int main(){
    string a;
    string b;
    string f;
    string g;
    int c=0,d,e;
    cin>>a;
    d=a.size();
    while(true){
        b="";
        cin>>f;
        e=f.size();
        if(f=="END_OF_TEXT"){
            cout<<c<<endl;
            break;
        }
        for(int i=0;i<e;i++){
            b += tolower(f[i]);
        }
        if(b==a){
            c++;
        }
    }
    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long


#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

const int N=1e5+5;
const int mod=1e9+7;
int32_t main() {
string s;
cin>>s;
vector<int> a,z;
FOR(i,0,s.size()-1){
    if(s[i]=='Z')z.push_back(i);
    else if(s[i]=='A')a.push_back(i);
}
sort(a.begin(),a.end());
sort(z.begin(),z.end());
cout<<z[z.size()-1]-a[0]+1;
}

Measured memory_bytes: 2168
#include<iostream>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;

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

  cout << min(a,b)+min(c,d) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 1001

ll nCm[NUM][NUM];

int main(){

	ll N,K;
	scanf("%lld %lld",&N,&K);

	if(N > K){
		printf("0\n");
		return 0;
	}

	nCm[0][0] = 1;
	for(int n = 1; n <= K; n++){
		for(int m = 0; m <= N; m++){

			if(n == 0){

				nCm[n][m] = 1;

			}else{

				nCm[n][m] = nCm[n-1][m]+nCm[n-1][m-1];

			}
			nCm[n][m] %= MOD;
		}
	}

	printf("%lld\n",nCm[K][N]);

	return 0;
}




Measured memory_bytes: 11032
import sys

input = sys.stdin.readline

def main():
    ans = 0
    mod = (10**9)+7
    n = int(input())
    a = list(map(int, input().split()))
    suma = sum(a)
    for i in range(n-1):
        suma -= a[i]
        ans += a[i]*suma
    print(ans%mod)

if __name__ == '__main__':
    main()

Measured memory_bytes: 31344
def main():
  N = int(input())
  A = list(map(int, input().split()))
  MOD = 10 ** 9 + 7
  ones = [sum(1 for a in A if a&(1<<i)) for i in range(60)]
  res = 0
  for i in range(60):
    res += ones[i] * (N - ones[i]) * ((2 ** i) % MOD)
    res %= MOD
  print(res)
if __name__ == "__main__":
    main()

Measured memory_bytes: 122808
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define ill long long
#define fcout cout << fixed << setprecision(10)
using namespace std;

int main() {
  int x, n;
  cin >> x >> n;
  vector<int> p(n);
  rep(i, 0, n) cin >> p[i];
  sort(p.begin(), p.end());
  int mn = 102, ki = 102;
  rep(i, 0, 102) {
    int f = 0;
    rep(j, 0, n) {
      if(p[j] == i) {
        f = 1;
        break;
      }
    }
    if(f == 0 && mn > abs(x-i)) {
      mn = abs(x-i);
      ki = i;
    }
  }
  cout << ki << "\n";
}

Measured memory_bytes: 3604
import Control.Monad
import Data.Array
import Data.List

patterns :: Int -> Int -> [[Int]]
patterns n m = do
  c <- [1..m]
  f [c] n
  where 
    f xs 1 = [xs]
    f t@(x:xs) n = do 
      p <- [1..x] 
      f (p:t) (n - 1)

score :: Array Int Int -> [(Int, Int, Int, Int)] -> Int
score xs [] = 0
score xs ((a,b,c,d):qs) = if (xs ! b - xs ! a == c) then d + score xs qs
                                                    else score xs qs

search :: [[Int]] -> [(Int,Int,Int,Int)] -> Int -> Int
search xss qs n = foldl (\x y -> let s = score (listArray (1, n) y) qs in if s > x then s else x ) 0 xss

main = do 
  (n:m:q:_) <- (fmap read . words) <$> getLine :: IO [Int]
  qs <- replicateM q $ do 
        (a:b:c:d:_) <- (fmap read . words) <$> getLine
        return (a,b,c,d) :: IO (Int, Int, Int, Int)
  print $ search (patterns n m) qs n


Measured memory_bytes: 4892
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    int x, y;
    cin >> x >> y;
    rep(i, 1000){
        rep(j, 1000){
            if(2 * i + 4 * j == y && i + j == x){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

const int MAX = 1000100;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    COMinit();
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    int X, Y; cin >> X >> Y;
    if((2*X-Y)%3 == 0 && (2*Y-X)%3 == 0){
        int a = (2*X-Y)/3;
        int b = (2*Y-X)/3;
        cout << COM(a+b, a) << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 23680
#include <iostream>
#include <algorithm>

using namespace std;

int v[101], n, x, i;

int Bsearch (int k)
{
  int max = n, min = 0, middle;
  
  while(min <= max)
  {
    middle = (max + min)/2;
    
    if(v[middle] == k)
    {
      return 0;
    }
    else if(v[middle] > k)
    {
      max = middle - 1;
    }
    else
    {
      min = middle + 1;
    }    
  }
  
  return 1;
}

int main ()
{
  cin >> x >> n;
  if(n == 0)
  {
    cout << x << endl;
  }
  else
  {
  for(i = 0; i < n; i++)
    {
      cin >> v[i];
    }

    sort(v, v+n);

    for(i = 0; i <= x; i++)
    {
      if(Bsearch(x-i))
      {
        cout << x-i << endl;
        break;
      }
      else if(Bsearch(x+i))
      {
        cout << x+i << endl;
        break;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 3628
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N, K := ReadInt(), ReadInt()
	A := ReadInts(N)
	insideInversion := 0
	outsideInversion := 0
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			if i == j {
				continue
			}
			if A[i] > A[j] {
				outsideInversion++
				if i < j {
					insideInversion++
				}
			}
		}
	}
	ans := ModAdd(
		ModMul(insideInversion, K),
		ModMul(outsideInversion, K*(K-1)/2),
	)
	fmt.Println(ans)
}

const Mod = int(1e9) + 7

func ModAdd(a, b int) int  { return ((Mod + a%Mod) + (Mod + b%Mod)) % Mod }
func ModMul(a, b int) int  { return (Mod + a%Mod) * (Mod + b%Mod) % Mod }
func ModInverse(n int) int { return ModPow(n, Mod-2) }
func ModDiv(a, b int) int  { return a * ModInverse(b) }
func ModPow(a, b int) int {
	x := 1
	for b > 0 {
		if b&1 == 1 {
			x = x * a % Mod
		}
		a = a * a % Mod
		b >>= 1
	}
	return x
}
func ModFactorial(n int) int      { return fac[n] }
func ModPermutation(n, r int) int { return fac[n] * finv[n-r] % Mod }
func ModCombination(n, k int) int { return fac[n] * (finv[k] * finv[n-k] % Mod) % Mod }

var fac, finv, inv []int

func init() {
	const MAX = 5 * 1e5
	fac, finv, inv = make([]int, MAX+1), make([]int, MAX+1), make([]int, MAX+1)
	fac[0], fac[1], finv[0], finv[1], inv[1] = 1, 1, 1, 1, 1
	for i := 2; i <= MAX; i++ {
		fac[i] = fac[i-1] * i % Mod
		inv[i] = Mod - inv[Mod%i]*(Mod/i)%Mod
		finv[i] = finv[i-1] * inv[i] % Mod
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 14044
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i < (n); ++i)  //0スタート
#define rep1(i,n) for (int i = 1; i < (n); ++i)  //1スタート
#define REP(i,a,b) for (int i = a; i < (b); ++i)  //aからbまで
#define mREP(i,a,b) for (int i = a; i > (b); --i)  //aからbまで
#define print(x) cout<<x<<endl  //xを改行付きで出力
#define scan(x) cin>>x //xを入力
const int INF = 1e9 + 7;  //最大値兼MOD
//  cin.tie(0);
//  ios::sync_with_stdio(false);
typedef long long ll;
using namespace std;
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(){
  ll a,b;
  cin>>a>>b;
  ll ans = 0;
  while(a <= b){
    a *= 2;
    ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)x.size()

using namespace std;

int a[200001];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int k, n;
    cin >> k >> n;
    int mx = 0;
    int ans = 0;
    cin >> a[0];
    for(int i = 1; i < n; i++) {
        cin >> a[i];
        ans += a[i] - a[i-1];
        mx = max(mx, a[i] - a[i-1]);
    }
    ans += k - a[n-1] + a[0];
    mx = max(mx, k - a[n-1] + a[0]);
    cout << ans - mx;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    ll s1 = 0, s2 = 0;
    vector<ll> w(n);
    rep(i, n){
        cin >> w[i];
        s2 += w[i];
    }
    ll ans = abs(s1 - s2);
    rep(i, n){
        s1 += w[i];
        s2 -= w[i];
        ll den = abs(s1 - s2);
        chmin(ans, den);
    }
    cout << ans;
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream> 
#include <string> 
  
using namespace std; 
  
int main (void) { 
  int n, a[100], b[100], sabun, temp; 
  string mes; 
  char ch; 
  
  while(1) { 
    cin >> n; 
    if(n == 0) break; 
  
    cin >> mes; 
  
    for(int i = 0; i < n; i++) { 
      cin >> a[i] >> b[i]; 
      a[i]--; b[i]--; 
    } 
  
    // decode 
    for(int i = n-1; i >= 0; i--) { 
      // susumeru 
      sabun = (b[i] - a[i])%26; 
  
      if(mes[a[i]] + sabun > 'z') { 
    mes[a[i]] = 'a' + (mes[a[i]] + sabun - 1 - 'z'); 
      } else { 
    mes[a[i]] += sabun; 
      } 
  
      if(mes[b[i]] + sabun > 'z') { 
    mes[b[i]] = 'a' + (mes[b[i]] + sabun - 1 - 'z'); 
      } else { 
    mes[b[i]] += sabun; 
      } 
  
      // change 
      ch = mes[a[i]]; 
      mes[a[i]] = mes[b[i]]; 
      mes[b[i]] = ch; 
    } 
  
    cout << mes << endl; 
  } 
  return 0; 
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=int(1e9+7);

int main() {
	ll n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	
	ll suffix[n+2];
	memset(suffix,0,sizeof(suffix));
	for(int i=n-1;i>=0;i--)
	suffix[i]=((suffix[i+1]%mod)+(a[i]%mod))%mod;
	
	ll sum=0;
    for(int i=0;i<n-1;i++)
    {
        sum=(((a[i]%mod)*(suffix[i+1]%mod))%mod + (sum%mod))%mod;
    }
	
	cout<<sum;
	return 0;
}


Measured memory_bytes: 5856