akhauriyash/Code-Regression huggingface dataset:
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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


int solve(){
  int d,g;cin>>d>>g;
  int p[d]; int c[d];
  rep(i, d){ cin>>p[i]>>c[i]; }

  int ans = INF;
  rep(i, 1<<d){
    // i: bonus
    int res = 0;
    int s = 0;
    rrep(j, d){
      if (i>>j&1){
        s += (100*(j+1))*p[j];
        s += c[j];
        res += p[j];
      }
    }
    int r = g-s;
    if (r<=0) {
      chmin(ans, res);
      continue;
    }
    else{
      for(int j=d-1; j>=0; j--){
        if ((i>>j&1)==0){
          int num = min((r+(100*(j+1))-1)/(100*(j+1)), p[j]-1);
          r -= (100*(j+1))*num;
          res += num;
          if (r<=0){
            chmin(ans, res);
            break;
          }
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  [n,_] <- map (read::String->Int) . words <$> getLine
  s <- map (read::String->Int) . words . unwords . lines <$> getContents
  (putStrLn . unlines . map (show .length) . elemIndicesList [1..n]) s

elemIndicesList [] list = []
elemIndicesList (x:xs) list  = elemIndices x list : elemIndicesList xs list

Measured memory_bytes: 4272
N, Y = gets.chomp.split.map(&:to_i)

0.upto([N, Y / 10000].min) do |yukichi|
    n_remain = N - yukichi 
    y_remain = Y - yukichi * 10000
    if (y_remain - 1000 * n_remain) % 4000 == 0
        ichiyo = (y_remain - 1000 * n_remain) / 4000
        hideyo = (y_remain - ichiyo * 5000) / 1000
        if ichiyo >= 0 && hideyo >= 0
            print [yukichi, ichiyo, hideyo].join(' ')
            exit
        end
    end
end

print '-1 -1 -1'

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<queue>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
  int a,b,c;
  cin >>a >> b>>c;
  
  
  if (b-a == c-b){
  	cout << "YES";
  }else{
    cout << "NO";
  }
    return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int a, b;
	cin >> a >> b;
	if (10 <= a + b)
		cout << "error" << endl;
	else
		cout << (a + b) << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

#define int long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define yn(x) ((x) ? "YES" : "NO")

typedef pair <int, int> ii;
typedef pair <int, ii> iii;

const int siz = 1e5 + 10;
const int SIZ = 1e5 + 10;
const int mod = 1e9 + 7;
const int maxx = 2e9;
const int MAXX = 1e18;
const string file = "3";

int quickPow(int x, int n) {
    if (n == 0) {
        return 1;
    }

    int t = quickPow(x, n / 2);
    (t *= t) %= mod;

    if (n % 2 == 0) {
        return t;
    }
    return (t * x) % mod;
}

int fact[SIZ];

void precalc() {
    fact[0] = 1;
    for (int i = 1; i < SIZ; i++) {
        fact[i] = (fact[i - 1] * i) % mod;
    }
}

int choose(int n, int k) {
    if (n < k) {
        return 0;
    }

    return ((fact[n] * quickPow((fact[n - k] * fact[k]) % mod, mod - 2)) % mod);
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

//    freopen ((file + ".inp").c_str(), "r", stdin);
//    freopen ((file + ".out").c_str(), "w", stdout);

    precalc();

    int n;
    cin >> n;

    int d;
    map <int, int> mp;
    for (int i = 1; i <= n + 1; i++) {
        int a;
        cin >> a;

        if (mp.find(a) != mp.end()) {
            d = i - mp[a] + 1;
        }
        else {
            mp[a] = i;
        }
    }

    for (int k = 1; k <= n + 1; k++) {
        cout << (choose(n + 1, k) - choose(n + 1 - d, k - 1) + mod) % mod << "\n";
    }

//    cerr << "Time: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

    return 0;
}


Measured memory_bytes: 10656
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  string s;
  cin >> n >> s;
  int ans=0;
  REP(i,1,s.size()) {
    string t=s.substr(0,i);
    string r=s.substr(i);
    bool u[26],u2[26];
    mem(u);mem(u2);
    rep(j,t.size()) u[t[j]-'a']=1;
    rep(j,r.size()) u2[r[j]-'a']=1;
    int cnt=0;
    rep(j,26) {
      if(u[j]&&u2[j]) cnt++;
    }
    ans=max(ans,cnt);
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> board(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> board.at(i).at(j);
    }
  }
  
  vector<int> dx(4);
  dx = {1, 0, -1, 0};
  vector<int> dy(4);
  dy = {0, 1, 0, -1};
  
  bool can = true;  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (board.at(i).at(j) == '.') continue;
      bool can2 = false;
      for (int d = 0; d < 4; d++) {
        int ni = i + dy.at(d);
        int nj = j + dx.at(d);
        if (ni < 0 || H <= ni) continue;
        if (nj < 0 || W <= nj) continue;
        if (board.at(ni).at(nj) == '#') can2 = true;
      }
      if(!can2) can = false;
    }
  }
  
  can ? cout << "Yes" << endl : cout << "No" << endl;
}

Measured memory_bytes: 256
import numpy as np
N,L  = map(int,input().split())
L_list=np.array(range(1,N+1))+L-1
if (0 in L_list):
    print(sum(L_list))
    exit()
if(N<=abs(L) and L<0):
    print(sum(L_list)-L_list[N-1])
    
    exit()
else:
    print(sum(L_list)-L_list[0])
    exit()

Measured memory_bytes: 26884
from sys import stdin


def main():
    n = int(stdin.readline().rstrip())
    #a = [int(input()) for i in range(n)]

    ans = None
    tmp = None
    for a in range(n):
        i = int(input())
        # 最大値の計算
        if tmp is None:
            # tmp未定義の場合は定義するだけ
            tmp = i
        elif ans is None:
            ans = i - tmp
        elif i - tmp > ans:
            ans = i - tmp

        # 時系列で最も安い価格の保存
        if tmp == 0:
            tmp = i
        elif tmp > i:
            tmp = i
        else:
            pass

    return ans


if __name__ == '__main__':
    print(main())



Measured memory_bytes: 5620
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     .      '                    Udit Gupta @luctivud         ,              
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                            ##      ##  #######  # #  ######
                            ##      ##  ##   ##  ###    ##
                            ##      ##  ##    #  # #    ##
                            ####### ##  #######  # #    ##
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| WORSHIPPER OF GREED |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

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

const long long int MODPRIME {1000000007};

#define FASTINPUTOUTPUTLIKELIGHT()    ios_base::sync_with_stdio(false);
#define TESTCASES()                   long long int TestCases; cin>>TestCases; while(TestCases--)
#define mems(arr,val)                 memset((arr), val, sizeof((arr)))
#define endl                          "\n"

// ///////////////////////////////////////////////////////////////////////////////////////////////
//               : AREA TO DEFINE ALL THE HELPER FUNCTIONS USED IN THE PROGRAM :                //
// ///////////////////////////////////////////////////////////////////////////////////////////////


// ///////////////////////////////////////////////////////////////////////////////////////////////
//                                 : MAIN PROGRAM STARTS HERE :                                 //
// ///////////////////////////////////////////////////////////////////////////////////////////////

void solve() {
    long int days, n;
    cin >> days >> n;

    for (long int i=0; i<n; i++) {
        long int x;
        cin >> x;
        days -= x;
    }
    
    cout << max(-1L, days);
    return;
}

signed main() {
    FASTINPUTOUTPUTLIKELIGHT()
    // TESTCASES()
        solve();
    return 0;
}
/*
THE LOGIC AND APPROACH WAS DEVELOPED BY ME @luctivud.
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
PLEASE DO NOT PLAGIARISE.
*/

Measured memory_bytes: 3652
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>

#include <algorithm>

using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
const ll INF = 1ll << 60;

ll MOD = 1e9 + 7;

int main()
{

    int n;
    cin >> n;

    vector<ll> h(n);
    REP(i, n)
    cin >> h[i];

    int tmp = 0;
    int max = 0;
    for (int i = 0; i < n - 1; ++i)
    {
        if (h[i] >= h[i + 1])
        {
            tmp++;
            if (tmp > max)
            {
                max = tmp;
            }
        }
        else
        {
            tmp = 0;
        }
    }
    cout << max << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String[] s = S.split(""); 
        int N = s.length;
        
        boolean isnine = true;
        for(int i = 1; i < N; i++) {
            if(s[i].equals("9")) {
                continue;
            }else {
                isnine = false;
                break;
            }
        }
        
        int ans = 0;
        
        if(isnine) {
            for(int i = 0; i < N; i++) {
                ans += Integer.parseInt(s[i]);
            }
        }else {
            ans = Integer.parseInt(s[0]) + 8 + 9*(N-2);
        }
    
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <math.h>

using namespace std;

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

Measured memory_bytes: 256
N,Y = map(int,input().split(" "))
M10000,M5000,M1000 = -1,-1,-1
for a in range(N+1):
  for b in range(N-a+1):
    c = N - a - b
    total = 10000 * a + 5000 * b + 1000 * c
    if total == Y:
      M10000 = a
      M5000 = b
      M1000 = c
ans = str(M10000) + " " + str(M5000) + " " + str(M1000)
print(ans)

Measured memory_bytes: 3064
import numpy as np

N = int(input())
city = [0]*N
score = [0]*N
itetator = [0]*N
for i in range(N):
    city_i, score_str = input().split()
    city[i] = city_i
    score_i = int(score_str)
    score[i] = score_i
    itetator[i] = i+1
for j in range(N):
    for k in range(N-1):
        if city[k] > city[k + 1]:
            city[k], city[k + 1] = city[k + 1], city[k]
            score[k], score[k + 1] = score[k + 1], score[k]
            itetator[k], itetator[k + 1] = itetator[k + 1], itetator[k]

        elif city[k] == city[k + 1] and score[k] < score[k + 1]:
            score[k], score[k + 1] = score[k + 1], score[k]
            itetator[k], itetator[k + 1] = itetator[k + 1], itetator[k]


for m in range(N):
    print("{}".format(itetator[m]))


Measured memory_bytes: 12508
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  
  long int A, tmp=0, x=99999;
  
  for(int i=0; i<N; i++){
    cin >> A;
    
    while(1){
      if(A%2==0){
        tmp++;
        A = A/2;
      }else{
        x = min(tmp,x);
        tmp = 0;
        break;
      }
    }
  }
  
  cout << x << endl;
}

Measured memory_bytes: 256
sx, sy, gx, gy = map(int, input().split())

cx = gx - sx
cy = gy - sy

dx = abs(gx - sx)
dy = abs(gy - sy)

if cx >= 0 and cy >= 0:
  ans = 'U'*dy+'R'*dx+'D'*dy+'L'*dx
  ans += 'LU'+'U'*dy+'R'*dx+'RD'
  ans += 'RD'+'D'*dy+'L'*dx+'LU'
elif cx < 0 and cy >= 0:
  ans = 'U'*dy+'L'*dx+'D'*dy+'R'*dx
  ans += 'RU'+'U'*dy+'L'*dx+'LD'
  ans += 'LD'+'D'*dy+'R'*dx+'RU'
elif cx >= 0 and cy < 0:
  ans = 'D'*dy+'R'*dx+'U'*dy+'L'*dx
  ans += 'LD'+'D'*dy+'R'*dx+'RU'
  ans += 'RU'+'U'*dy+'L'*dx+'LD'
else:
  ans = 'D'*dy+'L'*dx+'U'*dy+'R'*dx
  ans += 'RD'+'D'*dy+'L'*dx+'LU'
  ans += 'LU'+'U'*dy+'R'*dx+'RD'
print(ans)


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

int dx[12] = {-2, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 2};
int dy[12] = {-1, 0, 1, -2, 2, -2, 2, -2, 2, -1, 0, 1};

int dx2[9] = {-1, -1, -1, 0, 0, 0, 1, 1, 1};
int dy2[9] = {-1, 0, 1, -1, 0, 1, -1, 0, 1};

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

    int px, py;
    while(cin >> px >> py){
        if(px == 0 and py == 0) return 0;
        
        int n;
        cin >> n;
        vector<P> A(n);
        
        for(int i = 0; i < n * 2; i++){
            if(i % 2 == 0) cin >> A[i / 2].first;
            else cin >> A[i / 2].second;
        }

        bool f = false;
        queue<pair<P, int>> q; // {{now}, now_idx}
        q.push({{px, py}, 0});
        while(!q.empty()){
            pair<P, int> t = q.front();
            q.pop();
            int nx, ny, ni;
            nx = t.first.first;
            ny = t.first.second;
            ni = t.second;
            if(ni == n){f = true; break;}

            int gx, gy;
            gx = A[ni].first;
            gy = A[ni].second;
            for(int i = 0; i < 12; i++){
                int ax, ay;
                ax = dx[i] + nx;
                ay = dy[i] + ny;
                if(ax < 0 or ay < 0 or ax > 10 or ay > 10) continue;
                for(int j = 0; j < 9; j++){
                    int gdx, gdy;
                    gdx = gx + dx2[j];
                    gdy = gy + dy2[j];
                    if(ax == gdx and ay == gdy){
                        q.push({{ax, ay}, ni + 1});
                    }
                }
            }
        }
        cout << (f ? "OK" : "NA") << endl;
    }

    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i,N)cin >> A[i];
    ll total = 0;
    REP(i,N){
        total += A[i]-1;
    }
    cout << total << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define lb lower_bound
#define ld long double
using namespace std;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	int a[n+1];
	int ans = 0;
	int mp[n+1]={};
	for(int i = 1;i<=n;i++){
		cin>>a[i];
		mp[a[i]]++;
	}
	for(int i = 1;i<=n;i++){
		if(mp[i]){
			int cnt = mp[i];
			//cout<<cnt<<" ";
			ans+=((cnt*(cnt-(int)1))/(int)2);
		}
	}
	for(int i = 1;i<=n;i++){
		int cnt = mp[a[i]];
		int temp = ans - (cnt*(cnt-(int)1))/(int)2;
		cnt--;
		if(cnt)
			temp+=(cnt*(cnt-(int)1))/(int)2;
		cout<<temp<<"\n";
	}
}

Measured memory_bytes: 5760
<?php
list($a, $b, $c, $k) = explode(' ', trim(fgets(STDIN)));

$max_sum = 0;

if ($a >= $k){
    $max_sum += $k;
} elseif ($a + $b >= $k) {
    $max_sum += $a;
} else {
    $max_sum += $a;
    $m1 = $k - ($a + $b);
    $max_sum -= $m1;
}

echo $max_sum;

Measured memory_bytes: 16272
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <list>
#include <map>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
    int n, x;
    cin >> n;
    vi a;
    int sum = 0;
    forn(i, n) {
        cin >> x;
        a.pb(x);
        sum += a[i];
    }
    int ans = 1 << 10, cur = 0;
    forn(i, n - 1) {
        cur += a[i];
        ans = min(ans, abs(cur - (sum - cur)));
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
    int n,m,count=0,i;
    scanf("%d %d",&n,&m);
    double b,vote=0;
    int a[100];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        vote=vote+a[i];
    }
    b=ceil((vote/(4*m)));
    for(i=0;i<n;i++)
    {
        if(a[i]>=b)
            count++;
    }
    if(count>=m)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


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

typedef long double ld;
typedef pair <int, int> ii;
typedef pair <ld, ii> ldii;

const int Maxn = 1005;

int n;
vector <ldii> seq;
ld res;

ld Get(ld x, ld y) { return sqrt(x * x + y * y); }

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int x, y; scanf("%d %d", &x, &y);
        if (x || y) seq.push_back(ldii(atan2(ld(y), ld(x)), ii(x, y)));
    }
    sort(seq.begin(), seq.end());
    for (int i = 0; i < seq.size(); i++) {
        ld curx = 0, cury = 0;
        for (int j = 0; j < seq.size(); j++) {
            int ind = (i + j) % seq.size();
            curx += seq[ind].second.first;
            cury += seq[ind].second.second;
            res = max(res, Get(curx, cury));
        }
    }
    cout << fixed << setprecision(15) << res << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		ArrayList<Double> list = new ArrayList<Double>();

		for(int i =  0;i < n;i++) {
			list.add(scan.nextDouble());
		}

		Collections.sort(list);

		for(int i = 1;i < n;i++) {
			list.set(i, (list.get(i) + list.get(i - 1)) / 2);
		}

		System.out.println(list.get(n - 1));
	}
}

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

int main(){
  int n,k;cin>>n>>k;
  int a=1;
  rep(i,n){
    a>k?a+=k:a*=2;
  }
  cout <<a;
}

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

#define INF 1e18
#define PI 3.141592653589793238
typedef long long ll;
#define N 200010

int main() {
    ll n,k;cin>>n>>k;
    //ll ans=INF, tmp=INF;
    n=n%k;
    while(n>(k/2)){
        n = abs(k-n);
    }
    cout<<n<<endl;
    

    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int ans = 700;
  if (s[0] == 'o')
    ans += 100;
  else {}
  if (s[1] == 'o')
    ans += 100;
  else {}
  if (s[2] == 'o')
    ans += 100;
  else {}
  cout << ans << endl;
}

Measured memory_bytes: 256
import javax.swing.*;
import javax.swing.plaf.synth.SynthSpinnerUI;
import java.sql.SQLOutput;
import java.util.Scanner;
import java.util.function.DoubleToIntFunction;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int b= sc.nextInt();
		System.out.print((int)a/b+" ");
		System.out.print((int)a%b+" ");
		System.out.print(String.format("%.5f", (double)a/b));
	}
}


Measured memory_bytes: 26444
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;



int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	map<int,int> m;
	ll ans=1,j,i,tp,n;
	cin>>n;
	if(i==1){
		cout<<i<<endl;
		return 0;
	}
	for(i=2;i<=n;i++){
		tp=i;
		j=2;
		while(tp!=1){
//			cout<<"tp"<<" "<<tp<<" "<<j<<endl;
			if(tp%j==0){
				while(tp%j==0){
					if(m.find(j)==m.end()){
						m[j]=1;
					}
					else{
						m[j]++;
					}
					tp/=j;
				}
			}
			j++;
		}
	}
	map<int,int>::iterator it; 
	for(it=m.begin();it!=m.end();it++){
		ans*=(it->second)+1;
		ans%=P;
//		cout<< (it->second) <<endl;
	}
	fin(ans);
	
//////////////////////////////////////////////////////
return 0;}











Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

// functions and classes

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

	ll A, B;
	cin >> A >> B;

	if (A >= 10 || B >= 10)
		cout << -1 << endl;
	else
		cout << A * B << endl;

	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    s = input()
    t = input()

    c = 0
    for i, j in zip(s, t):
        c += i == j

    print(c)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  bool flag = true;
  if(S[0] != 'A')
    flag = false;
  if('A' <= S[1] && S[1] <= 'Z')
    flag = false;
  int ccnt = 0;
  for(int i = 2; i < S.size() - 1; i++) {
    if(S[i] == 'C')
      ccnt++;
      continue;
    if('A' <= S[i] && S[i] <= 'Z')
      flag = false;
  }
  if('A' <= S[S.size() - 1] && S[S.size() - 1] <= 'Z')
    flag = false;
  if(ccnt != 1)
    flag = false;
  if(flag)
    cout << "AC" << endl;
  else
    cout << "WA" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
#define inf 0x3f3f3f3f

const int maxn = 4e3 + 10;
int n, a[maxn] = {0}, p[maxn] = {0}, yes[maxn] = {0}, inq[maxn];
long long d[maxn] = {0};

struct Edge{
    int from, to, cap, flow;
    long long cost;
    Edge(int u, int v, int c, int f, long long c2): from(u), to(v), cap(c), flow(f), cost(c2) {}
};

vector <Edge> edges;
vector <int> G[maxn];

void AddEdge(int from, int to, int cap, int cost);

long long Mincost(int s, int t);

bool Bellman(int s, int t, int &flow, long long &cost);

int main(){
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        int x, y, c;
        scanf("%d%d%d", &x, &y, &c);
        AddEdge(0, (i + 1), c, 0);
        long long a1 = x + y, a2 = x - y, a3 = y - x, a4 = -(x + y);
        AddEdge((i + 1), (n + 1), inf, -a1);//x + y
        AddEdge((i + 1), (n + 2), inf, -a2);//x - y
        AddEdge((i + 1), (n + 3), inf, -a3);//y - x
        AddEdge((i + 1), (n + 4), inf, -a4);//- x - y
    }
    for(int i = 0; i < n; i++){
        int x, y, c;
        scanf("%d%d%d", &x, &y, &c);
        AddEdge((n + 4 + (i + 1)), (n + 4 + n + 1), c, 0);
        long long a1 = x + y, a2 = x - y, a3 = y - x, a4 = - (x + y);
        AddEdge(n + 1, (n + 4 + i + 1), inf, -a4);// - x - y
        AddEdge(n + 2, (n + 4 + i + 1), inf, -a3);// - x + y
        AddEdge(n + 3, (n + 4 + i + 1), inf, -a2);// - y + x
        AddEdge(n + 4, (n + 4 + i + 1), inf, -a1);// x + y
    }
    long long cost = Mincost(0, n + 4 + n + 1);
    printf("%lld", -cost);
    return 0;
}

void AddEdge(int from, int to, int cap, int cost){
    edges.push_back(Edge(from, to, cap, 0, cost));
    edges.push_back(Edge(to, from, 0, 0, -cost));
    int m = edges.size();
    G[from].push_back(m - 2);
    G[to].push_back(m - 1);
}

long long Mincost(int s, int t){
    long long cost = 0;
    int flow = 0;
    while(Bellman(s, t, flow, cost));
    return cost;
}

bool Bellman(int s, int t, int &flow, long long &cost){
    memset(inq, 0, sizeof(inq));
    memset(yes, 0, sizeof(yes));
    d[s] = 0; yes[s] = 1; inq[s] = 1; p[s] = 0; a[s] = inf;
    queue <int> Q;
    Q.push(s);
    while(!Q.empty()){
        int u = Q.front(); Q.pop();
        inq[u] = 0;
        for(int i = 0; i < G[u].size(); i++){
            Edge &e = edges[G[u][i]];
            if(e.cap > e.flow && ((d[e.to] > d[u] + e.cost) || (yes[e.to] == 0) )){
                d[e.to] = d[u] + e.cost;
                p[e.to] = G[u][i];
                a[e.to] = min(a[u], e.cap - e.flow);
                yes[e.to] = 1;
                if(!inq[e.to]){Q.push(e.to); inq[e.to] = 1;}
            }
        }
    }
    if(yes[t] == 0){return false;}
    flow += a[t];
    cost += d[t] * (long long)a[t];
    for(int u = t; u != s; u = edges[p[u]].from){
        edges[p[u]].flow += a[t];
        edges[p[u] ^ 1].flow -= a[t];
    }
    return true;
}


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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ld a, b, h, m;
	cin >> a >> b >> h >> m;
	ld rot = 2 * acos(-1);
	rot *= (h / 12) + (m / 720);
	pd hour = mp(a * cos(rot), a * sin(rot));
	rot *= 12;
	pd min = mp(b * cos(rot), b * sin(rot));
	
	ld distance = (hour.f - min.f) * (hour.f - min.f) + (hour.s - min.s) * (hour.s - min.s);
	distance = pow(distance, 0.5);

	cout << fixed << setprecision(11);
	cout << distance;
}


Measured memory_bytes: 4140
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}
int lcm(int a, int b){return a*b / gcd(a, b);}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int M = 1000005;
    sort(a.begin(), a.end());

    vector<int> cnt(M);
    for(int x : a){
        if(cnt[x] != 0){
            cnt[x] = 2;
            continue;
        }
        for(int i = x; i < M; i += x) cnt[i]++;
    }
    int ans = 0;
    for(int x : a){
        if(cnt[x] == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8012
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int x = sc.nextInt();

		int pos = 0;
		int count = 1;
		for(int i = 0; i < n; i++) {
			pos += sc.nextInt();
			
			if(pos > x) {
				break;
			}
			
			count++;
		}
		
		System.out.println(count);
	}

}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,M;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N >> M;
}

int solve(){
    int t=1900*M+100*(N-M);
    cout << t*(1<<M) << endl;
    return 0;
}   

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


Measured memory_bytes: 256
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
#define biggest(A,B) A=max(A,B)
#define smallest(A,B) A=min(A,B)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int n,m,a[100000+2];
LL cf[100008],ccf[100008];
int main(){
	fastio;
	cin>>n>>m;
	rb(i,1,n){
		cin>>a[i];
	}
	LL res=0;
	rb(i,2,n){
		if(a[i]==a[i-1]) continue;
		if(a[i-1]<a[i]){
			res+=a[i]-a[i-1];
			if(a[i]-a[i-1]>=2){
				ccf[a[i-1]+2]++;
				ccf[a[i]+1]--;
				cf[a[i]+1]-=a[i]-a[i-1]-1;
			}
		} 
		else{//a[i-1]>a[i]
			res+=m-a[i-1]+a[i];
			if(m-a[i-1]+a[i]>=2){
				if(a[i-1]+2>m){
					int s=a[i-1]+2-m;
					ccf[s]++;
					ccf[a[i]+1]--;
					cf[a[i]+1]-=a[i]-s+1;
				}
				else{
					ccf[a[i-1]+2]++;
					cf[1]+=m-a[i-1];
					ccf[a[i]+1]--;
					ccf[2]++;
					cf[a[i]+1]-=m-a[i-1]+a[i]-1;
				}
			}
		}
	} 
	LL maxi=0;
	rb(i,1,m)
		ccf[i]+=ccf[i-1],cf[i]+=ccf[i],cf[i]+=cf[i-1],maxi=max(maxi,cf[i]);
//	cout<<maxi<<endl;
	cout<<res-maxi<<endl;
	return 0;
}
/*

2 4
1 3

*/

Measured memory_bytes: 5540
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;

const long long MOD = 1000000007;

long long func (int lastN, int step, const vector<bool>& a, vector<vector<long long>>& memo) {
    if (lastN == step) {
        return 1;
    }
    if (lastN < 0) {
        return 0;
    }
    if (lastN - step >= 0 && a[lastN - step]) {
        return 0;
    }
    // cout << "lastN: " << lastN << ", step: " << step << endl;
    if (memo[lastN - 1][step - 1] != -1) {
        return memo[lastN - 1][step - 1];
    }
    memo[lastN - 1][step - 1] = (func(lastN - step, 1, a, memo) + func(lastN - step, 2, a, memo)) % MOD;
    return memo[lastN - 1][step - 1];
}

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

    vector<bool> a(N, false);
    for (int i = 0; i < M; i++) {
        int ai;
        cin >> ai;
        // cout << N - ai << endl;
        a[N - ai] = true;
    }

    vector<vector<long long>> memo(N, vector<long long>(2, -1));

    long long ans = (func(N, 1, a, memo) + func(N, 2, a, memo)) % MOD;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 12032
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
#define srep(i, j, k) for (int i = j; i < k; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using ull = unsigned long long;

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; }

//エラトステネスの篩
vector<int> estora(vector<int> num) {
    int sel = 0;
    while (sel < num.size()) {
        int d = num[sel];
        for (int i = 0; i < num.size(); i++) {
            if (num[i] % d == 0 && num[i] != d && d != 1) {
                num.erase(num.begin() + i);
                i--;
            }
        }
        sel++;
    }
    return num;
}
/*ライブラリ最大公約数*/
//ユーグリッドの互除法
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*素因数分解*/
//自作ライブラリ
//iを常に素数にしておかないとうまくできない&&計算量ヤバイ
//エストラネスの篩で素数を振るっておく必要性がありそう
vector<ll> fac(ll n, vector<ll> num) {
    ll kazu = n;
    for (int i = 2; i <= n; i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1)
        num[n]++;
    return num;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return num;
}
const int INF = 1001001001;

//mint用の定数 (10の9乗 + 7)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    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 { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    long double w, h, x, y;
    cin >> w >> h >> x >> y;
    int ans = 0;
    if (w / 2 == x && h / 2 == y) {
        ans = 1;
    }

    long double ans2 = w / 2 * h;
    printf("%.10LF ", ans2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3784
ABCD = list(input())
 
def Calc(a,b,op):
    if op == "+":
        return int(a) + int(b)
    else:
        return int(a) - int(b)
 
ops = [["+","+","+"], ["+","+","-"], ["+","-","+"], ["-","+","+"],
       ["-","-","+"], ["-","+","-"], ["+","-","-"], ["-","-","-"]]
 
for op1, op2, op3 in ops:
    AB = Calc(ABCD[0],ABCD[1],op1)
    ABC = Calc(AB, ABCD[2], op2)
    ans = Calc(ABC, ABCD[3], op3)
 
    if ans == 7:
        print(ABCD[0]+op1+ABCD[1]+op2+ABCD[2]+op3+ABCD[3] + "=7")
        break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define L_T_S_K ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);  
const int mod = 1e9 + 7;
const int N = 1e5 + 9;

int32_t main(){
 L_T_S_K;
 int n;
 cin >> n;
 int a[n];
 std::map<int, int> mp;
 for(int i = 0 ; i < n ;i++){
  cin >> a[i];
  if(a[i] == 1 and mp[a[i]] == 0){
    mp[a[i]] = i + 1;
    continue;
  }
  if(mp.find(a[i] - 1) != mp.end()){
    mp[a[i]] = i + 1;
  }
 }
 int last = 1;
 int ans = 0;
 int f = 0;
 for(int  i = 1 ; i <= n ;i++){
  if(mp[i]){
    ans+=mp[i] - last;
    last  = mp[i] + 1;
    f = 1;
    }else {
      ans+=(n - last + 1);
      break;
    }
 }
 if(!f) cout << -1;
 else cout << ans << "\n";
 return 0;
}

Measured memory_bytes: 16384
#include<stdio.h>
int main()
{
    int n,a,b,j;
    scanf("%d",&n);
    scanf("%d",&a);
    scanf("%d",&b);
    j=a-b;
    if(j%2==0)
    {
        printf("Alice");
        return 0;
    }
    if(j%2!=0)
    {
        printf("Borys");
        return 0;
    }
    if("j==1")
    {
        if("n==b")
        {
            printf("Alice");
            return 0;
        }
        else
        {
            printf("Borys");
            return 0;
        }
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n, cx, cy;
int x[100], y[100], h[100];
int height;
bool check;
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i] >> h[i];
    }

    for (int i = 0; i <= 100; i++)
    {
        cx = i;
        for (int j = 0; j <= 100; j++)
        {
            cy = j;
            check = true;
            for (int k = 0; k < n; k++)
            {
                if (h[k])
                {
                    height = h[k] + abs(x[k] - cx) + abs(y[k] - cy);
                    break;
                }
            }
            for (int k = 0; k < n; k++)
            {
                if (max(height - abs(x[k] - cx) - abs(y[k] - cy), 0) == h[k])
                    continue;
                else
                {
                    check = false;
                    break;
                }
            }

            if (check)
            {
                break;
            }
        }

        if (check)
        {
            break;
        }
    }
    cout << cx << " " << cy << " " << height << endl;
    return 0;
}

Measured memory_bytes: 256