akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()

int dist[10][10];

void wasyahuro(){
  rep(k,10){
    rep(i,10){
      rep(j,10){
        dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]);
      }
    }
  }
}

int main(){
  int H,W;cin>>H>>W;
  rep(i,10)rep(j,10)cin>>dist[i][j];
  int A[H][W];
  rep(i,H)rep(j,W)cin>>A[i][j];
  wasyahuro();
  //rep(i,10){rep(j,10){cout<<dist[i][j];}cout<<endl;};
  ll ans=0;
  rep(i,H){
    rep(j,W){
      if(A[i][j]==-1) continue;
      ans += dist[A[i][j]][1];
    }
  }
  cout << ans << endl;
}

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

int h, w;
long cnt;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
bool matrix[401][401], visited[401][401];

long dfs(int y, int x){
    visited[y][x] = true;
    long res = 0;
    if(matrix[y][x]) cnt++;
    else res = 1;
    for(int i = 0; i < 4; i++){
        int ny = y + dy[i], nx = x + dx[i];
        if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
        if(visited[ny][nx]) continue;
        if(matrix[y][x] == matrix[ny][nx]) continue;
        res += dfs(ny, nx);
    }
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h >> w;
    vector<pair<int, int>> black;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            char c; cin >> c;
            if(c == '#'){
                matrix[i][j] = true;
                black.emplace_back(i, j);
            }
        }
    }
    long long ans = 0;
    for(auto p : black){
        if(visited[p.first][p.second]) continue;
        cnt = 0;
        ans += cnt * dfs(p.first, p.second);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8820
n, mw = gets.chomp.split.map(&:to_i)
sum = []
w, v = gets.chomp.split.map(&:to_i)
mw.downto(0) do |i|
  if i >= w
    sum[i] = v
  else
    sum[i] = 0
  end
end

(n-1).times do
  w, v = gets.chomp.split.map(&:to_i)
  mw.downto(0) do |i|
    sum[i] = sum[i-w] + v if i >= w && sum[i] < sum[i-w] + v
  end
end

puts sum[mw]


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

    int t;
    t=1;
    while(t--)
    {
    	ll x,y,z;
    	ll k;
    	cin>>x>>y>>z>>k;
    		while(y<=x && k>0)
    		{
    			y=y*2;
    			k--;
			}
			while(z<=y && k>0)
			{
				z=z*2;
				k--;
			}
	
		if(x<y && y<z)
		{
			cout<<"Yes"<<endl;
		}
		else
		{
			cout<<"No"<<endl;
		}
	}
}

Measured memory_bytes: 3620
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        for(int i=s.length()-2; i>=1; i-=2){
            if(s.substring(0,i/2).equals(s.substring(i/2,i))){
                System.out.println(i);
                break;
            }
        }
        
    }
}

Measured memory_bytes: 23380
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

    using Graph = vector<vector<pint>>;
    int n;
    Graph G;

    void dfs(int v, int p, int pc, vec &res){
        int color = 1;
        if(color == pc) ++color;
        for(auto e : G[v]) {
            if(e.first == p) continue;
            res[e.second] = color;
            dfs(e.first, v ,color, res);
            ++color;
            if(color == pc) ++color;
        }
    }

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

    cin>>n;
    G.assign(n, vector<pint>());
    rep(i,n-1){
        int a,b;cin>>a>>b;
        --a;--b;
        G[a].emplace_back(b,i);
        G[b].emplace_back(a,i);
    }

    int max_color = 0; 
    rep(i,n){
        chmax(max_color, (int)G[i].size());
    }

    vec res(n-1, -3);
    dfs(0, -3, -3, res);
    cout<<max_color<<endl;
    for(auto v : res) cout << v << endl;

}

Measured memory_bytes: 11052
#include<bits/stdc++.h>
using namespace std;
int main(){
	char s1[100], s2[100], s3[100];
	char c1,c2,c3;
	scanf("%s %s %s", &s1, &s2, &s3);
	c1=s1[0];
	c2=s2[0];
	c3=s3[0];
	printf("%c%c%c", c1, c2, c3);
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))

count = 0
while True:
    zero = True
    allzero = True
    for i in range(len(h)):
        if h[i]>0 and zero:
            zero = False
            allzero = False
            count += 1
            h[i] -= 1
        elif h[i]>0:
            allzero = False
            h[i] -= 1
        else:
            zero = True
    if allzero:
        break
print(count)

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

int main() {
    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    sort(p.begin(), p.end());

    set<int> exist;
    rep(i, n) {
        exist.insert(p[i]);
    }

    int ans = -1e9;
    for (int a = -100; a <= 200; a++){
        if (exist.count(a)) continue;
        if(abs(x - ans) > abs(x - a)){
            ans = a;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
int n,m,i,j,k,l,x,y,p,r,t=0,h[20],w[20],q[1<<16],d[1<<16]={1};
int MIN(int a,int b){return a<b?a:b;}
int MAX(int a,int b){return a<b?b:a;}
int main(){
	char s[20],c[5]={"RGB"};
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d %d",&h[i],&w[i]);
	for(i=0;i<16;i++)scanf(" %c",&s[i]);
	q[t=0]=0;
	for(r=1;r-t;t++){
		for(i=0;i<n;i++){
			for(j=0;j<3;j++){
				for(k=-h[i]+1;k<4;k++){
					for(l=-w[i]+1;l<4;l++){
						m=q[t];
						for(y=MAX(0,k);y<MIN(4,k+h[i]);y++){
							for(x=MAX(0,l);x<MIN(4,l+w[i]);x++){
								//if(k+y<0||3<k+y||l+x<0||3<l+x)continue;
								p=(y)*4+x;
								if(s[p]==c[j])m|= (1<<p);
								else          m&=~(1<<p);
							}
						}//f(m);
						if(d[m]==0)d[q[r++]=m]=d[q[t]]+1;
					}
				}//printf("\n%d\n\n",r);
			}
		}//printf("\n\n%d ",r);
		//f(q[t]);
	}
	//for(i=0;i<(1<<16);i++)printf("%d\n",d[i]);
	printf("%d\n",d[(1<<16)-1]-1);
	return 0;
}


Measured memory_bytes: 2308
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int i = 1;
    while (true) {
      int n = sc.nextInt();
      if (n == 0) {
        return;
      }
      System.out.println("Case " + i + ": " + n);
      i++;
    }
  }
}


Measured memory_bytes: 41104
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
using namespace std;
int main()
{
    ll n,i,x,k,ans=0;
    cin>>n>>k;
    for(i=0;i<n;i++)
    {
        cin>>x;
        if(x>=k) ans++;
    }
    cout<<ans<<endl;

    return 0;
}





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

#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define pb push_back
#define X first
#define Y second

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
const ll INF = 1e18+1;
const ll MOD = 1000000007L;

#ifdef umang99m
    #include "/home/umang/.templates/header.h"
#else
    #define dbg(args...)
    #define timer()
#endif

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

    ll n,k;
    cin>>n>>k;
    set<int>d;
    rep(i,k) {
        int p;
        cin>>p;
        d.insert(p);
    }
    for(int i=n; i<MOD;i++){
        int temp = i;
        bool pos =true;
        while(temp > 0){
            if(d.count(temp%10)) pos = false;
            temp /= 10;
        }
        if(pos) {
        cout<<i<<endl;
        break;
        }

    }

    timer();
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main(){
    int N;
    cin >> N;
    map<string,int> cnt;

    string idx[] = {"AC","WA","TLE","RE"};

    REP(i,N){
        string s;
        cin >> s;
        cnt[s]++;
    }

    for(auto i : idx){
        cout << i << " x " << cnt[i] << endl; 
    }
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<stdlib.h>
 
struct node{   
  struct node *right,*left,*parent;
  int key;
};
 
typedef struct node * Node;
#define NIL NULL
Node root;
void insert(int);
void inorder(Node );
void preorder(Node );
Node treeSearch(Node , int);
Node treeMinimum(Node );
Node treeMaximum(Node );
Node treeSuccessor(Node );
void treeDelete(Node );
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( strcmp(com, "find") == 0 ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( strcmp(com, "findMin") == 0 ){
	Node minn = treeMinimum(t);
	printf("%d\n", minn->key);
      }
      else if ( strcmp(com, "findMax") == 0 ){
	Node maxn = treeMaximum(t);
	printf("%d\n", maxn->key);
      }
      else {
	if ( t != NIL ){
	  printf("yes\n");
	}
	else{
	  printf("no\n");
	}
      }
    }
    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( strcmp(com, "print") == 0 ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if ( strcmp(com, "delete") == 0 ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
 
  }
  return 0;
}
 
void insert(int k){
  int H;
  Node y;
  Node x;
  Node z;
  y = NIL;
  x = root; 
  z = malloc(sizeof(struct 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);
}

Node treeSearch(Node u, int k){   
  while( u != NIL && k != u->key ){
    if ( k < u->key ){
      u = u->left;
    }      
    else{
      u = u->right;
    }
  }
  return u;
}
 
Node treeMinimum(Node x){
  while( x->left != NIL ){
    x = x->left;
  }
  return x;
 
}
 
Node treeMaximum(Node x){
  while( x->right != NIL ){
    x = x->right;
  }
  return x;
}
 
 
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; 
  if ( z->left == NIL || z->right == NIL ) {
    y = z;
  }
  else {
    y = treeSuccessor(z);
  }
  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;
 
  }
 
  free(y);
 
 
}

Measured memory_bytes: 19364
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
int main(){
    int n,mc=0,mi=1e9;
    ll tl=0;
    cin>>n;
    int a[n];
    rep(i,0,n){
        cin>>a[i];
        if(a[i]<0){
            mc++;
            a[i]*=-1;
        }
        tl+=a[i];
        mi=min(mi,a[i]);
    }
    if(mc%2==0){
        cout<<tl<<endl;
    }else{
        cout<<tl-mi*2<<endl;
    }
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
#include <bitset>
typedef long long ll;
typedef long double ld;

#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
ll D, G;
vector<ll>P, C;

int main() {
	cin >> D >> G;
	P = C = vector<ll>(D);
	rep(i,D) {
		cin >> P[i] >> C[i];
	}
	ll ans = 1000;
	rep(bit,1<<D) {
		ll counter = 0;
		ll sum=0;
		rep(i,D) {
			if (bit&(1<<i)) {
				sum += (C[i] + P[i]*(i + 1) * 100);
				counter += P[i];
			}
			if (G<=sum) {
				ans = min(counter, ans);
				break;
			}
		}
		if (sum < G) {
			for (ll j = D - 1; 0 <= j; --j) {
				if (!(bit&(1 << j))) {
					ll tmpSum = G - sum;
					ll a = ((tmpSum - 1) / ((j + 1) * 100)) + 1;
					if (a <= P[j]) {
						counter += a;
						ans = min(counter, ans);
					}
				}
			}
		}
	}



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

Measured memory_bytes: 3572
#include<cstdio>
#define MAX 10000
#define NIL -1

struct Node { int parent, left, right; };

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d) {
	if ( u == NIL ) return;
	D[u] = d;
	setDepth(T[u].left, d + 1);
	setDepth(T[u].right, d + 1);
}

int setHeight(int u) {
	int h1 = 0, h2 = 0;
	if ( T[u].left != NIL )
		h1 = setHeight(T[u].left) + 1;
	if ( T[u].right != NIL )
		h2 = setHeight(T[u].right) + 1;
	return H[u] = ( h1 > h2 ? h1 : h2 );
}

// 節点 u の兄弟を返す
int getSibling(int u) {
	if ( T[u].parent == NIL ) return NIL;
	if ( T[T[u].parent].left != u && T[T[u].parent].left != NIL )
		return T[T[u].parent].left;
	if ( T[T[u].parent].right != u && T[T[u].parent].right != NIL )
		return T[T[u].parent].right;
	return NIL;
}

void print(int u) {
	printf("node %d: ", u);
	printf("parent = %d, ", T[u].parent);
	printf("sibling = %d, ", getSibling(u));
	int deg = 0;
	if ( T[u].left != NIL ) deg++;
	if ( T[u].right != NIL ) deg++;
	printf("degree = %d, ", deg);
	printf("depth = %d, ", D[u]);
	printf("height = %d, ", H[u]);
	
	if ( T[u].parent == NIL ) {
		printf("root\n");
	} else if ( T[u].left == NIL && T[u].right == NIL ) {
		printf("leaf\n");
	} else {
		printf("internal node\n");
	}
}

int main() {
	int v, l, r, root = 0;
	scanf("%d", &n);
	
	for ( int i = 0; i < n; i++ ) T[i].parent = NIL;
	
	for ( int i = 0; i < n; i++ ) {
		scanf("%d %d %d", &v, &l, &r);
		T[v].left = l;
		T[v].right = r;
		if ( l != NIL ) T[l].parent = v;
		if ( r != NIL ) T[r].parent = v;
	}
	
	for ( int i = 0; i < n; i++ ) if ( T[i].parent == NIL ) root = i;
	
	setDepth(root, 0);
	setHeight(root);
	
	for ( int i = 0; i < n; i++ ) print(i);
	
	return 0;
}


Measured memory_bytes: 2692
#include<iostream>

using namespace std;

int main() {
	int N, M;
	int A[10000];
	cin >> N >> M;
	for (int i = 0;i < M;i++) {
		cin >> A[i];
	}
	for (int i = 0;i < M;i++) {
		N -= A[i];
	}
	if (N < 0) {
		cout << -1 << endl;
	}
	else {
		cout << N << endl;
	}
	return 0;
}

Measured memory_bytes: 3188
import sys
import numpy as np

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

N = ir()
D = lr()
D2 = np.array(D)
E = D2[:, None] * D2[None, :]
E *= (np.ones((N, N), dtype=np.int32) - np.eye(N, dtype=np.int32))
answer = E.sum() // 2
print(answer)


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

int main(void){
    int d,g;
    cin >> d >> g;
    int p[d],c[d];
    for(int i = 0;i < d;i++)cin >> p[i] >> c[i];
    
    int ans = 1e9;
    for(int i = 0;i < (1 << d);i++){
        ll score = 0;
        int score2 = 0;
        for(int j = 0;j < d;j++){
            if(i & (1 << j)){
                score += (j+1)*p[j]*100;
                score += c[j];
                score2 += p[j];
            }
        }
        
        for(int j = d-1;j >= 0;j--){
            if(!(i & (1 << j)) && score < g){
                for(int l = 0;l < p[j];l++){
                    score += (j+1)*100;
                    score2++;
                    if(score >= g)ans = min(ans,score2);
                }
            }
        }
        
        if(score >= g){
            ans = min(ans,score2);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
n = int(input())
cities = list(map(int, input().split(' ')))
braves = list(map(int, input().split(' ')))
enemy_count = sum(cities)

for i, b in enumerate(braves):
  for _ in range(2):
    b = braves[i]
    if b <= 0:
      break
    if cities[i] > 0:
      if b >= cities[i]:
        braves[i] = b - cities[i]
        cities[i] = 0
      else:
        braves[i] = 0
        cities[i] = cities[i] - b
    elif cities[i] == 0:
      if b >= cities[i+1]:
        braves[i] = b - cities[i+1]
        cities[i+1] = 0
      else:
        braves[i] = 0
        cities[i+1] = cities[i+1] - b
    else:
      raise Exception

kill_count = enemy_count - sum(cities)
print(kill_count)

Measured memory_bytes: 19004
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define iii tuple<int, int, int>
#define ii pair<int, int>
#define fi first
#define se second

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    int dp[n + 1][m + 1] = {};

    for (int i = 0; i <= n; ++i)
        for (int j = 0; j <= m; ++j) {
            if (i < n && j < m && s[i] == t[j] && dp[i][j] + 1 > dp[i + 1][j + 1]) dp[i + 1][j + 1] = dp[i][j] + 1;
            if (i < n && dp[i][j] > dp[i + 1][j]) dp[i + 1][j] = dp[i][j];
            if (j < m && dp[i][j] > dp[i][j + 1]) dp[i][j + 1] = dp[i][j];
        }
    string res = "";
    // for (int i = 0; i <= n; ++i)
    //     for (int j = 0; j <= m; ++j) cout << dp[i][j] << " \n"[j == m];
    while (n || m) {
        if (n && m && s[n - 1] == t[m - 1] && dp[n][m] == dp[n - 1][m - 1] + 1) {
            --n, --m;
            res += s[n];
        } else if (n && dp[n][m] == dp[n - 1][m])
            --n;
        else
            --m;
    }
    reverse(res.begin(), res.end());
    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 35456
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    
    if( a + b == c){
      System.out.println("Yes");
    }else if( b + c == a){
      System.out.println("Yes");
    }else if( c + a == b){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 35740
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
int main(){
  string s;
  cin>>s;
  int n=s.size();
  vector<int> sa=suffix_array(s);
  vector<int> la=lcp_array(s,sa);
  int64_t c=0;
  for(int i=0;i<n-1;i++)
    c+=n-sa.at(i)-la.at(i);
  c+=n-sa.at(n-1);
  cout<<c<<endl;
}

Measured memory_bytes: 15676
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x;cin>>x;
    cout<<360/__gcd(x,360LL);
    return 0;
}

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

const int MAXN = 2e5 + 10;
int dp[MAXN][5], n, a[MAXN];

int getval(int val, int t) {
	if (t == 0 || t == 4)
		return val;
	if (t == 1 || t == 3) {
		if (val == 0)
			return 2;
		return val % 2;
	}
	return !(val % 2);
}

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= n; i++)
		for (int j = 0; j < 5; j++) {
			dp[i][j] = 1e9;
			for (int k = 0; k <= j; k++)
				dp[i][j] = min(dp[i][j], dp[i - 1][k] + getval(a[i], j));
		}
	cout << min(dp[n][0], min(dp[n][1], min(dp[n][2], min(dp[n][3], dp[n][4]))));
}

Measured memory_bytes: 4992
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
#include <bitset> // bitset
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    int N;
    cin >> N;
    vll data(N, 0);
    for (int i = 0; i < N; i++) {
        cin >> data[i];
    }
    ll num = 0;
    for (int i = 0; i < N; i++) {
        num = data[i] - num;
    }
    ll ans = num / 2;
    for (int i = 0; i < N; i++) {
        cout << ans * 2 << " ";
        ans = data[i] - ans;
    }
    cout << endl;
}


Measured memory_bytes: 3952
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define REP(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define TF(flag) (flag)?1:0
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================

// Template End ======================================================

int main(void){
  map<int,int> ans;
  rep(i,3){
    int N; cin>>N; ++ans[N];
  }
  cout<<ans.size()<<endl;
}














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

#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 ll long long

int main(){
	string s;
	cin >> s;
	if (s <= "2019/04/30"){cout << "Heisei" << endl;}
	else {cout << "TBD" << endl;}
}


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

using namespace std;

#define ll long long int
#define ull unsigned long long int 
#define Rep(i,n) for(ll i=0;i<n;i++) 
#define rRep(i,n) for(ll i=n;i>=0;i--)
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define rrep(i,a,b) for(ll i=b;i>=a;i--)
#define itr(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) 
#define vi vector<int>  
#define vl vector<ll> 
#define vul vector<ull>
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define Si set<int> 
#define Mi multiset<int> 
#define Sl set<ll> 
#define Ml multiset<ll>
#define mapi map<int,int>
#define mapl map<ll,ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second  
#define INF (ll)1e9;
#define mod (ll)(1e9+7);
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
#define T ll test;cin >> test;while(test--)

int main(){
    fast;    
    string s;cin>>s;
    ll n=s.size();
    if(s[n-1]=='s'){
        cout<<s<<"es"<<endl;
    }else{
        cout<<s<<"s"<<endl;
    }
return 0;
}


Measured memory_bytes: 3580
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var n = cin.ReadInt;
            var y = cin.ReadInt;

            for (var i1 = 0; i1 <= n; i1++) {
                for (var i2 = 0; i2 <= n-i1; i2++) {
                    var i3 = n - i1 - i2;
                    if (y == i1*10000+i2*5000+i3*1000) {
                        WriteLine(String.Format("{0} {1} {2}", i1, i2, i3));
                        return;
                    }
                }
            }
            WriteLine("-1 -1 -1");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 13268
import Control.Applicative
import Control.Monad.State

data SegTree a = Leaf a 
               | Tree { size :: Int
                      , toBePlused :: a
                      , left :: (SegTree a)
                      , right :: (SegTree a)
                      } deriving (Show)

main = do
    [n,q] <- map read.words<$>getLine
    let init = fromList $ replicate n 0
    evalStateT (query q) init

query 0 = return ()
query n = getQuery >> query (n-1)

getQuery = do
    (x:xs) <- lift $ map read.words<$>getLine
    case x of
      0 -> let [s,t,x] = xs in modify (addT s t x)
      1 -> let [i] = xs in get >>= \tr -> lift $ print $ getT i tr

fromList xs = fl n xs
    where n = length xs

fl n [x] = Leaf x
fl n xs = Tree n 0 leftT rightT
    where n' = n `div` 2
          (xsL, xsR) = splitAt n' xs
          leftT = fl n' xsL
          rightT = fl (n-n') xsR

addT :: Num a =>  Int -> Int -> a -> SegTree a -> SegTree a
addT _ _ x (Leaf v) = Leaf (v+x)
addT s t x tr
  | n < s = tr { right = addT (s-n) (t-n) x (right tr)}
  | n >= t = tr { left = addT s t x (left tr)}
  | t-s+1 == size tr = tr { toBePlused = toBePlused tr + x }
  | otherwise = tr { left = addT s n x (left tr)
                   , right = addT 1 (t-n) x (right tr)
                   }
    where n = size tr `div` 2

getT :: Num a => Int -> SegTree a -> a
getT _ (Leaf v) = v
getT i tr
  |  n < i = toBePlused tr + getT (i-n) (right tr)
  | n >= i = toBePlused tr + getT i (left tr)
  where n = size tr `div` 2

calcTree :: Num a => SegTree a -> Int -> SegTree a
calcTree = ct 0
ct :: Num a => a -> SegTree a -> Int -> SegTree a
ct acc (Leaf v) _ = Leaf (v+acc)
ct acc tr i
  | n < i = tr { toBePlused = 0
               , left = lt { toBePlused = toBePlused lt + toBePlused tr }
               , right = ct (acc + toBePlused tr) rt (i-n) }
  | n >= i = tr { toBePlused = 0
                , left = ct (acc + toBePlused tr) lt i
                , right = rt {toBePlused = toBePlused lt + toBePlused tr } }
    where n = size tr `div` 2
          lt = left tr
          rt = right tr



Measured memory_bytes: 93184
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, T = map(int, readline().split())

AB= list(map(int, read().split()))
A = AB[0::2]
B = AB[1::2]
ls = sorted(zip(A, B))
#ls = list(zip(A, B))
# 食べるのにかかる時間で昇順にソート
#ls.sort()
# 上の並び順において、ls[i:]の美味しさの最大値をdeli[i]とする
deli = [0]*N
deli[- 1] = ls[-1][- 1]
for i in range(N - 2, 0, - 1):
    deli[i] = max(deli[i + 1], ls[i][- 1])

res = 0
dp = np.zeros(T, np.int64)
for i in range(N - 1):
    dp[ls[i][0]:] = np.maximum(dp[ls[i][0]:], dp[:-ls[i][0]] + ls[i][1])
    res = max(res, dp[- 1] + deli[i + 1])
print(res)

Measured memory_bytes: 21908
#include <bits/stdc++.h>
#define _ << ' ' <<
#define squ(x)  ((x) * (x))
#define VAR_NAME(var)  cout << #var << " : ";
#define debug(var)  VAR_NAME(var); view(var);
#define max(v)  *max_element(v.begin(), v.end())
#define min(v)  *min_element(v.begin(), v.end())
#define sort(var)  std::sort(var.begin(), var.end());
#define rsort(var)  std::sort(var.begin(), var.end(), std::greater<>());
using namespace std;
using ll = long long;
int gcd(int m, int n){return !n ? m : gcd(n, m%n);}
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;
template<typename T> void view(const T e){ std::cout << e << std::endl;}
template<typename T> void view(const vector<T>& v){ for(const auto& e : v) std::cout << e << " "; std::cout << std::endl; }
template<typename T> void view(const VV<T>& vv){ for(const auto& v : vv){ view(v); } }

int main(){
  int N;
  cin >> N;
  vector<double> v(N);
  for(auto& e : v) cin >> e;
  sort(v);
  double value = v[0];
  for(size_t i=1; i<N; ++i) value = (value + v[i])/2.0;
  cout << value << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define numrep(i,p,n) for(int i=p;i<=n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)

//素直にやっても発想として特に変わるところはないがTLEする
//1~iまで出るさいころの期待値が(1+i)/2であることを利用すると解消されるが、何を問いたいのか謎
int main() {

  int N,K; cin >> N >> K;

  vector<int> p(N); rep(i,N) cin >> p[i];

  double ans=0;

  vector<double> X(2000);

  numrep(i,1,1000) X[i]=(double)(i+1)/2;

  vector<double> E(N+1);
  E[0]=0;
  numrep(i,1,N) E[i]=E[i-1]+X[p[i-1]];

rep(i,N-K+1){
  double temp=E[i+K]-E[i];
  ans=max(ans,temp);
}
  cout << fixed << setprecision(18);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2560
#include <cstdio>
#include<iostream>
#include <string>

using namespace std;

int main(void) {
	string input;
	int count = 0;
	cin >> input;

	for (int i = 0; i < 6; i++) {
		if (input[i] == '1') {
			count++;
		}
	}

	cout << count << endl;


	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<algorithm>


using namespace std;
using ld=long double;
using ll=long long;

struct pos_t
{
	int x, y;
};


bool cmp_x(const pos_t&a, const pos_t&b)
{
	return a.x<b.x;
}


bool cmp_y(const pos_t&a, const pos_t&b)
{
	return a.y<b.y;
}


void calc(int rq, ll&b, ll&s)
{
//      15707963267948966192LL
//  2^63=9223372036854775808
//        415926535897932384
	ll p=4292036732051033808LL;
	ll m=1000000000000000000LL;

	if(s)
	{
		b--;
		s=m-s;
	}

	for(int i=0;i<rq;i++)
	{
		s+=p;
		b+=s/m;
		s%=m;
	}

	if(s)
	{
		b++;
		s=m-s;
	}
}


void print(int dx, int dy, int rq)
{
	ll ans=(dx+dy)*100LL;
	ll b=0, s=0;

	if(rq>dx || rq>dy)
	{
		rq--;
		ans+=11;
		s=415926535897932384;
	}

	calc(rq, b, s);
	ans-=b;
	printf("%lld.%018lld\n", ans, s);
}


int main(void)
{
	pos_t s, g;
	int n;

	while(scanf("%d%d%d%d%d", &s.x, &s.y, &g.x, &g.y, &n)==5)
	{
		vector<pos_t> p(n);

		for(int i=0;i<n;i++)
		{
			scanf("%d%d", &p[i].x, &p[i].y);
		}
/*
		if(s.x==g.x)
		{
			sort(p.begin(), p.end(), cmp_x);
			auto it=lower_bound(p.begin(), p.end(), s, cmp_x);
			int is_hq=0;
			if(it!=p.end() && it->x==s.x)
			{
				if(s.y>g.y) swap(s, g);
				if(s.y<it->y && it->y<g.y) is_hq=1;
			}
			print(0, g.y-s.y, 0, is_hq);
			continue;
		}

		if(s.y==g.y)
		{
			sort(p.begin(), p.end(), cmp_y);
			auto it=lower_bound(p.begin(), p.end(), s, cmp_y);
			int is_hq=0;
			if(it!=p.end() && it->y==s.y)
			{
				if(s.x>g.x) swap(s, g);
				if(s.x<it->x && it->x<g.x) is_hq=1;
			}
			print(g.x-s.x, 0, 0, is_hq);
			continue;
		}
*/
		if(s.x>g.x)
		{
			swap(s, g);
		}
		if(s.y>g.y)
		{
			for(auto&pe:p) pe.y=-pe.y;
			s.y=-s.y;
			g.y=-g.y;
		}

		int min_y=min(s.y, g.y);
		int max_y=max(s.y, g.y);

		vector<pos_t> w;

		sort(p.begin(), p.end(), cmp_x);
		for(auto it=lower_bound(p.begin(), p.end(), s, cmp_x);it!=p.end();++it)
		{
			if(it->x>g.x) break;
			if(it->y<min_y || max_y<it->y) continue;
//printf("it=(%d,%d)\n", it->x, it->y);
			auto wit=lower_bound(w.begin(), w.end(), *it, cmp_y);
			if(wit==w.end())
			{
				w.push_back(*it);
			}
			else
			{
				*wit=*it;
			}
		}
//		for(auto&we:w) printf("%d %d\n", we.x, we.y);
		print(abs(s.x-g.x), abs(s.y-g.y), w.size());
	}
//printf("%.20Lf\n", PI);
	return 0;
}


Measured memory_bytes: 3956
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

void main() {
    int n;
    int[] a;

    scan(n);
    a = readln.split.to!(int[]);

    int[] b = new int[](n);

    foreach (i ; 0 .. n) {
        if (i < (n + 1) / 2) {
            b[i] = a[n - 1 - 2*i];
        }
        else {
            b[i] = a[(n & 1) + 2*(i - (n + 1) / 2)];
        }
    }

    writefln("%(%s %)", b);
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 13296
#include<iostream>
using namespace std;
	int main(){
	int a,b;int sum=0;
	int sums[5000];int k=0;
	while(cin>>sum){
	if(sum==0)break;
	for(int i=0;i<9;i++){
		cin>>b;
		sum-=b;
	}
	cout<<sum<<endl;
	}
 return 0;
}

Measured memory_bytes: 1160
import java.util.*;
import java.util.Map.Entry;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.rmi.server.UnicastRemoteObject;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        String s=sc.nextString();
        

        out.println(n<3200?"red":s);
        out.flush();
    }



    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

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

//class P {
//	int x, y;
//	P(int  x, int y) {
//	  this.x=x;
//	  this.y=y;
//	}
//}


//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

class P implements Comparable<P>{
    int a,b;
    P(int a, int b) {
    	this.b=b;
    	this.a=a;
    }

    public int compareTo(P p){
    	if(a==p.a) return b-p.b;
        return -p.a+a;
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 23124
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    cout<<(in<string>()=="ABC"?"ARC":"ABC")<<endl;
}


Measured memory_bytes: 3596
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib> 
#include <cmath>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
using namespace std;

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	
	if (abs(x-a) < abs(x-b)) {
		cout << "A" << endl;
	}
	else {
		cout << "B" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<map>
#include<math.h>
using namespace std;
#define ll long long
int main(){
   int N,M;
   cin >>N >> M;
   int i;
   int Xmax;
   int Ymin;
   cin >> Xmax >> Ymin;
   int x,y;
   for(i=0;i<N;i++){
     cin >> x;
     if(Xmax<x)Xmax=x;
   }
   for(i=0;i<M;i++){
     cin >> y;
     if(Ymin>y)Ymin=y;
   }
   if(Xmax>=Ymin){
     cout <<"War";
   }else{
     cout <<"No War";
   }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MOD = 1000000007;

template <class T>
map<T, T> prime_factorize(T n) {
    map<T, T> res;
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1)
        res[n] = 1;
    return res;
}

int main() {
    int n;
    cin >> n;
    cout << n << ':';
    map<int, int> m = prime_factorize(n);
    for (auto p : m) {
        while (p.second) {
            cout << ' ' << p.first;
            p.second--;
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;
	ll ans=0;
	cin>>n>>k;
	vl v(n);
	rep(i,n)cin>>v[i];
	rep(i,min(n,k)+1){
		rep(j,min(n-i,k-i)+1){
			ll sum=0;
			vl tab;
			rep(x,i)tab.push_back(v[x]);
			rep(y,j)tab.push_back(v[n-y-1]);
			sort(all(tab));
			rep(z,min(k-i-j,(int)tab.size()))if(tab[z]<0)tab[z]=0;
			rep(z,tab.size())sum+=tab[z];
			chmax(ans,sum);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	char a,b;
	scanf("%c %c",&a,&b);
	
	if(a=='H')
	{
		printf("%c\n",b);
	}
	else if(a=='D')
	{
		if(b=='H')
		{
			printf("D\n");
		}
		else
		{
			printf("H\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 888
from decimal import *
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline

M = mod = 998244353
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)

def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n')]
def li3():return [int(i) for i in input().rstrip('\n')]
def li4():return [float(i) for i in input().rstrip('\n').split(' ')]

n = val()
l = li4()
mihe = n//2 + 1


curr = 1
for i in l:curr *= (1 - i)
dp = [0 for i in range(n + 1)]
dp[0] = 1

for i in range(n):

    for j in range(i + 1,-1,-1):
        if not j:dp[j] *= 1 - l[i]
        else:dp[j] = dp[j-1] * l[i] + dp[j] *(1 - l[i])

ans = 0
for i in dp[-mihe:]:
    ans += i

print(round(ans,10))

Measured memory_bytes: 62440
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,X;
    cin >>N>>X;
    ll mx=1;
    string BG;
    //BG = "P"; 
    if(X<=N){
        cout<<0<<endl;
        return 0;
    }
    vector<ll>P(N+1);
    P[0] = 1;
    rep(i,N){
        mx = mx*2 + 3;
        P[i+1]= P[i]*2 + 1;
        //BG = "B" + BG + "P" + BG + "B";
        //cout<<BG<<endl;

    }
    ll nmx = mx;
    ll nx = X;
    ll nl = N;
    ll ans = 0;
    while(1){
        if(nmx == nx){
            ans += P[nl];
            //cout<<"a"<<endl;
            break;
        }else if(nx==(nmx+1)/2){
            ans += P[nl-1]+1;
            //cout<<"b"<<endl;
            break;
        }else if(nx == 0){
            //cout<<"c"<<endl;
            break;
        }else if(nx > (nmx+1)/2){
            //cout<<"d"<<endl;
            ans += P[nl-1]+1;
            nx -= (nmx-1)/2;
        }else{
            //cout<<"e"<<endl;
        }

        nmx = (nmx-3)/2;
        nl--;
        nx--;
 
    }
    
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3640
#include<stdio.h>
int main()
{
  int i,j,flag,tmp,count=0,N,A[100];
  scanf("%d",&N);
  for(i=0;i<N && N<=100 && N>=1;i++)
    {
      scanf("%d",&A[i]);
    }
  flag=1;
    while(flag!=0)
      {
	flag=0;
	for(j=N-1;j>=1;j--)
	  {
	    if(A[j]<A[j-1])
	      {
		tmp=A[j];
		A[j]=A[j-1];
		A[j-1]=tmp;
		flag=1;
		count++;
	      }
	  }
      }
  for(i=0;i<N;i++)
    {
  printf("%d",A[i]);
  if(i!=N-1)printf(" ");
    }
  printf("\n");
  printf("%d\n",count);
  return 0;
}
  
  



Measured memory_bytes: 2144
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    string S;
    ll K;
    cin >> S >> K;
    
    bool bAllSame = true;
    for (int i = 0; i < S.length()-1; ++i) {
        if (S[i] != S[i+1]) {
            bAllSame = false;
            break;
        }
    }
    if (bAllSame) {
        cout << K * S.length() / 2 << endl;
        return 0;
    }
    
    size_t L = S.length();
    ll Res = 0;
    ll Temp = 1;
    for (int i = 0; i < L-1; ++i) {
        if (S[i] == S[i+1]) {
            ++Temp;
        } else {
            Res += Temp / 2;
            Temp = 1;
        }
    }
    Res += Temp / 2;
    
    ll Loss = 0;
    if (S[0] == S[L-1]) {
        int f = 1;
        for (int i = 0; i < L-1; ++i) {
            if (S[i] == S[i+1]) {
                ++f;
            } else {
                break;
            }
        }
        
        int b = 1;
        for (int i = L-1; i > 0; --i) {
            if (S[i] == S[i-1]) {
                ++b;
            } else {
                break;
            }
        }
        
        Loss = (f+b)/2 - f/2 - b/2;
    }
    
    cout << Res * K + Loss * (K-1) << endl;

    return 0;
}


Measured memory_bytes: 256