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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

int a,b;

int main(){
  cin >> a >> b;
  if(max(a,b)<=9){cout << a*b;}else{cout << -1;}
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };



int ans = 0;
string str;

int main() {
	while ( cin >> str ) {
		for ( int i = 0; i < str.size(); i++ ) {
			if ( str[ i ] >= '0' && str[ i ] <= '9' ) {
				int Add = str[ i ] - '0';
				int j;
				for ( j = i + 1; j < str.size(); j++ ) {
					if ( str[ j ] >= '0' && str[ j ] <= '9' ) {
						Add *= 10;
						Add += str[ j ] - '0';
					}
					else {
						break;
					}
				}
				ans += Add;
				i = j;
			}
		}
	}
	printf( "%d\n", ans );
	return 0;
}

Measured memory_bytes: 1180
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#define Rint register int
#define mem(a,b) memset(a,(b),sizeof(a))
#define Temp template<typename T>
using namespace std;
typedef long long LL;
Temp inline void read(T &x){
    x=0;T w=1,ch=getchar();
    while(!isdigit(ch)&&ch!='-')ch=getchar();
    if(ch=='-')w=-1,ch=getchar();
    while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^'0'),ch=getchar();
    x=x*w;
}

const int maxn=100+10;
int a[maxn],ans;
int n;

int main(){
    read(n);
    for(Rint i=1;i<=n;i++){
		int x;
		read(x);
		a[x]=1;
	}
	for(Rint i=1;i<=100;i++){
		if(a[i]>0)ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
///
// File:  b.go
// Author: ymiyamoto
//
// Created on Sat May 12 20:36:32 2018
//
package main

import (
	"fmt"
)

var N, x int

func main() {
	fmt.Scan(&N, &x)

	if x == 1 || x == 2*N-1 {
		fmt.Println("No")
		return
	}

	arr := make([]int, 2*N-1)
	val := 1
	mid := (2*N - 1) / 2
	for i := 0; i < len(arr); i++ {
		if i == mid-1 {
			if x == 2 {
				arr[i] = x + 1
			} else {
				arr[i] = x - 2
			}
		} else if i == mid {
			if x == 2 {
				arr[i] = x
			} else {
				arr[i] = x + 1
			}
		} else if i == mid+1 {
			if x == 2 {
				arr[i] = x - 1
			} else {
				arr[i] = x
			}
		} else if i == mid+2 {
			if x == 2 {
				arr[i] = x + 2
			} else {
				arr[i] = x - 1
			}
		} else {
			if x == 2 {
				if val == x-1 {
					val = x + 3
				}
			} else {
				if val == x-2 {
					val = x + 2
				}
			}
			arr[i] = val
			val++
		}
	}

	fmt.Println("Yes")
	for i := range arr {
		fmt.Println(arr[i])
	}
}


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

const int MAX_N = 110000;
int dp[MAX_N];

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

    for (int i=0;i<MAX_N;++i) dp[i] = -1;
    dp[0] = 0;

    queue<int> que;
    que.push(0);

    while(!que.empty()){
        int v = que.front(); que.pop();
        for (int pow6 = 1;v+pow6 <= N;pow6 *= 6){
            if (dp[v+pow6] == -1){
                dp[v+pow6] = dp[v] + 1;
                que.push(v+pow6);
            }
        }
        for (int pow9 = 1;v+pow9 <= N;pow9 *= 9){
            if (dp[v+pow9] == -1){
                dp[v+pow9] = dp[v] + 1;
                que.push(v+pow9);
            }
        }
    }

    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
//
// using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  sort(ALL(v));
  ll res = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i+1; j < n; j++) {
      ll tmp1 = abs(v[i] - v[j]);
      ll tmp2 = v[i] + v[j];
      ll index1 = upper_bound(ALL(v), tmp1) - v.begin();
      ll index2 = lower_bound(ALL(v), tmp2) - v.begin();
      index2--;
      ll count = 0;
      if(index1 <= i && i <= index2) count++;
      if(index1 <= j && j <= index2) count++;
      // cout << index1 << ' ' << index2 << endl;
      // cout << count << endl;
      res += max(0ll, index2 - index1 + 1ll - count);
    }
  }

  cout << res / 3 << endl;
}


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

using namespace std;

#define reps(i, n, m) for (int i = n; i < m; i++)
#define rep(i, n) reps(i, 0, m)

int main()
{
  string s, t;
  cin >> s >> t;
  int n = s.length();
  int m = t.length();
  vector<vector<int>> dp(n+1, vector<int>(m+1, 0));
  vector<vector<int>> b(n+1, vector<int>(m+1, -1));
  reps(i, 1, n+1) {
    reps(j, 1, m+1) {
      if (s[i-1] == t[j-1]) {
        dp[i][j] = dp[i-1][j-1] + 1;
        b[i][j] = 0;
      }
      else {
        if (dp[i-1][j] < dp[i][j-1]) b[i][j] = 1;
        else b[i][j] = 2;
        dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      }
    }
  }
  int r = n, c = m;
  string res = "";
  while (b[r][c] != -1) {
    int x = b[r][c];
    if (x == 0) {
      res += s[r-1];
      r--;
      c--;
    } else if (x == 1) {
      c--;
    } else {
      r--;
    }
  }
  reverse(res.begin(), res.end());
  cout << res << endl;
}


Measured memory_bytes: 72192
#!/usr/bin/env python3

from collections import defaultdict
from heapq import heappush, heappop
import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")


def debug(*x):
    print(*x)


def solve1(N, K, heights):
    heights += [INF] * K
    costs = [INF] * (N + K)
    costs[0] = 0
    for i in range(N - 1):
        for k in range(1, K + 1):
            newcost = costs[i] + abs(heights[i + k] - heights[i])
            if newcost < costs[i + k]:
                costs[i + k] = newcost
    return costs[N - 1]


def solve(N, K, heights):
    costs = [0] * N
    costs[0] = 0
    for i in range(1, N):
        costs[i] = min(
            costs[j] + abs(heights[i] - heights[j])
            for j in range(max(i - K, 0), i)
        )

    return costs[-1]


def solve3(N, heights):
    costs = [None] * N
    costs[0] = 0
    costs[1] = abs(heights[1] - heights[0])

    def get_cost(i):
        if costs[i] != None:
            return costs[i]

        c = min(
            get_cost(i - 2) + abs(heights[i] - heights[i - 2]),
            get_cost(i - 1) + abs(heights[i] - heights
                                  [i - 1]),
        )
        costs[i] = c
        return c

    return get_cost(N - 1)


def main():
    N, K = map(int, input().split())
    heights = list(map(int, input().split()))
    print(solve(N, K, heights))


def _test():
    """
    >>> solve(5, 3, [10, 30, 40, 50, 20])
    30
    >>> solve(3, 1, [10, 20, 10])
    20
    >>> solve(2, 100, [10, 10])
    0
    >>> solve(10, 4, [40, 10, 20, 70, 80, 10, 20, 70, 80, 60])
    40
    """
    import doctest
    doctest.testmod()


def as_input(s):
    "use in test, use given string as input file"
    import io
    global read, input
    f = io.StringIO(s.strip())
    input = f.readline
    read = f.read


USE_NUMBA = False
if (USE_NUMBA and sys.argv[-1] == 'ONLINE_JUDGE') or sys.argv[-1] == '-c':
    print("compiling")
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', solve.__doc__.strip().split()[0])(solve)
    cc.compile()
    exit()
else:
    input = sys.stdin.buffer.readline
    read = sys.stdin.buffer.read

    if (USE_NUMBA and sys.argv[-1] != '-p') or sys.argv[-1] == "--numba":
        # -p: pure python mode
        # if not -p, import compiled module
        from my_module import solve  # pylint: disable=all
    elif sys.argv[-1] == "-t":
        _test()
        sys.exit()
    elif sys.argv[-1] != '-p' and len(sys.argv) == 2:
        # input given as file
        input_as_file = open(sys.argv[1])
        input = input_as_file.buffer.readline
        read = input_as_file.buffer.read

    main()


Measured memory_bytes: 19124
#include<bits/stdc++.h>
using namespace std;
int main(){
    int H,W,N;
    cin >> W >> H >> N;
    
    int w=0,h=0;
    for(int i = 0; i < N; i++){
        int x,y,a;
        cin >> x >> y >> a;
        switch (a)
        {
        case 1:
            w = max(w,x);
            break;
        case 2:
            W = min(W,x);
            break;
        case 3:
            h = max(h,y);
            break;
        case 4:
            H = min(H,y);
            break;
        
        default:
            break;
        }
    }
    int s = max((W-w),0) * max((H-h),0);
    cout << s << endl;
}

Measured memory_bytes: 256
const solve = (n) => {
  let a = {
    0: 0,
    1: 0
  }
  let b = {
    0: 0,
    1: 0
  }
  n.map((tile, i) => {
    if (i % 2 == 0) {
      a[tile]++
    } else {
      b[tile]++
    }
  })
  const p1 = a[0] + b[1]
  const p2 = a[1] + b[0]
  return Math.min(p1, p2)
  // ...
}
const main = (input) => {
  const n = input.split("")
  return solve(n)
}

if (process.env.NODE_ENV !== "test") {
  const input = require("fs").readFileSync("/dev/stdin", "utf8")
  console.log(main(input.trim()))
}

Measured memory_bytes: 9548
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

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

    cin >> A;
    cin >> B;
    cin >> N;

    for( ll i = 1 ; i <=10 ; i++ ){
        N = N * A - B;
        cout << N << endl;
    }
    

}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	string s; cin >> s;
	int w; cin >> w;
	rep(i, s.size()) {
		if (i % w == 0) cout << s[i];
	}
	cout << endl;
}



Measured memory_bytes: 256
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int N;
ll A[202020];

int b[20][202020], s[20][202020];

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    for (int i = 1; i <= N; ++i) cin >> A[i];

    for (int i = 0; i < 20; ++i) {
        for (int j = 1; j <= N; ++j) {
            b[i][j] = (A[j] & (1LL << i)) >> i;
        }
    }

    for (int i = 0; i < 20; ++i) {
        s[i][1] = b[i][1];
        for (int j = 2; j <= N; ++j)
            s[i][j] = s[i][j-1] + b[i][j];
    }

    ll ans = 1;
    int idx = 1;
    int acc[20]; fill(acc, acc+20, 0);
    for (int i = 0; i < 20; ++i) acc[i] = s[i][0];
    for (int j = 2; j <= N; ++j) {
        for (int i = 0; i < 20; ++i) {
            while (s[i][j] - s[i][idx-1] >= 2) ++idx;
        }
        ans += j - idx + 1;
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
	int n, r = 0;
	string s;
	cin >> n;
	cin >> s;
	for(auto i : s){
		if(i == 'R') r++;
	}
	if(2*r > n) cout << "Yes";
	else cout << "No";
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )

cReadLn :: IO Int
cReadLn = fst . fromJust . C.readInt <$> C.getLine

getParms :: IO [Int]
getParms = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  [n,y] <- getParms
  otsdm n y

otsdm'
  :: Int -> Int -> [(Int,Int,Int)]
otsdm' n y
  = [(a,b,c) | let a0 = y `quot` 10000
             , a <- [0 .. a0]
             , let b0 = (y - 10000*a) `quot` 5000
             , b <- [0 .. b0]
             , let c = n-a-b
             , a*10000 + b*5000 + c*1000 == y
             ]

otsdm
  :: Int -> Int -> IO ()
otsdm n y
  | null o    = putStrLn "-1 -1 -1"
  | otherwise = putStrLn $ show a ++ " " ++ show b ++ " " ++ show c
  where
    o = otsdm' n y
    (a,b,c) = head o

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
vector<int> a[1000];
int ans;
int bj[1005];
void dfs(int k,int n,int c)
{
    if(c==n)
    {
        ans++;
        return;
    }
    for(int i=0; i<a[k].size(); i++)
    {
        if(!bj[a[k][i]])
        {
            bj[a[k][i]]=1;
            dfs(a[k][i],n,c+1);
            bj[a[k][i]]=0;
        }
    }
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int u,v;
    for(int i=0; i<m; i++)
    {
        scanf("%d%d",&u,&v);
        a[u].push_back(v);
        a[v].push_back(u);
    }
    memset(bj,0,sizeof(bj));
    ans=0;
    bj[1]=1;
    dfs(1,n,1);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
const int MAX = 2002000;
const int MOD = 1e9+7;

template<int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod-p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int)(1LL*x*p.x%mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) { t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); }
        return ModInt(u);
    }
    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if(e%2 == 0) {p = (p*p) % mod; e /= 2;}
            else {a = (a*p) % mod; e--;}
        }
        return ModInt(a);
    }
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

struct combination {
    vector<ModInt<MOD>> fact;
    combination(int n) : fact(n+1) {
        fact[0] = 1;
        for (int i = 1; i <= n; i++) {
            fact[i] = (fact[i-1] * i);
        }
    }
    ModInt<MOD> operator() (int n, int r) {
        if (r < 0 || r > n) return 0;
        return fact[n]/(fact[n-r]*fact[r]);
    }
};

int main() {
    using mint = ModInt<MOD>;
    combination com(MAX);
    auto g = [&](int r, int c)->mint { 
        return (mint)com(r+c+2, c+1) - 1;
    };
    
    int r1, r2, c1, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    r1--; c1--;
    
    mint ans = g(r2, c2) - g(r1, c2) - g(r2, c1) + g(r1, c1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8064
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(len(a)):
  a[i]*=(-1)

import heapq
heapq.heapify(a)

for i in range(m):
  val=heapq.heappop(a)
  heapq.heappush(a,((val*(-1))//2)*(-1))

print(sum(a)*(-1))

Measured memory_bytes: 14224
#include <cstdio>
const int N = 1005;
char str[N];
char ans[N];
int tot;
int main(){
	scanf("%s", str);
	for(int i = 0; str[i]; i ++){
		if(str[i] == '0' || str[i] == '1'){
			ans[tot ++] = str[i];
		}else{
			tot --;
			if(tot < 0) tot = 0;
		}
	}
	for(int i = 0; i < tot; i ++){
		printf("%c", ans[i]);
	}printf("\n");
} 

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main() {
  int a[4] = {};
  int b[4] = {};
  while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]){
	int hit = 0, blow = 0;
	for(int i = 0; i < 4; ++i) {
	  for(int j = 0; j < 4; ++j) {
		if(i == j && a[i] == b[j]) {
		  hit++;
		}
		else if(i != j && a[i] == b[j]) {
		  blow++;
		}
	  }
	}
	cout << hit << " " << blow << endl;
  }
  return 0;
}

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

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

  vector<long> l(87);
  l.at(0) = 2;
  l.at(1) = 1;
  for (long i = 2; i <= n; i++) {
    l.at(i) = l.at(i - 1) + l.at(i - 2);
  }

  cout << l.at(n) << endl;
}


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

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

#define REP(i,n) for(ll 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

ll N, x;
vector<ll> a;

signed main()
{
    cin >> N >> x;
    a.assign(N, 0);
    REP(i, N) { cin >> a[i]; }
    SORT(a);
    ll ans = 0;
    REP(i, N) {
        if(x < a[i]) { break; }
        x -= a[i];
        ans++;
    }
    if(x != 0) {
        // あげてない子供がいるなら、その子にあまりをあげる
        if(ans == N) { ans--; }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

template<class T> void output(std::vector<T> & A) {
    const int n = A.size();
    for (int i = 0; i < n - 1; ++i) {
        std::cout << A[i] << " ";
    }
    std::cout << A[n - 1] << std::endl;
}

void swapval(int& a, int& b) {
    const int tmp = a;
    a = b;
    b = tmp;
}

void bubbleSort(std::vector<int>& A) {
    const int N = A.size();
    bool flag = true;
    int cnt = 0;
    int i = 0;
    while (flag) {
        flag = false;
        for (int j = N - 1; j > i; --j) {
            if (A[j] < A[j-1]) {
                swapval(A[j], A[j - 1]);
                flag = true;
                ++cnt;
            }
        }
        ++i;
    }
    output(A);
    std::cout << cnt << std::endl;

}


int main() {
    int n; std::cin >> n;
    std::vector<int> A(n);
    for (int i = 0; i < n; ++i) std::cin >> A[i];

    bubbleSort(A);

    return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
  int i,j,k;
  int n;
  cin>>n;
  vi a(n);
  rep(i,n)cin>>a[i];
  sort(all(a));
  int alice=0,bob=0;
  rep(i,n)
    if(i%2)bob+=a[n-1-i];
    else alice+=a[n-1-i];
  cout<<alice-bob<<endl;
}


Measured memory_bytes: 256
from collections import deque

H,W = map(int,input().split())
field = ["#"*(W+2)]
field += ["#"+input()+"#" for _ in range(H)]
field += ["#"*(W+2)]
d = [[-1]*(W+2) for _ in range(H+2)]
q = deque()
q.append([1,1])
d[1][1] = 1
dmov = [(-1,0),(1,0),(0,-1),(0,1)]
cnt = 0
for i in range(W+2):
  for j in range(H+2):
    if field[j][i] == ".":
      cnt += 1

while len(q) > 0:
  node = q.popleft()
  x = node[0]
  y = node[1]
  c = d[y][x]
  for i,j in dmov:
    xx = x+i
    yy = y+j
    if d[yy][xx] == -1 and field[yy][xx] == ".":
      d[yy][xx] = c+1
      q.append([xx,yy])
      
if d[H][W] == -1:
  print(-1)
else:
  print(cnt-d[H][W])

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  
  if(a==b && b!=c){
    cout << "Yes";
    return 0;
  }else if(b==c && b!=a){
    cout << "Yes";
    return 0;
  }else if(a==c && b!=a){
    cout << "Yes";
    return 0;
  }else{
    cout << "No\n";
  return 0;
  }
}

Measured memory_bytes: 256
def dfs(lst):
    global ans
    if len(lst) > n:
        return
    lowest = 1
    if lst != []:
        lowest = lst[-1]
    for i in range(lowest, m+1):
        lst.append(i)
        dfs(lst)
        lst.pop()
    if len(lst) == n:
        cnt = 0
        for i in range(q):
            a, b, c, d = ab[i]
            if lst[b-1] - lst[a-1] == c:
                cnt += d
        ans = max(cnt, ans)

n,m,q = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(q)]
ans = 0
dfs([])

print(ans)

Measured memory_bytes: 9140
n = int(input())
lst = list(map(int, input().split()))
m1 = {}
m2 = {}
for i in range(0, n, 2):
    if lst[i] in m1:
        m1[lst[i]] += 1
    else:
        m1[lst[i]] = 1
    if lst[i+1] in m2:
        m2[lst[i+1]] += 1
    else:
        m2[lst[i+1]] = 1
if max(m1, key=m1.get) != max(m2, key=m2.get):
    mm = n - max(m1.values()) - max(m2.values())
else:
    mm1 = max(m1.values())
    mm2 = max(m2.values())
    m1[max(m1, key=m1.get)] = 0
    m2[max(m2, key=m2.get)] = 0
    mm = min(n - max(m1.values()) - mm2, n - max(m2.values()) - mm1) 
print(mm)

Measured memory_bytes: 17056
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

ll power(ll a, ll b) {
	ll result = 1;
	while(b) {
		if(b % 2) result = (result * a) % P;
		a = (a * a) % P;
		b /= 2;
	}
	
	return result;
}

ll divide(ll a, ll b) {
	return a * power(b, P - 2) % P;
}

void solve() {
	int s;
	cin >> s;
	
//	---1--------------------------------------------------------	
//	ll ans = 0;
//	for(int i = 1; i <= s; i++) {
//		int n = s - 3 * i;
//		if(n < 0) break;
//		
//		ll res = 1;
//		for(int j = 1; j <= n + i - 1; j++) res = (res * j) % P;
//		for(int j = 1; j <= n; j++) res = divide(res, j);
//		for(int j = 1; j <= i - 1; j++) res = divide(res, j);
//		
//		ans = (ans + res) % P;
//	}

//	---2--------------------------------------------------------
//	int ans = 0;
//	
//	vi dp(s + 1, 0);
//	dp[0] = 1;
//	for(int i = 0; i < s; i++) {
//		vi ndp(s + 1, 0);
//		int pre = 0;
//		for(int j = 3; j <= s; j++) {
//			(pre += dp[j - 3]) %= P;
//			(ndp[j] += pre) %= P;
//		}
//		
//		(ans += ndp[s]) %= P;
//		
//		dp = ndp;
//	}
//	
//	cout << ans << endl;

//	---3--------------------------------------------------------
	vi dp(s + 1, 0);
	dp[0] = 1;
	
	for(int i = 3; i <= s; i++) {
		for(int j = 3; j <= i; j++) (dp[i] += dp[i - j]) %= P;
	}
	
	cout << dp[s] << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

Measured memory_bytes: 3608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String tes = null;
		
		ArrayList<Integer> al = new ArrayList<Integer>();
		ArrayList<Integer> al2 = new ArrayList<Integer>();
		ArrayList<Integer> al3 = new ArrayList<Integer>();
		ArrayList<Integer> al4 = new ArrayList<Integer>();
		
		int a,b;
		String[] fruit;
		while(true){
			try {
				tes = br.readLine();
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
			
			fruit = tes.split(",", 0);
			
			a = Integer.parseInt(fruit[0]);
			b = Integer.parseInt(fruit[1]);
			if(a == 0 && b == 0){
				break;
			}
			al.add(a);
			al2.add(b);
		}
		
		while(true){
			try {
				tes = br.readLine();
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
			if(tes == null){
				break;
			}
			
			if(tes.equals("")){
				break;
			}
			al3.add(Integer.parseInt(tes));
		}
		
		
		for(int i=0;i<al.size();i++){
			for(int j=i;j<al.size();j++){
				if(al2.get(i) <= al2.get(j)){
					a = al2.get(i);
					al2.set(i, al2.get(j));
					al2.set(j, a);
					
					a = al.get(i);
					al.set(i, al.get(j));
					al.set(j, a);
				}
			}
		}
		
		int f = 1;
		int c = 0;
		
		for(int i=0;i<al.size();i++){
			
			
			
			if(i != (al.size() -1) &&al2.get(i) ==al2.get(i+1)){
				f++;
			}
			
			if(i != (al.size() -1) &&al2.get(i) != al2.get(i+1)){
				c++;
				for(int j=0;j<f;j++){
					al4.add(c);
				}
				
				f=1;
			}
			if(i == (al.size() -1)){
				c++;
				for(int j=0;j<f;j++){
					al4.add(c);
				}
			}
			
			
		}
		
		
		for(int j=0;j<al3.size();j++){
			for(int i=0;i<al.size();i++){
				
				if(al3.get(j) == al.get(i)){
					System.out.println(al4.get(i));
				}
				
			}
		}
	}
			

}

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

int main() {
  int A,B;
  cin >> A >> B;
  if( A > B ){
   cout << A*2-1 <<endl;
  }
  else if ( A == B ){
    cout << A*2 << endl;
  }
  else {
    cout << B*2-1 << endl;
  }
}
  


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

sum_c = 0
for _ in range(N):
    A = int(input())
    choco = 0
    for i in range(0, 100):
        day = i * A + 1
        if day > D:
            break
        choco += 1
    sum_c += choco
print(sum_c + X)

Measured memory_bytes: 3060
n = int(input())
hh = list(map(int,input().split()))

count = 0
gr = [0]*n

for i in range(1,n):
    if hh[i-1] >= hh[i]:
        count += 1
        gr[i] = count
    else:
        count = 0
        gr[i] = 0        
print(max(gr)) 

Measured memory_bytes: 15020
#include <stdio.h>
int main(){
  int h1,h2,m1,m2,k,ans,ans1,ans2;
  scanf("%d %d %d %d %d", &h1, &m1, &h2,&m2, &k);
  ans1 = 60*h1+m1;
  ans2= 60*h2+m2;
  ans = ans2-ans1-k;
  printf("%d", ans);
  return 0;
}

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

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int ans[1000001];
ll sum[1000001];
bool is_prime[1000001];

int main(int argc, char const* argv[])
{
	int t;
	cin >> t;
	fill(is_prime, is_prime+1000001, true);
	is_prime[0] = false;
	is_prime[1] = false;
	for(int i = 2; i < 1000001; i++){
			if(is_prime[i]){
					ans[i] = i - 1;
					for(int j = 2; j * i < 1000001; j++){
							is_prime[j * i] = false;
					}
			}
	}
	sum[0] = 0;
	sum[1] = 2;
	for(int i = 2; i < 1000001; i++){
			if(!is_prime[i])ans[i] = i - 1 - ans[i];
			for(int j = 2; j * i < 1000001; j++){
					ans[j*i] += ans[i];
			}
			sum[i] = sum[i-1] + ans[i];
	}
	for(int i = 0; i < t; i++){
			int n;
			cin >> n;
			cout << sum[n] << endl;
	}
	return 0;
}



Measured memory_bytes: 15772
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in(),T=in();
	auto V=vecin(N);
	vector<int> R(N),D(N);
	R[N-1]=V[N-1];
	for(int i=N-2;i>=0;i--){
		R[i] = max(V[i],R[i+1]);
	}
	REP(i,N){
		D[i] = R[i]-V[i];
	}
	map<int,int> M;
	REP(i,N){
		M[D[i]]++;
	}
	
	out(M.rbegin()->second);
	return 0;
}

Measured memory_bytes: 6144
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        int[] NQ = ReadLineParseIntArray();
        string S = ReadLine();
        int[] counts = new int[NQ[1]];
        int[] memo = new int[NQ[0] + 1];
        for(int i = 2; i <= NQ[0]; i++)
        {
            memo[i] = memo[i - 1];
            memo[i] += S[i - 1] == 'C' && S[i - 2] == 'A' ? 1 : 0;
        }
        for(int i = 0; i < NQ[1]; i++)
        {
            int[] lr = ReadLineParseIntArray();
            counts[i] = memo[lr[1]] - memo[lr[0]];
        }
        for (int i = 0; i < NQ[1]; i++)
            WriteLine(counts[i]);
    }

    static int ReadLineParseInt() => int.Parse(ReadLine());
    static int[] ReadLineParseIntArray() => ReadLine().Split(' ').Select(int.Parse).ToArray();
}

Measured memory_bytes: 18868
"""
Tの文字にたいして、Sのインデックスをリストで持たせる
Tの頭から順繰りにたし上げていく（Loop数を数えること）
自分よりも大きい要素があれば、それを使うし、
なければ最も小さい要素を使いつつ、Loop数をCountUp
bisect_left()かな？

0123456
contest

01234567
sentence

s=[5]   -> 5  (6moji)
e=[4]   -> 7*1+4 (12moji)
n=[2]   -> 7*2+2 = 16
t=[3,6] -> 7*2+3 = 17
e=[4]   -> 7*2+4 = 18
n=[2]   -> 7*3+2 = 23
c=[0]   -> 7*4+0 = 28
e=[4]   -> 7*4+4 = 32 ( 33moji)
"""

from bisect import bisect_right, bisect_left
S = input()
T = input()

def calc(ch):
  return ord(ch) - ord('a')

## Tに含まれる文字に対し、Sのインデックスをふる
LST = [[] for _ in range(26)]
for t in T:
  nt = calc(t)
  if len(LST[nt]) > 0:
    continue
  for i in range(len(S)):
    if t == S[i]:
      LST[nt].append(i)
  if len(LST[nt]) == 0:
    print(-1)
    exit(0)
    
NS = len(S)
## Tの文字に対して順繰りにたしあげる
NofLoop = 0
now = 0
for i in range(len(T)):
  t = T[i]
  nt = calc(t)
  rel_now = now - NofLoop * NS
  if rel_now < LST[nt][0] :
    #print("R",t,nt,rel_now)
    now = NofLoop * NS + LST[nt][0] + 1
  elif LST[nt][-1] < rel_now :
    #print(t,i)
    NofLoop += 1
    now = NofLoop * NS + LST[nt][0] + 1
  else:
    idx = bisect_left(LST[nt], rel_now)
    #print(idx)
    now = NofLoop * NS + LST[nt][idx] + 1
    
print(now)

Measured memory_bytes: 12988
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <stack>
#include <queue>
#include <set>

#define mod 1000000007
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
using ll = long long;
using pii = pair<int, int>;

ll count(ll n){
    if(n == 1) return 1;
    return 2*count(n/2)+1;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll ans = count(n);
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		String s = sc.nextLine();
		char[] str = s.toCharArray();
		int len = s.length();
		
		Stack staNum = new Stack();
		Stack staOpr = new Stack();
		
		int num = 0;
		for(int i=0;i<len;i++) {
			num = 0;
			boolean f = false;
			while(i<len && str[i]<='9' && str[i]>='0') {
				num *= 10;
				num += str[i] - '0';
				i++;
				f = true;
			}
			if(f) {
				i--;
				staNum.push(num);
			}else if(str[i]=='+' || str[i]=='-' || str[i]=='*' || str[i]=='/'){
				int b = (int)staNum.pop();
				int a = (int)staNum.pop();
				switch(str[i]) {
					case '+': staNum.push(a + b); break;
					case '-': staNum.push(a - b); break;
					case '*': staNum.push(a * b); break;
					case '/': staNum.push(a / b); break;
					default: break;
				}
			}
/*			if(!staNum.isEmpty()) {
				System.out.println("sta.top(): " + staNum.top());
			}*/
		}
		System.out.println((int)staNum.pop());
	}
}
class Stack {
	Object[] value = new Object[200];
	int index = 0;
	
	public void push(Object o) {
		value[index++] = o;
	}
	
	public Object pop() {
		return value[--index];
		
	}
	
	public Object top() {
		return value[index-1];
	}
	
	public boolean isEmpty() {
		return index == 0;
	}
}



Measured memory_bytes: 26156
from itertools import permutations

n = int(input())
towns = [tuple(map(int, input().split())) for _ in range(n)]


def dist(i, j):
    return ((towns[i][0] - towns[j][0])**2 +
            (towns[i][1] - towns[j][1])**2)**0.5


ans = cnt = 0
for perm in permutations(range(n)):
    cand = 0
    for i in range(n - 1):
        cand += dist(perm[i], perm[i + 1])
    ans += cand
    cnt += 1

ans /= cnt
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int main(void){
    int n, m;
    while (cin>>n>>m && n) {
        vector<int> a(21,0), b(21,0);
        int t;
        for (int i = 0; i < n; i++) {
            cin >> t;
            a[t]++;
        }
        for (int i = 0; i < m; i++) {
            cin >> t;
            b[t]++;
        }
        int ans = 0;
        for (int i = 0; i < 21; i++) {
            ans += i * max(a[i], b[i]);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3060
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = getLine >>= print . minimum . map ( abs . subtract 753 . ( read :: String -> Int ) . take 3 ) . filter ( ( >= 3 ) . length ) . tails

Measured memory_bytes: 508
#include <iostream>
#include <iomanip>
using namespace std;
#define gc getchar_unlocked
#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define ll long long
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(s) scanf("%s", s)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(s) printf("%s\n", s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626

//=======================

int main()
{
    ios_base::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    int arr[1000000];
    for (int i = 0; i < m; i++)
    {
        cin >> arr[i];
    }
    long long sum = 0;
    for (int i = 0; i < m; i++)
    {
        sum += arr[i];
    }
    if (sum > n)
    {
        cout << -1 << endl;
    }
    else if (sum == n)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << n - sum << endl;
    }

    return 0;
}


Measured memory_bytes: 3644
awk 'function abs(x){
  return x < 0 ? -x : x
}
{
  N = $1
  L = $2
  a = N*(N-1)/2+N*L
  m = abs(L)
  k = L
  for(i=0;i<N;++i) if (m > abs(L + i)) {m = abs(L + i); k = L + i}
  print a - k
}'

Measured memory_bytes: 552
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

ll n;
ll c_ab[100003];
ll n_ab[100003];
ll c_ac[100003];
ll n_ac[100003];
vector<ll> node[100003];
void dfs_ab(ll x, ll cost){
    if(c_ab[x] == 1){
        return;
    }else{
        c_ab[x] = 1;
        n_ab[x] = cost;
        fore(d, node[x]){
            dfs_ab(d, cost + 1);
        }
    }
}
void dfs_ac(ll x, ll cost){
    if(c_ac[x] == 1){
        return;
    }else{
        c_ac[x] = 1;
        n_ac[x] = cost;
        fore(d, node[x]){
            dfs_ac(d, cost + 1);
        }
    }
}

int main(void){
    cin >> n;

    rep(i, 0, n-1){
        ll ta, tb;
        cin >> ta >> tb;
        ta--;
        tb--;
        node[ta].push_back(tb);
        node[tb].push_back(ta);
    }

    dfs_ab(0, 0);
    dfs_ac(n - 1, 0);

    ll f = 0, s = 0;
    rep(i, 0, n){
        if(n_ab[i] <= n_ac[i]){
            f++;
        }else{
            s++;
        }
    }
    if(f > s){
        cout << "Fennec" << endl;
    }else{
        cout << "Snuke" << endl;
    }

    return 0;


}


Measured memory_bytes: 11904
#include <iostream>
#include<math.h>
using namespace std;
int a[45];
int n;
int fib(int n){
    if(a[n-1]!=0){
    }else{
        a[n-1]=fib(n-1);
    }if(a[n-2]!=0){
    }else{
        a[n-2]=fib(n-2);
    }
    if(n==1)return 1;
    if(n==0)return 1;
    return a[n-1]+a[n-2];
}
    
int main(){
   
    cin >> n;
    fib(n);
    cout <<fib(n) <<endl;
}


Measured memory_bytes: 3104
#!/usr/bin/env python3
import sys


def solve(a: int, b: int):
    if a <= 0 <= b:
        print("Zero")
        return
    if 0 < a:
        print("Positive")
        return
    if (abs(a-b)+1) % 2 == 1:
        print("Negative")
        return
    print("Positive")

    return


# 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)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61808
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);

		while (true) {
			int n = s.nextInt();
			if (n == 0)
				break;

			int ptr = 0; // 得られた素数の数
			int[] prime = new int[2 * n];

			prime[ptr++] = 2;
			prime[ptr++] = 3;

			for (int t = 5; t <= 2 * n; t += 2) {
				boolean wflag = false;
				for (int i = 1; prime[i] * prime[i] <= t; i++) {
					if (0 == t % prime[i]) {
						wflag = true;
						break;
					}
				}
				if (!wflag) {
					prime[ptr++] = t;
				}
			}

			int count = 0;

			for (int i = 0; i < ptr; i++)
				if (prime[i] > n) {
					count++;
				}

			if (n == 1)
				count = 1;

			System.out.println(count);
		}
		s.close();
	}
}

Measured memory_bytes: 54396
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
using namespace std;
// using namespace _gnu_pbds;
#define vb __int128
#define ll long long
#define ld long double
#define full(a) a.begin(),a.end()
#define fr(i,a,b) for(ll i = a ; i < b ; i++)
#define stoink stack<ll>
#define quu queue<ll>
#define quee queue<pair<ll,ll>>
#define vec vector <ll>
#define vecd vector<ld>
#define vg vector<vector<ll> >
#define eg vector<pair<ll,ll>>
#define vgw vector<vector<pair<ll,ll> > >
#define pa pair<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define pre 0.00000000000000000001
#define inf 100000000
#define mod (ll)(1e9 + 7)
#define endl '\n'
vec fact(200005);
ll power(ll x,ll exp)
{ll res=1;while(exp>0){if(exp%2==1)res=((res%mod)*(x%mod)%mod);
 x=((x%mod)*(x%mod)%mod);exp=exp>>1;}return res;}
ll ncr(ll n,ll r) {
    ll ans = (fact[n] * power(fact[r],mod - 2)) % mod;
    ans = (ans * power(fact[n - r],mod - 2)) % mod;
    return ans;
}
int main()
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    fact[0] = 1;
    fr(i,1,200005) {
        fact[i] = (i * fact[i - 1]) % mod;
    }
    ll x,y,n;
    cin >> x >> y >> n;
    x--;
    y--;
    eg points;
    fr(i,0,n) {
        ll a,b;
        cin >> a >> b;
        a--;
        b--;
        points.pb({a,b});
    }
    ++n;
    points.pb({x,y});
    sort(full(points));
    vec dp(3001,0);
    fr(i,0,n) {
        dp[i] = ncr(points[i].ff + points[i].ss,points[i].ff);
        fr(j,0,i) {
            if(points[j].ff > points[i].ff || points[j].ss > points[i].ss)
                continue;
            ll temp = (dp[j] * ncr(points[i].ff - points[j].ff + points[i].ss - points[j].ss,points[i].ff - points[j].ff)) % mod;
            dp[i] = (dp[i] - temp + mod) % mod;         
        }
    }
    cout << dp[n - 1];
	return 0;
}	

Measured memory_bytes: 5116
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}

ll i,j,k,ii,jj,n,m,a,b,c,d,e,f,g,h,r,w,l;
ll num,ans,sum,ok,ng;
ll x[500005],y[500005],z[500005];
char s[500005],t[500005],u[500005];
bool dame,flag;

int main(){
	double a,b;
	cin >> a >> b;
	ps((a/b));
	return 0;
}


Measured memory_bytes: 24576
#include <cstdio>
#include <vector>
int main() {
  long long a, b, c, d;
  scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
  std::vector <long long> x, y;
  x.push_back(a);
  x.push_back(b);
  for (long long xx = -1; xx <= 1; ++xx) {
    if (a <= xx && xx <= b) {
      x.push_back(xx);
    }
  }
  y.push_back(c);
  y.push_back(d);
  for (long long xx = -1; xx <= 1; ++xx) {
    if (c <= xx && xx <= d) {
      y.push_back(xx);
    }
  }
  long long res = a * c;
  for (auto xx: x) {
    for (auto yy: y) {
      long long z = xx * yy;
      if (z > res) {
        res = z;
      }
    }
  }
  printf("%lld\n", res);
  return 0;
}


Measured memory_bytes: 3224
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <iomanip>
#include <cmath>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

ll BASE_NUM = 1000000007;

int main()
{
    // 整数の入力
    ll A,B,V,W,T;
    cin >> A >> V >>  B >> W >> T;
    ll d = abs(A- B);
    ll vv =  V - W;
    if (vv <= 0){
        cout << "NO" << endl;
    }else{
        ll t = (d + vv - 1)/vv;
        if (t <= T){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3596
#[allow(unused_imports)]
use {
    proconio::{fastout, input, marker::*},
    std::cmp::*,
    std::collections::*,
    std::ops::*,
};

const M: usize = 1000000007;

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n]
    }
    let mut sum = 0;
    for i in 0..n {
        sum += a[i];
        sum %= M;
    }
    let mut ans = 0;
    for i in 0..n - 1 {
        sum = (sum + M - a[i]) % M;
        ans += (a[i] * sum) % M;
        ans %= M;
    }
    println!("{}", ans);
}


Measured memory_bytes: 5644