akhauriyash/Code-Regression huggingface dataset:
import Control.Applicative
import Data.List
import qualified Control.Monad as Monad


main :: IO ()
main = opCalc 

opCalc :: IO()
opCalc = do 
  [x, _op, y] <- words <$> getLine
  let a = read x :: Int
  let b = read y :: Int
  let op = _op :: String
  Monad.when(op /= "?") $ do
   let str = show (convertStrToOp(op) a b)
   putStrLn str
   opCalc
   
convertStrToOp :: String -> (Int -> Int ->Int)
convertStrToOp "+" = (+)
convertStrToOp "-" = (-)
convertStrToOp "*" = (*)
convertStrToOp "/" = div



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

unordered_map<ll, ll> factor(ll n){
    unordered_map<ll, ll> ans;
    for(ll i = 2; i * i <= n; i++) while(n % i == 0){
        ans[i]++;
        n /= i;
    }
    if(n != 1) ans[n]++;
    return ans;
}
int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    for(auto& [p, e] : factor(n)){
        ll cnt = 1;
        while(e >= cnt){
            ans++;
            e -= cnt;
            cnt++;
        }
    }
    cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

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

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

using namespace std;


void dfs(int v, vector<vector<int>> &es, vector<int> &ing) {
	for (int u : es[v]) {
		if (ing[u] != 0) continue;
		ing[u] = ing[v];
		dfs(u, es, ing);
	}
}

int main(int argc, char *argv[]) {
	int N, K, L;
	cin >> N >> K >> L;

	vector<int> area_roads(N);
	vector<int> area_rails(N);

	vector<vector<int>> roads(N);
	vector<vector<int>> rails(N);
	for (int i = 0; i < K; i++) {
		int p, q;
		cin >> p >> q;
		roads[p-1].push_back(q-1);
		roads[q-1].push_back(p-1);
	}

	for (int i = 0; i < L; i++) {
		int r, s;
		cin >> r >> s;
		rails[r-1].push_back(s-1);
		rails[s-1].push_back(r-1);
	}

	for (int i = 0; i < N; i++) {
		if (area_roads[i] != 0) continue;
		area_roads[i] = i + 1;
		dfs(i, roads, area_roads);
	}

	for (int i = 0; i < N; i++) {
		if (area_rails[i] != 0) continue;
		area_rails[i] = i + 1;
		dfs(i, rails, area_rails);
	}
	
	map<pair<int, int>, int> cnt;
	for (int i = 0; i < N; i++) {
		cnt[make_pair(area_roads[i], area_rails[i])]++;
	}

	for (int i = 0; i < N; i++) {
		cout << cnt[make_pair(area_roads[i], area_rails[i])] << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 27776
#include "bits/stdc++.h"
using namespace std;

#define ll long long
#define pll pair<ll, ll>
#define rep(x, l, r) for (x = l; x < r; x++)

const ll mod=1000000007;
const char nl='\n';

void solve()
{
	ll i, j, k, l, m, n, u, v,x,y,z,c,r,g,q;
    cin>>n;
    vector<ll> ans(3,0);
    cin>>x>>y>>z;
    ans[0]=x;
    ans[1]=y;
    ans[2]=z;
    for(i=1;i<n;i++){
        cin>>x>>y>>z;
        x=max(ans[1],ans[2])+x;
        y=max(ans[0],ans[2])+y;
        z=max(ans[0],ans[1])+z;
        ans[0]=x;
        ans[1]=y;
        ans[2]=z;
    }
    cout<< *max_element(ans.begin(),ans.end());
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
//    cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
using namespace std;
int main(void){
    int n,a[100000],b=0,c=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]>=b){
            c++;
            b=a[i];
        }
    }
    cout<<c;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

int n;
vector<ll> a;
vector<vector<ll>> memo(3030, vector<ll>(3030));
vector<vector<bool>> flg(3030, vector<bool>(3030, false));

ll rec(int l, int r){
    if(flg[l][r]) return memo[l][r];
    flg[l][r]=true;

    if(l>r) return memo[l][r]=0;
    ll res = max(a[l]-rec(l+1, r), a[r]-rec(l, r-1));
    return memo[l][r]=res;
}

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

    cin >> n;
    a.resize(n+1);
    repr(i, 1, n+1) cin >> a[i];

    cout << rec(1, n) << endl;
    
    return 0;
}


Measured memory_bytes: 73728
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 300000

int n, a, b;
int r[MAXN];

int input() {
	if (scanf("%d %d %d", &n, &a, &b) < 0) return 0;
	return 1;
}

void init() {
}

long solve() {
	if (a+b-1>n) return 0;
	//if (a<=0 || b<=0 || long(a)*b<n) return 0;
	int t=n, s=1, p=0;
	while (p<n) {
		if (a<=0) return 0;
		int q = p;
		for (int i=0; i<a && p<n; i++) {
			r[p++] = t--;
		}
		reverse(r+q, r+p);
		a--;

		if (b<=0) return 0;
		b--;
		q = p;
		for (int i=0; i<b && p<n; i++) {
			r[p++] = s++;
		}
		reverse(r+q, r+p);
	}
	return 1;
}

void output(long ans) {
	if (!ans) {
		printf("-1\n");
		return;
	}
	for (int i=0; i<n; i++) printf("%d ", r[i]);
	printf("\n");
}

void cleanup() {
}

int main() {
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





Measured memory_bytes: 3328
#include<iostream>
#include<cmath>
int main() {
	for (int i = 1; i <= 9; ++i) {
		for (int j = 1; j <= 9; ++j) {
			std::cout << i << "x" << j << "=" << i*j << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2936
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

typedef struct list {
  int node;
  int i;
  struct list *next;
} list;

list *graph[MAX];

void initGraph(void) {
  for (int i = 0; i < MAX; i++)
    graph[i] = NULL;
}

void addEdge(int node1, int node2, int i)
{
  list *new1 = (list *)malloc(sizeof(list *));
  new1->node = node2;
  new1->next = graph[node1];
  new1->i = i;
  graph[node1] = new1;

  list *new2 = (list *)malloc(sizeof(list *));
  new2->node = node1;
  new2->next = graph[node2];
  new2->i = i;
  graph[node2] = new2;
}

int color[MAX] = {0};
int max = 0;

void paint(int parent, int now, int edge) {
  list *child = graph[now];
  int colors = 1;
  for (; child != NULL; child = child->next) {
    if (child->node == parent) continue;
    if (colors == edge) colors++;
    color[child->i] = colors;
    paint(now, child->node, colors);
    colors++;
  }
  max = max(max, colors - 1);
  return;
}

int main(void) {
  int n;
  scanf("%d", &n);
  initGraph();
  int a, b;
  rep(i, 1, n) {
    scanf("%d %d", &a, &b);
    addEdge(a, b, i);
  }

  paint(0, 1, 0);

  printf("%d\n", max);
  rep(i, 1, n) {
    printf("%d\n", color[i]);
  }
  return 0;
}


Measured memory_bytes: 8576
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

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

	string s;
	cin >> s;

	if (s == "ABC") {
		out("ARC");
	}
	else {
		out("ABC");
	}

	return 0;
}

Measured memory_bytes: 3612
/**
 * Program name:Stack
 * author:Xin Peng
 * date:2020/1/18
 * Pragram problem source: AOJ
*/
#include <iostream>
#include <stdio.h>
using namespace std;

#define MAX_STACK 100

class Stack
{
    int *data; //data pointer
    int *p;    //current position pointer
    int size;  //satck size

public:
    Stack() { this->data = NULL; }

    Stack(int _size)
    {
        this->size = _size;
        this->data = new int[_size];
        this->p = NULL;
    }

    bool push(int _data);

    int pop();

    bool isEmpty() { return (this->p == NULL); }

    bool isFull() { return (this->p - this->data == this->size - 1); }

    ~Stack()
    {
        if (this->data)
            delete[] this->data;
    }
};

// Stack::push()
bool Stack::push(int _data)
{
    if (this->isFull())
    {
        return false;
    }
    else if (this->isEmpty())
    {
        p = data;
        *p = _data;
        return true;
    }
    else
    {
        p++;
        *p = _data;
        return true;
    }
}

//Stack::pop()
int Stack::pop()
{
    if (this->isEmpty())
    {
        return -1;
    }

    int data = *p;

    if (p == this->data)
    {
        p = NULL;
    }
    else
    {
        p--;
    }

    return data;
}

int main()
{
    Stack stack(MAX_STACK);
    char ch;
    bool flag = false;

    for (int i = 0;; i++)
    {
        scanf("%c", &ch);

        if (ch >= '0' && ch <= '9')
        {
            if (i != 0 && flag == false)
            {
                int tmp;
                tmp = stack.pop();
                tmp = tmp * 10 + ch - '0';
                stack.push(tmp);
            }
            else
            {
                stack.push(ch - '0');
            }
            flag = false;
        }
        else if (ch == '+' || ch == '-' || ch == '*')
        {
            int op1 = stack.pop();
            int op2 = stack.pop();
            int res = 0;

            if (ch == '+')
            {
                res = op1 + op2;
            }
            else if (ch == '-')
            {
                res = op2 - op1;
            }
            else
            {
                res = op1 * op2;
            }

            stack.push(res);
            flag = false;
        }
        else
        {
            if (!flag)
            {
                flag = true;
            }
            else
            {
                break;
            }
        }
    }

    cout << stack.pop() << endl;

    return 0;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ini(a,i) memset(a,i,sizeof(a))
#define pb push_back
#define ll int64_t
#define inf LLONG_MAX

void solve()
{
	ll n,i;
	cin>>n;

	map<string,ll> f;

	for(i=0;i<n;i++)	
	{
		string str;
		cin>>str;

		f[str]++;
	}
	

	cout<<"AC x "<<f["AC"]<<endl;
	cout<<"WA x "<<f["WA"]<<endl;
	cout<<"TLE x "<<f["TLE"]<<endl;
	cout<<"RE x "<<f["RE"]<<endl;
}


signed main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//ll tt;	cin>>tt;	while(tt--)
	{
		solve();
 	}
	cerr<<" Execution : "<<(1.0*clock())/CLOCKS_PER_SEC<<"s \n";
		
		
return 0;
}

Measured memory_bytes: 3796
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author parsa bahrami
 */

#pragma GCC optimize("O2")

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

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef pair<string, string> pss;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sz(x)                       (ll) x.size()
#define jjoin(x)                    for (auto i : x) cout << i << endl;
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define sep                         ' '
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define kill(x)                     return cout << x << endl , 0;
#define Hkill(x)                    cout << x << endl; exit(0);
#define endl                        '\n'

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 2e5 + 10;
const ll MAXA = 210;
const ll INF = 8e18;
const ll MOD = 998244353; //1e9 + 7
const ld PI = 4 * atan((ld) 1);
bool adj[MAXA][MAXA];
ll T[MAXN], H[MAXN], n;

void dfs(ll v) {
    for (ll u = 1; u <= n; u++) {
        if (adj[u][v] && T[u] == INF) {
            T[u] = T[v] ^ 1;
            dfs(u);
        } else if (T[u] == T[v] && adj[u][v]) {
            //cout << T[u] << sep << 'u' << sep << T[v] << sep << 'v' << endl;
            Hkill(-1);
        }
    }
}

ll bfs(ll v) {
    fill(H, H + MAXN, 0);
    queue<ll> Q;
    Q.push(v);
    H[v] = 1;
    while (sz(Q)) {
        ll u = Q.front();
        Q.pop();
        for (ll ver = 1; ver <= n; ver++) {
            if (H[ver] == 0 && adj[ver][u]) {
                H[ver] = H[u] + 1;
                Q.push(ver);
            }
        }
    }
    return *max_element(H, H + MAXN);
}

int main() {
    fast_io;
    set_random;
    cin >> n;
    for (ll i = 1; i <= n; i++) {
        for (ll j = 1; j <= n; j++) {
            char c;
            cin >> c;
            adj[i][j] = c - '0';
        }
    }
    fill(T , T + MAXN , INF);
    T[1] = 1;
    dfs(1);
    ll ans = 0;
    for (ll i = 1; i <= n; i++) {
        ans = max(ans, bfs(i));
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3456
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC073A
{
    class Program
    {
        static void Main(string[] args)
        {
            String n;
            n = Console.ReadLine();

            if (n[0] == '9' || n[1] == '9')
                Console.WriteLine("Yes");

            else
                Console.WriteLine("No");

            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 11092
import sys
input = sys.stdin.buffer.readline
R,C,K = map(int,input().split())
goods = [[0]*(C+1) for _ in range(R+1)]
INF = 10**18
for i in range(K):
    ri,ci,vi = map(int,input().split())
    goods[ri][ci] = vi
DP = [[[-INF]*(C+1) for _ in range(R+1)] for _ in range(4)]
DP[0][1][1] = 0
if goods[1][1]:
    DP[1][1][1] = goods[1][1]
for j in range(1,C):
    DP[0][1][j+1] = 0
    if goods[1][j+1]:
        DP[1][1][j+1] = max(DP[1][1][j],DP[0][1][j]+goods[1][j+1])
        DP[2][1][j+1] = max(DP[2][1][j],DP[1][1][j]+goods[1][j+1])
        DP[3][1][j+1] = max(DP[3][1][j],DP[2][1][j]+goods[1][j+1])
    else:
        DP[1][1][j+1] = DP[1][1][j]
        DP[2][1][j+1] = DP[2][1][j]
        DP[3][1][j+1] = DP[3][1][j]
for i in range(1,R):
    DP[0][i+1][1] = max(DP[0][i][1],DP[1][i][1],DP[2][i][1],DP[3][i][1])
    if goods[i+1][1]:
        DP[1][i+1][1] = DP[0][i+1][1] + goods[i+1][1]
for i in range(2,R+1):
    for j in range(2,C+1):
        DP[0][i][j] = max(DP[0][i-1][j],DP[1][i-1][j],DP[2][i-1][j],DP[3][i-1][j],DP[0][i][j-1])
        if goods[i][j]:
            DP[1][i][j] = max(DP[0][i][j]+goods[i][j],DP[1][i][j-1])
            DP[2][i][j] = max(DP[2][i][j-1],DP[1][i][j-1]+goods[i][j])
            DP[3][i][j] = max(DP[3][i][j-1],DP[2][i][j-1]+goods[i][j])
        else:
            DP[1][i][j] = DP[1][i][j-1]
            DP[2][i][j] = DP[2][i][j-1]
            DP[3][i][j] = DP[3][i][j-1]
print(max(DP[0][R][C],DP[1][R][C],DP[2][R][C],DP[3][R][C]))

Measured memory_bytes: 430968
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int a[100010];
    rep(i, n) cin >> a[i + 1];
    int ans[2] = {};
    rep(j, 2) {
        int sum[100010] = {};
        REP(i, 1, n) {
            sum[i] += sum[i - 1] + a[i];
            if (i % 2 == j && sum[i] >= 0) {
                ans[j] += sum[i] + 1;
                sum[i] -= sum[i] + 1;
            } 
            else if(i % 2 == (j + 1) % 2 && sum[i] <= 0) {
                ans[j] += 1 - sum[i];
                sum[i] += 1 - sum[i];
            }
        }
    }
    cout << min(ans[0], ans[1]) << endl;

    return 0;
}


Measured memory_bytes: 1792
// print chess boards
#include <iostream>
using namespace std;

int main() {
        int H,W;

        while(1) {
                cin >> H >> W;
                if (H==0 && W==0) break;

                for (int i = 1; i <= H; i++) {
                        for (int j = 1; j <= W; j++) {
                                if (j%2 == (i%2==1?1:0)) cout << "#";
                                if (j%2 == (i%2==1?0:1)) cout << ".";
                        }
                        cout << endl;
                }
                cout << endl;
        }

        return 0;
}

Measured memory_bytes: 3040
n, a, b = input().split(" ")
n = int(n)
a = int(a)
b = int(b)
xs = input().split(" ")
m = list()
for x in xs:
	m.append(int(x))

fatigue = list()
for index, x in enumerate(m):
	if index < len(m) - 1:
		dist = abs(m[index + 1] - x)
		fatigue.append(min((a * dist), b))

print(sum(fatigue))


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N-1);
  for(int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  for(int i = 0; i < N; i++) {
    cin >> B.at(i);
  }
  for(int i = 0; i < N-1; i++) {
    cin >> C.at(i);
  }
  int p = 0;
  for(int i = 0; i < N; i++) {
    p += B.at(i);
  }
  for(int i = 0; i < N-1; i++) {
    if(A.at(i) + 1 == A.at(i+1)) {
      p += C.at(A.at(i)-1);
    }
  }
  cout << p << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n], b[n + 1], c[n];

    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++) {
        cin >> b[i];
    }
    for (int i = 0; i + 1 < n; i++) {
        cin >> c[i];
    }
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        sum += b[a[i]];
        if (a[i] + 1 == a[i + 1]) {
            sum += c[a[i] - 1];
        }
    }

    cout << sum << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int N; cin>>N;
	vi A(N);
	rpz(i,N) cin>>A[i];
	sort(allr(A));
	int a = 0, b = 0;
	rpz(i,N){
		if(i%2) b += A[i];
		else a += A[i];
	}
	// printf("a %d b %d\n",a,b);//
	ote(a-b);
}


Measured memory_bytes: 256
N = int(input())

list_X = [int(X) for X in input().split(' ')]
list_X_sorted = sorted(list_X)
mid_right = int(N / 2)
mid_left = mid_right - 1

for i in range(N):
    if list_X[i] < list_X_sorted[mid_right]:
        print(list_X_sorted[mid_right])
    else:
        print(list_X_sorted[mid_left])

Measured memory_bytes: 25556
#include "bits/stdc++.h"
 
using namespace std;
 
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
 
#define int long long
 
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
 
template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}
 
 
template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}
 
signed main(void) {
	int N;
	string S;
	cin >> N>>S;
	rep(i, S.size()) {
		if (S[i] + N <= 'Z') {
			S[i] = S[i] + N;
		}
		else {
			S[i] = S[i] + N-26;
		}
	}
	print(S);
}

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

int main()
{
  int N;
  cin >> N;
  if (N / 10 == 9 || N % 10 == 9)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 3568
#include <stdio.h>
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
int main() {
	//code
	int n,k;
	cin>>n>>k;
	int height[n];
	for(int i=0;i<n;i++){
	    cin>>height[i];
	}
	int l=sizeof(height)/sizeof(height[0]);
	sort(height,height+l);
	int count=0;
	for(int a=0;a<n;a++){
	    if(height[a]>=k){
	        count++;
	    }
	}
	cout<<count;
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
	unsigned long long n,m;
	unsigned long long ans;
	scanf("%llu%llu",&n,&m);
	if(n==1)
	{
		if(m==1) ans=1;
		else  ans=m-2;
	}
	else
	{
		if(m==1)
	 {
		if(n==1) ans=1;
		else ans=n-2;
	 }
	 else
	   ans=(m-2)*(n-2);
	}
	printf("%llu\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
// #pragma GCC optimization ("O3,unroll-loops")
// #pragma GCC target ("avx,avx2,fma")
using namespace std;

int32_t main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n; cin >> n;
    map<int, int> freq;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        freq[x]++;
    }
    vector<int> len, fq;
    for (auto [x, y] : freq) {
        len.emplace_back(x);
        fq.emplace_back(y);
    }
    int64_t cnt = 0;
    n = len.size();
    for (int i = 0; i + 2 < n; i++) for (int j = i + 1; j + 1 < n; j++) for (int k = j + 1; k < n; k++) {
        if (len[i] + len[j] > len[k]) cnt += fq[i] * fq[j] * fq[k];
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
    
    long long x,y;
    long long ans = LLONG_MAX;
    long long sum = 0;
    vector<long long> A;
    long long N;
    cin >> N;
    
    for ( long long i = 0; i < N; i++ ) {
        long long t;
        cin >> t;
        sum += t;
        A.push_back(sum);
    }
    
    for ( long long i = 0; i < N-1; i++ ) {
        
        x = A[i];
        y = A[N-1] - A[i];
        
        ans = min( ans, abs(x-y) );
        
    }
    
    
    
    
    
    
    cout << ans << endl;
    
    
    return 0;
}

Measured memory_bytes: 2420
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;

LL n,m,h,w;
LL val[505][505] = {0};

int main(){
	cin >> n >> m >> h >> w;
	if(!(n % h || m % w)){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	for(LL i = h;i <= n;i += h)
		for(LL j = w;j <= m;j += w)
			val[i][j] = - (h * w * 1000 - 999);
	for(LL i = 1;i <= n;i ++)
		for(LL j = 1;j <= m;j ++)
			cout << (val[i][j] ? val[i][j] : 1000) << (j == m ? '\n' : ' ');
	return 0;
}//

Measured memory_bytes: 3584
N = int(input())
H = list(map(int, input().split(' ')))

minimum_cost = [float('inf') for i in range(N)]
minimum_cost[0] = 0
minimum_cost[1] = abs(H[1] - H[0])
for i in range(2, N):
    temp1 = minimum_cost[i-1] + abs(H[i]-H[i-1])
    temp2 = minimum_cost[i-2] + abs(H[i]-H[i-2])
    minimum_cost[i] = min(temp1, temp2)

print(minimum_cost[N-1])


Measured memory_bytes: 13980
#include <iostream>
#include <string>
 
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
 
using namespace std;
 
 
bool ok[200][200];
bool check(const string &s){
    rep(i, s.size()-1) if(!ok[s[i]][s[i+1]]) return false;
    return true;
}
 
int main(){
    string a[] = {"BD", "ACE", "BF", "AEG", "BDFH", "CEI", "DH", "GEI", "FH"};
    rep(i, 9) rep(j, a[i].size()) ok['A'+i][a[i][j]] = 1;
 
    rep(i, 1000){
        string s;
        cin >> s;
        if(check(s)) cout << s << endl;
    }
 
    return 0;
}

Measured memory_bytes: 1196
n = gets.chomp.to_i
arr = gets.chomp.split.map(&:to_i)
brr = gets.chomp.split.map(&:to_i)

mons = arr.inject(:+)

a = arr[0]
arr[0] = arr[0] - [arr[0], brr[0]].min
brr[0] = brr[0] - [a, brr[0]].min

(1..n-1).each do |i|
	arr[i] = [arr[i] - brr[i-1], 0].max 
	a = arr[i]
	arr[i] = arr[i] - [arr[i], brr[i]].min
	brr[i] = brr[i] - [a, brr[i]].min
end
a = arr[n]
arr[n] = [arr[n] - brr[n-1], 0].max

puts mons - arr.inject(:+)


Measured memory_bytes: 26808
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;


int main(){
	char s[51];
	char t[51];

	scanf("%s", s);
	scanf("%s", t);

	int l1 = strlen(s);
	int l2 = strlen(t);

	int k = -1;

	for(int i=l1-1;i>=l2-1;i--){
		bool found = true;
		for(int j=0;j<l2;j++){
			if(s[i-j]!='?'){
				if(t[l2-1-j]!=s[i-j]){
					found = false;
					break;
				}
			}
		}
		if(found){
			k = i;
			break;
		}
	}

	if(k==-1){
		printf("UNRESTORABLE\n");
	}else{
		for(int j=0;j<l2;j++){
			if(s[k-j]=='?'){
				s[k-j] = t[l2-1-j];
			}
		}
		for(int j=0;j<l1;j++){
			if(s[j]=='?'){
				s[j] = 'a';
			}
		}
		printf("%s\n", s);
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
int k;
int q[200]={0};
int a,b;
int ans=0;
int mem[110][5][5]={{{0}}};
int check(int x,int y,int z);//x日目,前日y,前々日z
int main(void){
    cin>>n>>k;

	for(int i=0;i<k;i++){
        cin>>a;
        cin>>b;
        q[a-1]=b;
	}



    cout<<check(0,0,0)<<endl;
	return 0;
}
int check(int x,int y,int z){
    if(mem[x][y][z]!=0)return mem[x][y][z];

    if(x==n){

        return 1;
    }
    if(q[x]!=0){
        if(q[x]==1){
            if(y!=1||z!=1){
            return check(x+1,1,y);
            }
            else return 0;
        }
        else if(q[x]==2){
            if(y!=2||z!=2){
            return check(x+1,2,y);
            }
            else return 0;
        }
        else if(q[x]==3){
            if(y!=3||z!=3){
            return check(x+1,3,y);
            }
            else return 0;
        }

    }
    else{

        if(y!=z||y==0){
            int a=check(x+1,1,y)+check(x+1,2,y)+check(x+1,3,y);
            a%=10000;
            mem[x][y][z]=a;
            return a;

        }
        else if(y==1){

            int a=check(x+1,2,y)+check(x+1,3,y);
            a%=10000;
            mem[x][y][z]=a;
            return a;
        }
        else if(y==2){

            int a=check(x+1,1,y)+check(x+1,3,y);
            a%=10000;
            return a;
        }
        else if(y==3){

            int a=check(x+1,1,y)+check(x+1,2,y);
            a%=10000;
            mem[x][y][z]=a;
            return a;

        }
    }


}

Measured memory_bytes: 1172
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    double t,x;
    cin >> t >> x;

    cout << setprecision(17) << fixed;
    cout << t/x << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
	int N;
	int count = 0, ans = 1;
	int A[102];
	
	cin >> N;
	for(int i = 1; i <= N; i++){
	    cin >> A[i];
	}
	A[N+1] = 0;

    for(int i = 1; i <= N+1; i++){
        if(A[i] == 0){
            ans = max(ans, i - count);
            count = i;
        }
    }

	cout << ans << endl;
}



Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using Pair = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;

int main(){
  ll n,d;
  vector<ll> pos;
  cin >> n >> d;
  d*=d;
  ll ans = 0;
  for(int i=0;i<n;i++){
    ll x,y;
    cin >> x >> y;
    if(d >=x*x+y*y) ans++;; 
  }
  cout << ans << endl;
}


Measured memory_bytes: 3620
N, M = map(int, input().split(" "))
ary = [list(map(int, input().split(" ") + [i])) for i in range(M)]

sort_ary = sorted(ary, key=lambda x: (x[0], x[1]))

ken = sort_ary[0][0]
index = 1
for node in sort_ary:
    if ken != node[0]:
        ken = node[0]
        index = 1
    node += [index]
    index += 1

ans_ary = sorted(sort_ary, key=lambda x: x[2])

r = ""
for node in ans_ary:
    r += "%06d"%node[0] + "%06d"%node[3] + "\n"

print(r[:-1])


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

int main() {
  int A,B,C,K;
  cin >> A >> B >> C >> K ;
  if(A>=K){ cout << K << endl; }
  else if(A+B>=K && A<K){ cout << A << endl; }
  else if(A+B<K ){ cout << A - (K-A-B) << endl; } 
  return 0;
}



Measured memory_bytes: 3632
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long MOD = (long)Math.pow(10, 9) + 7;
    int n = sc.nextInt();
    int m = sc.nextInt();
    long[] x = new long[n];
    long[] y = new long[m];
    for(int i = 0; i < n; i++) {
      x[i] = sc.nextLong();
    }
    for(int i = 0; i < m; i++) {
      y[i] = sc.nextLong();
    }
    long p1 = 0;
    long p2 = 0;
    for(int i = 0; i < n; i++) {
      p1 += ((long)(2 * i - n + 1) * x[i]) % MOD;
      p1 = p1 % MOD;
    }
    for(int i = 0; i < m; i++) {
      p2 += ((long)(2 * i - m + 1) * y[i]) % MOD;
      p2 = p2 % MOD;
    }
    System.out.println((p1 * p2) % MOD);
  }
}

Measured memory_bytes: 85088
#include<stdio.h>

#define MAX 100

int bubbleSort(int *,int);

int main(){

  int  N , j , flag , i , aa , temp , q ;
  
  int  A[MAX] ;
  
  scanf("%d",&N);
  for( i=0 ; i<N ; i++ )scanf("%d",&A[i]);
  


 
    for(i = 0;i<N-1;i++){
    for(j = N-1;j>=i + 1;j--){ 
    if(A[j] < A[j - 1]){
	temp=A[j-1];
	A[j-1]=A[j];
	A[j]=temp;
	q++;
      }
    }
    
  }
  
  

  for( j=0;j<N; j++){
  
    printf("%d",A[j]);
   

    if(j<N-1){
      printf(" ");
    }

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







Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
void chmax(int &x,int y){if(x < y) x = y;}
void chmin(int &x,int y){if(x > y) x = y;}
int n,a[100005],m;ll dd[100005],d[100005],x[100005];
ll offset;
void add(int l,int r,int x){
    if(l > r) return;
    dd[l] += x;
    dd[r+1] -= x;
}
int main()
{
    scanf("%d%d",&n,&m);
    rep(i,1,n) scanf("%d",a+i);
    rap(i,1,n) {
        if(a[i] < a[i+1]){
            offset += a[i+1] - a[i];
            //rep(j,a[i]+1,a[i+1]) d[j]--;
            //d[a[i+1]+1] += a[i+1] - a[i] - 1;
            add(a[i]+2, a[i+1], -1);
            add(a[i+1]+1, a[i+1]+1, a[i+1] - a[i] - 1);
        }
        else {
            offset += m - a[i] + a[i+1];
            //rep(j,a[i]+2,m) d[j]--;
            //d[1] -= (m - a[i] - 1);
            //rep(j,1,a[i+1]) d[j]--;
            //d[a[i+1]+1] += m - a[i] + a[i+1] + 1;
            add(a[i]+2, m, -1);
            add(1, 1, -(m - a[i] - 1));
            add(1, a[i+1], -1);
            add(a[i+1]+1, a[i+1]+1, m - a[i] + a[i+1] - 1);
        }
    }
    rep(i,1,m) d[i] = d[i-1] + dd[i];
    rep(i,1,m) x[i] = x[i-1] + d[i];
    //rep(i,1,m) printf("%d ",x[i] + offset);
    ll u = (ll)4e18;rep(i,1,m) u = min(u, x[i] + offset);
    printf("%lld\n",u);
    return 0;
}

Measured memory_bytes: 6408
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,a,b,c;
  cin>>n>>a>>b>>c;
  int st = 5*5*5;
  vector<vecint> dp(n+1, vecint(st));
  a = min(a, 4);
  b = min(b, 4);
  c = min(c, 4);
  auto id = [](int x, int y, int z) {
    x = min(x, 4);
    y = min(y, 4);
    z = min(z, 4);
    return x*25 + y*5 + z;
  };
  dp[0][id(a,b,c)] = 1;
  vector<string> vq(n);
  REP(i,n) {
    string s;
    cin>>s;
    vq[i] = s;
    if (s == "AB") {
      REP(j,st) {
        if (!dp[i][j]) continue;
        int x = j / 25;
        int y = (j / 5) % 5;
        int z = j % 5;
        if (x == 0 && y == 0) continue;
        if (x <= y) {
          dp[i+1][id(x+1,y-1,z)] = 'A' * st + j;
        }
        if (x >= y) {
          dp[i+1][id(x-1,y+1,z)] = 'B' * st + j;
        }
      }
    } else if (s == "AC") {
      REP(j,st) {
        if (!dp[i][j]) continue;
        int x = j / 25;
        int y = (j / 5) % 5;
        int z = j % 5;
        if (x == 0 && z == 0) continue;
        if (x <= z) {
          dp[i+1][id(x+1,y,z-1)] = 'A' * st + j;
        }
        if (x >= z) {
          dp[i+1][id(x-1,y,z+1)] = 'C' * st + j;
        }
      }
    } else {
      REP(j,st) {
        if (!dp[i][j]) continue;
        int x = j / 25;
        int y = (j / 5) % 5;
        int z = j % 5;
        if (y == 0 && z == 0) continue;
        if (y <= z) {
          dp[i+1][id(x,y+1,z-1)] = 'B' * st + j;
        }
        if (y >= z) {
          dp[i+1][id(x,y-1,z+1)] = 'C' * st + j;
        }
      }
    }
  }
  int cur = find_if(ALL(dp[n]), [](auto&& x) { return x > 0; }) - begin(dp[n]);
  if (cur == st) {
    cout << "No\n";
    return 0;
  }
  vector<char> res;
  REP(i,n) {
    int j = n-i;
    string s = vq[j-1];
    res.push_back(dp[j][cur] / st);
    cur = dp[j][cur] % st;
  }
  cout<<"Yes\n";
  reverse(ALL(res));
  for(auto&& ch : res) {
    cout<<ch<<"\n";
  }
  return 0;
}


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

int main() {
  ll a,b,c;
  cin >> a >> b >> c;
  if(c > a+b)
    if(4*a*b < (c-(a+b))*(c-(a+b)))
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
//  C.cpp
//  Created on 2018-07-13 14:51

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <queue>
#include <vector>
#define f(i,st,ed) for(int i=st;i<=ed;i++)
#define fd(i,st,ed) for(int i=st;i>=ed;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long
using namespace std;
inline int read(){char ch=getchar();int ret=0,f=1;while(ch>'9'||ch<'0'){if(ch=='0')f=-1;ch=getchar();}while(ch>='0'&&ch<='9')ret=ret*10+ch-'0',ch=getchar();return ret*f;}

const int mx=2e5+233;
int n,a[mx],b;ll ans;

int main(){
//	freopen("C.in","r",stdin);
//	freopen("C.out","w",stdout);
	n=read();f(i,1,n) a[i]=read()-i;
	sort(a+1,a+1+n);
	b=a[(n+1)/2];
	f(i,1,n) ans+=abs(a[i]-b);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 896
#include<cstdio>
#include<iostream>
#include<cstdlib>
using namespace std;
const int MAXN=200005;
int a[MAXN],N;
void check(){
	if(a[1]){printf("-1\n"); exit(0);}
	int num=1;
	for(int i=N;i>0;i--){
		num=max(num-1,a[i+1]-1);
		if(a[i]<num){printf("-1\n"); exit(0);}
	}
}
int main(){
	scanf("%d",&N);
	for(int i=1;i<=N;i++) scanf("%d",&a[i]);
	check();
	long long ans=0;
	for(int i=1;i<=N;i++){
		if(!a[i]) continue;
		if(a[i]==a[i-1]+1) ans++;
		else ans+=a[i];
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

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

    ll N,W; cin >> N >> W;
    vector<ll> w(N+5), v(N+5);

    for(int i=1; i<=N; ++i) cin >> w[i] >> v[i];

    // dp[i][j] := i番目までの品物まで見たときに、重さがj以下になるように詰め込んだ時の価値の最大値
    vector< vector<ll> > dp(N+5, vector<ll>(3*W+5, 0));

    for(int i=1; i<=N; ++i){
        for(int j=0; j<=W; ++j){
            // chose item[i]
            if(0 <= j-w[i]) chmax(dp[i][j], dp[i-1][j-w[i]]+v[i]);
            // not chose item[i]
            chmax(dp[i][j], dp[i-1][j]);
        }
    }

    cout << dp[N][W] << endl;

	return 0;
}


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

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)
#define SCANFD(x) scanf("%d",&x)

int main(){
  int A,P;

  cin >> A >> P;
  
  P += A * 3;

  cout << P/2 << 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;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_XM = 100005;
ll myuse[MAX_XM];

int main()
{
	ll N;
	cin >> N;
	ll X,M;
	cin >> X >> M;
	ll temp = X;
	myuse[temp] = ll(1);
	ll cnt = 1, loop = 0, startcnt = 0;
	while(true)
	{
		cnt++;
		temp = temp*temp%M;
		if (myuse[temp] > 0)
		{
			loop = cnt - myuse[temp];
			startcnt = myuse[temp];
			break;
		}
		else
		{
			myuse[temp] = cnt;
			//loopsum += temp;
		}
	}
	ll loopsum = temp, startnum = temp;
	temp = temp * temp % M;
	while(temp != startnum)
	{
		loopsum += temp;
		temp = temp * temp % M;
	}
	//cout << cnt << " " << loop << " " << loopsum << " " << startcnt << endl; 
	ll ans = (N - (startcnt - 1)) / loop * loopsum;
	ll res = (N - (startcnt - 1)) % loop;
	temp = X;
	rep(i,startcnt-1)
	{
		ans += temp;
		temp = temp * temp % M;
	}
	temp = startnum;
	rep(i,res)
	{
		ans += temp;
		temp = temp * temp % M;
	}
	cout << ans << endl;
	return 0;
}

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

int a[101]={0};

int main()
{
	int n,x;
	cin>>n;
	
	for(int i=1; i<=n; i++)
	{
		cin>>x;
		a[x]=1;
	}
	
	int s=0;
	for(int i=1; i<=100; i++)
	{
		if(a[i]==1) s++;
	}
	
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int N;
vector<ll> a;

void input(void){
    cin >> N;
    a.resize(N);
    for (int i = 0; i < N; ++i)
        cin >> a[i];
}

bool _judge(ll k){
    vector<ll> a_copy = a;
    for (auto& ai : a_copy)
        ai += k - N + 1;
    ll tmp = 0;
    for (auto ai : a_copy)
        if (ai > 0)
            tmp += ai / (N + 1) + (ai % (N + 1) > 0 ? 1 : 0);
    return k >= tmp;
}

bool judge(ll k){
    for (ll i = k; i >= max(0LL, k - 100); --i)
        if (_judge(i)) return true;
    return false;
}

int main(void){
    input();
    ll ng = -1, ok = (ll)1e18;
    while (ok - ng > 1){
        ll mid = (ng + ok) / 2;
        if (judge(mid)) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
    return 0;
}

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

int main() {
 char x,y;
  cin >>x >> y;
  if ((int)x>(int)y)
    cout <<'>';
  if ((int)x==(int)y)
    cout <<'=';
  if ((int)x<(int)y)
    cout <<'<';
}


Measured memory_bytes: 256
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

""" どのパワー以上の組み合わせまで握手するのか二分探索で調べる
    同じパワーとなる組み合わせに注意 """
N, M = lr()
A = np.array(lr())
A.sort()

def check(x):
    # x以上の幸福度で握手した時、M回以下だとTrueを返す
    Y = np.searchsorted(A, x - A)
    return N*N - Y.sum() <= M

ok = 10 ** 6; ng = 0
while abs(ng-ok) > 1:
    mid = (ok+ng) // 2
    if check(mid):
        ok = mid
    else:
        ng = mid

Acum = np.zeros(N+1, np.int64)
Acum[1:] = A.cumsum()
Y = np.searchsorted(A, ok-A)
answer = (Acum[-1] - Acum[Y]).sum() + (A * (N-Y)).sum()
answer += ng * (M - (N-Y).sum())
print(answer)
# 24

Measured memory_bytes: 23452
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve();
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve()
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			string s = Console.ReadLine();
			string ans = "Yes";
			if (s[0] != 'a' && s[1] != 'a' && s[2] != 'a') {
				ans = "No";
			}
			if (s[0] != 'b' && s[1] != 'b' && s[2] != 'b') {
				ans = "No";
			}
			if (s[0] != 'c' && s[1] != 'c' && s[2] != 'c') {
				ans = "No";
			}
			Console.WriteLine(ans);

		}
	}
}


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

using namespace std;

//#Rohitpratap311
//#Keep Calm And Stay Happy

typedef long long ll;
typedef long double ld;

bool ifprime(ll n)
{
    if(n==2||n==3) { return true ; }
    for(ll i=2;i<=sqrt(n);i++)
    {
        if(n%i==0) { return false; }
    }
    return true;
}

ll gcd(ll a,ll b)
{
    if(b==0) { return a; }
    return gcd(b,a%b);
}
 
ll lcm(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
    {
       ll n;
      cin>>n;
      if(n==0) cout<<"1";
      if(n==1) cout<<"0";
    }
    return 0;
}

Measured memory_bytes: 3688
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scan(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define lim 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}

// header
int h,w;int cnt=0;
char r;
void input(){
    cin>>h>>w;
    rep(i,h){
        rep(j,w){
            cin>>r;
            if(r=='#')cnt++;
        }
    }
}
void src(){
    cout<<((cnt==(h+w-1))? "Possible":"Impossible" );
}   
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {
	int a, b, c, d;

	cin >> a >> b >> c >> d;

	if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256