akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cstring>
#include <cmath>
#include <deque>
using namespace std;
#define MAXA 1001
#define MAXB 1001
#define MAXH 1000000001
#define MAXW 301
#define INF (1 << 30)
#define MAXN 100001
#define MAXM 100001
#define MAXK 100002
#define MAXV 201
#define MAXP 1000001
#define MOD 1000000007
#define EPS (1e-10)
typedef long long ll;

int V, M, R;
int order[8];
int d[MAXV][MAXV];

void warshall_floyd(){
    for(int k = 0;k < V;k++){
        for(int i = 0;i < V;i++){
            if(d[i][k] < 0) continue;
            for(int j = 0;j < V;j++){
                if(d[k][j] < 0) continue;

                if(d[i][j] < 0) d[i][j] = d[i][k] + d[k][j];
                else d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }     
        }
    }
}


int main(){
    memset(d, -1, sizeof(d));
    cin >> V >> M >> R;
    for(int i = 0;i < R;i++){
        cin >> order[i];
    }
    int to, from, cost;
    for(int i = 0;i < M;i++){
        cin >> to >> from >> cost;
        to--;from--;
        d[to][from] = cost;
        d[from][to] = cost;
    }
    sort(order, order + R);
    warshall_floyd();
    int ans = INF, sum;
    do{
        sum = 0;
        
        for(int i = 0;i < R - 1;i++){
            sum += d[order[i] - 1][order[i + 1] - 1];
        }
        ans = min(ans, sum);
    }while(next_permutation(order, order + R));


    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);


int main() {
    string s;
    cin >> s;
    vector<int> st;
    int n = s.size()-1;
    ll ans = 0;
    for(int state = 0; state < (1<<n); state++) {
        ll cur = s[0]-'0';
        ll acc = 0;
        for(int i = 0; i < n; i++) {
            if ((state >> i) & 1) {
                cur = cur * 10 + s[i+1] - '0';
            } else {
                acc += cur;
                cur = s[i+1] - '0';
            }
        }
        acc += cur;
        ans += acc;
    }
    cout << ans << endl;
    return 0;
}




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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 432;

char s[N][N];
bool bio[N][N];

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

void solve() {
  int h, w; scanf("%d%d", &h, &w);
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      scanf(" %c", s[i]+j);
    }
  }
  long long ans = 0;
  set<pair<int, int>> next;
  next.emplace(0, 0);
  while (!next.empty()) {
    queue<pair<int, int>> q;
    q.push(*next.begin());
    bio[next.begin()->second][next.begin()->first] = true;
    next.erase(next.begin());
    long long black = 0, white = 0;
    while (!q.empty()) {
      const auto &p = q.front();
      next.erase(p);
      if (s[p.second][p.first] == '#') ++black;
      else ++white;
      for (int i = 0; i < 4; ++i) {
	if (p.first+dx[i] < 0 || p.first+dx[i] >= w || p.second+dy[i] < 0 || p.second+dy[i] >= h) continue;
	if (bio[p.second+dy[i]][p.first+dx[i]]) continue;
	if (s[p.second][p.first] == s[p.second+dy[i]][p.first+dx[i]]) {
	  next.emplace(p.first+dx[i], p.second+dy[i]);
	  continue;
	}
	q.emplace(p.first+dx[i], p.second+dy[i]);
	bio[p.second+dy[i]][p.first+dx[i]] = true;
      }
      q.pop();
    }
    ans += black*white;
  }
  printf("%lld", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}

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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;
const string yes = "Yes";
const string no = "No";

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

  for (int i=k; i<n; i++) {
    if (a[i] > a[i-k]) cout << yes << endl;
    else cout << no << endl;
  }

  return 0;
}


Measured memory_bytes: 4836
N, Y = map(int, input().split())
N += 1
ans = (-1, -1, -1)
for x in range(N):
    for y in range(N - x):
        z = N - x - y - 1
        if x * 10000 + y * 5000 + z * 1000 == Y:
            ans = (x, y, z)
            break

print(*ans)


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int a, b, c;cin >> a >> b >> c;
    int mx = max({a, b, c});
    int ans = 0;
    ans += (mx-a)/2;
    a += (mx-a)/2*2;
    ans += (mx-b)/2;
    b += (mx-b)/2*2;
    ans += (mx-c)/2;
    c += (mx-c)/2*2;
    mx = max({a, b, c});
    int cnt = (a < mx) + (b < mx) + (c < mx);
    if(cnt == 0) cout << ans << endl;
    if(cnt == 1) cout << ans+2 << endl;
    if(cnt == 2) cout << ans+1 << endl;
    return 0;
}


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

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

  vector<int> A(N, 0);
  
  for(int i=0; i<N; i++) {
    cin >> A[i];
  }
  
  int min_sec = 1e9;
  
  for(int i=0; i<N-K+1; i++) {
    int sec = 0;
    int l = A[i];
    int r = A[i+K-1];
    if(r<0) {
      sec = -l;
    } else if(l>0) {
      sec = r;
    } else {
      sec = min(-l, r) + r - l; 
    }
    if(min_sec>sec) {
      min_sec = sec;
    }
  }
  cout << min_sec << endl;
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<utility>
#include<cstdlib>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
using namespace std;
int mark[100001],A[100001];
int main ()
{
	int n,i,j,k,x,y,z,c=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>A[i];
	x=1;
	c=0;
	mark[1]=1;
	while (x!=2)
    {c++;
    x=A[x];
    if(mark[x])
    break;
	mark[x]=1;
	}
	if(x==2)
	cout<<c<<endl;
	else
	cout<<-1<<endl;
 return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



int n, a;

int main() {
    while (cin >> n) {
        if (n == 0) break;
        int res = 0;
        for (int i = 0; i < n/4; ++i) {
            cin >> a;
            res += a;
        }
        cout << res << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1156
#include<bits/stdc++.h>
#define M 1000000007
using namespace std;
typedef long long int ll;

ll fun(ll n)
{
    if(n==1)
        return 1;
    else
    {
        ll x = 1 + 2*fun(n/2);
       return x;
    }

}
int main()
{
    ll n;
    cin>>n;
   cout<< fun(n);

}


Measured memory_bytes: 256
#include <stdio.h>
int h,w;
char pic[105][105];

int main(){
	scanf("%d%d",&h,&w);
	for(int i=0;i<h;i++){
		scanf("%s",pic[i]);
	}
	for(int i=0;i<(w+2);i++){
		printf("#");
	}
	printf("\n");
	for(int i=0;i<h;i++){
		printf("#%s#\n",pic[i]);
	}
	for(int i=0;i<(w+2);i++){
		printf("#");
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;
const int MAX = 510000;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,p; cin >> n >> p;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    bool flag = ((int)count_if(ALL(a), [](int i)-> bool {return i%2==0;})==n);
    ll ans;
    if(flag) {
        ans = (p==0 ? powl(2,n) : 0);
    }
    else {
        ans = powl(2,n-1);
        ans = (ans==1 ? 0 : ans);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  long N; cin>>N;
  long S;
  for(int i=1;i<=sqrt(N);i++){
    if(N%i==0) S=i;
  }
  long T=N/S;
  cout<<S+T-2<<endl;
}

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

int main(void) {
  int N;
  cin >> N;
  vector<long long> member(5, 0);
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    if (s[0] == 'M') member[0]++;
    if (s[0] == 'A') member[1]++;
    if (s[0] == 'R') member[2]++;
    if (s[0] == 'C') member[3]++;
    if (s[0] == 'H') member[4]++;
  }

  vector<int> v1 = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
  vector<int> v2 = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
  vector<int> v3 = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};
  long long ans = 0;
  for (int i = 0; i < 10; i++) {
    ans += member[v1[i]] * member[v2[i]] * member[v3[i]];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
<?php
list($n,$k) = explode(" ",trim(fgets(STDIN)));
$l = explode(" ",trim(fgets(STDIN)));

rsort($l);
$i = 0;
$ans = 0;
while($i < $k){
    $ans += $l[$i];
    ++$i;
}
echo $ans;
?>

Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int,int> pii;
bool visited[100005];
const int max_N=1e5+10;
int N,M,C,ans=0;
int B[105],A[105][105];
int main(void)
{
  cin >> N >> M >> C;
  for (int i = 0; i < M; ++i)
    {
      cin >> B[i];
    }
  for (int i = 0; i < N; ++i)
    {
      int tmp=0;
      for (int j = 0; j < M; ++j)
	{
	  cin >> A[i][j];
	  tmp+=B[j]*A[i][j];
	}
      tmp+=C;
      if(tmp>0) ans++;
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int N; cin >> N;
    vector<pair<int, int> > R, B;
    for(int i = 0; i < N; i++){
        int a, b; cin >> a >> b;
        R.push_back(make_pair(a, b));
    }
    for(int i = 0; i < N; i++){
        int c, d; cin >> c >> d;
        B.push_back(make_pair(c, d));
    }
    sort(R.begin(), R.end());
    sort(B.begin(), B.end());
    int cnt = 0;
    int RC[N]; for(int i = 0; i < N; i++) RC[i] = 0;
    int BC[N]; for(int i = 0; i < N; i++) BC[i] = 0;
    for(int i = 0; i < N; i++){
        pair<int, int> r, b;
        b = B[i];
        int y = -1, idx = -1;
        for(int j = 0; j < N; j++){
            r = R[j];
            //int y = -1, idx = -1;
            if(r.first < b.first && r.second < b.second){
                if(y < r.second) { 
                    if(RC[j] == 0){
                        y = r.second; 
                        idx = j;
                    }
                }
            }
        }
        if(idx != -1) {RC[idx] = 1; cnt++;}
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import math
nd = list(map(int,input().split()))
n = nd[0]
d = nd[1]
x_dic = {}
for i in range(n):
    temp = list(map(int,input().split()))
    x_dic[i] = temp

def calc(list_1, list_2, d):
    dist_sq = 0
    for i in range(d):
        dist_sq += (list_1[i]-list_2[i])*(list_1[i]-list_2[i])
    dist = math.sqrt(dist_sq)
    return dist

ans = 0
for i in range(n):
    for j in range(i+1,n):
        temp = calc(x_dic[i], x_dic[j], d)
        if temp == math.ceil(temp):
            ans += 1
print(ans)

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

public static class Program
{
    public static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();
        string[] val = { "ABC" };
        var sp = s.Split(val, StringSplitOptions.None).ToArray();
        Console.WriteLine(sp.Length - 1);
    }
}

Measured memory_bytes: 13268
a = gets
b = a.split

if b[2].to_i - b[4].to_i < 0  then
    puts "No"
elsif b[2].to_i + b[4].to_i > b[0].to_i then
    puts "No"
elsif b[3].to_i - b[4].to_i < 0 then
    puts "No"
elsif b[3].to_i + b[4].to_i > b[1].to_i then
    puts "No"
else
    puts "Yes"
end


Measured memory_bytes: 6876
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9 + 7;
const int INF = (int)100100100;

int main() {
    ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    ll K; cin >> K;
    ll sum=0;
  	ll num[100000]={};
    for(int i=0;i<N;i++){
        ll a,b;
        cin >> a >> b;
      	num[a]+=b;
    }
    ll mat=0;
  	for(int i=0;i<100001;i++){
      	mat+=num[i];
      	if(mat>=K){
          	cout << i;
          	break;
        }
    }
}

/*



 */



Measured memory_bytes: 1024
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1'000'000'007;
constexpr ll MOD2   = 998'244'353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)      for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    int dp[1000000];

    dp[1] = abs(h[1] - h[0]);
    for(int i = 2; i < n; ++i){
        dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]),
                    dp[i - 1] + abs(h[i] - h[i - 1]));
    }

    cout << dp[n - 1] << endl;

return 0;
}


Measured memory_bytes: 4064
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;
int r[13];
double dp[13][13][4097];
int main(){
	int len;
	string s;
	while(cin>>len){
	getline(cin,s);
	int n=0,cnt=0;
	for(int i=1;i<s.size();i++){
		if(s[i]==' '){
			r[n]=cnt;
			n++;
			cnt=0;
		}
		else{
			cnt*=10;
			cnt+=s[i]-'0';
		}
	}
	r[n]=cnt;
	n++;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			for(int k=0;k<4097;k++){
				dp[i][j][k]=10000.0;
			}
		}
	}
	int w=1;
	for(int i=0;i<n;i++){
		dp[0][i][w]=r[i]+0.0;
		w*=2;
	}
	for(int i=0;i<n-1;i++){
		for(int j=0;j<n;j++){
			for(int k=0;k<w;k++){
				int h=1;
				for(int e=0;e<n;e++){
					if(k%(h*2)<h){
						double set=dp[i][j][k];
						set+=2*(double)sqrt((double)r[j]*r[e]);
						if(dp[i+1][e][k+h]>set){
							dp[i+1][e][k+h]=set;
						}
					}
					h*=2;
				}
			}
		}
	}
	bool ok=false;
	for(int j=0;j<n;j++){
		for(int k=0;k<w;k++){
			if(dp[n-1][j][k]+r[j]<=len){
				ok=true;
			}
		}
	}
	if(ok)cout<<"OK"<<endl;
	else cout<<"NA"<<endl;
	}
	return 0;
}

Measured memory_bytes: 5992
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

const ll mod = 1e9 + 7;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> s, t;
  rep(i,n) {
    cin >> a[i];
    if (a[i] < 0) t.push_back(a[i]);
    else s.push_back(a[i]);
  }
 
  int S = s.size();
  int T = t.size();
  bool ok = false;
  if (S > 0) {
    if (n == k) ok = (T%2==0);
    else ok = true;
  } else {
    ok = (k%2==0);
  }
 
  ll ans = 1;
  if (!ok) {
    sort(a.begin(), a.end(), [](int x, int y) {
      return abs(x) < abs(y);
    });
    rep(i,k) ans *= a[i],ans %= mod;
  } else {
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    if (k%2 == 1) {
      ans *= s.back();
      s.pop_back();
    }
    vector<ll> p;
    while (s.size() >= 2) {
      ll x = s.back(); s.pop_back();
      x *= s.back(); s.pop_back();
      p.push_back(x);
    }
    while (t.size() >= 2) {
      ll x = t.back(); t.pop_back();
      x *= t.back(); t.pop_back();
      p.push_back(x);
    }
    sort(p.rbegin(), p.rend());
    rep(i,k/2) ans *= p[i]%mod,ans %= mod;
  }
 
  cout << (ans + mod) % mod << endl;
  return 0;
}


Measured memory_bytes: 6324
#C
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
B = np.array(list(map(int, input().split())))

if sum(A) < sum(B):
    re = -1

else:
    diff = A - B
    diff.sort()

    i = 0
    j = -1
    a = diff[j]
    while diff[i] < 0:
        a += diff[i] 
        while a<0:
            j -= 1
            a+= diff[j]
        i += 1

    if i == 0:
        re = 0
    else:
        re = i - j

print(re)

Measured memory_bytes: 23936
#include <iostream>
#include <string>
using namespace std;
 
int main(){
  int N,D;
  cin >> N >> D;
  int k = N / (2*D + 1);
  int l = ((N % (2*D + 1))+2*D) / (2*D + 1);
  cout << k+l << endl;
}

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

using namespace std;

int main()
{
	int n;
	int count;
	while (1)
	{
		cin >> n;
		if (cin.fail()) break;

		bool *isPrime;
		isPrime = new bool[n + 1];
		memset(isPrime, true, sizeof(bool) * (n + 1));
		isPrime[0] = isPrime[1] = false;
		
		count = 0;
		for (int i = 2; i <= n;++i)
		{
			while (isPrime[i] != true)
			{
				++i;
				if (i > n) break;
			}

			for (int j = i + i; j <= n; j += i)
			{
				isPrime[j] = false;
			}
		}
		for (int i = 0; i <= n; ++i)
		{
			if (isPrime[i] == true)
				++count;
		}
		cout << count << endl;
		delete[] isPrime;
	}
	return 0;
}

Measured memory_bytes: 4052
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;


int main() {
	
	int index = 0;

	int A, B;
	cin >> A >> B;

	if ((A * B) % 2 == 0)
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}

	return 0;

}


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

int main() {
  string s;
  cin >> s;
  deque<char> dq;
  for (char c : s) dq.push_back(c); 
  bool reversed = false;
  int q;
  cin >> q;

  rep(i, q){
    int t;
    cin >> t;
    if(t == 1){
      reversed = !reversed;
    } else {
      int f; char c;
      cin >> f >> c;
      if(reversed) f = 3 - f;
      if(f == 1) {
        dq.push_front(c);
      } else {
        dq.push_back(c);
      }
    }
  }
  if(reversed) reverse(dq.begin(), dq.end());
  string ans;
  for(char c: dq) ans += c;
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N, K, s, c;
  cin >> N >> K;
  s = 1, c = 0;
  while(c < N){
    if(s + K > s * 2){
      s = s * 2;
    }
    else{
      s = s + K;
    }
    c = c + 1;
  }
  cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

#define ff first
#define ss second
#define pb push_back
#define sz size()
#define mp make_pair
#ifndef ONLINE_JUDGE 
#include "/home/asif/Codes/Library/debug.h"
#endif
/*--------------------------------------------------------------------*/

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

int main() {

  std::vector<int> v(5);
  int n = 5;
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  for(int i = 1; i <= n; i++){
    if(v[i - 1] == 0){
      cout << i << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3544
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


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

    ll n;
    cin >> n;
    ll a[n];
    rp(i,n) cin >> a[i];
    sort(a,a+n);
    ll ans=1;
    if(n%2 == 0){
        rp(i,n){
            if((i/2)*2 +1 != a[i])
            {
                ans = 0;
                break;
            }
            if(i%2==0) ans = ans*2%MOD;
        }
    }
    if(n%2 == 1){
        rp(i,n){
            if(!((i == 0 && a[i] == 0) || ((i+1)/2)*2 == a[i]))
            {
                ans = 0;
                break;
            }
            if(i%2 == 1) ans = ans*2%MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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

int main()
{
    int64_t X, t, zero = 0;
    cin >> X >> t;
    cout << max(X - t, zero) << endl;
}

Measured memory_bytes: 256
N=int(input())
from collections import defaultdict
branch=defaultdict(dict)
for i in range(N-1):
    u,v,w=map(int,input().split())
    u-=1
    v-=1
    branch[u][v]=w
    branch[v][u]=w
dist=[float('inf')]*N
dist[0]=0
check={0}
while len(check)>0:
    now=check.pop()
    for nex,d in branch[now].items():
        if dist[nex]>dist[now]+d:
            dist[nex]=dist[now]+d
            check|={nex}
for i in range(N):
    print(dist[i]%2)

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

int main(){
    string s;
    cin>>s;
    string t="ABC";
    bool arc=true;
    rep(i,3){
        if(s[i]!=t[i])arc=false;
    }

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

}
/*


*/


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

int main() {
  int A, B, T;
  std::cin >> A >> B >> T;

  int ans = 0, t = 0;
  while(t + A < T + 0.5) {
    t += A;
    ans += B;
  }

  std::cout << ans << std::endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static final Scanner sc    = new Scanner(System.in);
    static final int     MOD   = (int) 1E9 + 7;
    static final long    INF_L = (long) 4E18;
    static final int     INF   = Integer.MAX_VALUE;
    
    public static void main(String[] args) {
        int N = nint();
        int K = nint();
        int[] H = nints(N);
        if (K >= N) {
            System.out.println(0);
            return;
        }
        
        long ans = 0;
        Arrays.sort(H);
        for (int i = 0; i < N - K; i++) {
            ans += H[i];
        }
        System.out.println(ans);
    }
    
    static int gcd(int m, int n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
    
    static long lcm(int m, int n) {
        return (long) m * n / gcd(m, n);
    }
    
    @Deprecated
    static int nint() {
        return sc.nextInt();
    }

    @Deprecated
    static int[] nints(int N) {
        return nints(N, 0, 0);
    }

    @Deprecated
    private static int[] nints(int N, int padL, int padR) {
        int[] a = new int[padL + N + padR];
        for (int i = 0; i < N; i++)
            a[padL + i] = nint();
        return a;
    }

    static long nlong() {
        return sc.nextLong();
    }

    static long[] nlongs(int N) {
        return nlongs(N, 0, 0);
    }

    static long[] nlongs(int N, int padL, int padR) {
        long[] a = new long[padL + N + padR];
        for (int i = 0; i < N; i++)
            a[padL + i] = nlong();
        return a;
    }

    static double ndouble() {
        return sc.nextDouble();
    }

    static double[] ndoubles(int N) {
        return ndoubles(N, 0, 0);
    }

    static double[] ndoubles(int N, int padL, int padR) {
        double[] d = new double[N + padL + padR];
        for (int i = 0; i < N; i++) {
            d[padL + i] = ndouble();
        }
        return d;
    }

    static String nstr() {
        return sc.next();
    }

    static char[] nchars() {
        return sc.next().toCharArray();
    }

    static char[] nchars(int padL, int padR) {
        char[] temp = sc.next().toCharArray();
        char[] ret = new char[temp.length + padL + padR];
        System.arraycopy(temp, 0, ret, padL, temp.length);
        return ret;
    }

    static char[][] nchars2(int H, int W) {
        return nchars2(H, W, 0, 0);
    }

    static char[][] nchars2(int H, int W, int padLU, int padRD) {
        char[][] a2 = new char[H + padLU + padRD][W + padLU + padRD];
        for (int i = 0; i < H; i++)
            System.arraycopy(nchars(), 0, a2[padLU + i], padLU, W);
        return a2;
    }

    static long min(long... ls) {
        return Arrays.stream(ls).min().getAsLong();
    }

    static long max(long... ls) {
        return Arrays.stream(ls).max().getAsLong();
    }

    static long abs(long a) {
        return Math.abs(a);
    }
}


Measured memory_bytes: 64888
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,C,d[30][30],c[500][500];
	cin>>n>>C;
	for(int i=0;i<C;i++)
	for(int j=0;j<C;j++)
	cin>>d[i][j];
	for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	cin>>c[i][j];
	if(n==1)
	{
		cout<<0;
		return 0;
	}
	vector<int> da[3];
	for(int i=0;i<3;i++)
		for(int j=0;j<C;j++)
		{
			da[i].push_back(0);
			for(int k=0;k<n;k++)
				for(int i1=0;i1<n;i1++)
				if((k+i1+2)%3==i)
				{
					da[i][da[i].size()-1]+=d[c[k][i1]-1][j];
				}
		}
	int ans=INT_MAX;
	for(int i=0;i<C;i++)
		for(int j=0;j<C;j++)
		{
			if(j==i)
			continue;
			for(int k=0;k<C;k++)
			{
				if(k==j||k==i)
				continue;
				ans=min(ans,da[0][i]+da[1][j]+da[2][k]);
			}
		}
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 1280
import java.util.*;

public class Main {
    static int n;
    static int a[][];

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        a = new int[2][n];

        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < n; j++) {
                a[i][j] = sc.nextInt();
            }
        }

        System.out.println(solve(0, 0));
    }

    public static int solve(int i, int j) {
        int max = 0;

        if (i == 1 && j == n - 1) {
            max = a[i][j];
        } else if (i < 1 && j < n - 1) {
            max = Math.max(a[i][j] + solve(i + 1, j), a[i][j] + solve(i, j + 1));
        } else if (i < 1) {
            max = a[i][j] + solve(i + 1, j);
        } else if (j < n - 1) {
            max = a[i][j] + solve(i, j + 1);
        }
        return max;
    }
}


Measured memory_bytes: 22736
using System;
using System.Linq;
 
class icpc2012dA{
    static void Main(){
        int i,n;
        n=int.Parse(Console.ReadLine());
        for(i=0;i<n;i++){
            int[] a=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            a[0]-=1;a[1]-=1;
            Console.WriteLine(196471-a[0]*195-a[0]/3*5-a[1]*20+(a[0]%3!=2?a[1]/2:0)-a[2]);
        }
    }
}

Measured memory_bytes: 5956
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 55
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};
double C[31000];

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

    int Q;
    cin>>Q;
    multiset<ll> R,L;
    ll sumR=0,sumL=0,sumb=0,count=0,mid;
    R.insert(-INF);L.insert(INF);
    while(Q--){
        //cout<<mid<<endl;
        int q;
        cin>>q;
        if(q==1){
            ll a,b;
            cin>>a>>b;
            sumb+=b;
            count++;
            if(count%2==1){
                vector<ll> v;
                v.push_back(a);
                auto it=R.end();
                it--;
                sumR-=*it;
                v.push_back(*it);
                R.erase(it);
                it=L.begin();
                sumL-=*it;
                v.push_back(*it);
                L.erase(it);
                sort(v.begin(),v.end());
                R.insert(v[0]);
                sumR+=v[0];
                mid=v[1];
                L.insert(v[2]);
                sumL+=v[2];
            }else{
                if(a<mid){
                    R.insert(a);
                    L.insert(mid);
                    sumR+=a;sumL+=mid;
                }else{
                    R.insert(mid);
                    L.insert(a);
                    sumR+=mid;sumL+=a;
                }
            }
        }else{
            if(count%2==1) cout<<mid<<" "<<-sumR+sumL+sumb<<endl;
            else cout<<*R.rbegin()<<" "<<-sumR+sumL+sumb<<endl;
        }
    }
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PPQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue;
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> &vec){ return (ll)vec.size(); }
ll sz(string &s){ return (ll)s.size(); }
ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b; }


int main(){
    ll n,m;
    cin >> n >> m;
    if(n > m/2) cout << m/2 << endl;
    else cout << n + (m-2*n)/4 << endl;

    return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	cout << min(a * n, b) << endl;
}
	

Measured memory_bytes: 764
#include<bits/stdc++.h> 
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
typedef long long ll;
using namespace std;
const int maxn=1e5+5,mn=180+5;
int i,j,n,ans,mx,k,K;
bool f[maxn][mn];
void dfs(int x,int y){
	if (f[x][y]||y>=ans) return;
	if (!x) {
		ans=y;return;
	}
	f[x][y]=1;
	int i;
	fo(i,0,9) dfs((x*10+i)%K,y+i);
}
int main(){
	scanf("%d",&k);K=k;
	for(;k;k/=10) ans+=k%10;
	fo(i,1,9) dfs(i%K,i);
	printf("%d\n",ans);
}

Measured memory_bytes: 74496
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


h, w, k = LI()
ans = [[0] * w for _ in range(h)]
G = SRL(h)
co = []
L = []
ret = 0
no_s = set()
for y in range(h):
    flag = 0
    for x in range(w):
        if G[y][x] == '#':
            L += [y]
            flag = 1
            ret += 1
            co += [(y, x, ret)]
            ans[y][x] = ret
    if not flag:
        no_s.add(y)


for y, x, ret in co:
    for i in range(x + 1, w):
        if G[y][i] == '#':
            break
        ans[y][i] = ret
    for j in range(x - 1, -1, -1):
        if G[y][j] == '#':
            break
        ans[y][j] = ret




for k in no_s:
    if k == 0:
        for x in range(w):
            ans[k][x] = ans[k + 1][x]
    else:
        for x in range(w):
            ans[k][x] = ans[k - 1][x]


for y in L:
    y_plus = y + 1
    while y_plus in no_s:
        for x in range(w):
            ans[y_plus][x] = ans[y_plus - 1][x]
        y_plus += 1
    y_minus = y - 1
    while y_minus in no_s:
        for x in range(w):
            ans[y_minus][x] = ans[y_minus + 1][x]
        y_minus -= 1
    

for i in ans:
    print(*i)








Measured memory_bytes: 62124
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i,a,b) for(int i=a,almo5t=b;i<almo5t;++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int N = 1000000;

typedef long long int ll;

using namespace std;

int memo[N];


int main(){
    ll n;
    cin>>n;
    ll ans = 1;
    fore(i,1,n+1){
        ans %= MOD;
        ans *= (i%MOD);
        ans %= MOD;
    }
    cout<<(ans%MOD);
	return 0;
}



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

int main(){
    int a,b,c;
    char x;
    int r=0,m=0;
    while(cin>>a>>x>>b>>x>>c){
        if(a*a+b*b==c*c)r++;
        if(a==b)m++;
    }
    cout<<r<<endl
        <<m<<endl;
}

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

int main(){
  int N;
  string s[1000];
  int t[1000];
  string X;
  
  cin>>N;
  for (int i=0;i<N;i++)cin>>s[i]>>t[i];
  cin>>X;
  
  bool sleepflag=false;
  int res=0;
  
  for(int i=0;i<N;i++){
    
    if(sleepflag==true) res=res+t[i];
    if(s[i]==X) sleepflag=true;
  }
  cout<<res<<endl;
}

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

namespace CSharpSample01
{

    

    class Program
    {
        
        
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            int ans = a;

            if(b < a)
            {
                ans--;
            }

            Console.WriteLine(ans);

            
        }
    }
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  set <int> s;
  s.insert(a);
  s.insert(b);
  s.insert(c);

  cout << s.size() << endl;

  return 0;

}

Measured memory_bytes: 256
import java.util.*;

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

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

    private void run() {
        int s = sc.nextInt();
        int w = sc.nextInt();
        System.out.println(s <= w ? "unsafe" : "safe");
    }
}


Measured memory_bytes: 35820
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main()
{
    int a,b;
    while(scanf("%d %d",&a,&b)!=EOF)
    {
        int sun=0;
        if(a<=b)
            sun=a;
        else
            sun=a-1;
        printf("%d\n",sun);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN 2*int(1e5)+7
#define endl '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define max3(x, y, z) max(x, max(y, z))
using namespace std;
using namespace __gnu_pbds;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<unsigned ll, pair<int, int> > piii;
typedef pair<pair<int, int>, int> piii2;
typedef pair<char, pair<int, int>> pcii;
typedef tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> indexed_set;
 
int a[100], p[100]; 

int main() {
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		ans += x;
	}
	for(int i = 0; i < n-1; i++)
		cin >> p[i];
	
	for(int i = 1; i < n; i++) 
		if(a[i] == a[i-1]+1)
			ans += p[a[i-1]-1];
	
	cout << ans << endl;
}


Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,T;
vector<pair<LL,LL>> dish;//pair<食べるのにかかる時間,美味しさ>
 
LL ans = 0;

void solve(){
    //時間がかからない順にソート
    sort(dish.begin(),dish.end());
    //時間がかからない順に前からi番目まで見た時、
    //食べるのに必要な時間をjとした時
    //そのときのおいしさの最大値をdp[i][j]とおく
    vector<vector<LL>> dp(N+1,vector<LL>(6000,0));
    //配るイメージのDP
    for(int i=0;i<N;i++){
        LL time = dish[i].first;//食べるのにかかる時間
        LL taste = dish[i].second;//美味しさ
        //時間T以降は注文不可
        for(int j=0;j<T;j++){
            //i番目を注文した場合
            dp[i+1][j+time] = max(dp[i][j]+taste,dp[i+1][j+time]);
            //i番目を注文しなかった場合
            dp[i+1][j] = max(dp[i][j],dp[i+1][j]);

            ans = max(ans,dp[i+1][j+time]);
            ans = max(ans,dp[i+1][j]);
        }
    }
}
 
int main(){
    cin >> N >> T;
    for(int i=0;i<N;i++){
        LL a,b;
    	cin >> a >> b;
        dish.push_back(pair<LL,LL>(a,b));
    }
 
    solve();
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 141184
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};



void solve(){
    ll n,m;
    cin>>n>>m;
    cout<<n*n-m<<endl;

}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    solve();

    return 0;
}


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

using namespace std;

#ifndef ONLINE_JUDGE
  #define pr_debug(...) do { printf("DEBUG: line %d: %s: ", __LINE__, __PRETTY_FUNCTION__); printf(__VA_ARGS__); } while(0)
  #define pr_vars(...) do { pr_debug(" "); pr_var(split(#__VA_ARGS__, ',').begin(), __VA_ARGS__); } while(0)
#else
  __attribute__ ((constructor)) static void fast_cin() { ios_base::sync_with_stdio(false); cin.tie(0); }
  #define pr_debug(...) do { } while(0)
  #define pr_vars(...) do { } while(0)
#endif /* ONLINE_JUDGE */

using ll = int64_t;
using ull = uint64_t;

template<typename T> ostream &operator<< (ostream &fout, const vector<T> &vec)
{ for (const auto &el : vec) fout << el << ' '; return fout; }

template<typename T> istream &operator>> (istream &fin, vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fin >> vec[i]; return fin; }

vector<string> split(const string &s, char c) { vector<string> v; ull st = 0, fn = 0, lvl = 0;
for ( ; fn < s.size(); fn++ ) { if (s[fn] == c && lvl == 0) { v.push_back(s.substr(st, fn - st)); st = fn + 1; }
if (s[fn] == '(') { lvl++; } if (s[fn] == ')') { lvl--; } } v.push_back(s.substr(st, fn - st)); return v; }

void pr_var(vector<string>::iterator it) { (void) it; cout << endl; }
template<typename T, typename... Args> void pr_var(vector<string>::iterator it, T a, Args... args)
{ cout << *it << "=" << a << "  "; pr_var(++it, args...); }

ll div_ceil(ll n, ll d) { ll res = n / d; if (res >= 0) res += n % d ? 1 : 0; return res; }
ll gcd(ll a, ll b) { a = llabs(a); b = llabs(b); while (a && b) a > b ? a %= b : b %= a; return a + b; }
ll lcm(ll a, ll b) { ll c = gcd(a, b); return c == 0 ? 0 : llabs(a / c * b); }

#define setp(a) fixed << setprecision(a)
const double PI = acos(-1.0);
constexpr double EPS = 1e-9;
constexpr double INF = 2e18;

using mp = pair<ll, ll>;
using mt = tuple<ll, ll, ll>;    // unpack: tie(ll, ll, ll) = mt;

constexpr ll MAX = 1e5 + 5;

int main()
{
    ll n, m, k; cin >> n >> m >> k;
    for (ll a = 0; a <= n; a++) {
        for (ll b = 0; b <= m; b++) {
            if (a * (m - b) + b * (n - a) == k) {
                cout << "Yes" << endl;
                exit(0);
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  LL r, D, x; cin >> r >> D >> x;
  for (int i = 1; i <= 10; ++i) {
    x = r * x - D;
    cout << x << endl;
  }
}


Measured memory_bytes: 3632