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

int main() { long N; long M; cin >> N >> M;
vector<long> x(N); vector<long> y(N); vector<long> z(N);
for(int i = 0; i < N; i++){
  cin >> x.at(i) >> y.at(i) >> z.at(i);
}

vector<int> sign(3);
vector<long> sum(N);
long sumsummemo = 0;

for(int i = 0; i < 8; i++){//ビット符号
  for(int k = 0; k < 3; k++){
    if(i & (1 << k)) sign.at(k) = 1;//-
    else sign.at(k) = 0;//+
  }
  for(int t = 0; t < N; t++){
    sum.at(t) = pow(-1, sign.at(2)) * x.at(t) +
    pow(-1, sign.at(1)) * y.at(t) +
    pow(-1, sign.at(0)) * z.at(t);
  }
  sort(sum.begin(), sum.end());
  reverse(sum.begin(), sum.end());
  long sumsum = 0;
  for(int t = 0; t < M; t++) sumsum += sum.at(t);
  if(sumsum > sumsummemo) sumsummemo = sumsum;
}

// int i = 1;
//   for(int k = 0; k < 3; k++){
//     if(i & (1 << k)) sign.at(k) = 1;//-
//     else sign.at(k) = 0;//+
//   }
//     sum.at(0) = pow(-1, sign.at(2)) * x.at(0) +
//     pow(-1, sign.at(1)) * y.at(0) +
//     pow(-1, sign.at(0)) * z.at(0);

// cout << sign.at(0) << sign.at(1) << sign.at(2);
// cout << endl << sum.at(0);

cout << sumsummemo << endl;
  return 0;
 
}
   

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  int n, d;
  cin >> n >> d;
  int ans = 0;
  while (n--) {
    ll a, b;
    cin >> a >> b;
    double x = sqrt((a * a) + (b * b));
    x = ceil(x);
    if (x <= d)ans++;


  }
  cout << ans << endl;
}

Measured memory_bytes: 3644
// https://atcoder.jp/contests/abc088/tasks/abc088_b
"use strict"
function Main(input) {
  const params = input.split('\n');
  const n = Number(params[0]);
  const a = params[1].split(' ').map(Number);
  const sortA = a.sort((s1, s2) => s2 - s1);

  // リファクタでコメントアウト化
  // const aliceTotal = sortA.reduce((acc, cur, index) => {
  //   if (index % 2 === 0) {
  //     return acc + cur;
  //   }
    
  //   return acc;
  // }, 0);

  // const bobTotal = sortA.reduce((acc, cur, index) => {
  //   if (index % 2 !== 0) {
  //     return acc + cur;
  //   }
    
  //   return acc;
  // }, 0);

  let aliceTotal = 0;
  let bobTotal = 0;

  sortA.forEach((cur, index) => {
    if (index % 2 === 0) {
      aliceTotal += cur;
    } else {
      bobTotal += cur;
    }
  });

  console.log(aliceTotal - bobTotal);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
	long long int a;
	cin >> a;

	long long int x, y;
	for (int i = sqrt(a); i >= 1; i --) {
		if (a % i == 0) {
			x = i;
			y = a / i;
			break;
		}
	}
	cout << x + y - 2 << '\n';

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void){
	char s[210000];
	int ap,zp;
	
	scanf("%s",s);
	
	ap=0;
	zp = strlen(s);
	while(s[ap] != 'A') ap++;
	while(s[zp] != 'Z') zp--;
	
	printf("%d\n",zp-ap+1);
	
	return 0;
}

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

#define rep(i,l,n) for(int (i)=(l);(i)<(n);(i)++)
#define min(a,b) (a)<(b)?(a):(b)
#define max(a,b) (a)>(b)?(a):(b)

int kaibun(char*,int,int);

int main(){
	long double L; scanf("%Lf",&L);
	printf("%Lf",L*L*L/27);
	return 0;
}


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

int main() {
  long double a = 0, b = 0, c = 0;
  cin >> a >> b >> c;

  if(a + b - c + 2 * sqrt(a*b) < 0){
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const ll INF = 1e17+7;


int main(){

    ll x,y;
    cin >> x >> y;
    if((ll)abs(x-y) <= 1){
        cout << "Brown" << endl;
    }else{
        cout << "Alice" << endl;
    }







    return 0;
}

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

int main(int argc, char **argv)
{
	cin.tie(NULL);

	int N, T;
	cin >> N >> T;

	int c[N], t[N];

	for (int i = 0; i < N; i++)
	{
		cin >> c[i] >> t[i];
	}

	int min_cost = 1001;
	for (int i = 0; i < N; i++)
	{
		if (t[i] <= T)
		{
			if (c[i] < min_cost)
			{
				min_cost = c[i];
			}
		}
	}

	if (min_cost == 1001)
	{
		cout << "TLE" << endl;
	}
	else
	{
		cout << min_cost;
	}
	
	return 0;
}

Measured memory_bytes: 256
main :: IO ()
main = do
  a <- readLn
  b <- readLn 
  c <- readLn 
  x <- readLn 
  print $ sol a b c x

sol :: Int -> Int -> Int -> Int -> Int
sol a b c x
  = sum [f b c (x-500*a') | a' <- [0..a]]

-- # of ways to pay y yen by b 100 yen and c 50 yen.
f b c y = sum [g c (y-100*b') | b' <- [0..b]]

-- # of ways to pay z yen with c 50 yen.
g c z
  | z >= 0 && 50*c >= z = 1 
  | otherwise           = 0

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
 
int main(){

    short N;
    cin >> N;
    string S, T;
    cin >> S;
    cin >> T;
    string result(2*N, 'a');

    for(int i=0; i<(2*N - 1); i+=2){
        result[i] = S[i/2];
        result[i+1] = T[i/2];
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop

N, M, *A = map(int, open(0).read().split())

q = []
for v in A:
    heappush(q, -v)
    
for _ in range(M):
    v = heappop(q)
    heappush(q, -((-v) // 2))
    
print(-sum(q))


Measured memory_bytes: 95396
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

template<class T> class rollinghash {
	const ull mask30 = (1LL << 30) - 1;
	const ull mask31 = (1LL << 31) - 1;
	const ull mod61 = (1LL << 61) - 1;
	const ull base = 10000001;
	vector<ull> hashvalue, basepower;
	int length;
	ull modulo(ull a) {
		ull au = a >> 61; ull ad = a & mod61;
		ull res = au + ad; if (res >= mod61) res -= mod61;
		return res;
	}
  	ull multiply(ull a, ull b) {
		ull au = a >> 31; ull ad = a & mask31;
		ull bu = b >> 31; ull bd = b & mask31;
		ull mid = ad * bu + au * bd;
		ull midu = mid >> 30; ull midd = mid & mask30;
		return modulo(au * bu * 2 + midu + (midd << 31) + ad * bd);
	}
public:
	rollinghash(T s) {
		length = s.size();
		hashvalue = vector<ull>(length + 1);
		for (int i = 0; i < length; i++) {
			hashvalue[i + 1] = modulo(multiply(hashvalue[i], base) + s[i] + 1);
		}
		basepower = vector<ull>(length + 1);
		basepower[0] = 1;
		for (int i = 1; i <= length; i++) {
			basepower[i] = modulo(multiply(basepower[i - 1], base));
		}
	}
	ull hash(ll l, ll r) { // hash of [l, r)
		assert(l < r && 0 <= l && l < length && 0 < r && r <= length);
		return modulo(hashvalue[r] + mod61 * 3 - multiply(hashvalue[l], basepower[r - l]));
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	string s;
	cin >> s;
	rollinghash<string> rol(s);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			while (i + ans < j && j + ans < n) {
				if (rol.hash(i, i + ans + 1) != rol.hash(j, j + ans + 1)) break;
				ans++;
			}
		}
	}
	cout << ans << '\n';
}

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

namespace ABC178
{
    public class QuestionC
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            if (n == 1)
            {
                Console.WriteLine(0);
                return;
            }

            if (n == 2)
            {
                Console.WriteLine(2);
                return;
            }

            var m = 1000000007L;

            var countAll = 1L;
            var countIgnore0Or9 = 1L;
            var countIgnore0And9 = 1L;
            for (int i = 0; i < n; i++)
            {
                countIgnore0Or9 = (countIgnore0Or9 * 9L) % m;
                countIgnore0And9 = (countIgnore0And9 * 8L) % m;
                countAll = (countAll * 10L) % m;
            }

            var count = (((countAll + countIgnore0And9 - (2 * countIgnore0Or9)) % m) + m) % m;

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 27488
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#define rep(index,num) for(int index=0;index<num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
int INF=2e+9;
int main(){
	int N,a[100000];
	int amax=-1;
	int argamax=-1;
	double absmin=INF;
	int argabsmin=-1;
	scan(N);
	rep(i,N){
		scan(a[i]);
		if(amax<a[i]){
			argamax=i;
			amax=a[i];
		}
	}
	rep(i,N){
		if(i==argamax) continue;
		if(fabs(amax/2.0-a[i])<absmin){
			argabsmin=i;
			absmin=fabs(amax/2.0-a[i]);
		}
	}
	printf("%d %d\n",amax,a[argabsmin]);
	return 0;
}


Measured memory_bytes: 640
N, Q = map(int, input().split())
S = input()
c = [0]*N
for i in range(1, N):
    c[i] = c[i-1]
    if S[i-1]=="A" and S[i]=="C":
        c[i] = c[i-1] + 1
for _ in range(Q):
    l, r = map(int, input().split())
    print(c[r-1]-c[l-1])

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

using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0 ; i < n ; i++)
		cin >> a[i];
	vector<bool> dp(k + 5);
	for (int stone = 0 ; stone <= k ; stone++)
	{
		for (int x : a) // Foreach stones in array a
		{
			if (x <= stone && !dp[stone-x])
			{
				dp[stone] = true;
			} 			
		}
	}
	cout << (dp[k] ? "First" : "Second") << "\n";
	return 0;
}


/*
 	dp[i]: True if player 1 win with i stones remaining
    The relation is: if (current x <= i remaining stones AND dp[remaining stones] = false) dp[i] = true
    Why dp[stone-x] needs to be false: because after stone - x the turn will change to the player 2 and if dp[stone-x] = false is mean that player 2 loose => player 1 win
 */


Measured memory_bytes: 256
gets
s = gets.chomp

nc = 0
ncs = [0]

s[0..-2].each_char do |c|
  nc += 1 if c == 'W'
  ncs << nc
end

wc = 0
wcs = [0]
s.reverse[0..-2].each_char do |c|
  wc += 1 if c == 'E'
  wcs.unshift wc
end

ret = 1000000

ncs.zip(wcs).each do |n,s|
  ret = n+s if n+s < ret
end

p ret

Measured memory_bytes: 23772
#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()
{
  int K, A, B;

  cin >> K;
  cin >> A >> B;

  if (K == 1 || A % K == 0 || B % K == 0 || int(B / K) - int(A / K) >= 1)
  {
    cout << "OK" << endl;
  }
  else
  {
    cout << "NG" << endl;
  }
  return 0;
}



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

struct BIT{
    vector<int> data;

    void init(int n){
        data.assign(n+1, 0);// 1-indexed [1,n]
    }

    void add(int i, int x){
        while(i <= data.size()){
            data[i] += x;
            i += (i & -i);
        }
    }

    int sum(int i){
        int s = 0;
        while(i > 0){
            s += data[i];
            i -= (i & -i);
        }
        return s;
    }
};

int main(){
    int n;
    long long int d, a;
    cin >> n >> d >> a;

    vector<pair<long long int, long long int>> monster(n);
    vector<long long int> x(n);
    for(int i=0; i<n; i++){
        cin >> monster[i].first >> monster[i].second;
        x[i] = monster[i].first;
    }
    sort(monster.begin(), monster.end());
    sort(x.begin(), x.end());

    BIT bit;
    bit.init(n+1);

    long long int ans = 0;
    for(int i=0; i<n; i++){
        long long int mx = monster[i].first;
        int ni = upper_bound(x.begin(), x.end(), mx + 2*d) - x.begin();
        //cout << monster[i].second << " " << bit.sum(i+1) * a << endl;

        int times = max(0LL, (monster[i].second - bit.sum(i+1) * a + a - 1) / a);
        
        bit.add(i+1,   times);// 1-indexed
        bit.add(ni+1, -times);// 1-indexed
        ans += times;
    }
    cout << ans << endl;
    return 0;
}

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



int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	
	int a[3];
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}

	sort(a, a+3);
	if (a[0] == 5 && a[1] == 5 && a[2] == 7) {
		cout << "YES\n";
	}
	else {
		cout << "NO\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a,b,c,d;
  cin >>a >>b >>c >>d;
  if(a<=b &&c<=d){cout << a+c<<endl;}
  else if(a>=b &&c<=d){cout << b+c<<endl;}
  else if(a<=b &&c>=d){cout << a+d<<endl;}
  else if(a>=b &&c>=d){cout << b+d<<endl;}
  return 0;
}

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

using namespace std;

int main() {
  int a, b;
  string s;
  cin >> a >> b >> s;
  bool valid = true;
  for (int i = 0; i < s.size(); i++) {
    if (!((i == a && s[i] == '-') || (i != a && isdigit(s[i])))) valid = false;
  }
  cout << (valid ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;int h,n,a,b,i,j,k;main(){cin>>h>>n;vector<int>dp(h+1,1e9);dp[0]=0;for(i=0;i<n;i++){cin>>a>>b;for(j=0;j<h;j++)k=min(j+a,h),dp[k]=min(dp[k],dp[j]+b);}cout<<dp[h]<<"\n";}


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

vector<int> h(200100);

int main() {
  int n,k;
  cin >> n >> k;
  rep(i,200100) h[i] = INFINITY;
  rep(i,n) cin >> h[i];

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

  ll sum = 0;
  rep(i,n-k) {
    sum += h[i];
  }
  cout << sum << endl;

  return 0;
}


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

#define ll long long
#define ar array
// long a,b,n,d;
// long ans = 0;
// void solve(){
//     cin >> n;
//     long x = n/2 ;
//     while(x >= 0){
//         ans += (n-1)*4*x;
//         n-=2 ;
//         --x;
//     }
//     cout << ans ;


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

    ll n,a,b;
    cin >> n >> a>> b;
    ll c = n%(a+b);
    if(c >=a ){
        cout << n/(a+b)*a+a;
    }else{
        cout << n/(a+b)*a + c;
    }

}



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

struct Node {
  int key;
  struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

Node * treeMinimum(Node *x) {
  while(x->left != NIL)
    x = x->left;
  return x;
}

Node * find(Node *u, int k) {
  while(u != NIL && k != u->key) {
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

Node * treeSuccessor(Node *x) {
  if(x->right != NIL) return treeMinimum(x->right);
  Node *y = x->parent;
  while(y != NIL && x == y->right) {
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node *z) {
  Node *y; // 削除する対象
  Node *x; // yの子

  // 削除する節点を決める
  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  // yの子xを決める
  if(y->left != NIL) {
    x = y->left;
  } else {
    x = y->right;
  }

  if(x != NIL) {
    x->parent = y->parent;
  }

  if(y->parent == NIL) {
    root = x;
  } else {
    if(y == y->parent->left) {
      y->parent->left = x;
    } else {
      y->parent->right = x;
    }
  }

  if(y != z) {
    z->key = y->key;
  }
}

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;
  
  z = (Node *)malloc(sizeof(Node));
  z->key   = k;
  z->left  = NIL;
  z->right = NIL;
  
  while(x != NIL) {
    y = x;
    if(z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  
  z->parent = y;
  if(y == NIL) {
    root = z;
  } else {
    if( z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node *u) {
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u) {
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
  
int main(void) {
  int n, i, x;
  char com[16];
  scanf("%d",&n);
  
  for(i=0;i<n;i++) {
    scanf("%s",com);
    if(!strcmp(com,"find")) {
      scanf("%d",&x);
      Node *t = find(root,x);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    } else if(!strcmp(com,"insert")) {
      scanf("%d",&x);
      insert(x);
    } else if(!strcmp(com,"print")) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if(!strcmp(com,"delete")) {
      scanf("%d",&x);
      treeDelete(find(root,x));
    }
  }

  return 0;
}



Measured memory_bytes: 20440
total, legs = [int(i) for i in input().split()]

turtles = legs // 2 - total
cranes = total - turtles

# print(turtles, cranes)

res = turtles >= 0 and cranes >= 0 and turtles * 4 + cranes *2 == legs and turtles + cranes == total

print("Yes" if res else "No")


Measured memory_bytes: 9164
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] a = new int[n+1];
		int p;
		long sum = 1;
		for(int i=0;i<n;i++){
			p = sc.nextInt();
			for(int j=1;j<=p;j++){
				a[j]++;
				if(j==n){
					sum += p-n;
					break;
				}
			}
		}
		for(int i=1;i<=n;i++) sum += Math.min(i*4, a[i]);
		System.out.println(sum);
	}	
}

Measured memory_bytes: 21144
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(c)              c.begin(), c.end()
#define FastRead ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

int main()
{
    FastRead
    ll x;
    cin >> x;
    string s;
    cin.ignore();
    getline(cin,s);
    for(int i=0;i<s.size();i++)
    {
         int xx = s[i]-'A';
         xx+=x;
         xx%=26;
         int z=0;
         for(char c='A';c<='Z';c++)
         {
             if(xx==z){cout << c;break;}
             z++;
         }

    }
     cout << endl;
}


Measured memory_bytes: 256
'use strict'

function main(input){
  const lines = input.split('\n');
  const N = parseInt(lines.shift());
  const S = [];
  for(let i=0;i<N;i++){
    S.push(lines[i].split(''))
  }
  const march=Array(5).fill(0);

  for(let i=0;i<N;i++){
    if( lines[i][0]=='M' ){ march[0]++; }
    if( lines[i][0]=='A' ){ march[1]++; }
    if( lines[i][0]=='R' ){ march[2]++; }
    if( lines[i][0]=='C' ){ march[3]++; }
    if( lines[i][0]=='H' ){ march[4]++; }
  }

//march.fill(3000)

//  console.log(march)

  let result = 0;

  for(let i = 0;i<3;i++){
    for(let j = i+1;j<4;j++){
      for(let k = j+1;k<5;k++){
//        console.log([i,j,k])
//        console.log(march[i]*march[j]*march[k]);
//console.log(result);
//console.log('---');
        result += march[i]*march[j]*march[k];
      }
    }
  }

  console.log(result);

}

main( require('fs').readFileSync('/dev/stdin','utf8') );


Measured memory_bytes: 50616
#include <iostream>

using namespace std;

int main(){
   int i = 1;
   while (true){
      int x;
      cin >> x;
    
      if (x == 0) {
         break;
      }
      
      cout << "Case" << " " << i <<": " << x << endl;
      
      i++;
   
   }
   return 0;
}

Measured memory_bytes: 864
#include<algorithm>
#include<cmath>
#include<climits>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

	int r = N % 10;
	if (r == 3)
	{
		cout << "bon" << endl;
	} 
	else if (r == 0 || r == 1 || r == 6 || r == 8)
	{
		cout << "pon" << endl;
	}
	else
	{
		cout << "hon" << endl;
	}
	
	return 0;
}

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

int main(){
  long long n, a, b;
  long long x, start;
  long long ans = 0;

  cin >> n >> a >> b;

  cin >> start;
  
  for(int i=1; i<n; ++i){
    cin >> x;

    if((x-start)*a < b){
      ans += (x-start)*a;
    }else{
      ans += b;
    }
    start = x;
  }

  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;
ll val[200005];
ll vis[200005];
ll ans[200005];
vector<ll> adj[200005];
vector<ll> LIS;
void dfs(ll root,ll maxans){
    vis[root] = 1;
    ll pos = lower_bound(LIS.begin(), LIS.end(), val[root]) - LIS.begin();
    int flag = 0;
    ll prev = 0;
    if(pos==LIS.size()){
        LIS.pb(val[root]);
        flag = 1;
    }
    else{
        prev = LIS[pos];
        LIS[pos] = min(LIS[pos], val[root]);
    }
    ans[root] = max(pos + 1,maxans);
    ///if(root==2)
       /// cout << ans[root] << "\n";
    for(auto x:adj[root]){
        if(vis[x]==0)
            dfs(x,ans[root]);
    }
    if(flag==1){
        LIS.pop_back();
    }
    else{
        LIS[pos] = prev;
    }
    return;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll i, j, k, l, n, m;
    cin >> n;
    for (i = 1; i <= n;i++)
        cin >> val[i];
    for (i = 1; i < n;i++){
        cin >> k >> l;
        adj[k].pb(l);
        adj[l].pb(k);
    }
    dfs(1,0);
    for (i = 1; i <= n;i++)
        cout << ans[i] << "\n";
    return 0;
}

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

const int INF = 9999999;
const int MAXL = 3000+7;

string s,t;
int dp[MAXL][MAXL];
pair<int,int> an;
string ans;

inline string best(string a,string b){
    if(a.length() > b.length())return a;
    else return b;
}

int main(){
    cin >> s;
    cin >> t;
    if(s.length() < t.length())swap(s,t);

    ans = "";
    dp[0][0] = 0;
    for(size_t i = 1;i < s.length();++i)dp[i][0] = 0;
    for(size_t i = 1;i < t.length();++i)dp[0][i] = 0;

    for(size_t i = 1;i <= s.length();++i){
        for(size_t j = 1;j <= t.length();++j){
            if(s[i-1] == t[j-1]){
                dp[i][j] = dp[i-1][j-1]+1;
                if(dp[i][j] > dp[an.first][an.second])an = {i,j};
            }else{
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }

    for(int a = an.first,b = an.second; a > 0 and b > 0;){
        if(s[a-1] == t[b-1]){
            ans += s[a-1];
            --a,--b;
        }else{
            if(dp[a-1][b] > dp[a][b-1])--a;
            else --b;
        }
    }

    reverse(ans.begin(),ans.end());
    cout << ans << "\n";
}


Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n;
    cin >> n;
    vector<vector<int>> x(n), y(n);
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        x[i].resize(a), y[i].resize(a);
        for(int j = 0; j < a; ++j){
            cin >> x[i][j] >> y[i][j];
            --x[i][j];
        }
    }
    int ans = 0;
    for(int bit = 0; bit < (1 << n); ++bit){
        vector<int> table(n, 0);
        int cnt = 0;
        for(int i = 0; i < n; ++i){
            if((bit >> i) & 1)  table[i] = 1, ++cnt;
        }
        bool ok = true;
        for(int i = 0; i < n; ++i){
            if(!table[i])   continue;
            for(int j = 0; j < x[i].size(); ++j){
                if(table[x[i][j]] != y[i][j]){
                    ok = false;
                    break;
                }
            }
        }
        if(ok)  chmax(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define MX 10000000000
#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}

ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
void solve()
{
    int h,n;
    cin >> h >> n;
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        sum += a;
    }
    if (sum >= h)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }

}
int main()
{
	int t = 1;
//	cin >> t;
	while (t--)
	{
		solve();
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
int main() {
    //freopen("input.txt", "r", stdin);
    long n, q, b, c, temp, sum = 0;
    vector<long> a(100001);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> temp;
        a[temp]++;
        sum += temp;
    }
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> b >> c;
        sum -= a[c] * c;
        sum -= a[b] * b;
        a[c] += a[b];
        a[b] = 0;
        sum += a[c] * c;
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 3844
loop do
    n, m = gets.split.map(&:to_i)
    break if n == 0
    codes = (1..m).map { gets.to_i }.sort
    valid_codes = (0..255).map do |x| 
        a = codes.dup
        t = nil 
        t = a.shift until a.empty? || x + a[0] >= 0
        a.unshift t if t
        t = a.pop until a.empty? || x + a[-1] <= 255 
        a << t if t
        a.map{|c| x + c < 0 ? -x : c}.map{|c| x + c > 255 ? 255 - x : c}.uniq
    end 
    xs = (1..n).map { gets.to_i }
    costs = [Float::INFINITY] * 256 
    costs[128] = 0 
    xs.each do |x| 
        new_costs = [Float::INFINITY] * 256 
        (0..255).each do |y0|
            valid_codes[y0].each do |code|  
                y1 = y0 + code
                c = costs[y0] + (y1 - x) ** 2
                new_costs[y1] = c if c < new_costs[y1]
            end
        end
        costs = new_costs
    end 
    p costs.min
end

Measured memory_bytes: 31956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	int n;cin>>n;
	map<int,ll> mp;
	pair<int,ll> a[n];
	rep(i,n){
		cin>>a[i].first;
		mp[a[i].first]++;
	}
	rep(i,n){
		a[i].second=mp[a[i].first];
	}
	ll sum=0;
	for(auto i:mp){
		sum+=i.second*(i.second-1)/2;
	}

	rep(i,n){
		ll ans=sum,m=a[i].second;
		if(m>1){
			ans-=m*(m-1)/2-(m-1)*(m-2)/2;
		}
		cout<<ans<<"\n";
	}
}

Measured memory_bytes: 12672
#include <stdio.h>
#include <stdlib.h>

int getNumberOfElements();
int* creatArrayThroughNumberOfElements(int numberOfElements);
void selectionSort(int* array, int number, int* count);
void printArray(int* array, int number);
void swap(int* a, int* b);

int main(void)
{
	int numberOfElements = getNumberOfElements();
	int* sequence = creatArrayThroughNumberOfElements(numberOfElements);
	int count = 0;

	selectionSort(sequence, numberOfElements, &count);
	printArray(sequence, numberOfElements);
	printf("%d\n", count);
	return 0;
}

int getNumberOfElements()
{
	int input;
	scanf("%d", &input);
	return input;
}

int* creatArrayThroughNumberOfElements(int numberOfElements)
{
	int* array = (int*) malloc(numberOfElements * sizeof(int));
	int i;
	for (i = 0; i < numberOfElements; i++)
		scanf("%d", array + i);
	return array;
}

void selectionSort(int* array, int number, int* count)
{
	int now;
	int subOfMinInUnsearchedElements;
	int i, j;
	for (i = 0; i < number - 1; i++)
	{
		subOfMinInUnsearchedElements = i;
		for (j = i + 1; j < number; j++)
		{
			if (*(array + j) < *(array + subOfMinInUnsearchedElements))
			{
				subOfMinInUnsearchedElements = j;
			}
		}
		if (i != subOfMinInUnsearchedElements)
		{
			swap(array + i, array + subOfMinInUnsearchedElements);
			(*count)++;
		}
	}
}	

void printArray(int* array, int number)
{
	int i;
	for (i = 0; i < number - 1; i++)
		printf("%d ", *(array + i));
	printf("%d\n", *(array + i));
}

void swap(int* a, int* b)
{
	int temp = *a;
	*a = *b;
	*b = temp;
}


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

int main(){
  int X,Y,A,B,C;
  cin >> X >> Y >> A >> B >> C;
  vector<int64_t> p(A),q(B),r(C);
  for(int i=0;i<A;i++){
    cin >> p.at(i);
  }
  for(int i=0;i<B;i++){
    cin >> q.at(i);
  }
  for(int i=0;i<C;i++){
    cin >> r.at(i);
  }
  sort(p.begin(),p.end());
  reverse(p.begin(),p.end());
  sort(q.begin(),q.end());
  reverse(q.begin(),q.end());
  sort(r.begin(),r.end());
  reverse(r.begin(),r.end());
  int i=X-1,j=Y-1,k=0;
  while(min(p.at(i),q.at(j))<r.at(k)){
    if(p.at(i)>q.at(j)){
      q.at(j)=r.at(k);
      j--;
    }else{
      p.at(i)=r.at(k);
      i--;
    }
    k++;
    if(i<0) i++;
    if(j<0) j++;
    if(k>=C) break;
  }
  int64_t sum=0;
  for(int l=0;l<X;l++){
    sum += p.at(l);
  }
  for(int l=0;l<Y;l++){
    sum += q.at(l);
  }
  cout << sum << endl;
}
    

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

string s;
int cnt[26] = {};

long long fact(int n) {
	if (n == 0 || n == 1) return 1;
	return n*fact(n-1);
}

int main() {
	cin >> s;
	for (int i = 0; i < s.size(); i++) cnt[s[i]-'a']++;

	int odd_cnt = 0;
	for (int i = 0; i < 26; i++) if (cnt[i] % 2 == 1) odd_cnt++;

	if (odd_cnt == 0 || odd_cnt == 1) {
		for (int i = 0; i < 26; i++) cnt[i] /= 2;
		int half_length = 0;
		for (int i = 0; i < 26; i++) half_length += cnt[i];

		long long pat = fact(half_length);
		for (int i = 0; i < 26; i++) pat /= fact(cnt[i]);
		cout << pat << endl;
	} else
		cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define MOD 1000000007
#define MAX 1000005
#define loop(i,a,b) for(long long int i=a;i<b;i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
typedef long long int ll;

using namespace std;
//using namespace boost::multiprecision;

int prime[MAX];

ll modular_expo(ll x,ll n)
{
	ll ans = 1;
	while(n)
	{
		if(n&1)
		ans = (ans * x)%MOD;
		x = (x*x)%MOD;
		n = n>>1;
	}
	return ans%MOD;
}

void sieve()
{
	prime[1] = 1;
	for(int i=2;i*i<MAX;i++)
	if(prime[i]==0)
	for(int j=i*i;j<MAX;j+=i)
	prime[j] = 1;
}


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

string str;
cin>>str;

if(str[0]=='7' or str[1]=='7' or str[2]=='7')
cout<<"Yes\n";
else
cout<<"No\n";


return 0;
}


Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var item1 = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            var N = item1[0];
            var K = item1[1];

            var pList = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            // var pList = new List<int>();
            // foreach (var i in Enumerable.Range(0, N))
            // {
            //     pList.Add(i + 1);
            // }

            var lineQueue = new Queue<double>();
            foreach (var i in Enumerable.Range(0, K))
            {
                var kitai = 1 + ((pList[i] - 1) * 0.5);
                lineQueue.Enqueue(kitai);
            }

            var maxIndex = K;
            var maxValue = lineQueue.Sum();
            var curSum = maxValue;

            foreach (var i in Enumerable.Range(K, N - K))
            {
                var kitai = 1 + ((pList[i] - 1) * 0.5);
                var de = lineQueue.Dequeue();
                lineQueue.Enqueue(kitai);
                curSum = curSum - de + kitai;
                if (maxValue < curSum)
                {
                    maxIndex = i;
                    maxValue = curSum;
                }
            }

            Console.WriteLine(maxValue);
        }
    }
}


Measured memory_bytes: 32476
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <stack>
#include <queue>
#include <bitset>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring> 
#include <iostream>
#include <algorithm>
using namespace std;
 
int H, W;
int l, r;
set< pair<int, int> > s;
multiset<int> ms;
 
int main()
{
	scanf("%d%d", &H, &W);
	for(int i = 1;i <= W;++i)
		s.insert(make_pair(i, i)), ms.insert(0);
 
 
	for(int i = 1;i <= H;++i)
	{
		int l, r;
		scanf("%d%d", &l, &r);
 
		set< pair<int, int> >::iterator it;
		int mx = -1, xx = 0;
		vector< pair<int, int> > v;
		for(it = s.lower_bound(make_pair(l, 0));it != s.end() && (*it).first <= r;it++)
		{
			//cerr << (*it).first << " " << (*it).second << endl;
			mx = max(mx, (*it).second);
			int num = (*it).first - (*it).second;
			ms.erase(ms.find(num));
			v.push_back(*it);
		}
		int si = v.size();
		for(int j = 0;j < si;++j)
		{
			pair<int, int> a = v[j];
			s.erase(s.find(a));
		}
		if(mx != -1 && r + 1 <= W)
		{
			ms.insert(r + 1 - mx);
			s.insert(make_pair(r + 1, mx));
		}
		if(ms.size() > 0)
			printf("%d\n", *ms.begin() + i);
		else
			printf("-1\n");
	}
 
	return 0;
}

Measured memory_bytes: 22544
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a+b > c+d){
    cout << "Left";
  }else if(a+b == c+d){
    cout << "Balanced";
  }else{
    cout << "Right";
  }
}


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

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

bool course[1000001];

bool is_prime(int n) {
    if (n % 2 == 0) return false;
    for (int i = 3; i <= std::sqrt(n); i += 2)
        if (n % i == 0) return false;
    return true;
}

int main() {
    int n, x;
    while (std::cin >> n >> x && n > 0 && x > 0) {
        rep(i, x + 1) course[i] = false;

        int prices[n];
        rep(i, n) { std::cin >> prices[i]; }
        course[0] = true;

        int max = -1;
        rep(i, x + 1) rep(j, n) {
            if (i - prices[j] >= 0 && course[i - prices[j]]) {
                if (is_prime(i)) max = i;
                course[i] = true;
                break;
            }
        }
        if (max < 0)
            std::cout << "NA" << std::endl;
        else
            std::cout << max << std::endl;
    }
}

Measured memory_bytes: 4064
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    
    if ((A*B) % 2)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

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

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner();
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a <= 5)
			b = 0;
		else if(6 <= a && a <= 12)
			b /= 2;
		System.out.println(b);
	}
}

class Scanner {
	private static final int SPACE = (int)' ';
	private static final int LINE_END_0 = 13;
	private static final int LINE_END_1 = 10;
	private static final int BEFORE = -1;
	private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	public String next(){
		StringBuilder sb = new StringBuilder();
		
		int length = BEFORE;
		readLoop: while(true) {
			try {
				int value = br.read();
				switch(value) {
				case LINE_END_1:
					if(length == BEFORE)
						break;
					
					if((int)sb.charAt(length) == LINE_END_0)
						sb.deleteCharAt(length);
				case SPACE:
					break readLoop;
				}
				sb.append((char)value);
				length++;

			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return sb.toString();
	}
	
	public String[] nextArray(int length) {
		String[] array = new String[length];
		for(int i = 0; i < length; i++)
			array[i] = next();
		return array;
	}
	
	public double nextDouble() {

		return Double.parseDouble(next());
	}
	
	public double[] nextDoubleArray(int length) {
		double[] array = new double[length];
		for(int i = 0; i < length; i++)
			array[i] = nextDouble();
		return array;
	}
	
	public int nextInt() {

		return Integer.parseInt(next());
	}
	
	public int[] nextIntArray(int length) {
		int[] array = new int[length];
		for(int i = 0; i < length; i++)
			array[i] = nextInt();
		return array;
	}
	
	public long nextLong() {

		return Long.parseLong(next());
	}
	
	public long[] nextLongArray(int length) {
		long[] array = new long[length];
		for(int i = 0; i < length; i++)
			array[i] = nextLong();
		return array;
	}
	
	public boolean ready() {
		try {
			return br.ready();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}
}


Measured memory_bytes: 21332
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
int n;
ll a[410],cum[410];
void cumu(ll x[],ll s[],int m){
  s[0]=0;
  rep1(i,m){
    s[i]=s[i-1]+x[i-1];
  }
}
ll dp[410][410];
ll rec(int i,int j){
  if(dp[i][j]>0) return dp[i][j];
  ll res=INFLL;
  if(i+1==j) return a[i]+a[j];
  for(int k=i+1;k<j-1;k++){
    res=min(res,rec(i,k)+rec(k+1,j));
  }
  res=min(res,rec(i,j-1));
  res=min(res,rec(i+1,j));
  res+=cum[j+1]-cum[i];
  return dp[i][j]=res;
}
int main(){
  cin>>n;
  rep(i,n) cin>>a[i];
  fill(dp,0);
  cumu(a,cum,n);
  ll res=rec(0,n-1);
  prin(res);

  

  return 0;
}


Measured memory_bytes: 1536
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_vec() -> Vec<i64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let d: i64 = input();
    let c_vec = input_vec();
    let mut scores: Vec<Vec<i64>> = Vec::new();
    let last = vec![0; 26];
    for _ in 0..d {
        let score = input_vec();
        scores.push(score);
    }
    for day_idx in 0..d {
        let mut max = 0;
        let mut max_idx = 0;
        for contest_idx in 0..26 {
            let mut score = scores[day_idx as usize][contest_idx];
            for i in 0..26 {
                if i == contest_idx {
                    continue;
                }
                score -= c_vec[i] * (day_idx + 1 - last[i]);
            }
            if score > max {
                max = score;
                max_idx = contest_idx;
            }
        }
        println!("{}", max_idx + 1);
    }
}


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<vector<int>> a(n, vector<int>(m));
	vector<int> k(n);
	vector<int> sum(m);
	rep(i, n) {
		cin >> k[i];
		rep(j, k[i]) {
			cin >> a[i][j];
			sum[ a[i][j] - 1]++;
		}
	}
	int ans = 0;
	rep(i, m) {
		if (sum[i] == n) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7; // change if needed

struct Modint {
  ll val;
  
  Modint (ll _val = 0)
    : val(_val % MOD) {}

  Modint operator+ (Modint other) const {
    return Modint(val + other.val);
  }

  void operator+= (Modint other) {
    val += other.val;
    val %= MOD;
  }

  Modint operator- () const {
    return Modint(MOD - val);
  }

  Modint operator- (Modint other) const {
    return Modint(val + MOD - other.val);
  }

  void operator-= (Modint other) {
    val += MOD - other.val;
    val %= MOD;
  }

  Modint operator* (Modint other) const {
    return Modint(val * other.val);
  }

  void operator*= (Modint other) {
    val *= other.val;
    val %= MOD;
  }

  bool operator== (Modint other) const {
    return val == other.val;
  }

  bool operator!= (Modint other) const {
    return val != other.val;
  }
};

Modint exp (Modint a, int k) {
  if (k == 0) {
    return Modint(1);
  } else if (k % 2 == 0) {
    Modint half = exp(a, k / 2);
    return half * half;
  } else {
    return a * exp(a, k - 1);
  }
}

Modint inv (Modint a) {
  return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
  out << p.val;
  return out;
}

void failure () {
  cout << 0 << endl;
  exit(0);
}

const int MAX_N = 1e5 + 5;

ll arr [MAX_N];
Modint dp [MAX_N];
Modint cdp [MAX_N];

Modint get_sum (int l, int r) {
  if (l == 0) return cdp[r];
  return cdp[r] - cdp[l - 1];
}

int main () {
  ios::sync_with_stdio(false);

  int n;
  ll a, b;
  cin >> n >> a >> b;

  if (a > b) swap(a, b);

  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  arr[0] = arr[1] - b - 10;
  arr[n + 1] = arr[n] + b + 10;

  for (int i = 1; i + 2 <= n; i++) {
    if (arr[i + 2] - arr[i] < a) {
      failure();
    }
  }

  int l = 0, r = 0;
  dp[0] = 1;
  cdp[0] = 1;
  for (int i = 1; i <= n + 1; i++) {
    while (arr[i] - arr[r + 1] >= b) {
      r++;
    }

    if (l > r) {
      dp[i] = Modint(0);
    } else {
      dp[i] = get_sum(l, r);
    }
    cdp[i] = cdp[i - 1] + dp[i];

    // cerr << i << " " << l << " " << r << " " << dp[i] << endl;
    
    if (arr[i] - arr[i - 1] < a) {
      l = i - 1;
    }
  }

  cout << dp[n + 1] << endl;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  s[0]='2';s[1]='0';s[2]='1';s[3]='8';
  for(int i=0;i<s.size();i++){
    cout << s[i];
  }
  cout<<endl;
  return 0;
}


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

if N == 100000:
  print(90909)
elif N >= 10000:
  print(909 + N - 9999)
elif N >= 1000:
  print(909)
elif N >= 100:
  print(9 + N - 99)
elif N >= 10:
  print(9)
else:
  print(N)

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

#define rep(ver,n) rep2(ver,0,n)
#define rep2(ver,m,n) for(int ver=m;ver<(n);ver++)
#define loop while(true)
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(v) (v).begin(), (v).end()
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

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

int main(){
  int a;
  scanf("%d", &a);
  
  printf("%d", a+a*a+a*a*a);
  
  return 0;
}


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

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin>>n;
	int d=(n%1000);
	if(d==0)
		cout<<d<<"\n";
	else
		cout<<1000-d<<"\n";
}

Measured memory_bytes: 3648