akhauriyash/Code-Regression huggingface dataset:
//by Top1
#include <bits/stdc++.h>
          
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define cerr cout
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
      
const int inf = (1e9) + 1;
const int mod = 479001599;
const int maxn = 2e3 + 11;
        
using namespace std;          

int n, dp[maxn][maxn], mx;
pii a[maxn];


void solve(){   
	cin >> n;

	for (int i = 1; i <= n; i++){
		cin >> a[i].f;
		a[i].s = i;
	}

	sort(a + 1, a + n + 1);
	rev(a + 1, a + n + 1);


	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= i; j++){
			dp[j][n - (i - j)] = max(dp[j][n - i + j], dp[j - 1][n - i + j] + a[i].f * abs(j - a[i].s));
			dp[i - j][n - j] = max(dp[i - j][n - j], dp[i - j][n - j + 1] + a[i].f * abs(n - j + 1 - a[i].s));
			mx = max(mx, max(dp[j][n - i + j], dp[i - j][n - j]));
		}
	}

	cout << mx;
}                              
      
main(){
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

    boost;
    
    int q = 1;
 
    //cin >> q;
    
    while (q--){
        solve();
    }
}

Measured memory_bytes: 26336
//go:generate echo "https://atcoder.jp/contests/abc177/tasks/abc177_b"
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type scanner struct{ *bufio.Scanner }

func newScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 100000000)
	return &scanner{s}
}

func (s *scanner) String() string {
	s.Scan()
	return s.Text()
}

func (s *scanner) StringSlice(l int) []string {
	if l == 0 {
		return []string{}
	}
	sl := make([]string, l, l)
	for i := range sl {
		sl[i] = s.String()
	}
	return sl
}

func solve(s, t string) int {
	maxMatch := 0
	for i := 0; i+len(t) <= len(s); i++ {
		match := 0
		for ci, sc := range s[i : i+len(t)] {
			if sc == rune(t[ci]) {
				match++
			}
		}
		if maxMatch < match {
			maxMatch = match
		}
	}
	return len(t) - maxMatch
}

func main() {
	scan := newScanner(os.Stdin)
	s, t := scan.String(), scan.String()
	fmt.Println(solve(s, t))
}


Measured memory_bytes: 1780
#include <stdio.h>
void buildMaxHeap(int*);
void maxHeapify(int*, int);
int H;
int main(){
  int i,A[500001];
  scanf("%d",&H);
  for(i=1;i<=H;i++)
    scanf("%d",&A[i]);
  buildMaxHeap(A);
  for(i=1;i<=H;i++)
    printf(" %d",A[i]);
  printf("\n");
  return 0;
}
void buildMaxHeap(int* A){
  int i;
  for(i=H/2;i>=1;i--)
    maxHeapify(A, i);
}
void maxHeapify(int*A, int i){
  int l,r,largest,B;
  l=2*i;
  r=2*i+1;
  if(l <=H && A[l]>A[i])
    largest=l;
  else largest = i;
  if(r<=H && A[r]>A[largest])
    largest=r;

  if(largest!=i){
    B=A[i];
    A[i]=A[largest];
    A[largest]=B;
    maxHeapify(A, largest);
  }
}



Measured memory_bytes: 4528
"use strict";

var print = function print(x) {
  return console.log(x);
};

var readline = require('readline');

var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
var A, B, C;

function solve(A, B, C) {
  if (A + B >= C) return true;
  return false;
}

rl.on('line', function (line) {
  var ret = line.split(' ');
  A = parseInt(ret[0]);
  B = parseInt(ret[1]);
  C = parseInt(ret[2]);

  if (solve(A, B, C)) {
    print('Yes');
  } else {
    print('No');
  }
});


Measured memory_bytes: 7500
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    vector<string> c(3);
    for(int i=0;i<3;i++) cin>>c[i];
    cout<<c[0][0]<<c[1][1]<<c[2][2]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define lsb(x) (x & -x)

using namespace std;

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

    cin.tie(0);
    cout.tie(0);
    //freopen("a.in", "r", stdin);

    string a, b;
    cin >> a >> b;
    a = " " + a;
    b = " " + b;
    int n = a.size(), m = b.size();

    vector<vector<int>> dp(n, vector<int> (m, 0));
    vector<vector<pair<int, int>>> from(n, vector<pair<int, int>> (m, {0, 0}));
    vector<vector<char>> c(n, vector<char> (m, 0));

    for(int i = 1; i < n; i ++)
        for(int j = 1; j < m; j ++) {
            if(a[i] == b[j]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
                from[i][j] = {i - 1, j - 1};
                c[i][j] = a[i];
            }
            if(dp[i][j - 1] > dp[i][j]) {
                from[i][j] = {i, j - 1};
                c[i][j] = 0;
                dp[i][j] = dp[i][j - 1];
            }
            if(dp[i - 1][j] > dp[i][j]) {
                from[i][j] = {i - 1, j};
                c[i][j] = 0;
                dp[i][j] = dp[i - 1][j];
            }
        }

    int i = n - 1, j = m - 1;
    vector<char> ans;

    while(i != 0 && j != 0) {
        if(c[i][j] != 0)
            ans.push_back(c[i][j]);

        int auxi = i;
        i = from[i][j].first;
        j = from[auxi][j].second;
    }
    reverse(ans.begin(), ans.end());

    for(auto it : ans)
        cout << it;

    return 0;
}


Measured memory_bytes: 114944
def main():
    x,y,a,b,c=map(int,input().split())
    P=list(map(int,input().split()))
    P.sort(reverse=True)
    Q=list(map(int,input().split()))
    Q.sort(reverse=True)
    R=list(map(int,input().split()))
    A=P[:x]+Q[:y]+R
    A.sort(reverse=True)
    print(sum(A[:x+y]))
    
if __name__=='__main__':
    main()

Measured memory_bytes: 106348
#include<bits/stdc++.h>
using namespace std;
#define first ff
#define second ss
#define ll long long int
int main()
{
    int n;
    cin>>n;
    ll a[n+5],b[n+5];
    for(int i=0; i<=n; i++)
        cin>>a[i];
    for(int i=0; i<n; i++)
        cin>>b[i];
    ll sum=0;
    for(int i=0; i<n; i++)
    {
        if(a[i]>b[i]){sum+=b[i];b[i]=0;}
        else {sum+=a[i];b[i]-=a[i];}
        if(b[i])
        {
            if(a[i+1]>b[i]){sum+=b[i];a[i+1]-=b[i];}
        else {sum+=a[i+1];a[i+1]=0;}
        }
        //cout<<"Sum = "<<sum<<endl;
    }
    cout<<sum<<endl;

}


Measured memory_bytes: 5148
// Problem : B - Battle
// Contest : AtCoder - AtCoder Beginner Contest 164
// URL : https://atcoder.jp/contests/abc164/tasks/abc164_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include <unordered_map>
#define int long long int
#define double long double
#define endl "\n"
#define PI 3.141592653589793238462643383279502884
#define sp(x)   setprecision(x)
#define ceil(a,b)   (a+(b-1))/b
#define LCM(a,b)    (a*b)/__gcd(a,b)
#define all(v)  v.begin(),v.end()
#define alls(s,v)  s.begin(),s.end(),v
#define gena(arr,n,nxt)  generate(arr,arr+n, nxt)
#define genv(v,nxt)  generate(v.begin(),v.end(), nxt)
#define base ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define exit return 0;
using namespace std;
const int N=1000000;
bool prime[N];
void sieve(){memset(prime, true, sizeof(prime));for (int p=2; p*p<100000000; p++)
{if (prime[p] == true){for (int i=p*p; i<100000; i += p)prime[i] = false;}}}
int power(int x, int y){int res = 1;while (y > 0){if (y & 1)res = res * x;y = y >> 1;x = x*x;}return res;}
int nxt(){int x;cin >> x;return x;}
int32_t main(){
    base
    int a=nxt(),b=nxt(),c=nxt(),d=nxt();
    bool turn=0;
    string ans="Yes";
    while(1){
    	if(turn==0){
    		c-=b;
    		if(c<=0)break;
    		turn=1;
    		continue;
    	}
    	else{
    		turn=0;
    		a-=d;
    		if(a<=0){
    		ans="No";
    		break;
    		}
    		continue;
    	}
    	
    }
    cout<<ans;
    exit
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int h, n;
    cin >> h >> n;
    vector<int> dp(h+1,inf);
    dp[0]=0;
    rep(i,n){
        int a,b;
        //aは攻撃力,bはコスト
        cin>>a>>b;
        //dp[j]=i個目までを使って、Aの和がjの時の最小コスト
        rep(j,h){
            int nj = min(j+a,h); //どんなに攻撃しても,hを超す必要はない
            dp[nj] = min(dp[nj],dp[j]+b);
            //njのhpを減らすとき、新たに、今得た魔法を使うか?
        }
    }
    cout<< dp[h] <<endl;
    return 0;
}

Measured memory_bytes: 256
s = int(input())
fn = [s]
while True:
   if fn[-1] % 2 == 0:
       if fn[-1]//2 in fn[:len(fn)-1]:
           print(len(fn) + 1)
           break
       else:
           fn.append(fn[-1] // 2)
   else:
        if fn[-1]*3 + 1 in fn[:len(fn)-1]:
            print(len(fn) + 1)
            break
        else:
            fn.append(fn[-1]*3 + 1)

Measured memory_bytes: 61552
#include <cstdio>
#include <string>
#include <algorithm>
#include <cctype>

using namespace std;

int n;
char a_[11], b_[33];

int main(void) {
  scanf("%d", &n);
  while (n--) {
    scanf("%s%s", a_, b_);
    string a = a_, b = b_;
    for (int i = a.size() - 1; i >= 0; i--) {
      if (a[i] == 'J') rotate(b.rbegin(), b.rbegin() + 1, b.rend());
      if (a[i] == 'C') rotate(b.begin(), b.begin() + 1, b.end());
      if (a[i] == 'E') {
        reverse(b.begin(), b.end());
        reverse(b.begin(), b.begin() + (b.size())/2);
        reverse(b.begin() + (b.size() + 1)/2, b.end());
      }
      if (a[i] == 'A') reverse(b.begin(), b.end());
      if (a[i] == 'P') {
        for (int j = 0; j < int(b.size()); j++) {
          if (isdigit(b[j])) {
            b[j] = b[j] == '0' ? '9' : (b[j] - 1);
          }
        }
      }
      if (a[i] == 'M') {
        for (int j = 0; j < int(b.size()); j++) {
          if (isdigit(b[j])) {
            b[j] = b[j] == '9' ? '0' : (b[j] + 1);
          }
        }
      }
    }
    printf("%s\n", b.c_str());
  }
  return 0;
}



Measured memory_bytes: 2728
#ifdef _DEBUG
#include ".vscode/debug_print.hpp"
#else
#define debug(...)
#endif
#include <bits/stdc++.h>

using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1050000000;
constexpr long long INF64 = 4000000000000000000;
constexpr int MOD7        = 1000000007;
constexpr int MOD53       = 998244353;
constexpr long double PI  = 3.14159265358979323846;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

void vprint() { std::cout << '\n'; }
template <class H, class... T> void vprint(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << '\n';
    vprint(std::forward<T>(args)...);
}
template <class T> void vprint(std::vector<T> &v) {
    for (auto &&i : v) {
        std::cout << i << '\n';
    }
}

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

    int N, M;
    scan(N, M);
    vector<int> a(N);
    scan(a);

    sort(a.rbegin(), a.rend());
    int sum = accumulate(a.begin(), a.end(), 0);

    for (size_t i = 0; i < M; i++) {
        if ((ld)a[i] < (ld)sum / (4 * M)) {
            print("No");
            return 0;
        }
    }

    print("Yes");

    return 0;
}

Measured memory_bytes: 3636
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    def is_prime(n):
        if n == 1:
            return False
        for k in range(2, int(pow(n, 0.5)) + 1):
            if n % k == 0:
                return False
        return True

    n = int(input())

    L = []
    for i in range(2, 55556):
        if is_prime(i):
            L.append(i)

    res = []
    for num in L:
        if num % 5 == 1:
            res.append(num)
        if len(res) == n:
            print(*res)
            break


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int main(){
  ll N;
  cin>>N;
  vector<string> S(N);
  for(int i=0;i<N;i++){
    cin>>S[i];
  }

  vector<vector<int>> cnt(N,vector<int>(26,0));
  for(int i=0;i<N;i++){
    for(int j=0;j<S[i].length();j++){
      cnt[i][S[i][j]-'a']++;
    }
  }

  for(int i=0;i<26;i++){
    int tmp=1000000;
    for(int j=0;j<N;j++){
      tmp=min(tmp,cnt[j][i]);
    }
    cout<<string(tmp,'a'+i);
  }
  cout<<endl;
  return 0;
}




Measured memory_bytes: 256
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;
import core.stdc.stdlib;
import std.math;
import std.typecons;

void main() {
  auto N = readln.chomp.to!int;
  auto An = readln.split.to!(long[]);
  auto total = An.sum;

  long current_length_twice;
  long cost;
  foreach(index; 0..N) {
    current_length_twice += An[index]*2;
    if (current_length_twice == total) break;
    if (current_length_twice > total) {
      long previous_length_twice = current_length_twice - An[index]*2;
      long shrinkable_length = current_length_twice/2 - index - 1;

      long adjust_size_shrink = current_length_twice - total;
      long adjust_size_enlong = total - previous_length_twice;
      if (adjust_size_shrink < adjust_size_enlong && shrinkable_length >= adjust_size_shrink) {
        cost = adjust_size_shrink;
      } else {
        cost = adjust_size_enlong;
      }
      break;
    }
  }

  cost.writeln;
}


Measured memory_bytes: 11520
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let ab: usize = iterator.next().unwrap().parse().unwrap();
    let bc: usize = iterator.next().unwrap().parse().unwrap();
    let _ca: usize = iterator.next().unwrap().parse().unwrap();

    let ans = ab * bc / 2;
    return ans.to_string();
}


Measured memory_bytes: 2064
#include<bits/stdc++.h>
using namespace std;
int n,m,h[101010];
vector<int>v[101010];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>h[i];
	}
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	int ct=0;
	for(int i=1;i<=n;i++)
	{
		bool ok=true;
		for(int j=0;j<v[i].size();j++)
		{
			if(h[i]<=h[v[i][j]])
			{
				ok=false;
				break;
			}
		}
		if(ok)
		{
			ct++;
		}
	}
	cout<<ct<<endl;
	return 0;
}

Measured memory_bytes: 9136
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <deque>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <complex>
#include <cstring>
#include <cfloat>
#include <iomanip>
#include <stack>
#include <bitset>


using namespace std;
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define repd(i, a, b) for(int i = (a); i > (b); i--)
#define forIt(it, a) for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define forRev(it, a) for(__typeof((a).rbegin()) it = (a).rbegin(); it != (a).rend(); it++)
#define ft(a) __typeof((a).begin())
#define ll long long
#define ld long double
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define bitcount(n) __builtin_popcountll(n)
#define pii pair<int, int>


typedef complex<ld> cplex;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

const int N = 1000000 + 7;
const int M = 103;
const int inf = 1e9 + 7;
const long long linf = 1ll * inf * (inf - 1);
const double pi = acos(-1);
const double eps = 1e-6;
const bool multipleTest = false;

int n;
int a[N];

void solve(){
    cin >> n; n *= 2;
    
    for(int i = 0; i < n; ++i) scanf("%d", a + i);
    
    sort(a, a + n);
    
    int ans = 0;
    for(int i = 0; i < n; i += 2) ans += a[i];
    
    cout << ans;
    
}

void createTest() {
    freopen("in.txt", "w", stdout);
    int n = 10;
    cout << n << "\n";
    set<int> st;
    for(int i = 1; i < 2 * n; ++i) st.insert(i);
    
    for(int i = 1; i < 2 * n; ++i) {
        int u = rand() % 200000;
        ft(st) it = st.lower_bound(u);
        if (it == st.end()) --it;
        printf("%d ", *it);
        st.erase(it);
    }
}

int main() {
#ifdef _LOCAL_
    freopen("in.txt", "r", stdin);
    clock_t t1 = clock();
#endif
//    createTest();
//    return 0;
//    freopen("out.txt", "w", stdout);
    
    
    int Test = 1;
    if (multipleTest) {
        cin >> Test;
    }
    
    for(int i = 0; i < Test; ++i) {
//        printf("Case #%d: ", i + 1);
        solve();
    }
    
#ifdef _LOCAL_
    cout<<"\n" << 1.0 * (clock() - t1) / CLOCKS_PER_SEC<<endl;
#endif
    
}


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


#define int long long 


const int N = 2e5 + 7;


vector <tuple <int, int, int> > edge;


struct DSU{
	vector <int> p, sz;
	DSU(int n) {
		p.resize(n + 1); sz.resize(n + 1, 1);
		for(int i = 1; i <= n; i++) {
			p[i] = i;
		}
	}
	int find(int x) {
		return p[x] = (p[x] == x) ? p[x] : find(p[x]);
	}
	int merge(int x, int y) {
		x = find(x);
		y = find(y);
		if(x == y) {
			return 0;
		}
		p[x] = y;
		sz[y] += sz[x];
		return 1;
	}
};

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	vector <tuple <int, int, int> > v, w;
	for(int i = 1; i <= n; i++) {
		int x, y; cin >> x >> y;
		v.push_back(make_tuple(x, y, i));
		w.push_back(make_tuple(y, x, i));

	}
	sort(v.begin(), v.end());
	sort(w.begin(), w.end());

	for(int i = 1; i < n; i++) {
		int x1, y1, z1, x2, y2, z2;
		tie(x1, y1, z1) = v[i - 1];
		tie(x2, y2, z2) = v[i];
		edge.push_back(make_tuple(x2 - x1, z1, z2));
		tie(x1, y1, z1) = w[i - 1];
		tie(x2, y2, z2) = w[i];
		edge.push_back(make_tuple(x2 - x1, z1, z2));
	}
	sort(edge.begin(), edge.end());

	DSU d(n);
	int ans = 0;
	for(auto z: edge) {
		int w, i, j; tie(w, i, j) = z;
		if(d.merge(i, j)) {
			ans += w;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 14212
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int n; cin>>n;
	ll f[n][10]; rep(i,n)rep(j,10) cin>>f[i][j];
	ll p[n][11]; rep(i,n)rep(j,11) cin>>p[i][j];
	ll ans = -LINF;
	rep(i,1<<10){
		if(i==0) continue;
		ll tmp = 0;
		int bit = i;
		rep(j,n){
			int bit = i, cnt = 0;
			rep(k,10){
				if(bit%2&&f[j][k]) cnt++;
				bit/=2;
			}
			tmp += p[j][cnt];
		}

		// if(ans<tmp) cerr<< bitset<10>(i) <<endl;
		chmax(ans,tmp);
	}
	cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ; 
# define pb push_back
# define ll long long
# define mp make_pair 
# define endl "\n"
# define vi vector<int>
# define vc vector<char>
# define vll vector<ll> 
# define pi pair<int,int> 
const int MOD = 1e9 + 7 ; 
const ll inf = 1e18 ; 


int main() {

	int a , b ,c , x ; 
	cin >> a >> b >> c >> x ;
	while(b <= a) {
		b *= 2 ; 
		x -- ; 
	} 
	while(c <= b) {
		c *= 2 ; 
		x--;
	}
	if(x >= 0 ) {
		cout << "Yes" ; 
	}else 
	cout << "No" ; 
	//cout << a << " "  << b << " " << c ;
	return 0; 
}


Measured memory_bytes: 3672
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

int main() {
	IOS();
	int a[5];
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
	}
	int m = 10;
	for (int i = 0; i < 5; i++) {
		if (a[i] % 10) {
			m = min(m, a[i] % 10);
		}
	}
	ll ans = 0;
	for (int i = 0; i < 5; i++) {
		if (a[i] % 10 == 0)
			ans += a[i];
		else
			ans += (a[i] / 10 + 1) * 10;
	}
	ans -= 10 - m;
	dump(ans);
}

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

using namespace std;
using LL = long long;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = (int)1e9 + 7;

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

    int n, m;
    cin >> n >> m;
    vector<int> foods(m, 0);
    REP(i, n){
        int k;
        cin >> k;
        REP(j, k){
            int a;
            cin >> a;
            foods[a-1]++;
        }
    }
    int ans = 0;
    REP(i, m) if(foods[i] == n) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll arr[400],pref[400];
ll dp[400][400];
ll Cost(ll i,ll j)
{
	if(i==0)
		return pref[j];
	return pref[j] - pref[i-1];
}
ll MinCost(ll i,ll j)
{
	if(i>=j)
		return 0;
	if(dp[i][j]!=-1)
		return dp[i][j];
	ll mincost=1e18,cost=Cost(i,j);
	for(ll k=i;k<j;k++)
		mincost=min(mincost,MinCost(i,k)+MinCost(k+1,j)+cost);
	return dp[i][j] = mincost;
}
int main()
{
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++)
		cin>>arr[i];
	memset(dp,-1,sizeof(dp));
	pref[0]=arr[0];
	for(ll i=1;i<n;i++)
		pref[i]=pref[i-1]+arr[i];
	cout<<MinCost(0,n-1);
}

Measured memory_bytes: 4828
import Foundation

let N = Int(readLine()!)!
let A = readLine()!.components(separatedBy: " ").map { Decimal(Int($0)!) }
var M = Decimal(1)

guard A.filter({ $0 == 0 }).count == 0 else {
    print(0)
    exit(EXIT_SUCCESS)
}

for i in 0..<N {
    M *= A[i]
    guard M <= pow(Decimal(10), 18) else {
        print(-1)
        exit(EXIT_SUCCESS)
    }
}
print(M)

Measured memory_bytes: 24876
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

bool dfs(int cur, string t,string s){
  if(t==s) return true;
  if(cur>=t.length()) return false;
  bool ret = false;
  if(t[cur] != 'A') ret = dfs(cur+1,t,s);
  else{
    ret = dfs(cur,t.substr(0,cur)+t.substr(cur+1),s);
    if(dfs(cur+1,t,s)) ret = true;
  }
  return ret;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string s;cin >> s;
  string t = "AKIHABARA";
  YESNO(dfs(0,t,s));
  return 0;
}


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

int main (int argc, char const *argv[])
{
    int64_t N, K;
    char S[(int)1e5 + 1];
    int64_t len[(int)2e5] = {0}, tmp = 0, ans = 0;
    int64_t *p;

    scanf("%"PRId64"%"PRId64, &N, &K);
    scanf("%s", S);

    p = len;
    for (int i = 0; i < N; i++) {
        if (S[i] == S[i + 1]) {
            *p += 1;
        } else {
            *p += 1;
            p++;
        }
    }

    p = len;
    for (int i = 0; i < (K * 2); i++) {
        tmp += *p++;
        if (*p == 0) break;
    }
    if (S[0] == '1') tmp += *p;

    ans = tmp;

    fprintf(stderr, "%"PRId64"\n", tmp);

    if (S[0] == '1') {
        for (int i = 1; len[i] != 0; i++) {
            tmp -= len[i - 1];
            fprintf(stderr, "-%"PRId64, len[i - 1]);
            if ((i % 2) == 0) {
                tmp += len[i + K * 2 - 1];
                tmp += len[i + K * 2];
                fprintf(stderr, "+%"PRId64, len[i + K * 2 - 1]);
                fprintf(stderr, "+%"PRId64, len[i + K * 2]);
            }
            fprintf(stderr, " %"PRId64"\n", tmp);
            if (tmp > ans) ans = tmp;
        }
    } else {
        fprintf(stderr, "zero\n");
        for (int i = 1; len[i] != 0; i++) {
            tmp -= len[i - 1];
            fprintf(stderr, "-%"PRId64, len[i - 1]);
            if ((i % 2) == 1) {
                tmp += len[i + K * 2 - 1];
                tmp += len[i + K * 2];
                fprintf(stderr, "+%"PRId64, len[i + K * 2 - 1]);
                fprintf(stderr, "+%"PRId64, len[i + K * 2]);
            }
            fprintf(stderr, " %"PRId64"\n", tmp);
            if (tmp > ans) ans = tmp;
        }
    }

    printf("%"PRId64"\n", ans);
}


Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;

int main(void)
{
    priority_queue <string> word;
    char str[35];
    int top_num = 0, now_num = 0, max_len = 0;
    string s, max, top, prev;
    
    while (scanf("%s", str) == 1){
        word.push(str);
        s = str;
		if(max_len < s.size()){
            max_len = (int)s.size();
            max = s;
        }

    }
    
    prev = word.top();
    while (!word.empty()){
        if (prev == word.top()){
            now_num++;
            if (top_num < now_num){ 
                top_num = now_num;
                top = word.top();
            }
        }
        else now_num = 0;
        prev = word.top();
        word.pop();
    }
    
    printf("%s %s\n", top.c_str(), max.c_str());
    
    return 0;
}

Measured memory_bytes: 0
n = int(input())
a = list(map(int,input().split()))
a = [0] + a + [0]
sum = 0
for i in range(n+1):
    sum += abs(a[i+1]-a[i])
for i in range(1,n+1):
    if a[i-1]<=a[i]<=a[i+1] or a[i-1]>=a[i]>=a[i+1]:
        print(sum)
    else:
        print(sum - abs(a[i] - a[i-1]) - abs(a[i] - a[i+1]) + (abs(a[i-1] - a[i+1])))


Measured memory_bytes: 14168
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll t1, t2;std::cin >> t1 >> t2;
  ll a1, a2;std::cin >> a1 >> a2;
  ll b1, b2;std::cin >> b1 >> b2;
  ll go1 = (a1 - b1)*t1, go2 = (a2- b2)*t2;
  if(go1==-1*go2){
    std::cout << "infinity" << '\n';
    return 0;
  }
  if(abs(go1)>abs(go2)||(go1>0&&go2>0)||(go1<0&&go2<0)){
    std::cout << 0 << '\n';
    return 0;
  }
  go1 = abs(go1), go2 = abs(go2);
  if(go2>go1) swap(go1, go2);
  ll down = go1-go2;
  if(go2%down==0){
    ll ans = 2*(go2/down);
    std::cout << ans << '\n';
  }else{
    ll ans = 2*(go2/down + 1) - 1;
    std::cout << ans << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#define log(args...)
#else
#define log(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); logf(_it, args); }
void logf(istream_iterator<string> it) {
}
template<typename T, typename ... Args>
void logf(istream_iterator<string> it, T a, Args ... args) {
	cout << *it << " = " << a << endl;
	logf(++it, args...);
}
#endif

#define forn(i,k,n) for(ll i=(k); i<(n); i++)

const double PI = acos(-1);
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

/* Greedy...
 * Paint tree in two alternating colors.
 * Use color with less nodes, assign all i%3==1 values
 * to the nodes, andi%3==0.
 * Assign remaining numbers to other color nodes.
 *
 */
void solve() {
	cini(n);
	vvi adj(n);
	for (int i = 0; i < n - 1; i++) {
		cini(u);
		cini(v);
		u--;
		v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	if (n == 2) {
		cout << "1 2" << endl;
		return;
	}

	vb col(n);
	vi colcnt(2);
	colcnt[false]++;

	function<void(int, int)> dfs = [&](int node, int parent) {
		if (parent >= 0) {
			col[node] = !col[parent];
			colcnt[col[node]]++;
		}

		for (int c : adj[node])
			if (c != parent)
				dfs(c, node);
	};
	dfs(0, -1);

	bool val = true;
	if (colcnt[false] < colcnt[true])
		val = false;

	vi ans(n);
	vi idx = { 3, 1, 2 };
	if (colcnt[val] <= (n / 3)) {
		for (int i = 0; i < n; i++) {
			if (col[i] == val) {
				ans[i] = idx[0];
				idx[0] += 3;
			}
		}
	} else {
		for (int i = 0; i < n; i++) {
			if (col[i] == val) {
				if (idx[1] <= n) {
					ans[i] = idx[1];
					idx[1] += 3;
				} else {
					ans[i] = idx[0];
					idx[0] += 3;
				}
			}
		}
	}

	for (int i = 0; i < n; i++) {
		if (ans[i] == 0) {
			for (int j = 0; j < 3; j++) {
				if (idx[j] <= n) {
					ans[i] = idx[j];
					idx[j] += 3;
					break;
				}
			}
		}
	}

	for (int i = 0; i < n; i++)
		cout << ans[i] << " ";
	cout << endl;
}

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



Measured memory_bytes: 19712
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>

using namespace std;

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

int n, y;

int main(){

	cin >> n >> y;

	for (int a = 0; a <= n; ++a){
		for (int b = 0; b <= n - a; ++b){
			int c = n - a - b;
			int sum = a * 1000 + b * 5000 + c * 10000;
			if (sum == y){
				cout << c << " " << b << " " << a << endl;
				return 0;
			}	
		}
	}
	
	cout << "-1 -1 -1" << endl;

}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<list>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
#define MK make_pair
const ll E=1e18+7;
const ll MOD=1000000007;


class Topological_Sort{
private:
    ll v;
    vector<vector<ll>> E;
    vector<ll> count;
    
public:
    Topological_Sort(ll v):v(v){
        E.resize(v);
        count.resize(v,0);
    }
    
    void add_edge(ll from,ll to){
        E[from].push_back(to);
        count[to]++;
    }
    
    vector<ll> sort(){
        vector<ll> c=count;
        vector<ll> ret;
        for(int i=0;i<v;i++){
            if(c[i]==0){ret.push_back(i);}
        }
        for(int i=0;i<ret.size();i++){
            for(int t=0;t<E[ret[i]].size();t++){
                ll to=E[ret[i]][t];
                c[to]--;
                if(c[to]==0){ret.push_back(to);}
            }
        }
        return ret;
    }
};



int main(){
    ll v,e;
    cin>>v>>e;
    Topological_Sort T(v);
    for(int i=0;i<e;i++){
        ll s,t;
        cin>>s>>t;
        T.add_edge(s,t);
    }
    vector<ll> a=T.sort();
    if(a.size()==v){cout<<0<<endl;}
    else{cout<<1<<endl;}
    
    return 0;
}



Measured memory_bytes: 3172
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;
const int INF=1e9;

int main(){
    int n, a[101];
    cin>>n;
    for(int i=0; i<n; i++) cin>>a[i];
    sort(a, a+n, greater<int>());
    int alice=0, bob=0;
    for(int i=0; i<n; i++){
        if(i%2==0) alice+=a[i];
        else bob+=a[i];
    }
    cout<<alice-bob<<endl;
    
}


Measured memory_bytes: 256
/*
Author: Babin Dutta
*/
 
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
//#define endl "\n"
#define inf 1e18
#define mm 998244353
 
ll power(ll x, ll y, ll p)
{
    ll res = 1;  
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; 
        x = (x*x) % p;  
    }
    return res;
}
ll modInverse(ll A,ll M)
{
    return power(A,M-2,M);
}

void solve(){
    int n; cin>>n;
    ll ans = 0;
    ll mn = inf;
    ll a[n];
    f(i,n){
    	cin>>a[i];
    	ans += a[i];
	}
	sort(a,a+n);
	if(n == 2){
		cout<<a[1]<<endl;
		return;
	}
	if(n == 3){
		cout<<a[1]+a[2]<<endl;
		return;
	}
	ans = a[n-1];
	int j=1, k=1;
	while(j<n-1){
		ans += a[n-k-1];
		j++;
		if(j == n-1) break;
		ans += a[n-k-1];
		j++;
		k++;
	}
	cout<<ans<<endl;
}
 
int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

Measured memory_bytes: 5160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            long cnt = 0;
            Dictionary<string, int> table = new Dictionary<string, int>();; 
            for (int i = 0; i < n; i++)
            {
                string s = Console.ReadLine();
                s = Sort(s);
                if(!table.ContainsKey(s))
                {
                    table.Add(s, 0);
                }
                else
                {
                    table[s]++;
                    cnt += table[s];
                }
            }

            Console.WriteLine(cnt);
        }

        static string Sort(string s)
        {
            var sb = new StringBuilder();
            foreach (var c in s.ToCharArray().OrderBy(e => e))
            {
                sb.Append(c);
            }

            return sb.ToString();
        }
    }
}


Measured memory_bytes: 28072
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
using namespace std;


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

int main(){
  int n, x;
  cin >> n >> x;
  vector<int> m(n);
  rep(i, n){
    cin >> m[i];
  }

  int ans = 0;
  bool flag = true;
  int mi = INT_MAX;
  for(int i = 0; i < n && flag;++i){
    if(x < 0){
      flag = false;
    } else {
        ans++;
        x -= m[i];
    }
    mi = min(mi, m[i]);
  }

  while(flag){
    if(x < 0){
      flag = false;
    } else {
      ans++;
      x -= mi;
    }
  }
  ans--;


  cout << ans << endl;


}


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

namespace abc119d
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var one = 0;
            var zero = 0;
            foreach (var s in S)
            {
                if (s == '0')
                {
                    if(one == 0)
                    {
                        zero++;
                    }
                    else
                    {
                        one--;
                    }
                }
                else
                {
                    if(zero == 0)
                    {
                        one++;
                    }
                    else
                    {
                        zero--;
                    }
                }
            }
            Console.WriteLine(S.Length - one - zero);
#if DEBUG
            Console.ReadKey();
#endif
        }

        private static bool IsRange(int a, int from, int to) => (from <= a && a <= to);
        private static int ReadInt() => int.Parse(Console.ReadLine());
        private static List<int> ReadIntList() => Console.ReadLine().Split().Select(int.Parse).ToList();
        private static double ReadDouble() => double.Parse(Console.ReadLine());
        private static List<double> ReadDoubleList() => Console.ReadLine().Split().Select(double.Parse).ToList();
        private static long ReadLong() => long.Parse(Console.ReadLine());
        private static List<long> ReadLongList() => Console.ReadLine().Split().Select(long.Parse).ToList();
        private static List<int> Int2Digits(int a) => a.ToString().ToCharArray().Select(_ => int.Parse(_.ToString())).ToList();
        private static int BinarySearch<Type>(IReadOnlyList<Type> s, Type target) // target 以下の最大要素のインデックスを返す
            where Type : IComparable
        {
            var lower = 0;
            var upper = s.Count - 1;
            while (upper - lower > 1)
            {
                var mid = lower + (upper - lower) / 2;
                if (s[mid].CompareTo(target) <= 0)
                {
                    lower = mid;
                }
                else
                {
                    upper = mid;
                }

            }
            return lower;
        }
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // ABC159B - String Palindrome

        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        int len = s.length();

        boolean isOk = check(s);

        boolean isOk2 = check(s.substring(0, ((len - 1) / 2)));

        boolean isOk3 = check(s.substring((((len + 3) / 2) - 1), len));

        System.out.println((isOk && isOk2 && isOk3) ? "Yes": "No");
    }

    static boolean check(String s) {
        
        boolean isKai = true;

        int len = s.length();

        int half = len / 2;

        char[] c = s.toCharArray();

        for (int i = 0; i < half; i++) {
            if (c[i] != c[len - 1 - i]) {
                isKai = false;
                break;
            }
        }

        return isKai;
    }
}

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

int main(){
    int n;
    cin >> n;
    
    vector<int> x(n);
    for (int i=0; i<n; i++){
        cin >> x[i];
    }
    
    int cnt = 0;
    
    for (int i=0; i<n-1; i++){
        int mini = i;
        for (int j = i+1; j<n; j++){
            if (x[j]<x[mini]) {
                mini = j;
            }
        }
        if (i != mini) {
            cnt++;
            swap(x[i],x[mini]);
        }
    }
    
    for (int i=0; i<n; i++){
        if (i) cout << " ";
        cout << x[i];
    }
    cout << endl << cnt << endl;
    return 0;
}


Measured memory_bytes: 3084
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let x: usize = iterator.next().unwrap().parse().unwrap();

    if x <= 599 {
        "8".to_string()
    } else if x <= 799 {
        "7".to_string()
    } else if x <= 999 {
        "6".to_string()
    } else if x <= 1199 {
        "5".to_string()
    } else if x <= 1399 {
        "4".to_string()
    } else if x <= 1599 {
        "3".to_string()
    } else if x <= 1799 {
        "2".to_string()
    } else {
        "1".to_string()
    }
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
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; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)

// エラトステネスの篩

vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){
        IsPrime.resize(max+1,true); 
    } 
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(size_t i=2; i*i<=max; ++i)
        if(IsPrime[i])
            for(size_t j=2; i*j<=max; ++j)
                IsPrime[i*j] = false;
}

int main(){
  ll n;cin>>n;
  sieve(1000010);
  if(n==1LL){cout<<0;return 0;}
  int a=0;
  reps(i,2,1000010){
    if(IsPrime[i]){
      int d=1;
      while(true){
      bool f=true;
      for(int j=0;j<d;j++){
        if(n%i==0){
          n/=i;
        }else{
          f=false;break;
        }
      }
      if(f){
        a++;d++;
      }else{break;
      }
    }
    }
  }
  if(n!=1)a++;
  cout<<a;
}

Measured memory_bytes: 3752
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

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

	vector<int> arr(n);
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}

	sort(arr.begin(), arr.end());
	
	cout << arr[n - 1] - arr[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vi A, B;
string S, T;

void input() {
  int x, y, z;
  cin >> S;
  ;
}
void solve() {
  int ai = 0;
  int zi = INF;
  rep(i, 0, S.size() - 1) {
    if (S[i] == 'A') {
      ai = i;
      break;
    }
  }
  rrep(i, S.size() - 1, 0) {
    if (S[i] == 'Z') {
      zi = i;
      break;
    }
  }
  cout << zi - ai + 1 << endl;

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

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0064
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int res = 0;
            while (true)
            {
                string line = Console.ReadLine();
                if (line == null) break;

                string tmp = "";
                for (int i = 0 ; i < line.Length ; i++)
                {
                    if (line[i] >= 48 && line[i] <= 57)
                    {
                        tmp += line[i];
                    }
                    else
                    {
                        if (tmp.Length > 0)
                        {
                            res += int.Parse(tmp);
                            tmp = "";
                        }
                    }
                }
                if (tmp.Length > 0) res += int.Parse(tmp);
            } 
            Console.WriteLine(res);

        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 15880