akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define YES "Yes"
#define NO "No"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
template<class T> inline bool chmax(int a, int b, T c, T d) { return c > d ? a : b; }
template<class T> inline bool chmin(int a, int b, T c, T d) { return c > d ? a : b; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<ut, VI, greater<LL> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 3e5 + 1000;
const int SIZE2 = 2010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
const LL inf = 1000000000;
typedef pair<ld, ut> pld;
ut N, M, K, L, Q, D, H, W, R;
VI edges[SIZE];
LL vals[SIZE], answer = zero;
LL maps[SIZE2][SIZE2];
LL A[SIZE];
LL solve() {
	LL ans = 0, h, w;
	cin >> H >> W >> h >> w;
	REP(i, H) REP(j, W) {
		if (i%h == h - 1 and j%w == w-1) {
			maps[i][j] = -inf;
		}
		else if (i%h == 0 and j%w == 0) {
			maps[i][j]=inf-1;
		}
		ans += maps[i][j];
	}
	if (ans <= 0) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	REP(i, H) {
		REP(j, W) {
			if (j) cout << " ";
			cout << maps[i][j];
		}
		cout << endl;
	}
}




//!!!!!!!!!!!!!!!!!!!実装を詰める!!!!!!!!!!!!!!!!!!!!!!!!!
signed main() {

	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(0);
	solve();


	//cin >> N;
	return 0;

}

Measured memory_bytes: 19712
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int H,W; cin >> H >> W;
    if(H==1 || W==1) cout << 1 << endl;
    else {
        cout << (H*W+1)/2 << endl;
    }
}

Measured memory_bytes: 256
n=int(input())
s=input()
W_cnt=[0]
E_cnt=[0]

for ss in s:
  w=W_cnt[-1]
  if ss=="W":
    w+=1
  W_cnt.append(w)

for ss in reversed(s):
  e=E_cnt[-1]
  if ss=="E":
    e+=1
  E_cnt.append(e)
E_cnt=E_cnt[::-1]

minc=float("inf")
for i in range(n):
  c=(W_cnt[i] + E_cnt[i+1])
  minc=min(minc,c)
print(minc)


Measured memory_bytes: 26048
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
int main() {
    int n;cin >> n;
    rep(i, n){
        int a;cin >> a;
        if(a%2){
            cout << "first" << endl;
            return 0;
        }
    }
    cout << "second" << endl;
    return 0;
}

Measured memory_bytes: 3592
n = int(input())
c = [input() for i in range(n)]
MOD = 10 ** 9 + 7


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

for i , char in enumerate(c):
    if char == "-":
        for j in range(n + 1):
            if j + 1 < n + 1:
                dp[i + 1][j + 1] += dp[i][j]
                dp[i + 1][j + 1] %= MOD

    if char == "U":
        for j in range(n + 1):
            dp[i + 1][j] += dp[i][j]
            dp[i + 1][j] %= MOD
            if j + 1 < n + 1:
                dp[i + 1][j + 1] += dp[i][j] * (i - j)
                dp[i + 1][j + 1] %= MOD

    if char == "D":   
        for j in range(n + 1):
            if j + 1 < n + 1:
                dp[i + 1][j + 1] += dp[i][j] * (i - j)
                dp[i + 1][j + 1] %= MOD
            if j + 2 < n + 1:
                dp[i + 1][j + 2] += dp[i][j] * (i - j) ** 2
                dp[i + 1][j + 2] %= MOD

print(dp[-1][-1])


Measured memory_bytes: 6172
module Main where
import qualified Data.Set as S
import qualified Data.ByteString.Char8 as B
import Data.List(sortOn, foldl')

readIntPair :: B.ByteString -> (Int,Int)
readIntPair s = p
    where
    Just p = do
        (n1, s') <- B.readInt s
        (n2, _ ) <- B.readInt (B.tail s')
        return (n1,n2)

main :: IO ()
main = do
    n <- fmap read getLine :: IO Int
    asbs <- fmap (map readIntPair . B.lines) B.getContents
    let l  = reverse $ sortOn (uncurry (+)) asbs
        ps = cycle [1,-1]
        ans = foldl' (\acc ((a,b),p) -> if p == 1 then acc + a else acc - b) 0 $
                (zip l ps)
    print ans                


Measured memory_bytes: 44412
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
const ll waru=1e9;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int dp[100001][2];

int main(){
    string T;
    cin>>T;
    reverse(T.begin(),T.end());
    string parts[4]={"maerd","remaerd","esare","resare"};
    int iter=0;
    bool flag=false;
    while(iter<T.length()){
        bool done=false;
        for(auto part:parts){
            string cmp=T.substr(iter,part.length());
            if(cmp==part){
                done=true;
                iter+=part.length();
            }
        }
        if(!done){
            flag=true;
            break;
        }
    }
    cout<<(flag?"NO":"YES")<<endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		
		String[] de = {"dream", "dreamer", "erase", "eraser"};
		
		s = s.replaceAll("eraser", "");
		s = s.replaceAll("erase", "");
		s = s.replaceAll("dreamer", "");
		s = s.replaceAll("dream", "");
		
		String ans = s.length() == 0 ? "YES" : "NO";
		System.out.println(ans);
		
		sc.close();
	}
}




Measured memory_bytes: 33076
import sys
e=sys.stdin.readline
p={'N':(1,5,2,3,0,4),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3),
   'S':(4,0,2,3,5,1),'R':(0,2,4,1,3,5),'L':(0,3,1,4,2,5)}
for n in iter(e,'0\n'):
 a=1;s=[1,2,3,4,5,6]
 for _ in[0]*int(n):
  s=[s[i]for i in p[e()[0]]]
  a+=s[0]
 print(a)


Measured memory_bytes: 5660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
    ll n; cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
    }
    vector<int> perm(n);
    for (int i = 0; i < n; ++i) perm[i] = i;

    double dist = 0;
    do {
        for (int i = 0; i < n - 1; ++i) {
            int xi = x[perm[i]];
            int nextxi = x[perm[i + 1]];
            int yi = y[perm[i]];
            int nextyi = y[perm[i + 1]];
            dist += sqrt(pow((nextxi - xi), 2) + pow((nextyi - yi), 2));
        }
    } while (next_permutation(perm.begin(), perm.end()));
    for (int i = 2; i <= n; ++i) {
        dist /= i;
    }
    cout << setprecision(20); 
    cout << dist << endl;
}

Measured memory_bytes: 3804
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n=0,m=0,k=0;
	cin>>n>>m>>k;
	vector<int> a(n);
	for(auto &i: a)
		cin>>i;
	vector<int> b(m);
	for(auto &i: b)
		cin>>i;
	lli sum=0;
	for(int i=0;i<n;++i)
		sum+=a[i];
	int l=n,r=0,ct=0;
	while(true)
	{
		if(sum<=k)
		{
			ct=max(ct,l+r);
			if(r<m)
			{
				sum+=b[r];
				++r;
			}
			else
				break;
		}
		else
		{
			if(l==0)
				break;
			--l;
			sum-=a[l];
		}
	}
	cout<<ct<<endl;
}

Measured memory_bytes: 4792
import math
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
    A[i] = A[i]-i-1
A.sort()
f = math.floor(N/2)

ans = 0
for i in range(f):
    ans -= A[i]
    ans += A[N-i-1]

print(ans)

Measured memory_bytes: 26832
#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
	#endif
}

int dp[3004][3004];
int n;
vi a;
vi pre;

int cal(int l,int r)
{
	if(dp[l][r]!=-1)
		return dp[l][r];
	int &ans=dp[l][r];
	ans=0;
	if(l==r)
		return ans=a[l];
	ans = max(-cal(l+1,r) + a[l] + pre[r] - pre[l],-cal(l,r-1) + a[r] + pre[r-1] - (l>0?pre[l-1]:0));
	return ans;
}

int32_t main()
{
	fastIO
	//inp_out();
	memset(dp,-1,sizeof(dp));
	cin>>n;
	a=pre=vi(n);
	for(int i=0;i<n;++i)
	{
		cin>>a[i];
		pre[i]+=a[i];
		if(i>0)
			pre[i]+=pre[i-1];
	}

	cout<< 2 * cal(0,n-1) - pre[n-1];

	return 0;
}

Measured memory_bytes: 71040
h, w, n = [int(i) for i in input().split()]
sr, sc = [int(i) for i in input().split()]
s = input()
t = input()

ok = True
x = sr
for i, j in zip(s, t):
    if i == "U":
        x -= 1
    if not 1 <= x <= h:
        ok = False
    if j == "D":
        x += 1
    if not 1 <= x <= h:
        x -= 1

x = sr
for i, j in zip(s, t):
    if i == "D":
        x += 1
    if not 1 <= x <= h:
        ok = False
    if j == "U":
        x -= 1
    if not 1 <= x <= h:
        x += 1
x = sc
for i, j in zip(s, t):
    if i == "L":
        x -= 1
    if not 1 <= x <= w:
        ok = False
    if j == "R":
        x += 1
    if not 1 <= x <= w:
        x -= 1

x = sc
for i, j in zip(s, t):
    if i == "R":
        x += 1
    if not 1 <= x <= w:
        ok = False
    if j == "L":
        x -= 1
    if not 1 <= x <= w:
        x += 1

if ok:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3888
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int a, b;
  cin >> a >> b;

  if (a >= 13) cout << b << endl;
  else if (a >= 6 && a <= 12) cout << b / 2 << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 3632
N = int(input())


def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
kou=N
a= num2alpha(kou)   

print(a.lower())

Measured memory_bytes: 9120
import sys
import numpy as np


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

a = np.array(sorted(list(map(int, input().split()))))
f = np.array(sorted(list(map(int, input().split())), reverse=True))

asum = a.sum()

l,r = 0, 10**13
while l != r:
    mid = (l+r)//2

    can = (asum - np.minimum(mid//f, a).sum()) <= k

    if can:
        r = mid 
    else:
        l = mid +1

print(l)

Measured memory_bytes: 37288
#include <bits/stdc++.h>
#define lli long long int
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(lli i=0, i##_len=(lli)(n); i<i##_len; i++)
#define repf(i, n) for(lli i=1, i##_len=(lli)(n+1); i<i##_len; i++)
#define per(i, n) for(lli i=((lli)(n))-1; i>=0; i--)
#define perf(i, n) for(lli i=((lli)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli n;
    cin >> n;
    vi a(n, 0);
    vi b(n, INFLL);
    rep(i, n-1) cin >> b[i];
    a[0] = b[0];
    repf(i, n-1) a[i] = min(b[i-1], b[i]);
    lli sum = 0;
    rep(i, n) sum += a[i];
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<cstring>
using namespace std;

#define INF 1000000007
int n,m;
int dp[50001];
int c[50000];

int dfs(int k){
  for(int i = 0; i < m ; i++){
    if(k+c[i] <= n)dp[k+c[i]] = min(dp[k+c[i]], dp[k]+1);
  }
  if(k < n) return dfs(k+1);
  else return 0;
}

int main(){
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    cin >> c[i];
  }

  memset(dp, INF, sizeof(dp));
  dp[0] = 0;
  dfs(0);

  cout << dp[n] << endl;
}



Measured memory_bytes: 3284
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func gcd(a, b int) int {
	if a%b == 0 {
		return b
	}
	return gcd(b%a, a)
}

func main() {
	var N int
	fmt.Scan(&N)
	A := make([]int, N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := range A {
		A[i] = nextInt(sc)
	}
	// sort.Ints(A)
	GCDL := make([]int, N)
	GCDR := make([]int, N)
	GCDL[0] = A[0]
	for i := 1; i < N; i++ { // 前から計算した累積GCD
		GCDL[i] = gcd(GCDL[i-1], A[i])
	}
	GCDR[N-1] = A[N-1]
	for i := N - 2; i >= 0; i-- { // 後ろから計算した累積GCD
		GCDR[i] = gcd(GCDR[i+1], A[i])
	}
	// fmt.Println("N", N, "GCDL", GCDL, "GCDR", GCDR)
	ans := 1
	for i := 0; i < N; i++ { // i番目の数を除いた場合の最大のGCDを求める
		var t int
		if i == 0 {
			t = GCDR[1]
		} else if i == N-1 {
			t = GCDL[N-2]
		} else {
			t = gcd(GCDL[i-1], GCDR[i+1])
		}
		ans = max(ans, t)
	}
	fmt.Println(ans)
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 4736
def main():
    A, B, C = map(int, input().split())
    count5 = 0
    count7 = 0
    if A == 5:
        count5 += 1
    elif A == 7:
        count7 += 1

    if B == 5:
        count5 += 1
    elif B == 7:
        count7 += 1

    if C == 5:
        count5 += 1
    elif C == 7:
        count7 += 1

    if count5 == 2 and count7 == 1:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

const int MOD = 1000 * 1000 * 1000 + 7;

long long mul(long long a, long long b)
{
	return (a * b) % MOD;
}

int main()
{
	int N;
	cin >> N;
	vector<string> S(2);
	cin >> S[0] >> S[1];

	long long ans;
	int i;
	bool f;
	if (S[0][0] == S[1][0]) {
		ans = 3;
		f = true;
		i = 1;
	}
	else {
		ans = 6;
		f = false;
		i = 2;
	}
	while (i < N) {
		if (S[0][i] == S[1][i]) {
			if (f) {
				ans = mul(ans, 2);
			}
			else {
				ans = mul(ans, 1);
			}
			f = true;
			i += 1;
		}
		else {
			if (f) {
				ans = mul(ans, 2);
			}
			else {
				ans = mul(ans, 3);
			}
			f = false;
			i += 2;
		}
	}
	cout << ans << endl;
}


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

ll f[100005], fi[100005];

ll perm(int n, int r) {
    if (n < r) return 0;
    return f[n] * fi[n - r] % MOD;
}

ll comb(int n, int r) {
    if (n < r) return 0;
    return f[n] * fi[r] % MOD * fi[n - r] % MOD;
}

ll dp[2005][2005];
ll cnt[2005][2005];

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

    int n;
    cin >> n;
    vector<ll> x(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i];
    }

    f[0] = 1;
    for (int i = 1; i <= n; ++i) {
        f[i] = f[i - 1] * i % MOD;
    }
    fi[n] = modpow(f[n], MOD - 2);
    for (int i = n; i > 0; --i) {
        fi[i - 1] = fi[i] * i % MOD;
    }

    ll sum = 0, ans = 0;
    for (int i = 1; i < n; ++i) {
        (sum += modpow(i, MOD - 2)) %= MOD;
        (ans += f[n - 1] * sum % MOD * (x[i] - x[i - 1]) % MOD) %= MOD;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3968
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
		}

		int min = 100;
		int max = -100;
		for (int i = 0; i < n; i++) {
			if (a[i] < min) {
				min = a[i];
			}
			if (a[i] > max) {
				max = a[i];
			}
		}

		int mincost = 1999999999;
		int cost = 0;

		for (int i = min; i <= max; i++) {
			cost = 0;
			for (int j = 0; j < n; j++) {
				int sa = i - a[j];
				cost += sa * sa;
			}
			if(cost < mincost){
				mincost = cost;
			}
		}

		System.out.println(mincost);
		in.close();

	}

}

Measured memory_bytes: 9556
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
set<int> st;
int a[200000];
P p[200000];
int main() {
	int n; cin >> n;
	st.insert(n); st.insert(-1);
	rep(i, n) {
		cin >> a[i]; p[i] = { a[i],i };
	}
	sort(p, p + n);
	ll sum = 0;
	rep(i, n) {
		int x = p[i].second;
		st.insert(x);
		auto itr = st.find(x); itr--;
		int le = *itr; itr++; itr++;
		int ri = *itr;
		sum += (ll)(x - le)*(ll)(ri - x)*(ll)(i + 1);
	}
	cout << sum << endl;
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n,m;cin>>n>>m;
    vector<vector<char>>c(n+2,vector<char>(m+2));
    for(int i=1;i<=n;++i){
        for(int j=1;j<=m;++j){
            cin>>c[i][j];
        }
    }
    for(int i=1;i<=n;++i){
        for(int j=1;j<=m;++j){
            if(c[i][j]!='#'){
                char cnt='0';
                for(int k=-1;k<=1;++k){
                    for(int l=-1;l<=1;++l){
                        if(c[i+k][j+l]=='#')cnt++;
                    }
                }
                c[i][j]=cnt;
            }
            if(j!=m)cout<<c[i][j];
            else cout<<c[i][j]<<endl;
        }
    }
}

Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {
		new Main().run();
	}

	long solve(int n, long k, long[] a, long[] b) {
		long ans = 0;
		for (int unused = -1; unused == -1 || (1L << unused) <= k; ++unused) {
			if (unused >= 0 && ((1L << unused) & k) == 0)
				continue;
			long sum = 0;
			out: for (int i = 0; i < n; ++i) {
				if (unused != -1 && ((1L << unused) & a[i]) > 0)
					continue out;
				for (int j = unused + 1; j <= 30; ++j) {
					if (((1L << j) & k) == 0 && ((1L << j) & a[i]) > 0)
						continue out;
				}
				sum += b[i];
			}
			ans = Math.max(ans, sum);
		}
		return ans;
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long k = sc.nextLong();
		long[] a = new long[n];
		long[] b = new long[n];
		for (int i = 0; i < n; ++i) {
			a[i] = sc.nextLong();
			b[i] = sc.nextLong();
		}
		System.out.println(solve(n, k, a, b));
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 90160
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int n;
int a[N],b[N];
int t[N];
int cal[N];
int ans=0;
int lowbit(int x){
	return x&(-x);
}
void add(int pos){
	for(int i=pos;i<=n;i+=lowbit(i))
		t[i]++;
}
int query(int pos){
	int ret=0;
	for(int i=pos;i>=1;i-=lowbit(i))
		ret+=t[i];
	return ret;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		add(a[i]);
		int prev=query(a[i]-1);
		a[i]-=prev;
	}
	memset(t,0,sizeof(t));
	for(int i=1;i<=n;i++){
		scanf("%d",&b[i]);
		add(b[i]);
		int prev=query(b[i]-1);
		b[i]-=prev;
	}
	cal[0]=1;
	for(int i=1;i<=n;i++) cal[i]=cal[i-1]*i;
	for(int i=1;i<=n;i++){
		ans+=(a[i]-b[i])*cal[n-i];
	}
	printf("%d\n",abs(ans));
	exit(0);
}

Measured memory_bytes: 640
def d_powerful_discount_tickets():
    from heapq import heapify, heappop, heappush
    N, M = [int(i) for i in input().split()]
    A = [-int(i) for i in input().split()]

    heapify(A)
    for _ in range(M):
        heappush(A, -(-heappop(A) // 2))
    return -sum(A)

print(d_powerful_discount_tickets())

Measured memory_bytes: 14180
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
    ll N;
    cin>>N;
    map <ll,ll> _mp;
    for(auto i=0;i<N;i++){
        ll a;cin>>a;
        _mp[a]++;
    }
    map<ll,ll> mp;
    ll cnt=0;
    ll s=0;
    for(auto p:_mp){
        s++;
        if(p.second>1){
            if(p.second%2==1){
                mp[p.first]=1;
            }else{
                mp[p.first]=2;
                cnt++;
            }
        }else{
            mp[p.first] = p.second;
        }
    }
    if(cnt%2==0){
        cout<<s<<endl;
    }else{
        cout<<s-1<<endl;
    }
    
}
 

Measured memory_bytes: 12800
#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>;

int main() {
    string s;
    cin >> s;

    if (s == "ABC") {
        cout << "ARC" << endl;
    }
    else {
        cout << "ABC" << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
// ARC089
// B - Hina Arare

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

int N;

int main() {
    string s;
    bool isFour = false;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> s;
        if (s == "Y") {
            isFour = true;
        }
    }

    cout << (isFour ? "Four" : "Three") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <algorithm>
#include <iterator>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  int B = 10*b;
  set<int> BZ{B,B+1,B+2,B+3,B+4,B+5,B+6,B+7,B+8,B+9};
  int A = a*25/2;
  set<int> AZ{A,A+1,A+2,A+3,A+4,A+5,A+6,A+7,A+8,A+9,A+10,A+11,A+12}; 
  if (a%2==1){
    AZ.erase(A);
  }
  set<int> v;
  set_intersection(BZ.begin(),BZ.end(),AZ.begin(),AZ.end(),inserter(v,v.end()));
  if (v.empty())
    cout << -1 << endl;
  else{
    cout << *begin(v) << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
static const int MAX = 10000;
static const int INFTY = (1<<20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int,int> > adj[MAX];

void dijkstra(){
  int i, j;
  priority_queue<pair<int,int> > P;
  int color[MAX];
  int d[MAX];
  for( i = 0 ; i < n ; i++ ){
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  P.push(make_pair(0,0));
  color[0] = GRAY;

  while( !P.empty() ){
    pair<int,int> f = P.top();
    P.pop();
    int u = f.second;
    color[u] = BLACK;
    if( d[u] < f.first*(-1) ) continue;

    for( j = 0 ; j < adj[u].size() ; j++ ){
      int v = adj[u][j].first;
      if( color[v] == BLACK ) continue;
      if( d[v] > d[u] + adj[u][j].second ){
	d[v] = d[u] + adj[u][j].second;
	P.push(make_pair(d[v]*(-1),v));
	color[v] = GRAY;
      }
    }
  }

  for( i = 0 ; i < n ; i++ ){
    cout << i << " " << ( d[i] == INFTY ? -1 : d[i] ) << endl;
  }
}

int main(){
  int i, j, k, u, v, c;

  cin >> n;

  for( i = 0 ; i < n ; i++ ){
    cin >> u >> k;
    for( j = 0 ; j < k ; j++ ){
      cin >> v >> c;
      adj[u].push_back(make_pair(v,c));
    }
  }

  dijkstra();

  return 0;
}



Measured memory_bytes: 8116
INF = 1 << 29
while True:
    n = input()
    if n == 0:
        break
    dic = {}
    for _ in xrange(n):
        name, cost = raw_input().split()
        dic[name] = int(cost)
    m = input()
    recipe = []
    for _ in xrange(m):
        data = raw_input().split()
        if data[1] <= 0:
            m -= 1
            continue
        recipe.append([data[0]]+data[2:])
    for _ in xrange(m):
        for i in xrange(m):
            dic[recipe[i][0]] = min(dic[recipe[i][0]] if recipe[i][0] in dic else INF, 
                                    sum(map(lambda x:dic[x] if x in dic else INF, recipe[i][1:])))
    print dic[raw_input()]

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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;

int main(){
    ll N;
    std::cin >> N;

    ll abc[N+1][3];
    for(ll i=0; i<N; ++i){
        for(ll j=0; j<3; ++j){
            std::cin >> abc[i][j];
        }
    }

    ll dp[N+1][3];
    for(ll i=0; i<N+1; ++i){
        for(ll j=0; j<3; ++j){
            dp[i][j]=0;
        }
    }
    //i:1>N; i日目にjを選んだ時に得られる最大の幸福度
    for(ll i=0; i<N; ++i){
        for(ll j=0; j<3; ++j){
            for(ll k=0; k<3; ++k){
                if(j==k) continue;
                chmax(dp[i+1][k], dp[i][j] + abc[i][k]);
            }
        }
    }

    ll ans=0;
    for(ll i=0; i<3; ++i){
        chmax(ans, dp[N][i]);
    }
    std::cout << ans;

    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
double kitaiti(int num){
  return double(num+1)/2;
}

int main(){
  int N,K;
  cin>>N>>K;
  vector<int>data(N);
  for(int i=0;i<N;i++)  cin>>data[i];
  
  vector<double> sum(N+1,0);// 累積和
  for(int i=0;i<N;i++){
    sum[i+1]=sum[i]+kitaiti(data[i]);
  }
  double MAX=0;
  for(int i=0;i+K<=N;i++){
    MAX=max(MAX,sum[i+K]-sum[i]);
  }
  cout<<fixed<<setprecision(10)<<MAX<<endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

const int MAXN = 300;
const int MOD = 1000000007;
const int INF = 2000000000;
const double PI = 3.14159265358979;
const int dir_4r[] = { -1, 1, 0, 0 };
const int dir_4c[] = { 0, 0, -1, 1 };
const int dir_8r[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
const int dir_8c[] = { -1, 0, 1, -1, 1, -1, 0, 1 };

int main()
{
	int n, a;
	cin >> n;
	for (a = 1; a <= n; a <<= 1)
		;
	cout << a / 2 << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    // static int INF = (1 << 30) - 1;
    // static long L_INF = (1L << 62) - 1;
    // static long MOD = (long) 1e9 + 7;

    // 数列に対し, ある要素に値を加える操作と,
    // 区間和を求める操作をそれぞれ対数時間で行うことが出来るデータ構造。
    // 計算量: O(logN)
    //
    // sum: 区間[1, i]の合計を求める。
    // add: 要素iに値xを加える。
    static class BIT {
        // [1, n]
        int bit[];
        int n;

        BIT(int n) {
            this.bit = new int[n + 1];
            this.n = n;
        }

        int sum(int i) {
            int s = 0;
            while (i > 0) {
                s += bit[i];
                i -= i & -i;
            }
            return s;
        }

        void add(int i, int x) {
            while (i <= n) {
                bit[i] += x;
                i += i & -i;
            }
        }
    }

    static class Solver {
        int n, q;

        // write your code
        // // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_B&lang=jp
        void solve(InputReader in, PrintWriter out) {
            n = in.nextInt();
            q = in.nextInt();
            BIT bit = new BIT(n);
            while (q > 0) {
                int com = in.nextInt();
                int x = in.nextInt();
                int y = in.nextInt();
                if (com == 0) {
                    bit.add(x, y);
                } else {
                    out.println(bit.sum(y) - bit.sum(x - 1));
                }
                q--;
            }
        }

        void debug(Object... os) {
            System.err.println(Arrays.deepToString(os));
        }
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}



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


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

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

i64 a, b, k;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    cin >> k;
    cin >> a >> b;
    int now = 0;
    while (now <= b) {
        now += k;
        if (now >= a && now <= b) {
            cout << "OK" << '\n';
            return 0;
        }
    }
    cout << "NG" << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

int main() {
	int n, a[100000];
	cin >> n;

	int x = 0, y = 0;
	REP(i, n) {
		cin >> a[i];
		x = max(x, a[i]);
	}
	REP(i, n) {
		if (abs(y - x / 2) > abs(a[i] - x / 2)) {
			y = a[i];
		}
	}

	cout << x << " " << y;



	return 0;
}

Measured memory_bytes: 640
using System;

namespace abc136_b
{
    static class Program
    {
        static void Main(string[] args)
        {
            var n = Console.ReadLine().ToInteger();
            // 何桁まであるか？
            var maxDigit = (int)Math.Log(n, 10) + 1;

            var count = 0;
            for (int i = 1; i <= maxDigit; i++)
            {
                // 奇数桁
                if (i % 2 != 0)
                {
                    if (maxDigit != i)
                    {
                        // 個数
                        count += (int)Math.Pow(10, i) - (int)Math.Pow(10, i - 1);
                    }
                    else
                    {
                        // 最終桁
                        count += n - (int)Math.Pow(10, i - 1) + 1;
                    }
                }
            }

            Console.WriteLine($"{count}");
        }

        static int ToInteger(this string s)
        {
            return int.Parse(s);
        }
    }
}


Measured memory_bytes: 13268
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    K = int(input())
    x = list(map(int, input().split()))

    ans = 0
    for i in range(N):
        ans += min(K - x[i], x[i]) * 2
    print(ans)


if __name__ == "__main__":
    main()

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

using namespace std;
const int mod = 1e9+7;
int n;
vector<vector<int> > tree;
vector<vector<int> > dp;

void dfs(int cur, int par = -1){
	int w = 1,b = 1;
	for(int child : tree[cur]){
		if(child==par) continue;
		dfs(child,cur);
		w = (1ll * w * (dp[child][0] + dp[child][1]))%mod;
		b = (b * 1ll * dp[child][0]) %mod;
	}
	dp[cur][0] = w;
	dp[cur][1] = b;

}

int main(){
	cin >> n;
	tree.resize(n+1);
	dp.resize(n+1,vector<int>(2,0));
	for(int i = 0; i < n-1; i++){
		int a,b; cin >> a >> b;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}	
	dfs(1);
	cout << (dp[1][0] + dp[1][1] )%mod;
	
	return 0;
}


Measured memory_bytes: 18176
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int N = nextInt();
		long ans =0;
		for(int a=1;a<=N;a++){
			for(int b=1;b<=N;b++){
				for(int c=1;c<=N;c++){
					ans+=gcd(gcd(a,b),c);
				}

			}

		}
		System.out.println(ans);

	}

	public static long gcd(long a, long b) {
		long x, y;
		if (a < b) {
			x = b;
			y = a;
		} else {
			x = a;
			y = b;
		}
		long r;
		while ((r = a % b) != 0) {
			a = b;
			b = r;
		}
		return b;
	}
	public static boolean isPalindromicStr(String s) {
		int h = 0;
		int t = s.length() - 1;
		while (h <= t) {
			if (s.charAt(h) != s.charAt(t)) {
				break;
			}
			h++;
			t--;
		}
		if (h > t) {
			return true;
		}
		return false;
	}


	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 25888
X, Y = map(int, input().split())

ans = 0
if X < 4:
    ans += (4 - X) * 10**5

if Y < 4:
    ans += (4 - Y) * 10**5

if X == 1 and Y == 1:
    ans += 4 * 10**5

print(ans)

Measured memory_bytes: 38396
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	if a >= 13 {
		fmt.Print(b)
	} else if a <= 12 && a >= 6 {
		fmt.Print(b / 2)
	} else {
		fmt.Print(0)
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.12lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
const int mod = 1000 * 1000 * 1000 + 7;
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;
 
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265359;
 
int dx[6] = {-1,-1,0,0,1,1};
int dy[6] = {-1,0,-1,1,0,1};

vector<int>v;


int CeilIndex(std::vector<int>& v, int l, int r, int key) 
{ 
    while (r - l > 1) { 
        int m = l + (r - l) / 2; 
        if (v[m] >= key) 
            r = m; 
        else
            l = m; 
    } 
  
    return r; 
} 
  
int LIS(std::vector<int>& v) 
{ 
    if (v.size() == 0) 
        return 0; 
  
    std::vector<int> tail(v.size(), 0); 
    int length = 1;  
  
    tail[0] = v[0]; 
    for (size_t i = 1; i < v.size(); i++) { 
  
         
        if (v[i] < tail[0]) 
            tail[0] = v[i]; 
        else if (v[i] > tail[length - 1]) 
            tail[length++] = v[i]; 
        else
            tail[CeilIndex(tail, -1, length - 1, v[i])] = v[i]; 
    } 
  
    return length; 
} 

int a[105];

int main(){
   int n;
   cin>>n;
   int ans=INF;
   for(int i=0;i<n;++i)
      cin>>a[i];
   for(int i=1;i<=100;++i){
      int tot=0;
      for(int j=0;j<n;++j){
         tot+=(a[j]-i)*(a[j]-i);
      }
      ans=min(ans,tot);
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
(defun main ()
  (let* ((n (read))
	 (a (make-array (1+ n))))
    (dotimes (i n)
      (setf (aref a (1+ i)) (read)))
    (loop for i from 1
       below (1+ n)
       when (and (oddp i) (oddp (aref a i)))
       count i)))

(format t "~d~%" (main))


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using LL = long long;
using ULL = unsigned long long;

void solve() {
	ULL n, k; cin >> n >> k;
	ULL ans = 0;
	if (k % 2 != 0) {
		ans = (n / k) * (n / k) * (n / k);
	}
	else {
		ans += (n / k) * (n / k) * (n / k);
		n += k / 2;
		ans += (n / k) * (n / k) * (n / k);
	}
	cout << ans << endl;
}

int main() {

	solve();

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[200001];
int b[200001];
map<int,int> f;
int main()
{
	int n,s=0,i,t;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	for(i=0;i<n;i++)
	{
		t=1;
		while(t<=a[i])
			t*=2;
		b[i]=t-a[i];
	}
	for(i=0;i<n;i++)
		f[a[i]]++;
	for(i=n-1;i>=0;i--)
	{
		if(f[a[i]])
		{
			f[a[i]]--;
			if(f[b[i]])
			{
				f[b[i]]--;
				s++;
			}
		}
	}
	printf("%d",s);
	return 0;
}

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

namespace AtCoder.Contests.ABC163
{
    /// <summary>
    /// 
    /// </summary>
    static class C
    {
        static void Main(string[] args)
        {
            var n = NextInt();
            var aas = ReadIntArray();
            var bukas = new int[n + 1];
            foreach (var a in aas)
            {
                bukas[a]++;
            }
            for (int i = 1; i <= n; i++)
            {
                Console.WriteLine(bukas[i]);
            }
        }

        #region Console
        static int _index = 0;
        static string[] _buffer;

        static string Next()
        {
            if (_buffer == null || _index >= _buffer.Length)
            {
                _buffer = Console.ReadLine().Split();
                _index = 0;
            }

            return _buffer[_index++];
        }
        static int NextInt()
        {
            return int.Parse(Next());
        }
        static long NextLong()
        {
            return long.Parse(Next());
        }
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }
        static List<T> ReadObjects<T>(int n, Func<int[], T> creator)
        {
            var l = new List<T>(n);

            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                l.Add(creator(a));
            }

            return l;
        }

        static int[,] ReadMatrix(int n, int m)
        {
            var r = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                for (int j = 0; j < m; j++)
                {
                    r[i, j] = a[j];
                }
            }
            return r;
        }
        #endregion
    }
}


Measured memory_bytes: 43876