akhauriyash/Code-Regression huggingface dataset:
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n;
int d[300];

int main(){
	while(cin>>n){
		rep(i,n){
			cin>>d[i];
		}
		int p = 0;
		unsigned long long int dp[100][22]={0};//dp[i][j]
		dp[0][d[0]] = 1;
		for(int i = 1;i < n-1;i++){
			for(int j = 0;j <=20;j++){
				if(dp[i-1][j]>0){
					if(j+d[i] <=20){
						dp[i][j+d[i]] +=dp[i-1][j];
					}
					if(j-d[i]>=0)
						dp[i][j-d[i]] +=dp[i-1][j];
				}
			}
		}
		int sum = 0;
		for(int i = 0;i <=1000000000;i++){
			sum +=1;
		}
		cout <<dp[n-2][d[n-1]]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1176
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
import java.util.function.Function;


public class Main {
    Scanner sc = new Scanner(System.in);

    double function(final double y, double a, final double dx) {
        double nx = a + dx;
        if (Math.abs(Math.floor(a) - Math.floor(nx)) < 1e-6) {
            double sx1 = Math.floor(a);
            double sx2 = sx1 + 1;
            double rx1 = Math.floor(nx);
            double rx2 = rx1 + 1;
            double dist = Math.min(a - sx1 + nx - rx1, sx2 - a + rx2 - nx);
            return y + dist;
        } else {
            return y + nx - a;
        }
    }

    void run() {
        double d = sc.nextDouble();
//        double d = Math.sqrt(1.25);
        double max = d * Math.sqrt(2);
//        debug(max);
        for (int i = 1; i <= 10; ++i) {
            if (d < i) {
                break;
            }
            // (0, i) <-> (10, i)
            final double dx = Math.sqrt(d * d - i * i);
//            final double y = i;
            // (0, 0) <-> (1, 0)
//            double x = goldenSectionSearch(0, 1, a -> function(y, a, dx), Comparator.comparingDouble(Double::doubleValue));
            if (Math.floor(dx) < 1) {
                max = Math.max(max, i + 1);
            } else {
                max = Math.max(max, i + dx);
            }
//            double res = function(y, x, dx);
//            debug(y, dx, res);
//            max = Math.max(max, res);
        }
        System.out.printf("%.16f", max);
        System.out.println();
    }

    final static double GOLDEN_RATIO = (1.0 + Math.sqrt(5)) / 2.0;

    double goldenSectionSearch(double left, double right, Function<Double, Double> f, Comparator<Double> comp) {
        double c1 = divideInternally(left, right, 1, GOLDEN_RATIO);
        double c2 = divideInternally(left, right, GOLDEN_RATIO, 1);
        double d1 = f.apply(c1);
        double d2 = f.apply(c2);
        for (int i = 0; i < 10000000; ++i) {
            if (comp.compare(d1, d2) > 0) {
                right = c2;
                c2 = c1;
                d2 = d1;
                c1 = divideInternally(left, right, 1, GOLDEN_RATIO);
                d1 = f.apply(c1);
            } else {
                left = c1;
                c1 = c2;
                d1 = d2;
                c2 = divideInternally(left, right, GOLDEN_RATIO, 1);
                d2 = f.apply(c2);
            }
        }
        return left;
    }

    double divideInternally(double a, double b, double m, double n) {
        return (n * a + m * b) / (m + n);
    }

    int ni() {
        return sc.nextInt();
    }

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

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

Measured memory_bytes: 28180
N,K=map(int,input().split())
ans = 0
for i in range(1,N+1):
    if i>= K:
        ans += (1/N)
    else:
        cnt = 0
        t = i
        while(True):
            i *= 2
            cnt += 1
            if i >= K:
                ans += (t/N)*(1/i)
                break
print(ans)

Measured memory_bytes: 38768
from math import sqrt
inpl = lambda: list(map(int,input().split()))
N = int(input())
ans = [0]*(N+1)
M = int(sqrt(N-1))
for x in range(1,M):
    for y in range(x,M):
        n = x*x + y*y + 1 + x*y + y + x
        if n > N:
            break
        for z in range(y,M):
            n = x*x + y*y + z*z + x*y + y*z + z*x
            if n > N:
                break
            elif x==y==z:
                ans[n] += 1
            elif x==y or y==z:
                ans[n] += 3
            else:
                ans[n] += 6
for n in range(1,N+1):
    print(ans[n])


Measured memory_bytes: 69740
#include"iostream"
#include"cmath"
#include"string"
#include"string.h"
#include"algorithm"
#include"vector"
#include"map"
#include"queue"
#include"stack"
#include"set"
#include"climits"
#include"deque"
#include"tuple"
#include"iomanip"
using namespace std;
#define int                  int64_t
#define double               long double
#define vi                   vector<int>
#define di                   deque<int>
#define si                   set<int>
#define vpii                 vector<pair<int,int>>
#define dpii                 deque<pair<int,int>>
#define pi                   pair<int,int>
#define pub                  push_back
#define puf                  push_front
#define pob                  pop_back
#define pof                  pop_front
#define all(a)               (a).begin(),(a).end()
#define rall(a)              (a).rbegin(),(a).rend()
#define PI                   3.1415926535897932384626433832795
#define rep(i,s,n)           for(int i = s; i < n; ++i)
#define repe(i,s,n)          for(int i = s; i <= n; ++i)
#define repr(i,n,s)          for(int i = n;i >= s; --i)
#define read(a)              for(auto& x : a) cin >> x
#define speak(a)             for(auto x : a) cout << x << ' '
#define work(x,a)            for(auto& x : a)
#define endl                 '\n'
#define gap                  ' '
#define MAX                  LLONG_MAX
#define MIN                  LLONG_MIN
#define min3(a,b,c)          min(a, min(b, c))
#define max3(a,b,c)          max(a, max(b, c))
#define MOD                  1000000007
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    map<string,int>mp;
    int n;cin >> n;
    rep(i,0,n)
    {
        string s;cin >> s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
}


Measured memory_bytes: 3644
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
    int n, sum = 0;
    scanf("%d", &n);
    int a[n + 2];
    a[0] = 0;
    a[n + 1] = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i + 1]);
        sum += abs(a[i + 1] - a[i]);
    }
    sum += abs(a[n + 1] - a[n]);
    for (int i = 1; i < n + 1; i++) {
       printf("%d\n", sum + abs(a[i + 1] - a[i - 1]) - abs(a[i + 1] - a[i]) - abs(a[i] - a[i-1]) ); 
    }
    return 0;
}


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

#define lli long long int
#define pb push_back

lli dp[101][100001];

main()
{
    lli n,c,a,b,i,j;
    cin>>n>>c;
    lli w[n],v[n];

    for(i=0;i<n;i++)
    {
        cin>>w[i]>>v[i];
    }

    for(i=0;i<=c;i++)
    {
        if(i<w[0])
        {
            dp[0][i] = 0;
        }
        else
        {
            dp[0][i] = v[0];
        }
    }

    for(i=1;i<n;i++)
    {
        dp[i][0] = 0;
        for(j=1;j<=c;j++)
        {
            if(j<w[i])
            {
                dp[i][j] = dp[i-1][j];
            }
            else
            {
                dp[i][j] = max(dp[i-1][j] , (dp[i-1][j-w[i]] + v[i]));
            }
        }
    }

    cout<<dp[n-1][c];
}


Measured memory_bytes: 78336
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int A = scan.nextInt();
		int B = scan.nextInt();

		if (1 <= A && A <= 100) {
			if(1 <= B && B <= 100) {
				int ans = A * B;
				System.out.println(ans);
			}
		}
		scan.close();




	}

}


Measured memory_bytes: 35772
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int A,B,C;
inline void solve(){
  IN3(A,B,C);
  OUT(A^B^C);
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
const int INF = 0x3f3f3f3f;
//const double M_PI = acos(double(-1));

struct Point{ double x, y;};

void koch(int d, Point x1, Point x2){
	if(!d) return;
	Point s, u, t;
	double th = M_PI * 60.0 / 180.0;

	s.x = (2.0 * x1.x + x2.x) / 3.0;
	s.y = (2.0 * x1.y + x2.y) / 3.0;
	u.x = (x1.x + 2.0 * x2.x) / 3.0;
	u.y = (x1.y + 2.0 * x2.y) / 3.0;
	t.x = (u.x - s.x) * cos(th) - (u.y - s.y) * sin(th) + s.x;
	t.y = (u.x - s.x) * sin(th) + (u.y - s.y) * cos(th) + s.y;

	koch(d - 1, x1, s);
	printf("%.8f %.8f\n", s.x, s.y);
	koch(d - 1, s, t);
	printf("%.8f %.8f\n", t.x, t.y);
	koch(d - 1, t, u);
	printf("%.8f %.8f\n", u.x, u.y);
	koch(d - 1, u, x2);
}

int main(){
	int n;
	cin >> n;
	Point x1, x2;
	x1.x = 0.0; x1.y = 0.0; x2.x = 100.0; x2.y = 0.0;
	printf("%.8f %.8f\n", x1.x, x1.y);
	koch(n, x1, x2);
	printf("%.8f %.8f\n", x2.x, x2.y); 
	return 0;
}

Measured memory_bytes: 3152
n,a,b,k = map(int,input().split())
mod = 998244353

fact = [1,1]
finv = [1,1]
inv = [0,1]
 
for i in range(2,n+5):
    fact.append((fact[-1]*i)%mod)
    inv.append((inv[mod%i]*(mod-mod//i))%mod)
    finv.append((finv[-1]*inv[-1])%mod)
 
def nCr(n,r,mod):
    if r > n:
        return 0
    else: 
        return fact[n]*finv[r]*finv[n-r]%mod

def nPr(n,r,mod):
    if r > n:
        return 0
    else: 
        return fact[n]*finv[n-r]%mod


ans = 0
for i in range(n+1):
    if i*a > k:
        break
    d = k-i*a
    if d%b or d//b > n:
        continue
    ans += nCr(n,i,mod)*nCr(n,d//b,mod)%mod
    ans %= mod
print(ans)

Measured memory_bytes: 44928
#include <cstddef>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>



using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;

    int n, k;
    cin >> n >> k;

    vec<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];

    sort(h.begin(), h.end());

    int minV = numeric_limits<int>::max();
    for (int i = 0; i < n - k + 1; i++) {
        int d = h[i + k - 1] - h[i];
        minV = min(minV, d);
    }

    cout << minV << endl;

    
    return 0;
}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int k,x;
  cin >> k >> x;

  if(k*500>=x) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}




Measured memory_bytes: 3660
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE RecordWildCards       #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.Foldable               as F
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    [n, k] <- map read.words <$> getLine :: IO [Int]
    xs <- U.unfoldrN n (B.readInt.B.dropWhile isSpace) <$> B.getLine
    print $ solve n k xs

solve :: Int -> Int -> U.Vector Int -> Int
solve n k xs = F.foldl' max (f k) [f $ g i | i<-[0..63], testBit k i]
  where
    f x = U.sum $ U.map (xor x) xs
    g i = F.foldl' (.|.) (k .&. complement (bit (i + 1) - 1))
        [bool 0 (bit j) $ 2 * (freq U.! j) < n | j<-[0..i-1]]

    !freq = U.generate 64 $ \i ->
        U.length $ U.filter (flip testBit i) xs


Measured memory_bytes: 6012
N = gets.to_i
S = gets.chomp.chars
MOD = 10 ** 9 + 7
table = Hash.new { 0 }

S.each do |ch|
  table[ch] += 1
end

n = 1
table.values.each do |v|
  n = n * (2 + v - 1) % MOD
end
puts n - 1


Measured memory_bytes: 6908
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef int keytype;

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int main(){
    int n, x;
    int a[100];

    scanf("%d %d", &n, &x);
    for(int i = 0; i < n; ++i){
        scanf("%d", &a[i]);
    }

    quicksort(a, 0, n-1);
    int sum = 0;
    int ans;
    for(int i = 0; i < n; ++i){
        sum += a[i];
        if(sum > x){
            ans = i;
            break;
        }else if(sum == x){
            ans = i + 1;
        }else{
            if(i == n - 1){
                ans = i;
            }else{
                ;
            }
        }
    }

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 1736
#include <iostream>
#include <stdio.h>
#include <stdint.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <deque>

using namespace::std;

int ri()
{
	int x;
	scanf("%d", &x);

	return x;
}

int64_t ri64()
{
	int64_t x;
	scanf("%lld", &x);

	return x;
}

void wi(int x)
{
	printf("%d\n", x);
}

void wvi(vector<int> &v)
{
	for (int i = 0; i < v.size(); i++)
		printf("%d ", v[i]);
	printf("\n");
}

void dbg(string &str, int x)
{
	cout << str << ": ";
	wi(x);
}

void dbg(string &str, vector<int> &x)
{
	cout << str << ": ";
	wvi(x);
}

int64_t mod = 1000000007;

int main()
{
        int N = ri();
        string str;
        cin >> str;

        if (str[0] != 'B')
        {
                wi(0);
                return 0;
        }

        vector<int> A(2 * N);
        A[0] = 0;

        for (int i = 1; i < 2 * N; i++)
        {
                if (str[i] == str[i - 1])
                        A[i] = 1 - A[i - 1];
                else
                        A[i] = A[i - 1];

                //cout << i << " : " << str[i] << " " << str[i - 1] << " : " << A[i] << endl;
        }

        /*
        for (int i = 0; i < 2 * N; i++)
                cout << A[i] << " ";
        cout << endl;
        */

        bool ok = true;
        int cnt = 0;

        for (int i = 0; i < 2 * N; i++)
        {
                if (A[i] == 0)
                        cnt++;
                else
                        cnt--;

                if (cnt < 0)
                {
                        ok = false;
                        break;
                }
        }

        if (cnt != 0)
                ok = false;

        if (!ok)
        {
                wi(0);
                return 0;
        }

        int64_t ans = 1;

        cnt = 0;
        for (int i = 0; i < 2 * N; i++)
        {
                if (A[i] == 0)
                        cnt++;
                else
                {
                       ans = (ans * cnt) % mod;
                       cnt--; 
                }
        }

        for (int64_t i = 1; i <= N; i++)
                ans = (ans * i) % mod;

        wi(ans);

	return 0;
}


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

using i64 = long long;

const int N = 1000000 + 7;

int n;
int a[N], b[N];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d", a + i);
	std::sort(a + 1, a + n + 1, [](int a, int b) { return a > b; });
	for (int i = n; i; --i)
		b[i] = a[i] != a[i + 1] ? 1 : b[i + 1] ^ 1;
	for (int i = 1; i <= n; ++i)
		if (a[i + 1] < i + 1) {
			if (a[i] == i)
				printf(b[i] ? "Second" : "First");
			else
				printf((a[i] - i)  % 2 || (a[i + 1] == i && b[i + 1]) ? "First" : "Second");
			return 0;
		}
}


Measured memory_bytes: 4736
from sys import stdin
import numpy as np
N,M,Q = [int(x) for x in stdin.readline().rstrip().split()]

cumsum_2d = np.zeros([N+1,N+1]) 
for i in range(M):
    L,R = [int(x) for x in stdin.readline().rstrip().split()]
    cumsum_2d[L,R] += 1
    
np.cumsum(cumsum_2d,axis=0,out=cumsum_2d)
np.cumsum(cumsum_2d,axis=1,out=cumsum_2d)
    
for i in range(Q):
    p,q = [int(x) for x in stdin.readline().rstrip().split()]
    ans = cumsum_2d[q,q] - cumsum_2d[q,p-1] - cumsum_2d[p-1,q] + cumsum_2d[p-1,p-1]
    print(int(ans))

Measured memory_bytes: 16364
#include<iostream>
#include<stack>
#include<cstdio>
#include<map>
#include<set>
#include<queue>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
#define me(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
const int N=500005;
int main()
{
	int v[10][10]={0};
	int a[5][5],b[50000];
	int n,sum,w=0;
	me(v,0);
	for(int i=1;i<=3;i++)
	for(int j=1;j<=3;j++)
	cin>>a[i][j];
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>b[i];
		for(int j=1;j<=3;j++)
		{
			for(int k=1;k<=3;k++)
			{
				if(a[j][k]==b[i])v[j][k]=1;
			}
		}
	}
	for(int i=1;i<=3;i++)
	{
		sum=0;
		for(int j=1;j<=3;j++)
		{
			if(v[i][j]==1)sum++;
		}
		if(sum==3)
		{
			w=1;break;
		}
	}
	for(int i=1;i<=3;i++)
	{
		sum=0;
		for(int j=1;j<=3;j++)
		{
			if(v[j][i]==1)sum++;
		}
		if(sum==3)
		{
			w=1;break;
		}
	}
	if(v[1][1]==1&&v[2][2]==1&&v[3][3]==1)w=1;
	if(v[1][3]==1&&v[2][2]==1&&v[3][1]==1)w=1;
	if(w==1)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
from collections import deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    N=int(input())

    minroute=10**15
    for i in range(1,int(N**0.5)+2):
        if N%i==0:
            minroute=min(minroute,i+(N//i)-2)

    print(minroute)




resolve()

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

int main() {
  int h,w;
  cin>>h>>w;
  vector<vector<char>> tab(h,vector<char>(w));
  vector<int> r;
  vector<int> c;
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>tab.at(i).at(j);
    }
  }

  int cnt=0;
  
  for(int i=0;i<h;i++){
    cnt=0;
    for(int j=0;j<w;j++){
      if(tab.at(i).at(j)=='.') cnt++;
    }
  if(cnt!=w) r.push_back(i);
  }

  for(int i=0;i<w;i++){
    cnt=0;
    for(int j=0;j<h;j++){
      if(tab.at(j).at(i)=='.') cnt++;
    }
  if(cnt!=h) c.push_back(i);
  }

  for(int x:r){
    cnt=0;
    for(int y:c){
      if(cnt==c.size()-1) {
        cout<<tab.at(x).at(y)<<endl;
        break;
      }
      cout<<tab.at(x).at(y);
      cnt++;
    }
      
  }
  return 0;
}



Measured memory_bytes: 3492
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n = inp()
vlist = np.array(inpl())
vlist.sort()
temp = vlist[0]
for i in range(len(vlist)):
    temp = (temp + vlist[i])/2.0
print(temp)

Measured memory_bytes: 12548
n = int(input())
P =[]
s = 0
for i in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for i in range(n):s += (P[i][0]*P[i+1][1] - P[i][1]*P[i+1][0])
print(abs(s)*0.5)

Measured memory_bytes: 7708
package main

import (
	"bufio"
	"fmt"
	"index/suffixarray"
	"math"
	"os"
	"regexp"
	"strconv"
	"strings"
)

func main() {

	s := ScanWord()
	if count(s) {
		P("Yes")
	} else {
		P("No")
	}
}

func count(s string) bool {
	if len(s) < 2 {
		return false
	}
	for len(s) > 0 {
		if strings.HasPrefix(s, "hi") {
			s = s[2:]
		} else {
			return false
		}
	}
	return true
}

func countR(s string) int {
	r := regexp.MustCompile("hi")
	index := suffixarray.New([]byte(s))
	return len(index.FindAllIndex(r, -1))
}

/*********************** I/O ***********************/

var in *bufio.Scanner
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt()
	}
	return arr
}
func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }
func LCM(a, b int64) int64   { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

int main() {
	string s;
	string front = "";
	string back = "";

	cin >> s;
	int q;
	cin >> q;
	int re = 0;

	for (int i = 0;i < q;i++) {
		int t;
		cin >> t;
		if (t == 1) {
			re++;
		}
		else {
			int f;
			char c;
			cin >> f >> c;
			if (re % 2 == 0) {
				if (f == 1) {
					front = c + front;
				}
				else {
					back = back + c;
				}
			}
			else
			{
				if (f == 1) {
					back = back + c;
				}
				else {
					front = c + front;
				}
			}
		}
	}
	s = front + s + back;

	if (re % 2 == 1) {
		reverse(s.begin(), s.end());
	}

	cout << s << endl;
	return 0;
}

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

int syc(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	string s;
	cin >> s;
	int a[s.length()];
	int b=0,c=0,min=99999;
	
	for(int i=0;i<s.length();i++){
					a[i]=s[i]-'0';
	}
	
	for(int i=0;i<=s.length()-3;i++){
		b += 100*a[i]+10*a[i+1]+a[i+2];
		c=abs(753-b);
		b=0;
		if(i==0)min=c;
		else if(i>0)if(c<min)min=c;
	}
	cout << min << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 100010
ll n,a[N];
ll f[N],g[N],h[N],cs[N];
int main(){
    cin>>n;lol(i,n)cin>>a[i];
    f[0]=1;
    for(ll i=1;i<N;i++)f[i]=f[i-1]*i%mod;
    g[n+1]=1;
    for(ll i=n;i>=1;i--)g[i]=g[i+1]*i%mod;
    for(ll i=1;i<n;i++){
	h[i+1]=f[i]*g[i+2]%mod;
    }h[1]=g[2];
    cs[0]=cs[1]=0;
    for(ll i=2;i<N;i++)cs[i]=(cs[i-1]+h[i])%mod;
    ll ans=0;
    lol(i,n){
	ll cur=cs[i+1]+cs[n-i]+h[1];
	ans=(ans+cur*a[i])%mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4096
d, n = map(int, raw_input().split())
t = [input() for i in range(d)]
a = [map(int, raw_input().split()) for i in range(n)]
dp = [[-1]*n for i in range(d)]
for i in range(n):
    if a[i][0] <= t[0] <= a[i][1]: dp[0][i] = 0
for i in range(1,d):
    for j in range(n):
        if a[j][0] <= t[i] <= a[j][1]:
            for k in range(n):
                if dp[i-1][k] >= 0: dp[i][j] = max(dp[i][j], dp[i-1][k] + abs(a[j][2] - a[k][2]))
ans = 0                
for i in range(n):
    ans = max(ans, dp[d-1][i])
print ans

Measured memory_bytes: 6992
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

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

	int ans = 0;
	for (int i = 0; i < 3; ++i) {
		if (s[i] == t[i]) { ++ans; }
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
K, N = list(map(int, input().split()))
A = sorted(list(map(int, input().split())))
dist = [min(abs(A[0]-A[-1]), K-abs(A[0]-A[-1]))]
for i in range(N-1):
    dist.append(min(abs(A[i+1]-A[i]), K-abs(A[i+1]-A[i])))
print(K-max(dist))

Measured memory_bytes: 87932
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <sstream>
#include <fstream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <tuple>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;

using ll=long long;

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <vll> vl2d;
typedef vector <vi> vi2d;
typedef vector <char> vc;
typedef vector <bool> vb;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <char,int> mci;
typedef map <int,int> mii;
typedef map <long,long> ml;
typedef map <string,string> mss;
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define foreach(x,arr) for(auto& x:arr)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define endl '\n' // Normal `cout << endl` flushes the output every time wich hit performance badly
#define INF 1000000000
#define MOD 1000000007
#define deb(x) cout<<#x<<": "<<x<<endl;
#define printArray(arr) for(auto x: arr) { cout<<x<<"\n"; }
#define printMatrix(mat) for(auto x: mat) { cout<<" "; printArray(x); cout<<endl; }
#define printMap(mmap) for(auto p: mmap) { cout<< p.first<<": "<<p.second<<endl; }
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define forch(ch,str) for(char& c : str)
#define FILL(a,b) memset(a,b,sizeof(a))
//Swift related stuff
#define append push_back
#define nil nullptr
#define guard(_condition) if (bool(_condition)){}
#define count size()
#define let auto
#define var auto
#define startsWith(str) rfind(str, 0)
#define prq priority_queue
#define tostr(argument) to_string(argument)
#define alphabet "abcdefghijklmnopqrstuvwxyz"

void join(const vector<string>& v, char c, string& s) {

   s.clear();

   for (vector<string>::const_iterator p = v.begin();
        p != v.end(); ++p) {
      s += *p;
      if (p != v.end() - 1)
        s += c;
   }
}

ll cost(vll costs, int n) {
    vll dp(n, INF);
    dp[0] = 0;
    dp[1] = abs(costs[0]-costs[1]);
    
    rep(i, 2, n) {
        dp[i] = min(dp[i-2] + abs(costs[i]-costs[i-2]),
                    dp[i-1] + abs(costs[i]-costs[i-1]));
    }
    return dp[n-1];
}


int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); // Fast input
    
    int n;
    cin>>n;
    vll arr;
    rep(i, 0, n) {
        ll num;
        cin>>num;
        arr.append(num);
    }
    cout<<cost(arr, n)<<endl;
    return 0;
}


Measured memory_bytes: 2804
import itertools
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

l = [i for i in range(1, n+1)]
prm = list(itertools.permutations(l))

a = prm.index(p)
b = prm.index(q)

print(abs(a-b))

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

#define ll            long long
#define pb            push_back
#define si            set <int>
#define F             first
#define S             second
#define mii           map<int ,int >
#define msi           map<string,int >
#define mis           map<int , string>
#define fr(i,a,b)     for(int  i=a;i<=b;i++)
#define loop(i,n)     for(int i=0;i<n;i++)
#define all(v)        v.begin(),v.end()
#define vi            vector<int >
#define vii           vector<pair<int , int >>
#define vs            vector<string>
#define sz(x)         (int )x.size()
#define M             1000000007
#define mp            make_pair
#define input(arr,n)  loop(i,n) cin>>arr[i]
#define output(arr,n) loop(i,n) cout<<arr[i]<<" "
#define mod           998244353
#define sof           sizeof
using namespace std;
int gcd(int a,int b){
  if(b==0)return a;
  return gcd(b,a%b);
}

bool isPrime(int num){
    
    if(num==2) return true;
    if(num<2 || num%2==0) return false;
    for(int i = 3; i*i <=num; i+=2) {
       if(num % i == 0) {
          
          return false;
       }
    }
    return true;
   
}

bool comp(const pair<int,int> &a,const pair<int,int> &b){
  return a.F>b.F;
}



void solve(){
  // a simple dp problem
  int n,k;
  cin>>n>>k;
  ll arr[n];
  input(arr,n);
  ll f[n];
  k=min(n,k);
  loop(i,k){
    f[i]=abs(arr[i]-arr[0]);
  }
  fr(i,k,n-1){
    int mi=INT_MAX;
    fr(j,1,k){
      if(mi>abs(arr[i]-arr[i-j])+f[i-j]){
        mi=abs(arr[i]-arr[i-j])+f[i-j];
      }
    }
    f[i]=mi;
  }
  cout<<f[n-1];
 


}




signed main()   
{
  ios_base::sync_with_stdio(false);
  cin.tie(0); 
  cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout); 
  #endif  

  int t;
  t=1;
  //cin>>t;
  loop(i,t){

      solve();
      if(i<t-1) cout<<"\n";
  }

  
  
  //directed graph
    



}
  


  



Measured memory_bytes: 5128
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

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

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	a := getInts(N)
	ans := 0
	for i := 0; i < N; i++ {
		if (i+1)%2 == 1 && a[i]%2 == 1 {
			ans++
		}
	}
	out(ans)
}


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

int main() {
    int n, a;
    cin >> n >> a;
    if (n < 1 || n > 10000 || a < 0 || a > 1000) {
        cout << "No" << endl;
    } else if (n % 500 <= a) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
grid = []
for _ in range(h):
    grid.append(list(input()))
 
dp = [[0]*(w+1) for i in range(h+1)]
#dp[i][j] = i,jでの最小の操作回数
 
if grid[0][0] == '#':
    dp[0][0] += 1
 
for i in range(1,h):
    p = 0
    if grid[i][0] == '#' and grid[i-1][0] == '.':
        p += 1
    dp[i][0] = dp[i-1][0] + p
 
for i in range(1,w):
    p = 0
    if grid[0][i] == '#' and grid[0][i-1] == '.':
        p += 1
    dp[0][i] = dp[0][i-1] + p
 
for x in range(1,h):
    for y in range(1,w):
        a,b = 0,0
        if grid[x][y] == '#' and grid[x-1][y] == '.':
            a += 1
        if grid[x][y] == '#' and grid[x][y-1] == '.':
            b += 1
        dp[x][y] = min(dp[x-1][y] + a,dp[x][y-1] + b)
print(dp[h-1][w-1])
#print(dp)

Measured memory_bytes: 42224
a, b, c, x, y = map(int, input().split())

cost_min = 1000000 * 5000
for i in range(2 * max(x, y) + 1):
    cost = c * i
    if x - i // 2 > 0:
        cost += a * (x - i // 2)
    if y - i // 2 > 0:
        cost += b * (y - i // 2)
    cost_min = min(cost, cost_min)
print(cost_min)

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

const ll INF = 1e18;
const int MX = 2005;

int main() {
  ll n,k;
  cin >> n >> k;
  ll h[n];
  ll dp[n+k];
  rep(i,n) cin >> h[i];
  rep(i,n) dp[i] = INF;
  dp[0] = 0;
  rep(i,n){
    rep(j,k){
      if(h[i+j+1] > h[i]){
        dp[i+j+1] = min(dp[i+j+1],dp[i] + h[i+j+1] - h[i]);
      }else{
        dp[i+j+1] = min(dp[i+j+1],dp[i] - h[i+j+1] + h[i]);
      }
    }
  }
  cout << dp[n-1] << endl;
  return 0;
}

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

int x;

void merge(int s[], int left, int middle, int right);
void merge_sort(int s[], int begin, int end);


int main()
{
    x = 0;
    int n;
    cin >> n;
    int s[n];

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

    merge_sort(s, 0, n);

    for(int i = 0; i < n; i++)
    {
        if(i) cout << " ";
        cout << s[i];
    }

    cout << endl;
    cout << x << endl;
    
    return 0;
}

void merge(int s[], int begin, int middle, int end, int n)
{
    int i;
    int l = middle - begin;
    int r = end - middle;

    int L[n], R[n];
    for(i = 0; i < l; i++)
    {
        L[i] = s[i+begin];
    }

    for(i = 0; i < r; i++)
    {
        R[i] = s[i+middle];
    }

    L[l] = INT_MAX;
    R[r] = INT_MAX;

    i = begin;
    int j = 0, k = 0;
    while(!(j == l && k == r)){
        if(L[j] <= R[k])
        {
            s[i] = L[j];
            i++;
            j++;
        }
        else
        {
            s[i] = R[k];
            i++;
            k++;
        }
        
        x++;
    }



}

void merge_sort(int s[], int begin, int end)
{
    if(begin == (end - 1)) return ;
    int middle = (begin + end) / 2;

    merge_sort(s, begin, middle);
    merge_sort(s, middle, end);
    merge(s, begin, middle, end, end);

}


Measured memory_bytes: 8868
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int R=stdIn.nextInt();
		if(N>=10)
			System.out.println(R);
		else
			System.out.println(100*(10-N)+R);
	}
}


Measured memory_bytes: 23764
#include <stdio.h>

int main(void){
	int h,w;
	int i,j;

	do{
		scanf("%d %d",&h,&w);
		if(h == 0&&w == 0){
			break;
		}

		for(i = 0;i < w;i++){
			printf("#");
		}
		printf("\n");
		for(i = 0;i < h-2;i++){
			printf("#");	
			for(j = 0;j < w-2;j++){
				printf(".");
			}
			printf("#\n");
		}
		for(i = 0;i < w;i++){
			printf("#");
		}
		printf("\n\n");
	}while(1);

	return 0;
}

Measured memory_bytes: 588
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main (void)
{
    int h1, m1, h2, m2, k;

    scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);

    printf("%d", ((h2 * 60 + m2) - (h1 * 60 + m1) - k));

    return 0;
}


Measured memory_bytes: 1732
#include<iostream>
#include<vector>
#include<string>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int N;cin>>N;
	for(int i=0;i<N;i++){
		int a1,a2;
		int x,y,b,p;//x:入浴料y:プール料b:入用枚数p:プール枚数
		cin>>x>>y>>b>>p;
		a1=x*b+y*p;
		if(b>=5&&p>=2)a1=a1*0.8;
		
		if(b<5)b=5;
		if(p<2)p=2;
		a2=(x*b+y*p)*0.8;
		
		cout<<min(a1,a2)<<endl;
		//cout<<x<<" "<<y<<endl;
	}
	return 0;
}

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

int main() {
  int n,i,x;
  int t;
  int a[10000];

  cin >> n;

  a[0] = 1;
  x = 1;
  t = 6;
  while(t <= n){
    a[x] = t;
    x++; t = t*6;
  }

  t = 9;
  while(t <= n){
    a[x] = t;
    x++; t = t*9;
  }

  sort(a,a + x);

  ll dp[n + 1];
  rep(j,0,n + 1) dp[j] = 100100100100;

  dp[0] = 0;
  rep(j,0,x) dp[a[j]] = 1;

  int j,k;
  for(i = 1;i <= n;i++){
    for(j = 0;j < x;j++){
      if(i + a[j] > n) break;

      dp[i + a[j]] = min(dp[i + a[j]],dp[i] + 1);
    }
  }

  cout << dp[n] << endl;

  return 0;
}


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

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define ll long long
#define pii pair<int, int>
#define is insert
#define er erase

using namespace std;

const int MAX_N = 1e5 + 1;

int solve();

#define TASK ""

int main()
{
    #ifdef DEBUG
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
        //freopen(TASK".in", "r", stdin);
        //freopen(TASK".out", "w", stdout);
    #endif // DEBUG
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

int n;

ll a[MAX_N];

int solve()
{
    cin >> n;
    ll ans = 0;
    bool t = false;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        if (a[i] % 2 == 1)
        {
            t = true;
        }
    }
    if (t)
    {
        cout << "first" << endl;
    }
    else
    {
        cout << "second" << endl;
    }
    return 0;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  rep(i, 1, 50001) {
    if ((i * 108) / 100 == n) {
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1000000007;
int n;
char s[300003];
int dp[300003][3][3];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	dp[0][0][0]=1;
	for(int i=0;i<n;i++)
		for(int j=0;j<3;j++)
			for(int k=0;k<3;k++)
			{
				if(s[i+1]!='0')
				{
					if(k==0) dp[i+1][min(j+1,2)][k]=(dp[i+1][min(j+1,2)][k]+dp[i][j][k])%mod;
					else dp[i+1][j][k-1]=(dp[i+1][j][k-1]+dp[i][j][k])%mod;
				}
				if(s[i+1]!='1')
				{
					if(k==2) dp[i+1][j][1]=(dp[i+1][j][1]+dp[i][j][k])%mod;
					else dp[i+1][j][k+1]=(dp[i+1][j][k+1]+dp[i][j][k])%mod;
				}
			}
	int ans=0;
	for(int i=0;i<3;i++)
		for(int j=0;j<=i;j++)
			ans=(ans+dp[n][i][j])%mod;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 11136
void main() {
	writeln(canFind(rs, "AC") ? "Yes" : "No");
}

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

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0)

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }

    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int n,x,y;
vi a;

int main() {
    n = ri();
	x = ri(), y = ri();
	a.resize(n);
	FOR(i,n) a[i] = ri();
	if (n==1) {
		cout << abs(a[0]-y) << endl;
	} else {
		cout << max(abs(a[n-1]-y), abs(a[n-1]-a[n-2])) << endl;
	}
    return 0;
}


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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define sz(c) (static_cast<int>(c.size()))
#define endl "\n"

using ld = long double;
using ll = long long;

inline ll addm(ll __a, ll __b, ll __m);
inline ll subm(ll __a, ll __b, ll __m);
inline ll mulm(ll __a, ll __b, ll __m);
ll powm(ll __a, ll __b, ll __m);
ll inv(ll __x, ll __m);
// }}}

const ll INFL = numeric_limits<ll>::max() / 2;
const ll INF = numeric_limits<int>::max() / 2;
const ll MOD = 1e9+7;

const int _W = 100500;
const int N = 105;

ll dp[_W];
void solve()
{
    int n, W; cin >> n >> W;
    for (int i = 0; i < n; i++) {
        ll w, v; cin >> w >> v;
        for (int j = W; j >= w; j--) {
            dp[j] = max(dp[j], dp[j-w] + v);
        }
    }
    ll ans = 0;
    for (int i = 0; i <= W; i++)
        ans = max(ans, dp[i]);
    cout << ans << endl;
}

// main {{{
int main()
{
    cin.sync_with_stdio(0); cin.tie(NULL);
    solve();
    return 0;
}

inline ll addm(ll __a, ll __b, ll __m = MOD) {
    return ((__a+__b)%__m);
}
inline ll subm(ll __a, ll __b, ll __m = MOD) {
    return (((__a-__b)%__m+__m)%__m);
}
inline ll mulm(ll __a, ll __b, ll __m = MOD) {
    return ((__a*__b)%__m);
}
ll powm(ll __a, ll __b, ll __m = MOD) {
    ll ret = (!__b) ? 1 : powm(__a, __b/2, __m);
    return (!__b) ? 1 : mulm(mulm(ret, ret, __m), (__b%2) ? __a : 1, __m);
}
ll inv(ll __x, ll __m = MOD) {
    return powm(__x, __m-2, __m);
}
// }}}


Measured memory_bytes: 1024