akhauriyash/Code-Regression huggingface dataset:
<?php
        // Input < n,m,l
        $input = preg_split('/ /', trim(fgets(STDIN)));
        $n = $input[0];
        $m = $input[1];
        $l = $input[2];

        // Input < A(n*m)
        $arrayA = array();
        for($loop_n = 0; $loop_n < $n;  $loop_n++)
        {
                $input = preg_split('/ /', trim(fgets(STDIN)));
                if($m == count($input))
                {
                        $arrayA[] = $input;
                }
                else
                {
                        $loop_n--;
                }
        }

        // Input < B(m*l)
        $arrayB = array();
        for($loop_m = 0; $loop_m < $m;  $loop_m++)
        {
                $input = preg_split('/ /', trim(fgets(STDIN)));
                if($l == count($input))
                {
                        $arrayB[] = $input;
                }
                else
                {
                        $loop_m--;
                }
        }

        // Output < C(n*l)
        for($i = 0; $i < $n; $i++)
        {
                $ans = array();
                for($j = 0; $j < $l; $j++)
                {
                        $c = 0;
                        for($k = 0; $k < $m; $k++)
                        {
                                $c = $c + $arrayA[$i][$k] * $arrayB[$k][$j];
                        }
                        $ans[] = $c;
                }
                echo implode(' ' , $ans) . "\n";
        }
?>


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

using namespace std;

int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='7')
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


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

typedef long long LL;
typedef std::pair<LL, LL> pi;
const int mod = 1000000007;
void reduce(int & x) { x += x >> 31 & mod; }
int remod(LL x) { x %= mod; return x + (x >> 63 & mod); }
const int MAXN = 100;
LL fib[MAXN]; int bak;
pi li[MAXN][MAXN];
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	fib[1] = 1;
	for (bak = 1; fib[bak] <= 1e18; )
		fib[bak + 1] = fib[bak] + fib[bak - 1], ++bak;
	li[1][1] = pi(1, 2);
	for (int i = 2; i < bak; ++i) {
		for (int j = 1; j < i; ++j) {
			pi t = li[i - 1][j];
			li[i][j] = pi(t.second, t.first + t.second);
		}
		li[i][i] = pi(fib[i + 2], fib[i] + fib[i + 2]);
	}
	int Q; std::cin >> Q;
	while (Q --> 0) {
		LL x, y; std::cin >> x >> y;
		if (x > y) std::swap(x, y);
		int ax = std::upper_bound(fib + 2, fib + bak + 1, x) - fib - 2;
		int ay = std::upper_bound(fib + 2, fib + bak + 1, y) - fib - 2;
		int K = std::max(std::min(ax, ay - 1), 1);
		int ans = 0;
		for (int i = 1; i <= K; ++i) {
			pi t = li[K][i];
			for (int j = 0; j != 2; ++j) {
				if (t.first <= x && t.second <= y)
					reduce(ans += remod((y - t.second) / t.first + 1) - mod);
				std::swap(t.first, t.second);
			}
		}
		if (K == 1) reduce(ans += remod(x) - mod);
		std::cout << K << ' ' << ans << '\n';
	}
	return 0;
}


Measured memory_bytes: 4224
function Main(input) {
  input = input.trim()
  input = input.split(" ").map(Number);
  if(Math.abs(input[0]-input[2])<=input[3]||(Math.abs(input[0]-input[1])<=input[3]&&Math.abs(input[1]-input[2])<=input[3]))　console.log("Yes");
  else console.log("No")
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
# -*- coding: utf-8 -*-

import sys
from math import sqrt

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def is_prime(num):
    """ 素数判定 """
    if num < 2: 
        return False
    if num in [2, 3, 5]: 
        return True
    if num % 2 == 0 or num % 3 == 0 or num % 5 == 0:
        return False
    # 疑似素数(2でも3でも割り切れない数字)で次々に割っていく
    prime = 7
    step = 4
    num_sqrt = sqrt(num)
    while prime <= num_sqrt:
        if num % prime == 0:
            return False
        prime += step
        step = 6 - step
    return True

N = INT()
ans = 0
for i in range(N):
    a = INT()
    if is_prime(a):
        ans += 1
print(ans)



Measured memory_bytes: 5700
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

vector<int> a;
int n;

int partition(int s,int g){
    int x = a[g];
    int i = s - 1;
    for(int j=s;j<g;++j){
        if(a[j] <= x){
            i++;
            swap(a[i],a[j]);
        }
    }
    swap(a[i+1],a[g]);
    return i+1;
}

int main(){
    cin >> n;
    a.resize(n);
    for(int i=0;i<n;++i)cin >> a[i];
    int res = partition(0,n-1);
    for(int i=0;i<n;++i){
        if(i == res)cout << "[" << a[i] << "]";
        else cout << a[i];
        if(i!=n-1)cout << " ";
    }
    cout << "\n";
}


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

using namespace std;

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define debug(a) cout << #a << ": " << a << endl;

int main() {
  int N;
  cin >> N;
  vector<int> A(N + 1);
  rep(i, N + 1) { cin >> A[i]; }
  vector<int> B(N);
  rep(i, N) { cin >> B[i]; }

  ll cnt = 0;
  rep(i, N) {
    if (A[i] >= B[i]) {
      cnt += B[i];
    } else {
      int newA = A[i + 1] - (B[i] - A[i]);
      if (newA >= 0) {
        cnt += B[i];
        A[i + 1] = newA;
      } else {
        cnt += A[i];
        cnt += A[i + 1];
        A[i + 1] = 0;
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 1024
//header{{{
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/trie_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) begin(x),end(x)
#define Fixed fixed << setprecision(12)
#define int int_fast64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7;
constexpr int mod2 = 998244353;
 
template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}
 
    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};
 
template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
 
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
template <class T> using Set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class K, class V> using Umap = gp_hash_table<K, V>;
using Trie = trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update>;
 
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }
 
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};
//}}}

template<typename T>
vector<T> smallest_prime_factors(T n) {
 
    vector<T> spf(n + 1);
    for (int i = 0; i <= n; i++) spf[i] = i;
 
    for (T i = 2; i * i <= n; i++) {
        if (spf[i] == i) {
            for (T j = i * i; j <= n; j += i) {
                if (spf[j] == j) {
                    spf[j] = i;
                }
            }
        }
    }
 
    return spf;
}
 
template<typename T>
vector<T> factolization(T x, vector<T> &spf) {
    vector<T> ret;
    while (x != 1) {
        ret.push_back(spf[x]);
        x /= spf[x];
    }
    sort(ret.begin(), ret.end());
    return ret;
}

signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(10);

    int n;
    cin >> n;

    int res = 0;

    auto spf = smallest_prime_factors<int>(1e6+1);

    for(int i = 1; i < n; ++i){
        int x = n - i;
        Umap<int, int> cnt;
        for(auto&& e : factolization(x, spf)){
            ++cnt[e]; 
        }
        int tmp = 1;
        for(auto&& e : cnt){
            tmp *= e.second + 1;
        }
        res += tmp;
    }

    cout << res << '\n';

    return 0;
}

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

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

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


int main(){
	int n ,m;
	cin >>n >>m;
	VI gk(m);
	rep(i, m) cin >>gk[i];
	
	VI dp(n+3, 1<<27);
	dp[0]=0;
	
	rep(i, m) rep(j,n){
		if(j + gk[i] <= n ) dp[j + gk[i] ] = min(dp[j + gk[i] ] , dp[j] + 1);
	}
	cout << dp[n] <<"\n";
	return 0;
}




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

using namespace std;

char mapping['Z'];
bool seen[1 << 25];

int base_convert(const string &s) {
	int conv = 0;
	int pow4 = 1;
	for (auto c: s) {
		conv += mapping[c] * pow4;
		pow4 *= 4;

	}
	return conv;
}

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

	mapping['A'] = 1;
	mapping['C'] = 2;
	mapping['G'] = 3;
	mapping['T'] = 4;

	int n;
	cin >> n;

	while (n--) {
		string cmd, A;
		cin >> cmd >> A;
		if (cmd[0] == 'i') {
			seen[base_convert(A)] = true;
		} else {
			if (seen[base_convert(A)]) {
				cout << "yes";
			} else {
				cout << "no";
			}
			cout << '\n';
		}
	}
}


Measured memory_bytes: 4568
import java.math.*;
import java.util.*;
import java.io.*;

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

	ArrayList<Integer>[] g;
	int[] parent;
	int[] height;
	int[][] lca;

	void dfs(int cur, int par) {
		parent[cur] = par;
		for (int dst : g[cur]) {
			if (dst == par)
				continue;
			height[dst] = height[cur] + 1;
			dfs(dst, cur);
		}
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		lca = new int[N][N];
		ArrayList<Integer> list = new ArrayList<>();
		for (int i = 0; i < N; ++i)
			for (int j = 0; j < N; ++j) {
				lca[i][j] = -1;
			}
		g = new ArrayList[N];
		parent = new int[N];
		height = new int[N];
		int[] A = new int[N - 1];
		int[] B = new int[N - 1];
		Arrays.fill(parent, -1);
		for (int i = 0; i < N; ++i)
			g[i] = new ArrayList<Integer>();
		for (int i = 0; i < N - 1; ++i) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			--a;
			--b;
			g[a].add(b);
			g[b].add(a);
			A[i] = a;
			B[i] = b;
		}
		dfs(0, -1);
		{
			for (int u = 0; u < N; ++u) {
				for (int v = 0; v < N; ++v) {
					int curu = u;
					int curv = v;
					while (curu != curv) {
						if (height[curu] < height[curv]) {
							curu ^= curv;
							curv ^= curu;
							curu ^= curv;
						}
						curu = parent[curu];
					}
					lca[u][v] = curu;
				}
			}
			for (int h = N; h >= 0; --h) {
				for (int i = 0; i < N; ++i) {
					if (height[i] == h) {
						list.add(i);
					}
				}
			}
		}
		int M = sc.nextInt();
		int[] u = new int[M];
		int[] v = new int[M];
		for (int i = 0; i < M; ++i) {
			u[i] = sc.nextInt();
			v[i] = sc.nextInt();
			--u[i];
			--v[i];
		}
		long ans = 0;
		for (int s = 0; s < (1 << M); ++s) {
			int[] w = new int[N];
			for (int shift = 0; shift < M; ++shift) {
				if ((s >> shift) % 2 == 0)
					continue;
				int common = lca[u[shift]][v[shift]];
				w[u[shift]]++;
				w[v[shift]]++;
				w[common]--;
				w[common]--;
			}
			int ng = 0;
			for(int i=0;i<list.size();++i) {
				int cur=list.get(i);
				if(cur==0)continue;
				w[parent[cur]]+=w[cur];
				if(w[cur]>0) {
					++ng;
				}
			}
			int ok=N-1-ng;
			ans += (Integer.bitCount(s) % 2 == 0 ? 1 : -1) * (1L << ok);
		}
		System.out.println(ans);
	}

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

}


Measured memory_bytes: 92768
#include<cstdio>
#include<string>
#include<iostream>
using ll = long long;
using ull = unsigned long long;
const static unsigned MOD = 1000000007;
ull dp[2][13];

ll RepeatSquaring(ll N, ull P, ull mod){
	if(P == 0 || N == 1) return 1;
	if(N == -1) return P & 1 ? -1 : 1;
	if(!(P & 1)){
		ll t = RepeatSquaring(N, P >> 1, mod);
		return t*t %mod;
	}
	return N*RepeatSquaring(N, P - 1, mod) % mod;
}

int main(){
    std::string S;
    std::cin >> S;
    unsigned even = 0, sz = S.size(), ten = RepeatSquaring(10, sz-1, 13), decided = 0;
    dp[0][0] = 1;
    for (size_t i = 0; i < sz; i++){
        if(S[i] != '?') decided = (decided + (S[i] - '0')*ten) %13;
        else{
            even ^= 1;
            for (size_t remainder = 0; remainder < 13; remainder++) dp[even][remainder] = 0;
            for (size_t digit = 0; digit <= 9; digit++){
                for (size_t remainder = 0; remainder < 13; remainder++){
                    (dp[even][(remainder + digit*ten) % 13] += dp[even^1][remainder]) %= MOD;
                }
            }
        }
        ten = ten*4 %13;
    }
    printf("%llu\n", dp[even][(18 - decided) %13]);
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
//#include<bits/stdc++.h>
#include<cstdio>
#define ll long long
#define ull unsigned long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#include<cstring>
//#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
const int maxn=1e5+10;
const double eps=1e-6;
int a[maxn];
int main()
{
    int n;
    cin>>n;
    int cnt=0;
     rep(i,1,n+1)
     {
         scanf("%d",&a[i]);

     }
     rep(i,1,n+1)
     {
         if(i==a[i]&&i<n)
             swap(a[i],a[i+1]),cnt++;
          else if(i==a[i]&&i==n)
                swap(a[i],a[i-1]),cnt++;
     }
      cout<<cnt<<endl;

}


Measured memory_bytes: 3932
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on

const ll mod = 1000000007;

struct mint {
  ll x;
  mint(ll x = 0) : x(x % mod) {}
  mint& operator+=(const mint a)
  {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
};

mint pt[MAX_N + 1][MAX_N + 1];

bool ok(string l4)
{
  for (int i = 0; i < 4; i++) {
    string last4 = l4;
    if (i >= 1) {
      swap(last4[i - 1], last4[i]);
    }
    if (last4.find("AGC") != std::string::npos) {
      return false;
    }
  }
  return true;
}

int n;
map<string, mint> m[MAX_N];

mint dfs(int cur, string last3)
{
  if (m[cur].count(last3) > 0) return m[cur][last3];
  if (cur == n) return 1;
  mint ret = 0;
  string ACGT = "ACGT";
  for (int i = 0; i < 4; i++) {
    char c = ACGT[i];
    string last4 = last3 + c;
    if (ok(last4)) {
      ret = (ret + dfs(cur + 1, last3.substr(1, 2) + c));
    }
  }
  m[cur][last3] = ret;
  return ret;
}
int main(void)
{
  cin >> n;
  cout << dfs(0, "TTT").x << endl;
}


Measured memory_bytes: 768
N, K = map(int, input().split())
A = list(map(int, input().split()))
P = set([1])
Q = [1]
loop_st = 0
r = 0
i = 0

for _ in range(N):
  if A[i] not in P:
    P.add(A[i])
    Q.append(A[i])
    i = A[i] - 1
  else:
    loop_st = A[i]
    break

s = Q.index(loop_st)
loop_len = len(Q) - s

if K < s:
  print(Q[K])
else:
  r = (K - s) % loop_len
  print(Q[s+r])

Measured memory_bytes: 32600
#include <stdio.h>

int main()
{
	char S[11];
	scanf("%s", S);
	
	int i, j, l, flag[10] = {};
	long long sum = 0, tmp[10] = {};
	for (l = 0; S[l] != 0; l++);
	while (flag[l-1] == 0) {
		for (i = 0, j = 0, tmp[0] = S[0] - '0'; i < l - 1; i++) {
			if (flag[i] == 0) tmp[j] = tmp[j] * 10 + S[i+1] - '0';
			else tmp[++j] = S[i+1] - '0';
		}
		for (i = 0; i <= j; i++) sum += tmp[i];
		
		for (i = 0; flag[i] == 1; i++);
		for (flag[i--] = 1; i >= 0; i--) flag[i] = 0;
	}
	
	printf("%lld\n", sum);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

#define rep(i, a, b) for(auto (i)=a;i<b;i++)
#define list(i, N) for(auto (i)=0;i<N;i++)

typedef long long ll;
typedef vector <ll> vi;
typedef pair <ll, ll> pi;
#define mp make_pair
#define pb push_back
#define eb emplace_back

#define int double
#define INF 1e18+5
#define mod 1000000007

template<class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int32_t main() {

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

    long long n, k; cin >> n >> k;
    long long po[n]; list(i,n) cin >> po[i];
    double p[n];

    list(i,n){
        //if p[i] is odd
        if(po[i]%2==1){
            p[i] = po[i]/2 + 1;
        }else {
            int temp = po[i];
            int half = temp / 2;
            int curr = half + half + 1;
            curr /= 2;
            p[i] = curr;
        }
    }

//    list(i,n){
//        cout << "p[" << i << "] = " << p[i] << "\n";
//    }

    int prevSum = 0;
    list(i,k) prevSum += p[i];
    int best = prevSum;
    //run a window algo
    rep(i,1,n-k+1){
        int currSum = prevSum;
        currSum += p[i+k-1];
        currSum -= p[i-1];
        best = max(best,currSum);
        prevSum = currSum;
    }

//    cout << best << "\n";
    printf("%.12f\n",best);
    return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b&&b==c&&a%2==0)cout << -1;
  else{
    int i=0,p,q,r;
    while(a%2==0&&b%2==0&&c%2==0){
      p=a;
      q=b;
      r=c;
      a=(q+r)/2;
      b=(p+r)/2;
      c=(p+q)/2;
      i++;
    }
    cout << i;
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
vector<int> doublestep(int n){
  vector<int> A(0);
  while (n != 0){
    A.push_back(n%2);
    n /= 2;
  }
  reverse(A.begin(), A.end());
  return A;
}
const vector<int> modi = doublestep(mod-2);
int64_t inved(int64_t x){
  int64_t y = 1;
  for (int i=0;i<modi.size();i++){
    if (modi.at(i) == 1){
      y *= x;
      y %= mod;
    }
    if (i != modi.size() - 1){
      y *= y;
      y %= mod;
    }
  }
  return y;
}
int64_t frac(int64_t n){
  int64_t y = 1;
  for (int64_t i=0;i<n;i++){
    y *= i + 1;
    y %= mod;
  }
  return y;
}
int main(){
  int r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;
  int64_t f01, f02, f10, f20, f11, f22, f21, f12;
  f01 = inved(frac(r1));
  f02 = inved(frac(r2+1));
  f10 = inved(frac(c1));
  f20 = inved(frac(c2+1));
  f11 = frac(r1+c1);
  f22 = frac(r2+c2+2);
  f21 = frac(r1+c2+1);
  f12 = frac(r2+c1+1);
  int64_t g = 0LL;
  g += (((f22 * f02) % mod) * f20) % mod;
  g %= mod;
  g += (((f11 * f01) % mod) * f10) % mod;
  g %= mod;
  g += mod - (((f21 * f01) % mod) * f20) % mod;
  g %= mod;
  g += mod - (((f12 * f02) % mod) * f10) % mod;
  g %= mod;
  cout << g << endl;
  return 0;
}

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

int main()
{
    int n,m;
    cin >> n >> m;
    int a[n];
    for(int i=0;i<n;i++)
        cin >> a[i];
    for(int i=1;i<m+1;i++)
        for(int j=0;j<n-1;j++)
            if(a[j]%i>a[j+1]%i) swap(a[j],a[j+1]);
    for(int i=0;i<n;i++)
        cout << a[i] << endl;
    return 0;
}



Measured memory_bytes: 3108
import itertools

n,m,q = list(map(int, input().split()))
lst = [None for i in range(q)]
for i in range(q):
    a,b,c,d = list(map(int, input().split()))
    lst[i] = (a,b,c,d)

numlst = [i+1 for i in range(m)]
comb = list(itertools.combinations_with_replacement(numlst,n))

ans = 0
for i in comb:
    # print("i",i)
    koho = 0
    for Q in range(q):
        # print("Q", Q)
        # print("lst[Q]",lst[Q])
        if i[lst[Q][1]-1]-i[lst[Q][0]-1]==lst[Q][2]:
            koho+=lst[Q][3]
            # print("o")
    # print(koho)
    ans = max(ans, koho)

print(ans)


Measured memory_bytes: 21616
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
#define int long long
typedef long long ll;
using namespace std;

const int N = 222222;
pair<int, int> mo[N];
int n, d, a;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> d >> a;
    rep(i, 1, n) {
        cin >> mo[i].fi >> mo[i].se;
    }
    sort(mo + 1, mo + n + 1);
    vector<pair<int, int> > rem;
    int ri = 0, bo = 0;
    int ans = 0;
    rep(i, 1, n) {
        int x = mo[i].fi, h = mo[i].se;
        while(ri < rem.size() && rem[ri].fi < x) {
            bo -= rem[ri].se;
            ri++;
        }
        h -= bo * a;
        int need = max(0LL, (h + a - 1) / a);
        ans += need;
        bo += need;
        rem.pb(make_pair(x + 2 * d, need));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9072
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main() {
  int a_price, b_price, ab_price, a_need, b_need;
  cin >> a_price >> b_price >> ab_price >> a_need >> b_need;
  int cost = 0;
  if (a_price + b_price > ab_price * 2) {
    // buy ab pizza
    cost = min(a_need, b_need) * ab_price * 2;
  } else {
    // buy a and b separately
    cost = min(a_need, b_need) * (a_price + b_price);
  }
  if(a_need > b_need) {
    if (a_price > ab_price * 2) {
      cost += abs(a_need - b_need) * ab_price * 2;
    } else {
      cost += abs(a_need - b_need) * a_price;
    }
  } else {
    if (b_price > ab_price * 2) {
      cost += abs(a_need - b_need) * ab_price * 2;
    } else {
      cost += abs(a_need - b_need) * b_price;
    }
  }
  cout << cost;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
typedef long long ll;
const int N=20;
int n;
char s[N<<1],t[2][N],c[N];
ll dp[N][N];
int main() {
    scanf("%d%s",&n,s+1);
    for(int i=0;i<n;i++) c[i]=s[n*2-i];
    ll ans=0;
    for(int i=0;i<1<<n;i++) {
        int la=0,lb=0;
        for(int j=0;j<n;j++) if(i>>j&1) t[0][++la]=s[j+1];else t[1][++lb]=s[j+1];
        for(int j=0;j<=n;j++) for(int k=0;k<=la;k++) dp[j][k]=0;
        dp[0][0]=1;
        for(int j=0;j<n;j++) {
            for(int k=0;k<=j;k++) {
                if(!dp[j][k]) continue;
                int len=j-k;
                if(k<=j&&c[j]==t[0][k+1]) dp[j+1][k+1]+=dp[j][k];
                if(len<=j&&len<lb&&c[j]==t[1][len+1]) dp[j+1][k]+=dp[j][k];
            }
        }
        ans+=dp[n][la];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int n, b, f, r, v, room[4][3][10] = {{{0}}};
	int i, j, k;
	scanf("%d", &n);
	while (scanf("%d %d %d %d", &b, &f, &r, &v) != EOF)
		room[b - 1][f - 1][r - 1] += v;
	for (i = 0; i < 4; i++) {
		for (j = 0; j < 3; j++) {
			for (k = 0; k < 10; k++) {
				printf(" %d", room[i][j][k]);
			}
			putchar('\n');
		}
		if (i != 3)
			puts("####################");
	}
	return 0;
}

Measured memory_bytes: 612
def abs(x1,x2):
    if x1>x2:
        return x1-x2
    else:
        return x2-x1
    
n=int(input())
x=[]
y=[]
h=[]

for i in range(n):
    xi,yi,hi=map(int,input().split())
    x.append(xi)
    y.append(yi)
    h.append(hi)

hmax=h[0]
xhmax=x[0]
yhmax=y[0]
ihmax=0

for i in range(n):
    if hmax<h[i]:
        hmax=h[i]
        xhmax=x[i]
        yhmax=y[i]
        ihmax=i
    
for cx in range(101):
    for cy in range(101):
        hh=hmax+abs(xhmax,cx)+abs(yhmax,cy)
        yesno="yes"
        for i in range(n):
            if h[i]!=max(hh-abs(x[i],cx)-abs(y[i],cy),0):
                yesno="no"
                break
        if yesno=="yes":
            print(cx,cy,hh)

Measured memory_bytes: 3064
#include <iostream>
#include <queue>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;

int R,W,H,X,Y;
int f[500][500];
int v[500][500];
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};

class State
{
	public:
		int y,x,l;
		State(int a, int b, int c)
		{
			y=a; x=b; l=c;
		}

		bool operator<(const State &s) const
		{
			return l>s.l;
		}
};

void bfs(vector<int> &lv, vector<int> &rm)
{
	int nlv=0,nrm=0;

	memset(v,0,sizeof(v));
	priority_queue<State> q;

	v[Y][X] = 1;
	q.push(State(Y,X,f[Y][X]));

	while(!q.empty())
	{
		State s=q.top(); q.pop();
	
		if(nlv < s.l)
		{
			lv.push_back(nlv);
			rm.push_back(nrm);
			nlv = s.l;
		}
		nrm++;

		for(int i=0; i<4; i++)
		{
			int ny = s.y+dy[i];
			int nx = s.x+dx[i];

			if(0<=ny && ny<H && 0<=nx && nx<W)
			{
				if(!v[ny][nx])
				{
					v[ny][nx] = 1;
					q.push(State(ny,nx,f[ny][nx]));
				}
			}
		}
	}
	lv.push_back(nlv);
	rm.push_back(nrm);
}

int main()
{
	while(cin >> R, R)
	{
		vector<int> lv[2],rm[2];
		for(int k=0; k<2; k++)
		{
			cin >> W >> H >> X >> Y;
			for(int y=0; y<H; y++)
			for(int x=0; x<W; x++)
			{
				cin >> f[y][x];
			}

			X--; Y--;
			bfs(lv[k],rm[k]);
		}

		int ans = (1<<30);
		for(int i=0; i<rm[0].size(); i++)
		{
			int j = lower_bound(rm[1].begin(), rm[1].end(), R-rm[0][i]) - rm[1].begin();

			if(j<rm[1].size())
			{
				ans = min(ans, lv[0][i]+lv[1][j]);
			}
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 4888
s=list(input())
n=len(s)

cnt0=0
cnt1=0

for i in range(n):
  if i%2==0:
    cnt0+=(1-(0^int(s[i])))
    cnt1+=(1&int(s[i]))
  else:
    cnt0+=(1&int(s[i]))
    cnt1+=(1-(0^int(s[i])))
    
print(min(cnt0,cnt1))

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

int ms(int n) {
	int t = n, d = 0;
	while (t /= 10)
		++d;

	int s = 1;
	for (int i = 0; i < d; ++i)
		s *= 10;

	return n / s;
}

void solve() {
	int n, c[10][10] = { 0 };
	cin >> n;
	for (int i = 1; i <= n; ++i)
		++c[ms(i)][i % 10];

	int ans = 0;
	for (int i = 0; i <= 9; ++i)
		for (int j = 0; j <= 9; ++j)
			ans += c[i][j] * c[j][i];

	cout << ans << endl;
}

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

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

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        int output = 1;
        int dice[] = {1, 2, 3, 4, 5, 6, };
        for (int i = 0; i < n; i++) {
            string command;
            cin >> command;
            if (command == "North") {
                dice[0] = dice[1];
                dice[1] = dice[5];
            } else if (command == "East") {
                dice[2] = dice[0];
                dice[0] = dice[3];
            } else if (command == "West") {
                dice[0] = dice[2];
                dice[2] = dice[5];
            } else if (command == "South") {
                dice[1] = dice[0];
                dice[0] = dice[4];
            } else if (command == "Right") {
                dice[1] = dice[2];
                dice[2] = dice[4];
            } else if (command == "Left") {
                dice[2] = dice[1];
                dice[1] = dice[3];
            }
            dice[3] = 7 - dice[2];
            dice[4] = 7 - dice[1];
            dice[5] = 7 - dice[0];
            output += dice[0];
        }
        cout << output << endl;
    }
}

Measured memory_bytes: 0
n, k = map(int, input().split())
amari = 0
for i in range(k, n+1, 1):
  if i == 2:
    amari += (2*n - 1)%(pow(10, 9)+7)
  else:
    amari += (i*n - (1+(i-1))*(i-1) + 1)%(pow(10, 9)+7)
amari += 1
print(int(amari%(pow(10, 9)+7)))

Measured memory_bytes: 9200
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	static int m=1000000007;
	public static long Solve(int a[],int k) {
		int n=a.length;
		long dp[][]=new long[n][k+1];
		for(int i=0;i<=k;i++) {
			if(i>a[0]) break;
			else dp[0][i]=1;
		}
		
		for(int i=1;i<n;i++) {
			for(int j=0;j<=k;j++) {
				if(j==0) dp[i][j]=dp[i-1][j];
				else dp[i][j]=(dp[i-1][j]%m+dp[i][j-1]%m-(j>=a[i]+1?dp[i-1][j-1-a[i]]:0)%m+m)%m;
			}
		}
		return dp[n-1][k];
		
	}
	public static void main(String[] args) {
	FastScanner sc=new FastScanner();
	int n=sc.nextInt(),k=sc.nextInt();
	int a[]=sc.readArray(n);
	long ans=Solve(a, k);
	System.out.println(ans);

	}


	static class FastScanner{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		int [] readArray(int n) {
			int a[]=new int[n];
			for(int i=0;i<n;i++) a[i]=nextInt();
			return a;
		}
		
		
	}
	

}




Measured memory_bytes: 136756
import java.util.*;

public class Main {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }



    // int N = scanner.nextInt();
    // scanner.nextLine();
    // int[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    static void solve(Scanner scanner) {
        int N = scanner.nextInt(), M = scanner.nextInt();
        scanner.nextLine();
        int[] a = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        Queue<Integer> q = new PriorityQueue<>(Comparator.comparingInt(x -> -x));
        for (int n: a) {
            q.add(n);
        }

        for (int i = 0; i < M; i++) {
            q.add(q.poll() / 2);
        }

        long ans = 0;
        while (!q.isEmpty()) {
            ans = ans + q.poll();
        }

        System.out.println(ans);
    }

}


Measured memory_bytes: 53540
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
#include <string>
#include <math.h>
#define MOD 1000000007

using namespace std;
int main()
{
    int abcd;
    int a, b, c, d;
    cin >> abcd;
    a = abcd / 1000;
    b = abcd % 1000 / 100;
    c = abcd % 100 / 10;
    d = abcd % 10;
    if(a+b+c+d==7){
        cout<<a<<'+'<<b<<'+'<<c<<'+'<<d<<"=7"<<endl;
        return 0;
    }else if(a+b+c-d==7){
        cout<<a<<'+'<<b<<'+'<<c<<'-'<<d<<"=7"<<endl;
        return 0;
    }else if(a+b-c+d==7){
        cout<<a<<'+'<<b<<'-'<<c<<'+'<<d<<"=7"<<endl;
        return 0;
    }else if(a+b-c-d==7){
        cout<<a<<'+'<<b<<'-'<<c<<'-'<<d<<"=7"<<endl;
        return 0;
    }else if(a-b+c+d==7){
        cout<<a<<'-'<<b<<'+'<<c<<'+'<<d<<"=7"<<endl;
        return 0;
    }else if(a-b+c-d==7){
        cout<<a<<'-'<<b<<'+'<<c<<'-'<<d<<"=7"<<endl;
        return 0;
    }else if(a-b-c+d==7){
        cout<<a<<'-'<<b<<'-'<<c<<'+'<<d<<"=7"<<endl;
        return 0;
    }else if(a-b-c-d==7){
        cout<<a<<'-'<<b<<'-'<<c<<'-'<<d<<"=7"<<endl;
        return 0;
    }
    return 0;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const int INF = 1e9;

struct Edge{
  int to, cap, cost, rev;
  Edge(int to_=0, int cap_ = 0, int cost_ = 0, int rev_ = 0)
	:to(to_), cap(cap_), cost(cost_), rev(rev_){}
};

const int MAX_V = 400;
int V = MAX_V;
vector<Edge> G[MAX_V];
int dist[MAX_V];
int prevv[MAX_V], preve[MAX_V]; //??´??????????????¨???

void add_edge(int from, int to, int cap, int cost){
  G[from].push_back(Edge(to, cap, cost, G[to].size()));
  G[to].push_back(Edge(from, 0, -cost, G[from].size()-1));
}
int min_cost_flow(int s, int t, int f){
  int res = 0;
  while(f > 0){
	fill(dist, dist+V, INF);
	dist[s] = 0;
	bool update = true;
	while(update){
	  update = false;
	  for(int v=0;v<V;++v){
		if(dist[v] == INF) continue;
		for(int i=0;i<G[v].size();++i){
		  Edge& e = G[v][i];
		  if(e.cap > 0 && dist[v] + e.cost < dist[e.to]){
			dist[e.to] = dist[v] + e.cost;
			prevv[e.to] = v;
			preve[e.to] = i;
			update = true;
		  }
		}
	  }
	}

	if(dist[t] == INF) return -1;

	int d = f;
	for(int v=t;v!=s;v=prevv[v])
	  d = min(d, G[prevv[v]][preve[v]].cap);

	f -= d;
	res += d * dist[t];
	for(int v=t;v!=s;v=prevv[v]){
	  Edge& e = G[prevv[v]][preve[v]];
	  e.cap -= d;
	  G[v][e.rev].cap += d;
	}
  }
  
  return res;
}

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

  int N, M, K;
  cin >> N >> M >> K;

  int A = N + M + 1;
  int S = A + 1;
  int T = S + 1;
  int TT = T + 1;
  REP(i,N){
	int a; cin >> a;
	add_edge(i, A, 1, -a);
  }
  REP(j,M){
	REP(i,N){
	  int b; cin >> b;
	  add_edge(i, N+j, 1, -b);
	}
  }
  REP(j,M){
	int t; cin >> t;
	add_edge(N+j, T, t, 0);
  }
  add_edge(T, TT, N-K, 0);
  add_edge(A, TT, N, 0);
  REP(i,N)
	add_edge(S, i, 1, 0);

  cout << -min_cost_flow(S, TT, N) << endl;
  
  return 0;
}

Measured memory_bytes: 3452
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MAXN = 1e5+5;

int n, a[MAXN];
int x, y;

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	x = n+1, y = -1;
	for (int i = 0; i < n; ++i)
		x = min(x, a[i]), y = max(y, a[i]);
	if (y-x >= 2) {
		cout << "No\n";
		return 0;
	}

	if (y == x) {
		if (x <= n/2 || x == n-1)
			cout << "Yes\n";
		else
			cout << "No\n";
		return 0;
	}

	int ctx = 0, cty = 0;
	for (int i = 0; i < n; ++i)
		ctx += (a[i] == x), cty += (a[i] == y);

	if (y <= ctx+cty/2 && y >= ctx+1)
		cout << "Yes\n";
	else
		cout << "No\n";
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI acos(-1.0)
#define test() int t; cin>>t; while(t--)
#define ll long long int

int main()
{
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	cin >> n;
	vector<int> dp(3);
	while (n--) {
		vector<int> a(3, 0);
		vector<int> c(3);
		for (int i = 0; i < 3; i++) {
			cin >> c[i];
		}
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (i != j) {
					a[j] = max(a[j], dp[i] + c[j]);
				}
			}
		}
		dp = a;
	}
	cout << max({dp[0], dp[1], dp[2]});
	return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <cstdlib>
using namespace std;
#define ll long long
#define MAX 100005
#define pb push_back
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const double PI  =3.141592653589793238463;
long long MOD = 1000000007;

int stringToInteger(string x){
    int gg=0;
    stringstream geek(x);
    geek >> gg;
    return gg;
}

ll powmod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0){ if(b%2)
        {ans*=a; ans%=m;}
         b/=2; a=a*a; a=a%m;
        }
        return ans%m;
}
ll gcd(ll a,ll b)
{

    return __gcd(a,b);
}
ll mulmod(ll a,ll b,ll m)
{  ll ans=0;
    a %=m;
    while (b>0)
    {       if(b&1) ans = (ans + a) % m;
        a = (a * 2)%m;
        b /= 2;
    }
    return ans % m;
}

ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a;
 while(b > 0)
 	{
 		if(b%2 == 1)
 	{
 		x=(x*y);
 		if(x>MOD) x%=MOD;
 	}
 	y = (y*y);
 	if(y>MOD) y%=MOD;
 	b /= 2;
 	}
 return x;
}


bool prime[100005];
void seive()
{  memset(prime,true,sizeof(prime));
    for(int i=2;i*i<=100005;i++)
    {
         if(prime[i]==true) {
        for(int j=2*i;j<=(100005);j+=i)
           { prime[j]=false;}
           }

    }
}
 ll lcm(ll a, ll b)
 {
    return (a/gcd(a, b))*b;
 }
 ll fact(int n)
 {
     if(n==1) return 1;
     return n*fact(n-1);
 }
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  ll n,a,b;
  cin>>n>>a>>b;
  ll aa,bb;
  aa=max(a,b);
  bb = min(a,b);
  cout<<bb<<" "<<max(0ll,(aa+bb)-n)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

    // VI a[4];
    // REP(i,4) a[i] = s[i] - '0';

    ll n;
    cin >> n;
    VL a(n+1);
    a[0] = 2;
    a[1] = 1;
    FOR(i,2,n){
        a[i] = a[i-1] + a[i-2];
    }
    cout<< a[n] << endl;

    return 0;
}


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

int main() {
  long long N, K;
  cin >> N >> K;
  
  double d = double(N) / double(K);
  
  long long result;
  if (d - int(d) > 0) {
    result = 1;
  } else {
    result = 0;
  }
  
  cout << result << endl;
  
  return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#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 FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define sum(x)              accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

class CLamps {
public:
  static void solve(istream &cin, ostream &cout) {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    vector<int> check(N, N);
    rep(_, K) {
      if (A == check) break;
      vector<int> cum_sum(N + 1, 0);
      rep(i, N) {
        cum_sum[max(0LL, i - A[i])]++;
        cum_sum[min(N, i + A[i] + 1)]--;
      }
      rep(i, N) {
        cum_sum[i + 1] += cum_sum[i];
        A[i] = cum_sum[i];
      }
    }
    rep(i, N) cout << A[i] << " ";
    cout << endl;
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  CLamps solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 7932
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
    # combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

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

def main():
    n = int(input())
    a = readInt()
    ans = 0
    for i in range(1,n):
        if a[i-1]>a[i]:
            ans += a[i-1]-a[i]
            a[i] = a[i-1]
    print(ans)
    return

if __name__=='__main__':
    main()


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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int N;
	
	cin >> N;
	
	int a[N];
	int count_4 = 0, count_2 = 0;
	
	rep(i, N){
		cin >> a[i];
		if(a[i] % 4 == 0)
			count_4++;
		else if(a[i] % 2 == 0)
			count_2++;
	}
	
	if(N / 2 <= count_4 || count_4 + count_2 / 2 >= N / 2)
		cout << "Yes";
	else
		cout << "No";
	
	return 0;
}

Measured memory_bytes: 640
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int i = a; i <= (n); ++i)
#define repD(i, a, n) for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a) memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int maxn = 1019;
char g[maxn][maxn];

char g3[3][3] = {{ 'a', 'b', 'b' },
				 { 'a', '.', 'a' },
				 { 'b', 'b', 'a' }};

char g4[4][4] = {{ 'a', 'b', 'c', 'c' },
				 { 'a', 'b', 'd', 'd' },
				 { 'c', 'c', 'a', 'b' },
				 { 'd', 'd', 'a', 'b' }};

char g5[5][5] = {{ 'a', 'b', 'b', 'c', 'c' },
				 { 'a', '.', 'a', 'd', 'd' },
				 { 'b', 'b', 'a', 'e', 'e' },
				 { 'c', 'd', 'e', '.', '.' },
				 { 'c', 'd', 'e', '.', '.' }};

char g7[7][7] = {{ 'a', '.', '.', 'c', 'c', 'f', 'f' },
				 { 'a', '.', '.', 'd', 'd', 'g', 'g' },
				 { '.', 'b', 'b', 'e', 'e', 'h', 'h' },
				 { 'c', 'd', 'e', '.', '.', '.', '.' },
				 { 'c', 'd', 'e', '.', '.', '.', '.' },
				 { 'f', 'g', 'h', '.', '.', '.', '.' },
				 { 'f', 'g', 'h', '.', '.', '.', '.' }};

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	int n; cin >> n;
	if(n == 2){
		cout << -1 << endl;
		return 0;
	}
	rep(i,n) rep(j,n) g[i][j] = '.';
	if(n%3 == 0){
		rep(i,n/3){
			rep(ii,3){
				rep(jj,3){
					g[3*i + ii][3*i + jj] = g3[ii][jj];
				}
			}
		}
	}else{
		int nn = n;
		while(nn%5 != 0 && nn%7 != 0){
			int ni = nn - 4;
			rep(ii,4){
				rep(jj,4){
					g[ni + ii][ni + jj] = g4[ii][jj];
				}
			}
			nn -= 4;
		}
		if(nn%5 == 0){
			while(nn > 0){
				int ni = nn - 5;
				rep(ii,5){
					rep(jj,5){
						g[ni+ii][ni+jj] = g5[ii][jj];
					}
				}
				nn -= 5;
			}
		}else{
			while(nn > 0){
				int ni = nn - 7;
				rep(ii,7){
					rep(jj,7){
						g[ni+ii][ni+jj] = g7[ii][jj];
					}
				}
				nn -= 7;
			}
		}
	}
	rep(i,n){
		rep(j,n){
			cout << g[i][j];
		}
		cout << '\n';
	}
	return 0;
}



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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main() {
	llong S;
	cin >> S;

	llong ax, bx, by;
	llong upper_sqrt = sqrt(S)+1;
	ax = by = upper_sqrt;

	bx = upper_sqrt * upper_sqrt - S;

	if (S == 1000000000000000000ll) {
		cout << "0 0 1000000000 0 0 1000000000" << endl;
	} else {
		cout << "0 0 " << ax << " 1 " << bx << " " << by << endl;
	}

	return 0;
}

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

int main() {
	// your code goes here
	string s;
	cin>>s;
	if(s=="Sunny") cout<<"Cloudy\n";
	else if(s=="Cloudy") cout<<"Rainy\n";
	else if(s=="Rainy") cout<<"Sunny\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,m;
    cin>>n>>m;
    int arr[m];
    long long int ans=0;
    for(int i=0;i<m;i++)
    {
        cin>>arr[i];
        ans+=arr[i];
    }
    if(n-ans<0)
    cout<<"-1";
    else
    cout<<n-ans;
}

Measured memory_bytes: 3660
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)){
        	while(true) {
        		int n = sc.nextInt();
        		int m = sc.nextInt();
        		if(n==0 && m==0) break;
        		int [] score = new int[n+1];
        		for(int i=0;i<n;i++) {
        			score [i] = sc.nextInt();
        		}
        		score[n] = 0;
        		int [] sum = new int [(n+1)*(n+1)];
        		for(int i=0;i<n+1;i++) {
        			for(int j=0;j<n+1;j++) {
        	        	sum[(n+1)*i+j] = score[i]+score[j];
            		}
        		}
        		Arrays.sort(sum);
        		search:
        			for(int i=m;i>0;i--) {
        				for(int j=0;j<(n+1)*(n+1);j++) {
        					int low = 0;
            				int high = sum.length;
            				while(low<high) {
            					int mid = (low+high)/2;
            					if(sum[mid]==i-sum[j]) {
            						System.out.println(i);
            						break search;
            					}else if(sum[mid]>i-sum[j]) {
            						high = mid;
            					}else if(sum[mid]<i-sum[j]) {
            						low = mid+1;
            					}
            				}
        				}
        			}
        	}
        }
    }
}


Measured memory_bytes: 58940