akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	N, K := nextInt(), nextInt()

	A, F := make([]int, N), make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = nextInt()
	}
	sort.Ints(A)

	for i := 0; i < N; i++ {
		F[i] = nextInt()
	}
	sort.Sort(sort.Reverse(sort.IntSlice(F)))

	l, r := 0, int(math.Pow(10, 12))
	for l < r {
		mid := l + (r-l)/2
		trning := 0

		for i := 0; i < N; i++ {
			if A[i]*F[i] > mid {
				trning += A[i] - (mid / F[i])
			}
		}

		if K < trning {
			l = mid + 1
		} else {
			r = mid
		}
	}

	fmt.Println(l)
}


Measured memory_bytes: 6272
n = gets.to_i
cnt = 0
1.upto(n) do |a|
  a.next.upto(n) do |b|
    break if a * b >= n
    cnt += 1
  end
end
cnt *= 2
1.upto(n) do |c|
  break if c * c >= n
  cnt += 1
end
puts cnt

Measured memory_bytes: 14428
d,m=1e9+7,dp[10001][2][100];
char s[11111];
f(l,i,k,t,x,L)
{
	int*r=dp[i][t]+k;
	*r=i-l?*r:!k;
	if(!~*r)
	{
		*r=0;
		L=t?9:s[i]-48;
		for(x=0;x<=L;*r%=m)*r+=f(l,i+1,(k+x++)%d,t|x<L);
	}
	return*r;
}
main()
{
	scanf("%s%d",s,&d);
	memset(dp,-1,sizeof dp);
	printf("%d",(f(strlen(s),0,0,0)-1+m)%m);
}

Measured memory_bytes: 8832
N = int(input())
a_s = list(map(int, input().split()))

a_s = sorted(a_s)

alice = 0
bob = 0
for i in range(N):
    if i % 2 == 0:
        alice += a_s.pop()
    else:
        bob += a_s.pop()

print(alice-bob)


Measured memory_bytes: 3316
s=input()
t=input()
s=sorted(s)
t=sorted(t,reverse=True)
S=""
for x in s:
  S+= x
T=""
for x in t:
  T+= x
A=[S,T]
a=sorted(A)
if a[0]==S:
  if a[1]==S:
    print("No")
  else:
    print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
/*
  AOJ 2123
  Title:Divisor Function
  @kankichi573
*/
#include <stdio.h>
#include <float.h>
#define max(x,y) (((x)>(y))?(x):(y))

#define NPRIME 13
double ret;

int prime[NPRIME]={2,3,5,7,11,13,17,19,23,29,31,37,41};
 
void solve(long long n,int prime_c,double val,double sum)
{
  long long prime_power;     
  long long prime_power_sum; 

  //printf(":%lld %d %lf %lf\n",n,prime_c,val,sum); 
  if (val > n || prime_c == NPRIME)
    return;
  ret=max(ret,sum/val);

  prime_power=prime_power_sum =1;
  while(1)
    {
      if(prime_power> n/val)
	break;
      if(prime_power !=1)
	solve(n,prime_c+1,val*prime_power,sum*prime_power_sum);
      prime_power *= prime[prime_c];
      prime_power_sum += prime_power;
    }
}
 
main()
{
  int i;
  long long  n;

  while(scanf("%lld",&n) && n)
    {
      ret = 1;
      solve(n,0,1,1);
      printf("%.6lf\n",ret);
    }
  return(0);
}

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

public class Main {

	static int N, A;
	static long[][][] dp;
	static int[] a;

	static long solve(int i, int j, int k) {
		if (i == N)
			return j != 0 && j * A == k ? 1 : 0;
		if (dp[i][j][k] != -1)
			return dp[i][j][k];
		long take = solve(i + 1, j + 1, k + a[i]);
		long leave = solve(i + 1, j, k);
		return dp[i][j][k] = take + leave;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		A = sc.nextInt();
		a = new int[N];
		for (int i = 0; i < N; i++)
			a[i] = sc.nextInt();
		dp = new long[N][N][2501];
		for (int i = 0; i < N; i++)
			for (int j = 0; j < N; j++)
				Arrays.fill(dp[i][j], -1);
		System.out.println(solve(0, 0, 0));
	}

}


Measured memory_bytes: 60752
import java.util.Scanner;
class Main{
  public static void main(String args[]){
    int N;
    int[] josi;
    Scanner sc = new Scanner(System.in);
    josi = new int[sc.nextInt()];
    for(int i =0;i<josi.length-1;i++){
      josi[sc.nextInt()-1]++;
    }
    for(int i = 0;i<josi.length;i++){
      System.out.println(josi[i]);
    }
  }
}

Measured memory_bytes: 57544
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>
#include <map>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)
#define ALL(v) v.begin(),v.end()

#define PI 3.14159265358979323846

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;


int main(void){
    FAST_IO
    
    ll n;
    cin >> n;
    ll op = n;
    ll count = 0;
    while(op > 0){
        count++;
        op -= count;
    }

    ll ignore_i = abs(op);

    ll sum = 0;
    string s = "";
    for(int i = 1;i <= count;i++){
        if(i != ignore_i){
            s += to_string(i) + '\n';
            sum += i;
        }
    }
    cout << s << endl;
    
    if(sum != n){
        cout << "ERROR" << endl;
    }
    return 0;
}

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

#define PI 4*atan(1)
#define INF 1e8

typedef long long ll;

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

int main(){
  string S;
  cin >> S;
  for(int i = 0; i < S.size() - 8; i++)cout << S[i];
  cout << endl;
}


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

int main()
{
  ll N, A, B; cin >> N >> A >> B;
  ll ans = 0;

  for(int i = 1; i < N+1; i++) {
    string s = to_string(i);
    ll tmp = 0;
    rep(j, s.size()) {
      tmp += s[j] - '0';
    }
    if (A <= tmp && tmp <= B) {
      ans += i;
    }

  }

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

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

#define ll long long

using namespace std;

ll n, k;
vector<ll> v;

bool check(ll l) {
    ll cuts = 0;
    for (auto &x : v) {
        cuts += (x-1)/l;
    }
    return cuts <= k;
}

void solve() {
    ll l = 1, r = 1000000000;
    cin >> n >> k;

    v.resize(n);
    for (int i = 0; i < n; ++i)
        cin >> v[i];

    if (check(1)) {
        cout << 1 << endl;
        return;
    }

    ll mid;
    while (l <= r) {
        mid = (l + r) / 2;

        if (!check(mid)) {
            if (check(mid+1))
                break;
            l = mid;
        } else {
            r = mid;
        }

        if (l == r && l == 1 && check(1)) {
            cout << 1 << endl;
            return;
        }
    }

    cout << mid+1 << endl;
}

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

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

    int t = 1;
    // cin >> t;

    for (int i = 0; i < t; ++i) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 4784
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main() {
  ll k,x;
  cin>>k>>x;
  ll l = max(-1000000LL,x-k+1);
  ll r = min(1000000LL,x+k-1);
  rep(i,l,r+1){
    cout << i;
    if(i!=r)cout << " ";
  }
  cout << 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 REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    string s;
    cin >> s;
    ll n = s.size();
    vll a(n);
    REP(i, n) {
        a[i] = int(s[i] - '0');
    }
    reverse(a.begin(), a.end());
    a.push_back(0);

    ll res = 0;
    REP(i, n) {
        if (a[i] < 5 || (a[i] == 5 && a[i + 1] < 5)) res += a[i];
        else {
            res += (10 - a[i]);
            a[i + 1]++;
        }
    }
    res += a[n];
    cout << res << endl;
    return 0;
}

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

int inner_product(int *u, int *v, int l){
 int result = 0;
 for(int i=0; i<l; i++) result += u[i]*v[i];
 return result;
 };

int main()
{
  int N,M,C;
  cin >> N >> M >> C;
  int A[N][M];
  int B[M];
  for(int i=0; i<M; i++) cin >> B[i];
  for(int i=0; i<N; i++){
    for(int j=0; j<M; j++){
    cin >> A[i][j];
    };
  };
  int result = 0;
 for(int i=0; i<N; i++){
   int res = inner_product(A[i],B,M) + C;
   if(res>0) result++;
 };
cout << result << endl;

return 0;
};

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

namespace CSharpSample01
{

    class Program
    {
        
        static void Main(string[] args)
        {

            while (true)
            {
                string[] input = Console.ReadLine().Split(' ');
                int n = int.Parse(input[0]);
                int r = int.Parse(input[1]);

                if(n == 0 && r == 0)
                {
                    break;
                }

                int[] card_ary = new int[n];

                int val = 1;
                for(int i = n - 1; i >= 0; i--)
                {
                    card_ary[i] = val;
                    val++;
                }

                //Console.WriteLine("ary : " + string.Join(" ", card_ary));

                for(int i = 0; i < r; i++)
                {
                    input = Console.ReadLine().Split(' ');
                    int p = int.Parse(input[0]) - 1;
                    int c = int.Parse(input[1]);

                    int[] card_ary_next = new int[n];
                    int index = 0;

                    for(int j = p; j <= p + c - 1; j++)
                    {
                        card_ary_next[index] = card_ary[j];
                        index++;
                    }

                    for(int j = 0; j < p; j++)
                    {
                        card_ary_next[index] = card_ary[j];
                        index++;
                    }

                    for(int j = p + c; j < n; j++)
                    {
                        card_ary_next[index] = card_ary[j];
                        index++;
                    }

                    card_ary_next.CopyTo(card_ary, 0);
                    //Console.WriteLine("ary : " + String.Join(" ", card_ary));

                }

                Console.WriteLine(card_ary[0]);

            }




        }
    }
}


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

#define pb push_back
#define MAX 100005
#define ff first
#define ss second
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 2e5+5;
ll t[4*MAXN];
void build(int v, int tl, int tr){
	if(tl==tr)
		t[v]=0LL;
	else{
		int tm = (tl+tr)/2;
		build(v*2,tl,tm);
		build(v*2+1,tm+1,tr);
		//depende la operación a realizar.
		t[v]=max(t[v*2],t[v*2+1]);
	}
}
ll get(int v, int tl, int tr, int l, int r){
	if(l>r)
		//retornar valor neutro de la opéración.
		return 0;
	if(tl==l&&tr==r)
		return t[v];		
	int tm = (tl+tr)/2;
	return max(get(v*2,tl,tm,l,min(r,tm)),get(v*2+1,tm+1,tr,max(tm+1,l),r));
		
}
void update(int v,int tl, int tr, int pos, ll new_val){
	if(tl==tr)
		t[v]=new_val;
	else{
		int tm  = (tl+tr)/2;
		if(pos<=tm)
			update(v*2,tl,tm,pos,new_val);
		else
			update(v*2+1,tm+1,tr,pos,new_val);
		t[v]=max(t[v*2],t[v*2+1]);
	}
}

int n,h[MAXN];
ll dp[MAXN],a[MAXN];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i =0; i<n; ++i){
        cin>>h[i];
    }
    for(int i =0; i<n; ++i){
        cin>>a[i];
    }
    ll ans =0;
    build(1,0,n);
    for(int i =0; i<n; ++i){
        dp[i] = get(1,0,n,0,h[i]-1);
        //error(i,dp[i]);
        dp[i]+=a[i];
        //error(i,dp[i]);
        update(1, 0, n, h[i], dp[i]);
        ans = max(ans,dp[i]);
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 8448
a, b = map(int, input().split())

if a < b < 0:
  if (abs(a - b) + 1) % 2 == 0:
    print('Positive')
  else:
    print('Negative')
elif a < 0 < b:
  print('Zero')
elif 0 < a:
  print('Positive')

Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
using namespace std;
int main() { 
  double w,h,x,y;
  cin>>w>>h>>x>>y;
  cout<<setprecision(20)<<w*h/2<<" " <<(w/2==x&&h/2==y?1:0)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    string s;
    cin >> s;
    int cnt = 0;
    for (int j = 'a'; j <= 'z'; j++)
    {
        cnt = 0;
        for (int i = 0; i < s.length(); i++)
        {
            if (j == s[i])
            {
                cnt++;
            }
        }
        if (cnt == 0)
        {
            cout << (char)j << endl;
            return 0;
        }
    }

    cout << "None" << endl;
    return 0;
}


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

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

    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;

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

        if (s == "AC"){
            ac++;
        }else if(s == "WA") {
            wa++;
        }else if (s == "TLE") {
            tle++;
        }else if(s == "RE") {

            re++;
        }
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;

    return 0;
}


Measured memory_bytes: 3620
use std::collections::HashMap;

fn main() {
    let line = read_line();
    let n: i32 = line.trim().parse().unwrap();

    let mut results = HashMap::new();
    results.insert(String::from("AC"), 0);
    results.insert(String::from("WA"), 0);
    results.insert(String::from("TLE"), 0);
    results.insert(String::from("RE"), 0);
    for _ in 0..n {
        let count = results.entry(read_line()).or_insert(0);
        *count += 1;
    }
    println!("AC x {}", results["AC"]);
    println!("WA x {}", results["WA"]);
    println!("TLE x {}", results["TLE"]);
    println!("RE x {}", results["RE"]);
}

fn read_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}


Measured memory_bytes: 2156
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    long long ans = 1;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
    {
        ans = (ans*i)%1000000007;
    }
    cout << ans;
    return 0;
}


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

namespace kozaiyApp
{
    public class BFrog2
    {
        static void Main()
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int K = int.Parse(input[1]);
            string[] inputH = Console.ReadLine().Split(' ');
            int[] H = Array.ConvertAll(inputH, int.Parse);

            int[] DP = new int[N];
            int[] ck = new int[N]; // 未確認:0 確認済:1
            for (int i = 0; i < N; i++)
            {
                for (int j = 1; j <= K; j++)
                {
                    if (i == 0)
                    {
                        DP[i] = 0;
                        ck[i] = 1;
                        break;
                    }

                    if (i < j) break;

                    // i行が初回チェックの場合はとりあえず今回の値を入れる
                    if (ck[i] == 0)
                    {
                        DP[i] = DP[i - j] + Math.Abs(H[i - j] - H[i]);
                        ck[i] = 1;
                    }
                    else
                    {
                        DP[i] = Math.Min(DP[i], DP[i - j] + Math.Abs(H[i - j] - H[i]));
                    }
                }
            }

            Console.WriteLine(DP[N - 1]);
        }
    }
}



Measured memory_bytes: 17248
#include <iostream>
using namespace std;
int main(void){
    int n;
    
    cin >> n;
    
    char s[n], t[n];
    
    cin >> s >> t;
    
    for(int i = 0; i < n; i++){
        cout << s[i] << t[i];
    }
    
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int n,k,q;
int least[100005];

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

    cin >> n >> k >> q;

    for (int i = 0 ; i < q ; i++){
        int in;
        cin >> in;
        least[in]++;
    }


    for (int i = 1 ; i  <= n ;i++){
        if (k + least[i] - q <= 0)cout << "No" <<endl;
        else cout << "Yes" <<endl;
    }

    return 0;
}


Measured memory_bytes: 1024
import sys
input=sys.stdin.readline
from collections import Counter
def get_counter(s):
    return Counter(s.upper().replace(' ', ''))

n=int(input())
#a=[get_counter(input().rstrip('\r\n')) for i in range(n)]
a=["".join(sorted(input().rstrip('\r\n'))) for i in range(n)]
def r(n):
    cnt=0
    for i in range(n):
        cnt+=i+1
    return cnt

my_dic={}
for i in a:
    if i in my_dic:
        my_dic[i]+=1
    else:
        my_dic[i]=1

res=0
for i in my_dic.values():
    res+=r(i-1)
        
print(res)


Measured memory_bytes: 19752
#include <iostream>

using namespace std;

int main(){
    int H, W;
    int a[26] = {0};
    int fours, twos;
    cin >> H >> W;
    fours = (int(H/2))*(int(W/2));
    twos = (int(H/2))*(W%2) + (int(W/2))*(H%2);
    for(int i = 0; i < H*W; i++){
        char tmp;
        cin >> tmp;
        a[int(tmp - 'a')]++;
    }

    //for(int j = 0; j < 26; j++){cout << a[j] << '\n';}

    for(int i = 0; i < fours; i++){
        for(int j = 0; j < 26; j++){
            if(a[j] >= 4){
                a[j] -= 4;
                break;
            }
            if(j == 26 - 1){
                cout << "No\n";
                return 0;
            }
        }
    }

    for(int i = 0; i < twos; i++){
        for(int j = 0; j < 26; j++){
            if(a[j] >= 2){
                a[j] -= 2;
                break;
            }
            if(j == 26 - 1){
                cout << "No\n";
                return 0;
            }
        }
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int n;
  cin>>n;
  vector<tuple<string,int,int>> a;
  for(int i=1;i<=n;i++){
    string s;
    int p;
    cin>>s>>p;
    p=-p;
    a.emplace_back(s,p,i);
  }
  sort(a.begin(),a.end());
  for(int i=0;i<n;i++){
    string s;
    int p;
    int id;
    tie(s,p,id)=a[i];
    cout<<id<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
vvl G;
vl dp;  // dp[v] : 人vに対応する頂点を根とした部分木のトーナメントの深さの最小値
 
void dfs(ll v) {
    vl x;  // vの子のdp値を入れるvector
    dp[v] = G[v].size();  // 少なくとも子の数以上の深さは必要
    for(auto u : G[v]) {
        dfs(u);
        x.pb(dp[u]);
    }
    sort(rall(x));
    rep(i, G[v].size()) {
        chmax(dp[v], x[i] + i+1);
    }
}
 
int main() {
    ll n;
    cin >> n;
    
    G.resize(n);
    rep(i, n-1) {
        ll v;
        cin >> v;
        v--;
        G[v].pb(i+1);
    }

    dp.resize(n);
    dfs(0);
    
    out(dp[0]);
    re0;
}

Measured memory_bytes: 17408
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>

using namespace std;


int main() {
  int N, D;
  cin >> N >> D;
  
  int X[20][20];
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= D; j++) {
      cin >> X[i][j];
    }
  }
  
  int count = 0;
  for (int i = 1; i <= N-1; i++) {
    for (int j = i+1; j <= N; j++) {
      
      double val = 0;
      for (int d = 1; d <= D; d++) {
        val += pow(X[i][d]-X[j][d],2);
      }
      val = pow(val, 0.5);
      long lval = val;
      if(lval==val) count++;
    }
  }
  
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<queue>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<cstdlib>
#define lson l,mid,o<<1
#define rson mid + 1,r,o<<1|1
#define sc(x) scanf("%d",&x);
#define For(i,a,b)  for(i = a; i <= b; i++)
typedef long long LL;
typedef unsigned long long uLL;
const int INF = 0x3f3f3f3f;
const LL MAX_N = 1e5 + 5;
const LL mod = 1e9 + 7;
const double PI = acos(-1);
using namespace std;

int main()
{
    int A,B;
    cin>>A>>B;
    cout<<((A+B)%24)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include<vector>
#include<map>
typedef long long ll;
#define cle(n) memset(n,0,sizeof(n))
#define maxn 300005
using namespace std;


int n,m,t;
ll a[maxn];
ll sum;
int main()
{
  int n;
  while(cin>>n)
  {
      sum=0;
      for(int i=0;i<3*n;i++)
        cin>>a[i];
      sort(a,a+3*n);
      for(int i=3*n-2,j=0;j<n;i=i-2,j++)
       {
           sum+=a[i];


       }
       cout<<sum<<endl;




  }


 return 0;
}



Measured memory_bytes: 2560
/*
  I used a template program in C.
*/

#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
 
Node root;
 
Node treeMinimum(Node x){

  /*my code beginning*/
  while(x->left!=NIL){
    x=x->left;
  }
  return x;
  /*my code end*/

}
 
Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){

  /*my code beginning*/
  if(u==NIL || k==u->key){
    return u;
  }
  if(k < u->key){ 
    return treeSearch(u->left,k);
  } else { 
    return treeSearch(u->right,k);
  }
  /*my code end*/

}
 
Node treeSuccessor(Node x){

  /*my code beginning*/
  Node y;
  if(x->right!=NIL){ 
    return treeMinimum(x->right);
  }
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
  /*my code end*/

}
 
Node treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  /*my code beginning*/
  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;
  }
  return y;
  /*my code end*/

}
 
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  /*my code beginning*/
  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;
  }
  /*my code end*/

}
 
void inorder(Node u){

  /*my code beginning*/
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
  /*my code end*/

}
void preorder(Node u){

  /*my code beginning*/
  if(u!=NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
  /*my code end*/

}
 
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  /*my code beginning*/
  root=NIL;
  /*my code end*/

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
 
  return 0;
}

Measured memory_bytes: 24040
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(), c.end()
int main()
{
    int n, m;
    cin >> n >> m;
    int arr[m], sum = 0;
    for (int i = 0; i < m; i++)
    {
        cin >> arr[i];
        sum += arr[i];
    }
    if (sum > n)
        cout << "-1" << endl;
    else
    {
        cout << n - sum << endl;
    }

    return 0;
}

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

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

  ll n;
  cin >> n;
  for (ll k = 0; k < n; k++) {
    ll b;
    cin >> b;
    for (ll i = 0; i < 3; i++) {
      for (ll j = 0; j < 3; j++) {
        if (a[i][j] == b) a[i][j] = 0;
      }
    }
  }

  for (ll i = 0; i < 3; i++) {
    if (a[i][0] + a[i][1] + a[i][2] == 0) {
      cout << "Yes" << endl;
      return 0;
    }
    if (a[0][i] + a[1][i] + a[2][i] == 0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  if (a[0][0] + a[1][1] + a[2][2] == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  if (a[0][2] + a[1][1] + a[2][0] == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int N, K;
  long long S;
  cin >> N >> K >> S;
  for(int i=0; i<K; i++) cout << S << " ";
  if(S<100010){
    for(int i=K; i<N; i++) cout << S+1 << " ";
  }
  else{
    for(int i=K; i<N; i++) cout << 1 << " ";
  }
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int K; string S; 
	cin >> K >> S; 
	int L = S.size(); 
	if(L <= K) cout << S << "\n"; 
	else cout << S.substr(0, K) << "..." << "\n"; 
}

Measured memory_bytes: 3644
#include <iostream>


using namespace std;

int main(void) {

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

	return 0;
}

Measured memory_bytes: 1160
n, k = map(int, input().split())
plst = list(map(int, input().split()))
ans_double = k + sum(plst[:k])
total = ans_double
for i in range(n - k):
    total -= plst[i]
    total += plst[i + k]
    ans_double = max(ans_double, total)
print(ans_double / 2)

Measured memory_bytes: 32192
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define ld long double
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define f first
// #define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

// I am questioning life and universe and 
// everything else after looking at this


const ll MAXN = 1e5 + 5;
ll a[MAXN],dp[MAXN];
ll n,k;

ll rec(ll idx){
    if(idx > n) return 1e10;
    if(idx == n) return 0;

    ll &ans = dp[idx];

    if(ans != -1) return ans;
    ans = 1e10;

    FOR(i,1,k)  {
        if(idx+i<=n)ans = min(ans,rec(idx+i)+abs(a[idx+i]-a[idx]));
    }

    return ans; 
}

void solve(){
    cin>>n>>k;

    FOR(i,1,n) cin>>a[i];
    memset(dp,-1,sizeof(dp));

    ll ans = rec(1);

    cout<<ans<<endl;

}

signed main(){


    FastRead;    

    ll t;
    t = 1; 
    // cin>>t;
    while(t--) solve();
    
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define fi first
#define se second
#define endl '\n'
#define MOD(n,k) ( (n % k) + k ) % k
#define isOn(S, j) (S & (1 << j) )
#define setBit(S, j) (S | (1 << j ) )
#define LSB(S) (S & (-S))

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n, m, x, y;
	vii a;

	cin >> n >> m;

	bitset<200005> bs;

	for (int i = 0; i < m; i++) {
		cin >> x >> y;
		a.emplace_back(x, y);
		if (x == 1)
			bs[y] = 1;
	}

	for (int i = 0; i < m; i++) {
		if (bs[a[i].fi] && a[i].se == n) {
			cout << "POSSIBLE";
			return 0;
		}
	}

	cout << "IMPOSSIBLE";

	return 0;
}


Measured memory_bytes: 2420
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int max = 0;
        int sum = 0;
        for (int i = 0; i < N; i++) {
            int tmp = sc.nextInt();
            sum += tmp;
            if (tmp >= max) {
                max = tmp;
            }
        }
        if (max < (sum - max)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

}

Measured memory_bytes: 21972
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
  int N; cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];

  sort(A.begin(), A.end());
  A.erase(unique(A.begin(), A.end()), A.end());

  if (A.size() == N) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 1792
mod=10**9+7
n,k=map(int,input().split())
mt=[1]
invt=[1]
for i in range(1,n+1):
  mt.append((mt[-1]*i)%mod)
  invt.append(pow(mt[-1], mod-2, mod))

for i in range(1,k+1):
  a=mt[n-k+1]*invt[i]*invt[n-k-i+1]
  b=mt[k-1]*invt[i-1]*invt[k-i]
  print((a*b)%mod if n-k+1>=i else 0)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vector<T>>;
using vl = vector<ll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}
//--------------------------------------------------------------------------------//

int main() {
    init();
    string s;
    cin >> s;
    ll N = s.size();
    ll K;
    cin >> K;

    set<string> L;
    rep(i, N) rep(j, min(N - i, K)) {
        L.emplace(s.substr(i, j + 1));
    }
    auto it = L.begin();
    rep(i, K - 1) it++;
    cout << *it << endl;

    return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define forn(low,high,i) for(i = low;i < high;i++)
#define forrev(high,low,i) for(i = high; i >= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';        
#define debug(x) cerr << __LINE__ << ' ' << #x << " = " << x << '\n';
#define dln cerr << '\n';
#define dsp cerr << ' ';
#define pln cout << '\n';
#define psp cout << ' ';

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int inf = 1e9;
const ll INF = 1e18;
const ll mod = 1e9 + 7;

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

int main(){
  fastio

  int n, m;
  cin >> n >> m;
  priority_queue<int> pq;
  while(n--){
    int p;
    cin >> p;
    pq.push(p);
  }

  ll ans = 0;

  while(m){
    int x = pq.top();
    pq.pop();
    pq.push(x / 2);
    m--;
  }

  while(sz(pq)){
    ans += 1LL * pq.top();
    pq.pop();
  }

  cout << ans << '\n';

  ktj();
}


Measured memory_bytes: 892
N = int(input())
T = list(map(int, input().split()))
A = list(map(int, input().split()))

if T[-1] != A[0]:
    print(0)
    exit()

max_h = [1] * N

#max_h[0] = T[0]
#max_h[-1] = A[-1]

h = [None] * N
#Tから見ていく
for i in range(1,N-1):

        ht = ha = None
        if T[i] > T[i-1]:
            ht = T[i]
        if A[i] > A[i+1]:
            ha = A[i]

        if ht != None and ha != None:
            if ht == ha:
                h[i] = ht
            else:
                print(0) # 矛盾するので終わり
                exit()
        
        elif ht != None:
            if A[i] < ht:
                print(0) # 矛盾するので終わり
                exit()
            #h[i] = ht
        elif ha != None:
            if T[i] < ha:
                print(0) # 矛盾するので終わり
                exit()
            #h[i] = ha
        

        elif ht == None and ha == None:
            max_h[i] = min(T[i], A[i])


MOD = 10**9 + 7
def mul(a, b):
    return ((a % MOD) * (b % MOD)) % MOD
ans = 1
for i in range(N):
    ans = mul(ans, max_h[i])
    #ans *= max_h[i]

print(ans)

Measured memory_bytes: 18624
#include <iostream>

#define n 20

using namespace std;

int N;
int A[n] = {}, C[n - 1] = {};

int tmp,ans=0;

int main(){
    cin >> N;
    for (int i = 0; i < N;i++){
        cin >> A[i];
    }
    for (int i = 0; i < N;i++){
        cin >> tmp;
        ans += tmp;
    }
    for (int i = 1; i < N;i++){
        cin >> C[i];
    }

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

    cout << ans;

    return 0;
}

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

/*
templates for competitive programming
type long long -> type ll 
define constants : EPS, INF, MOD, PI
define macros : REP, FOR, ALL, SORT, REVERSE
define number theory functions: qp(a, b), qp(a, b, mo), gcd(a, b)
define dx, dy
*/
   typedef long  ll;

   const double EPS = (1e-7);
   const int INF =(1e9);
   const double PI = (acos(-1));
   const int MOD = (int(1e9) + 7);

   #define REP(i, n) for(int i = 0; i < (int)(n); i++)
   #define FOR(i, a, b) for (int i = (a); i < (b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((int)(x).size())


   #define dump(x) cerr<< #x << "= " << (x) << endl;

   int gcd(int a,int b){return b?gcd(b,a%b):a;};
   ll power(ll a, ll b){
       if (b == 0) return 1;
       else if (b % 2 == 0) return power(a * a, b / 2);
       else return a * power(a, b - 1);
   }

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


void solve() {
}

int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int n, a;
   cin >> n >> a;
   vector<int> x(n);
   REP(i, n){
       int xi;
       cin >> xi;
       x[i] = xi - a;
   }
   vector<int> x_plus;
   vector<int> x_minus;
   int x_zero = 0;
   REP(i, n){
       if (x[i] > 0){
           x_plus.push_back(x[i]);
       }
       else if (x[i] < 0){
           x_minus.push_back(- x[i]);
       }
       else{
           x_zero ++;
       }
   }
   const int MAX_S = 50 * 50;
   vector<ll> s_plus(MAX_S);
   vector<ll> s_minus(MAX_S);
   s_plus[0] = s_minus[0] = 1;

   REP(i, x_plus.size()){
       for(int j = MAX_S; j > 0; j--){
           if (j >= x_plus[i]){
               s_plus[j] += s_plus[j - x_plus[i]];
           }
       }
   }
    REP(i, x_minus.size()){
        for(int j = MAX_S; j > 0; j--){
            if (j >= x_minus[i]){
                s_minus[j] += s_minus[j - x_minus[i]];
            }
        }
    }
    ll ans = 0;
    REP(i, MAX_S){
        ans += s_plus[i] * s_minus[i];
    }
    ans *= power(2, x_zero);
    cout << ans - 1 << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int inf = 5e18;  
const int mod = 1e9+7;
const int mod1 = 998244353;
const int nax = 200005;
const int mxm = 2019;
int suff[nax],r[mxm];
int n;
string s;
void solve()
 {
  cin>>s;
  n = s.size();
  int cnt = 0;
  suff[n] = 0;
  int p = 1;
  memset(r,0,sizeof r);
  r[0] = 1;
  loopb(i,n-1,-1)
   {
    p %= mxm;
    int now = ((s[i] - '0')*p)%mxm;
    p *= 10;
    suff[i] = (now + suff[i+1])%mxm;
    r[suff[i]]++;
   }
  loop(i,0,2019)
   cnt += r[i]*(r[i] - 1)/2;
  cout<<cnt;
 } 
int32_t main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
   /*int t;
   cin>>t;
   while(t--)*/
     solve();
 // cerr<<END<<1.0*clock()/CLOCKS_PER_SEC;
  return 0;
} 

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

struct Dice{
  int s[6];
  void roll(char c){
    int b;

    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='R'){
      b=s[1];
      s[1]=s[3];
      s[3]=s[4];
      s[4]=s[2];
      s[2]=b;
    }
    if(c=='L'){
      b=s[1];
      s[1]=s[2];
      s[2]=s[4];
      s[4]=s[3];
      s[3]=b;
    }
  }
};

Dice D[6];
string s[10][10];
int a[10][10];

int n,ans;
int used[25];

void dfs(int dep){
  if(dep==n){
    int T=n*6;
    r(i,6){
      memset(used,0,sizeof(used));
      int MAX=0;
      r(j,n){
	used[D[j].s[i]]++;
	MAX=max(MAX,used[D[j].s[i]]);
      }
      T-=MAX;
    }
    ans=min(T,ans);
    return ;
  }
  r(k,2){
    D[dep].roll('E');
    r(i,4){
      D[dep].roll('S');
      r(j,4){
	D[dep].roll('R');
	dfs(dep+1);
      }
    }
  }
}

int main(){
  while( cin>>n , n ){
    ans=1e9;
    vector<string>v;
    r(i,n){
      r(j,6){
	cin>>s[i][j];
	v.push_back(s[i][j]);
      }
    }
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    map<string,int>M;
    r(i,v.size()){
      M[v[i]]=i;
    }
    r(i,n){
      r(j,6){
	a[i][j]=M[s[i][j]];
	D[i].s[j]=a[i][j];
      }
    }
    dfs(0);
    cout<<ans<<endl;
  }
}



Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>

using namespace std;

int a[3];

int main(void) {
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}
	sort(a, a + 3);
	int sum = 0;
	for (int i = 0; i < 2; i++) {
		sum += (a[2] - a[i]) / 2;
		a[i] += ((a[2] - a[i]) / 2) * 2;
	}
	int x = a[2] - a[0], y = a[2] - a[1];
	if (x + y == 0) {
		cout << sum << endl;
	}
	else if (x + y == 1) {
		cout << sum + 2 << endl;
	}
	else if (x + y == 2) {
		cout << sum + 1 << endl;
	}
	//system("pause");
}

Measured memory_bytes: 256
x=[[[0]*10 for i in range(3)] for j in range(4)]
n=int(input())
for i in range(n):
    a,b,c,d=map(int, input().split())
    x[a-1][b-1][c-1]+=d

for i in range(4):
    for j in x[i]:
        print(' ',end='')
        print(*j)
    if i!=3:print('#'*20)


Measured memory_bytes: 5624
#pragma GCC optimize(3)
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-9
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0xff,sizeof(a))
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

string s;
bool can[200010];
int a[200010],b[200010];
int main(int argc,char** argv){
	ios::sync_with_stdio(0);
	int n,k,c,d;
	cin>>n>>k>>c>>s;
	rep(i,n){
		if(s[i]=='o')can[i]=1;
	}
	int pos=0;
	rep(i,k){
		//cout<<i<<" "<<pos<<endl;
		a[i]=pos;
		pos+=c+1;
		while(!can[pos]&&pos<n)pos++;
	}
	pos=n-1;
	for(int i=k-1;i>=0;i--){
		b[i]=pos;
		pos-=c+1;
		while(!can[pos]&&pos>=0)pos--;
	}
	rep(i,k){
		if(a[i]==b[i]){
			cout<<a[i]+1<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    int a;
    cin >> a;
    cout << a+a*a+a*a*a << endl;
}

Measured memory_bytes: 3596
n,m=map(int,input().split())
xyz=[list(map(int,input().split())) for i in range(n)]

ans=0
for i in [-1,1]:
  for j in [-1,1]:
    for k in [-1,1]:
      l=[i*xyz[z][0]+j*xyz[z][1]+k*xyz[z][2] for z in range(n)]
      l.sort(reverse=True)
      ans=max(ans,sum(l[:m]))
print(ans)

Measured memory_bytes: 3380
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;

int flag[100];
char a[105];
int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		scanf(" %c", &a[i]);
		flag[a[i] - 'A'] = 1;
	}
	int ans = 0;
	for(int i = 1; i <= 30; i++)
	{
		if(flag[i] == 1) ans++;
	}
	//printf("%d\n", ans);
	if(ans == 3) printf("Three\n");
	else printf("Four\n");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define REP(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll  a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
  bool ans=true;
  if(v<=w)ans=false;
  else{
    if(a>b) swap(a,b);
    ll k=v-w;
    ll s=b-a;
    if(s>t*k) ans=false;
  }
  YES(ans);
}

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

using namespace std;

typedef long long ll;
#define _ ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);

#define sll(x) scanf("%I64d",&x)
#define sd(x)  scanf("%d",&x)
#define pll(x) printf("%I64d",x)
#define pd(x)  printf("%d",x)

#define clr(x) memset(x,0,sizeof x)

#define mid    ((l+r)>>1)
#define Pi acos(-1)
#define EPS 1e-12
#define MOD  1000000007
#define MOD1 1000000009
#define INFL 10000000000000LL
#define INF  2000000000

#define N 100015

pair<int,int> ar[1000];
ll dp[110][N],n,W;
ll solve(int i, ll w){
if(w > W) return -1*INFL;
if(i == n) return 0;

if(dp[i][w] != -1) return dp[i][w];

ll c1 = -1*INFL,c2= -1*INFL;
c1 = solve(i+1,w+ar[i].first) +ar[i].second;
c2 = solve(i+1,w);

ll ret = max(c1,c2);

return dp[i][w] = ret;

}

int main()
{_

    cin >> n >> W;
    ll maV=0;
    for(int i=0;i<n;i++){
        int wi,vi; cin >> wi >> vi;
        ar[i] = {wi,vi};
        maV += vi;
    }
    // will try working on REACHING "ALL VALUES" with minimum coast
    for(int i=0;i<n;i++)
        for(int j=0;j<maV+1;j++) dp[i][j] = INFL;
        dp[0][0] = 0;

    for(int i=0;i<n;i++)
        for(int curV=0;curV<maV+1;curV++){
            if(curV >= ar[i].second){
                dp[i+1][curV] = min(dp[i][curV],dp[i][curV-ar[i].second] + ar[i].first);
            }
            else
                dp[i+1][curV] = dp[i][curV];
        }

    ll ans = 0;
    for(int i=0;i<maV+1;i++) if(dp[n][i] <= W) ans = i;
    cout << ans;

    return 0;
}


Measured memory_bytes: 80128