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

using namespace std;

int maxbek(int K) // 最大で何回投げるか
{
    int answer = 0; // answerの初期値：0
    int number = 1; // numberの初期値：1
    while(number < K) // numberがK以上になるまで
    {
        number *= 2; // 何回か２を掛ける
        answer++; // 何回２を１に掛ければK以上になるか
    }
    return answer; // 何回２を１に掛ければK以上になるか　（つまり最大で何回投げるか）　を返す
}

int maxmom(int K) // 最大で分母は何になるか
{
    int number = 1; // numberの初期値：0
    while(number < K) // numberがK以上になるまで
    {
        number *= 2; // 何回か２を掛ける 
    }
    return number; // 最大で何回投げるか
}

int bek(int K, int i) // 何回投げるか
{
    
    int answer = 0; // 何回投げるか
    int number = i; // 倍々にする上での初期値
    while(number < K) // K以上になるまで
    {
        answer++; // 投げる回数
        number *= 2; // 倍々にする
    }
    return answer; // 投げる回数を返す
}

int mom(int K, int i) // 何回か投げたときの分母
{
    int answer = 1;
    int number = i; // 倍々にする上での初期値
    while(number < K) // K以上になるまで
    {
        number *= 2; // 倍々にする
        answer *= 2;
    }
    return answer; // 分母を返す
}

pair<int,int> tuu(vector<pair<int,int>> V)
{
    int max = 0;
    for(int i=0;i<V.size();i++)
    {
        if(max < V.at(i).second)
        {
            max = V.at(i).second;
        }
    }

    pair<int,int> answer = {0,max}; // 分子、分母

    for(int i=0;i<V.size();i++) 
    {
        answer.first += V.at(i).first * (max / V.at(i).second); 
    }

    return answer;
}

int main()
{
    int N,K; // N:初期値のパターン　K:境界値
    cin >> N >> K;

    int max = maxbek(K); // 最大で何回投げるか

    vector<pair<int,int>> V(N); // first:分子　second:分母

    for(int i=0;i<N;i++) // 各初期値１～Nに応じたパターン
    {
        V.at(i).first = 1;
        V.at(i).second = mom(K,i+1);
    }

    pair<int,int> answers = tuu(V);

    answers.second *= N;

    double answer = (double)answers.first / (double)answers.second;

    printf("%15.13f\n",answer);

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n; cin >> n;
  M m;
  REP(i,n) {
    int a;
    cin >> a;
    m[a]=i+1;
  }
  REP(i,n) cout << m[i+1] << " ";
  return 0;
}

Measured memory_bytes: 5504
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
static const int NMAX = 100;
#define INF (1 << 30)
int ADJ[NMAX][NMAX];

int main() {
  int n;
  cin >> n;
  int tmp;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> tmp;
      ADJ[i][j] = (tmp == -1) ? INF : tmp;
    }
  }

  bool visited[n];
  int edges[n];

  // add node 0
  for (int i = 0; i < n; i++) {
    edges[i] = ADJ[0][i];
    visited[i] = false;
  }
  visited[0] = true;

  int cost = 0;
  while (true) {
    int minnode = -1;
    int mincost = INF;
    // find min edge
    for (int i = 0; i < n; i++) {
      if (visited[i] == false && edges[i] < mincost) {
        minnode = i;
        mincost = edges[i];
      }
    }
    if (minnode == -1)
      break;

    // add node
    visited[minnode] = true;
    cost += mincost;

    // update connected edges
    for (int i = 0; i < n; i++) {
      edges[i] = min(edges[i], ADJ[minnode][i]);
    }
  }
  cout << cost << endl;
}

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

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

    int n,k;
    cin>>n>>k;

    int ans=0;

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

        ans+=min(2*x,2*abs(k-x));
    }

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3656
N, A = map(int,input().split())
X = list(map(int,input().split()))
dp = [[[0 for k in range(50 * N + 1)] for j in range(N + 1)] for i in range(N + 1)]
dp[0][0][0] = 1
for i in range(1,N+1):
    for j in range(i+1):
        for k in range(50 * N + 1):
            dp[i][j][k] += dp[i-1][j][k]
            if j != 0 and k - X[i-1] >= 0:
                dp[i][j][k] += dp[i-1][j-1][k - X[i-1]]
ans = 0
for i in range(1, N+1):
    ans += dp[N][i][A * i]
print(ans)

Measured memory_bytes: 95836
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N = input()[:-1]
    if "7" in N:
        print("Yes")
    else:
        print("No")
        


if __name__ == '__main__':
    main()

Measured memory_bytes: 72764
/*
csc -debug C.cs && mono --debug C.exe <<< "4 2
1 3
2 4"
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Reflection;

public class HelloWorld {
    public static void SolveCodeForces() {
        var N = cin.NextInt();
        var M = cin.NextInt();

        var min = 1;
        var max = N;

        for (var i = 0; i < M; i++) {
            var l = cin.NextInt();
            var r = cin.NextInt();
            min = Math.Max(min, l);
            max = Math.Min(max, r);
        }

        System.Console.WriteLine(Math.Max(0, max - min + 1));
    }

    static Scanner cin = new Scanner();
    static StringBuilder cout = new StringBuilder();

    static public void Main () {
        SolveCodeForces();
        // IncreaseStack(SolveCodeForces);
        // System.Console.Write(cout.ToString());
    }

    public static void IncreaseStack(ThreadStart action, int stackSize = 128000000)
    {
        var thread = new Thread(action, stackSize);
        thread.Start();
        thread.Join();
    }
}

public static class Helpers {
    public static T[] CreateArray<T>(int length, Func<int, T> itemCreate) {
        var result = new T[length];
        for (var i = 0; i < result.Length; i++)
            result[i] = itemCreate(i);
        return result;
    }
}

public class Scanner
{
    private string[] line = new string[0];
    private int index = 0;

    public string Next() {
        if (line.Length <= index) {
            line = Console.ReadLine().Split(' ');
            index = 0;
        }
        var res = line[index];
        index++;
        return res;
    }

    public int NextInt() {
        return int.Parse(Next());
    }

    public long NextLong() {
        return long.Parse(Next());
    }

    public ulong NextUlong() {
        return ulong.Parse(Next());
    }

    public string[] Array() {
        line = Console.ReadLine().Split(' ');
        index = line.Length;
        return line;
    }

    public int[] IntArray(int emptyPrefixLen = 0) {
        var array = Array();
        var result = new int[emptyPrefixLen + array.Length];
        for (int i = 0; i < array.Length; i++)
            result[emptyPrefixLen + i] = int.Parse(array[i]);
        return result;
    }

    public long[] LongArray() {
        var array = Array();
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = long.Parse(array[i]);
        return result;
    }

    public ulong[] UlongArray() {
        var array = Array();
        var result = new ulong[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = ulong.Parse(array[i]);
        return result;
    }
}

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

int main(){
  int N;
  cin >> N;
  int S = N;
  int x;
  int C = 0;

  while (S != 0){
    x = S % 10;
    C += x;
    S = (S - x) / 10;
  }
  
  if ((N % C) == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <functional>
#include <cmath>

using namespace std;

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

	int n, l[3000];
	int cnt = 0;
	int i, j, k;

	cin >> n;
	for (i = 0; i < n; i++)
		cin >> l[i];

	sort(l, l + n);

	for (i = 0; i < n - 2; i++)
	{
		for (j = i + 1; j < n - 1; j++)
		{
			for (k = j + 1; k < n; k++)
			{
				if (l[i] < l[j] + l[k])
					if (l[k] < l[j] + l[i])
						if (l[j] < l[i] + l[k])
							cnt++;
			}
		}
	}
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
ll n, dp[3005][3005];
const ll inf = 1e18+5;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n;
	vector<ll> a(n);
	for (ll i= 0; i< n; i++)cin >> a[i];
	for (ll i = n-1; i >= 0; i--){
		for (ll j = i; j < n; j++){
			ll L = i, R= j;
			dp[i][j] = max(a[L] - dp[L+1][R], (R == 0 ? -inf:a[R] - dp[L][R-1]));
		}
	}
	cout << dp[0][n-1];
}


Measured memory_bytes: 70016
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pint;

signed main()
{
    int N,M; cin>>N>>M;
    vector<vector<int>> G(N);
    M+=N-1;
    vector<int> indeg(N);
    for(int i=0;i<M;i++){
        int a,b; cin>>a>>b;
        a--; b--;
        G[a].push_back(b);
        indeg[b]++;
    }
    queue<int> Q;
    for(int i=0;i<N;i++){
        if(indeg[i]==0){
            Q.push(i);
        }
    }
    vector<int> ans(N,-1);
    while(!Q.empty()){
        int v=Q.front();
        Q.pop();
        for(int u:G[v]){
            indeg[u]--;
            if(indeg[u]==0){
                ans[u]=v;
                Q.push(u);
            }
        }
    }
    for(int i=0;i<N;i++){
        cout<<ans[i]+1<<endl;
    }
}


Measured memory_bytes: 7808
def solve(n, t_list):

    px = 0
    py = 0
    pt = 0
    ans = "Yes"
    for t, x, y in t_list:
        d = abs(x-px) + abs(y-py)
        dt = t - pt
        if ((d %2 == 0 and dt % 2 == 0) or (d % 2 == 1 and dt %2 == 1) )and dt >= d:
            px = x
            py = y
            pt = t
        else:
            ans = "No"
            break

    return ans


if __name__ == "__main__":
    n = int(input())
    t_list = [[int(j) for j in input().split()] for i in range(n)]
    print(solve(n, t_list))

Measured memory_bytes: 21108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cstdlib>
#include <cstdio>
#include <stack>
#include <queue>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if(a - 2*b <= 0) {
		cout << 0 << endl;
	}
	else {
		cout << a-2*b << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi=3.14159265358979;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k,ans=1;
    cin>>n>>k;
    if(n>k){
        cout<<0<<endl;
        return 0;
    }
    rep(i,n){
        ans*=(k-i);
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<vector<unsigned long>> edge(N);
    for(unsigned long i{1}, A, B; i < N; ++i){
        cin >> A >> B;
        --A;
        --B;
        edge[A].push_back(B);
        edge[B].push_back(A);
    }
    constexpr unsigned long MOD = 1000000007;
    unsigned long ans{(N + (N & 1) * MOD) >> 1}, minus{N};
    vector<unsigned long> pow2(N);
    pow2[0] = 1;
    for(unsigned long i{1}; i < N; ++i)pow2[i] = pow2[i - 1] * 2 % MOD;
    [dfs_impl = [&edge, &ans, &pow2, &minus](auto f, auto now, auto prev) -> unsigned long {
        unsigned long ret{0};
        for(const auto& i : edge[now]){
            if(i != prev){
                auto t = f(f, i, now);
                ret += t;
                minus += pow2[t] - 1;
            }
        }
        if(1 + ret != edge.size())minus += pow2[edge.size() - 1 - ret] - 1;
        return 1 + ret;
    }]{dfs_impl(dfs_impl, 0, 0);}();
    unsigned long num{1};
    for(unsigned long i{0}; i < N; ++i)(num += (num & 1) * MOD) >>= 1;
    cout << (ans + (MOD - minus % MOD) * num) % MOD << endl;
    return 0;
}

Measured memory_bytes: 19712
# coding=utf-8

import collections
get = lambda: int(raw_input().strip())
gets = lambda: map(int, raw_input().strip().split())
getss = lambda x: [gets() for _ in xrange(x)]


N, M = gets()
count = collections.Counter()
penalty = 0
ac = set()
for i in xrange(M):
    p, s = raw_input().split()
    p = int(p)
    if p in ac: continue
    if s == 'AC':
        ac.add(p)
        penalty += count[p]
    else:
        count[p] += 1
print len(ac), penalty


Measured memory_bytes: 10992
#include<stdio.h>

int main(){
  int a, b;

  scanf("%d %d", &a, &b);

  int c = 0;
  int check = 0; 
  for(c = 1; c <= 3; c++){
    if((a * b * c % 2) == 1){
      check = 1;
      break;
    }
  }

  if(check){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>
#include <map>

using namespace std;

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

	int N;
	cin >> N;

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

	map<char, int> ch_count;

	for (char i = 'a'; i <= 'z'; i++)
	{
		int min_count = 51;
		for (int j = 0; j < N; j++)
		{
			int curr_count = 0;
			for (int k = 0; k < S[j].size(); k++)
			{
				if (S[j][k] == i) curr_count++;
			}

			min_count = min(min_count, curr_count);
		}

		ch_count[i] = min_count;
	}

	string result;
	for (auto e : ch_count)
	{
		for (int i = 0; i < e.second; i++)
		{
			result.push_back(e.first);
		}
	}

	cout << result;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define first first
#define second se
using namespace std;
typedef pair<int, int> P;
typedef vector<int> vi;


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

int h = 10, w = 10;

bool contain(int y, int x){
    return (0 <= y && y < h && 0 <= x && x < w);
}

signed main(){
    int x, y, s;
    char c;
    int d[11][11] = {0};
    while(cin >> x >> c >> y >> c >> s){
        // cout << x << ' ' << y << ' ' << s << endl;
        if(s == 1){
            d[y][x]++;
            rep(i, 0, 4){
                int ny = y + dy[i];
                int nx = x + dx[i];
                if(contain(ny, nx)){
                    d[ny][nx]++;
                }
            }
        }
        if(s >= 2){
            rep(i, 0, 3){
                rep(j, 0, 3){
                    int ny = y + i - 1;
                    int nx = x + j - 1;
                    if(contain(ny, nx)){
                        d[ny][nx]++;
                    }
                }
            }
        }
        if(s == 3){
            rep(i, 0, 4){
                int ny = y + 2 * dy[i];
                int nx = x + 2 * dx[i];
                if(contain(ny, nx)){
                    d[ny][nx]++;
                }
            }
        }
    }
    int ans = 0, MAX = 0;
    rep(i, 0, 10){
        rep(j, 0, 10){
            // o(d[i][j]);
            if(d[i][j] == 0) ans ++;
            MAX = max(MAX, d[i][j]);
        }
    }
    cout << ans << endl;
    cout << MAX << endl;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto&& e : a) {
    cin >> e;
  }
  int res = 2e9;
  for (int x = 1; x <= 100; ++x) {
    int cur = 0;
    for (int e : a) {
      cur += (e - x) * (e - x);
    }
    res = min(res, cur);
  }
  cout << res << '\n';
}


Measured memory_bytes: 256
package main

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

var scanner = bufio.NewScanner(os.Stdin)

type ship struct {
	from int
	to   int
}

type ships []ship

func (s ships) Len() int {
	return len(s)
}

func (s ships) Less(i, j int) bool {
	return s[i].from < s[j].from
}

func (s ships) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

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

	n, m := nextInt(), nextInt()
	s := make([]ship, m)
	for i := 0; i < m; i++ {
		s[i].from, s[i].to = nextInt(), nextInt()
	}

	sort.Sort(ships(s))
	a, b := make([]int, m), make([]int, m)
	for i, v := range s {
		a[i], b[i] = v.from, v.to
	}

	ans := "IMPOSSIBLE"
	endIndex1 := sort.Search(m, func(i int) bool { return a[i] >= 2 }) - 1
LABEL:
	for i := 0; i <= endIndex1; i++ {
		startIndexBi := sort.Search(m, func(j int) bool { return a[j] >= b[i] })
		endIndexBi := sort.Search(m, func(j int) bool { return a[j] > b[i] }) - 1
		for j := startIndexBi; j <= endIndexBi; j++ {
			if b[j] == n {
				ans = "POSSIBLE"
				break LABEL
			}
		}
	}
	fmt.Println(ans)
}

func next() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	i, err := strconv.Atoi(next())
	if err != nil {
		fmt.Println(err)
	}
	return i
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

int main() {
    int n;
    cin >> n;
    vector<pair<ll,ll>> p;
    rep(i,n) {
        ll x, y;
        cin >> x >> y;
        p.emplace_back(x-y, x+y);
    }
    sort(p.begin(), p.end());
    ll ans1 = p[n-1].first - p[0].first;
    vector<pair<ll,ll>> p2;
    rep(i,n) {
        p2.emplace_back(p[i].second, p[i].first);
    }
    sort(p2.begin(), p2.end());
    ll ans2 = p2[n-1].first - p2[0].first;
    ll ans = max(ans1, ans2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12444
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
long int sum[200020] = {};
int main() {
	vector<int> sum;
	int goukei = 0;
	for (int i = 0; i < 5; i++) {
		int a = 0;
		cin >> a;
		goukei = goukei + (a + 9) / 10 * 10;
		sum.push_back(a);
	}
	vector<int> s;
	for (int i = 0; i < 5; i++) {
		s.push_back(sum[i] % 10);
	}
	sort(s.begin(), s.end());
	for (int i = 0; i < 5; i++) {
		if (s[i] != 0) {
			cout << goukei - (10 - s[i]);
			break;
		}
		if (i == 4) {
			cout << goukei;
		}
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int dp[100001];
	int x;
	scanf("%d",&x);	
	dp[0]=1;	
	for(int i=100;i<=x;i++){
		if(dp[i-100] == 1 || dp[i-101]==1||dp[i-102]==1|| dp[i-103]==1||dp[i-104]==1||dp[i-105]==1)dp[i]=1;
		//else dp[i]=0;
	}
	if(dp[x]==1)printf("1\n");
	else printf("0\n");
	//printf("%d\n",dp[x]);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for (int i=0; i < (n); i++)
typedef double D;
typedef complex<D> P;
typedef vector<P> VP;
const D EPS = 1e-7;
#define X real()
#define Y imag()
 
#define EQ(n,m) (abs((n)-(m)) < EPS)
VP crosspointCC(P a, D ar, P b, D br) {
  VP ps;
  P ab = b-a;
  D d = abs(ab);
  D crL = (norm(ab) + ar*ar - br*br) / (2*d);
  if (EQ(d, 0) || ar < abs(crL)) return ps;
  
  P abN = ab * P(0, sqrt(ar*ar - crL*crL) / d);
  P cp = a + crL/d * ab;
  ps.push_back(cp + abN);
  if (!EQ(norm(abN), 0)) ps.push_back(cp - abN);
  return ps;
}
 
int n;
D x[11],y[11],z[11],a[11];
 
inline bool ch(double mid){
  VP v;
  rep(i,n){
    a[i] = sqrt(z[i]*z[i] - mid*mid);
    if(a[i]<0)return 0;
    v.push_back(P(x[i],y[i]));
  }
  rep(i,n)rep(j,n)if(i<j){
    VP p=crosspointCC(P(x[i],y[i]),a[i],P(x[j],y[j]),a[j]);
    rep(k,p.size()){
      v.push_back(p[k]);
    }
  }
  rep(i,v.size()){
    int flag=0;
    rep(j,n){
      D dist=sqrt((x[j]-v[i].X)*(x[j]-v[i].X)+(y[j]-v[i].Y)*(y[j]-v[i].Y));
      if(dist<=a[j]+EPS)flag++;
    }
    if(flag==n)return 1;
  }
  return 0;
}
 
signed main(){
  while(cin>>n,n){
    rep(i,n)cin>>x[i]>>y[i]>>z[i];
    D l=0,r=1e9;
    rep(o,100){
      D mid=(l+r)/2;
      if(!ch(mid))r=mid;
      else l=mid;
    }
    printf("%.9f\n",l);
  }
}


Measured memory_bytes: 3344
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
    #define pb push_back
    #define sz size()
     
    using namespace std;
    using ll = long long int;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
     
const int MOD = 1e9 + 7;
const ll ZER = 0;


int main(){
    string s;
    cin >> s;
    cout << s.substr(0, 4) << " " << s.substr(4, 8) << endl;
}



Measured memory_bytes: 3544
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]
E = [0] * 26
for i in range(D):
    ans = -1
    max_v = -float("inf")
    for j in range(26):
        tmp = S[i][j] - (C[j] * (i-E[j]))
        if tmp > max_v:
            ans = j + 1
            max_v = tmp
    E[ans-1] = i
    print(ans)

Measured memory_bytes: 9392
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <fstream> //ofstream
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int n,ans,ans2;

void solve(){
        ans=int(n/1.08);
        ans2=int(ans*1.08);
        rep(i,3){
                if(n==int((ans+ -1+i)*1.08)) {
                        cout<<ans+ -1+i<<endl;
                        return;
                }
        }
        cout<<":("<<endl;
}

int main(){
        cin>>n;

        solve();
        return 0;
}


Measured memory_bytes: 256
'use strict'
const main = (N,A) => {
    const result = A.reduce((x,i)  => {return x+=(1/i)},0)
    return 1/result
}
const input = require('fs').readFileSync('/dev/stdin','utf8').split("\n")
const N = Number(input[0])
const A = input[1].split(" ").map( x => Number(x))
console.log(main(N,A))

Measured memory_bytes: 21064
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<string>
#include<typeinfo>
#include<cassert>
#include<functional>
#include<algorithm>
#include<climits>
#include<map>

using namespace std;



int main(){


	string s;
	cin >> s;

	sort(s.begin(),s.end());
    
	string t;
	cin >> t;
	sort(t.begin(),t.end());
	reverse(t.begin(),t.end());
	
	if(s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	
   return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int fail = 0;
  int N = S.size();
  for (int i = 0; i < N; i++) {
    if (i % 2 != 0 && S.at(i) != 'L' && S.at(i) != 'U' && S.at(i) != 'D') {
      fail++;
    }
    else if (i % 2 == 0 && S.at(i) != 'R' && S.at(i) != 'U' && S.at(i) != 'D') {
      fail++;
    }
  }
  if (fail == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<numeric>
#include<algorithm>
#include<limits.h>
#include<utility>
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(i,n,a) for(int i=0;i<n;i++)cin >> a[i]
using namespace std;

int main(){
     int n,m;
     cin >> m >> n;
     vector<int> a;
     vector<int> b;
     lp(i,n){
     int temp;
     cin >> temp;
     a.push_back(temp);
     }
     sort(a.begin(),a.end());
     lp(i,n-1){
     int temp;
     temp = a[i+1] - a[i]; 
     b.push_back(abs(temp));
     }
     sort(b.begin(),b.end(),greater<int>());
   //  lp(i,n)cout << a[i]<<  " ";
   //  cout << endl;
   //  lp(i,n-1)cout << b[i] << " ";
int ans = 0;
for(int i=m-1;i<n-1;i++){
     ans += b[i];
}
cout << ans << endl;
     return 0;

}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std ;

int cnt,m,d;

int main(){

	
	cin>>m>>d;
	
	int i,j;
	
	for(i=2; i<=(d/10); i++){
		for(j =2; j<=9;j++){
			if(i*j<=m&&(10*i+j)<=d){
				cnt++;
				//cout<<i<<" "<<j<<" ";
			}
		}
	}
		
	
	cout<<cnt<<'\n';
	return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        
        if (n % 2 != 0) {
            System.out.println(0);
            return;
        }
        
        n /= 2;
        
        long count = 0;
        while (n != 0) {
            count += n / 5;
            n /= 5;
        }
        
        System.out.println(count);
    }
}


Measured memory_bytes: 23124
n = int(input())
for _ in range(n):
    a, b = input(), input()
    indices = []
    for cb in b:
        bgn_idx = 0
        for i, cur_idx in enumerate(indices):
            chr_idx = a.find(cb, bgn_idx) + 1
            if not chr_idx:
                break
            if chr_idx < cur_idx:
                indices[i] = chr_idx
            bgn_idx = cur_idx
        else:
            chr_idx = a.find(cb, bgn_idx) + 1
            if chr_idx:
                indices.append(chr_idx)
    print(len(indices))

Measured memory_bytes: 7648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, m;
  in2(n, m);
  ll a;
  a = 0;
  a += n * (n - 1) / 2;
  a += m * (m - 1) / 2;
  out(a);
  memi;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define MOD 1000000007;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(a%b == c){
		cout << "YES" << endl;
		return 0;
	}
	int p=a;
	while(true){
		p+=a;
		if(p%b == c){
			cout << "YES" << endl;
			return 0;
		}else if(p%b == a%b){
			cout << "NO" << endl;
			return 0;
		}
	}
}

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

const int MOD = 1000000007;
const int MAX_SIZE = 200001;

vector<ll> fac(MAX_SIZE);
vector<ll> fac_inv(MAX_SIZE);
vector<ll> inv(MAX_SIZE);

void init_com()
{
    fac.at(0) = fac.at(1) = 1;
    fac_inv.at(0) = fac_inv.at(1) = 1;
    inv.at(1) = 1;
    for (int i = 2; i < MAX_SIZE; i++)
    {
        fac.at(i) = fac.at(i - 1) * i % MOD;
        inv.at(i) = MOD - inv.at(MOD % i) * (MOD / i) % MOD;
        fac_inv.at(i) = fac_inv.at(i - 1) * inv.at(i) % MOD;
    }
}

ll com(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac.at(n) * (fac_inv.at(k) * fac_inv.at(n - k) % MOD) % MOD;
}

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

    init_com();

    if (k > n - 1)
        k = n - 1;

    ll res = 0;
    for (int z = 0; z <= k; z++)
    {
        res += com(n, z) * com(n - 1, z) % MOD;
        res %= MOD;
    }
    cout << res << endl;
}


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

template <typename Edge>
class graph {
    using graph_t = std::vector<std::vector<Edge>>;
public:
    using reference = std::vector<Edge>&;
    using const_reference = std::vector<Edge> const&;
    using iterator = typename graph_t::iterator;
    using const_iterator = typename graph_t::const_iterator;
    using reverse_iterator = typename graph_t::reverse_iterator;

    graph() : g() {}
    graph(int n) : g(n) {}

    reference operator[](int x) { return g[x]; }
    const_reference operator[](int x) const { return g[x]; }

    iterator begin() { return std::begin(g); }
    iterator end() { return std::end(g); }
    reverse_iterator rbegin() { return std::rbegin(g); }
    reverse_iterator rend() { return std::rend(g); }

    int size() const { return g.size(); }

    void add_node(std::vector<Edge> es) {
        g.push_back(std::move(es));
    }

    void add_edge(int node_idx, Edge e) {
        g[node_idx].push_back(std::move(e));
    }

private:
    std::vector<std::vector<Edge>> g;
};


class directed_edge {
public:
    directed_edge(int t) : to(t) {}

    int to;
};

class directed_graph : public graph<directed_edge> {
public:
    directed_graph(int n) : graph(n) {}

    using graph::add_edge;
    void add_edge(int from, int to) {
        add_edge(from, directed_edge{to});
    }
};

template <typename Cost>
class weighted_edge {
public:
    using cost_type = Cost;

    weighted_edge(int t, Cost c) : to(t), cost(c) {}

    int to;
    cost_type cost;
};

template <typename Cost>
class weighted_graph : public graph<weighted_edge<Cost>> {
    using base_t = graph<weighted_edge<Cost>>;
public:
    weighted_graph(int n) : base_t(n) {}

    using base_t::add_edge;
    void add_edge(int from, int to, Cost cost) {
        add_edge(from, weighted_edge<Cost>{to, cost});
    }
};

template <typename Edge, typename Cost = typename Edge::cost_type>
std::vector<Cost> spfa(graph<Edge> const& g, int s, Cost inf = std::numeric_limits<Cost>::max() / 2) {
    std::vector<Cost> d(g.size(), inf);
    std::vector<int> in_q(g.size()), count(g.size());
    std::queue<int> que;
    d[s] = Cost(0);
    in_q[s] = true;
    count[s] = 1;
    que.push(s);
    while(!que.empty()) {
        const int v = que.front();
        que.pop();
        in_q[v] = false;
        for(const auto& e : g[v]) {
            if(d[e.to] <= d[v] + e.cost) continue;
            d[e.to] = d[v] + e.cost;
            if(in_q[e.to]) continue;
            que.emplace(e.to);
            in_q[e.to] = true;
            if(++count[e.to] >= static_cast<int>(g.size())) {
                return std::vector<Cost>{};
            }
        }
    }
    return d;
}

using namespace std;

constexpr int INF = 1e9;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m, r; cin >> n >> m >> r;
    weighted_graph<int> g(n);
    for(int i = 0; i < m; ++i) {
        int s, t, d; cin >> s >> t >> d;
        g.add_edge(s, t, d);
    }
    auto ans = spfa(g, r, INF);
    for(int i = 0; i < n; ++i) {
        if(INF == ans[i]) {
            cout << "INF" << "\n";
        } else {
            cout << ans[i] << "\n";
        }
    }
}



Measured memory_bytes: 13184
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

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

    ll N;
    cin >> N;

    vector<ll> A(N);
    map<ll, ll> mp, ct;
    rep(i, N){
        cin >> A[i];
        ++mp[A[i]];
    }

    ll sum = 0;
    for(auto m : mp){
        ll k = m.first, v = m.second;
        ct[k] = v * (v - 1) / 2;
        sum += ct[k];
    }

    rep(i,N){
        ll now = A[i];
        print(sum - ct[now] + (mp[now] - 1) * (mp[now] - 2) / 2);
    }
    

    

    return 0;
}

Measured memory_bytes: 18944
#include <stdio.h>
int main (){
int n;
  scanf ("%d",&n);
if (n<2){
printf ("1");
}
  else if(n<4){
  printf ("2");
  }
  else if(n<8){
  printf ("4");
  }
  else if(n<16){
  printf ("8");
  }
  else if(n<32){
  printf ("16");
  }
  else if(n<64){
  printf ("32");
  }
  else if(n<110){
  printf ("64");
  }
return 0;
}

Measured memory_bytes: 128
//
//  main.cpp
//  sanpie
//
//  Created by h3037178 on 2017/07/28.
//  Copyright ?? 2017??´ ?????£?????????. All rights reserved.
//

#include <iostream>
using namespace std;
int main(){
    int i,o,s;
    for(i=1;i<=9;i++){
        for(o=1;o<=9;o++){
            s=i*o;
            cout<<i<<"x"<<o<<"="<<s<<endl;
        }
    }
}

Measured memory_bytes: 3044
#include <iostream>

using namespace std;

#define MAX 2000000
#define K 10001
int A[MAX];
int B[MAX];
int C[K];

void CountingSort(int A[], int B[], int n)
{
	for (int i = 0; i < K; ++i) C[i] = 0;

	// 在C[i]中记录A[i]元素出现的次数
	for (int i = 0; i < n; ++i) ++C[A[i]];

	// 在C[i]中记录小于等于A[i]元素出现的次数
	for (int i = 1; i < K; ++i) C[i] = C[i] + C[i - 1];

	int index = 0;
	for (int i = n - 1; i >= 0; --i)
	{
		index = C[A[i]] - 1;
		B[index] = A[i];
		--C[A[i]];
	}
}

int main()
{
	int n; cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> A[i];
		B[i] = A[i];
	}

	CountingSort(A, B, n);

	for (int i = 0; i < n; ++i)
		cout << B[i] << (i != n - 1 ? " " : "\n");
}


Measured memory_bytes: 18740
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
      	Integer[] array = new Integer[N];
      	for(int i=0;i<N;i++){
        	array[i] = sc.nextInt();
        }
      	Arrays.sort(array, Comparator.reverseOrder());
      	array[0] /= 2;
      	int sum = 0;
      	for(int i=0;i<N;i++){
        	sum += array[i];
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 23380
R, C, K = map(int, input().split())
# dp = [[[0] * 4 for _ in range(C + 1)]for _ in range(R + 1)]
dp2 = [[[0] * (C + 1) for _ in range(R + 1)]for _ in range(4)]

grid = [[0] * C for _ in range(R)]
for _ in range(K):
    r, c, v = map(int, input().split())
    grid[r - 1][c - 1] = v
for i in range(R):
    for j in range(C):
        for k in range(2, -1, -1):
            # chmax(dp[i][j][k + 1], dp[i][j][k] + grid[i][j])
            # dp[i][j][k + 1] = max(dp[i][j][k + 1], dp[i][j][k] + grid[i][j])
            dp2[k + 1][i][j] = max(dp2[k + 1][i][j], dp2[k][i][j] + grid[i][j])
        for k in range(4):
            # dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k])
            dp2[0][i + 1][j] = max(dp2[0][i + 1][j], dp2[k][i][j])
            # dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k])
            dp2[k][i][j + 1] = max(dp2[k][i][j + 1], dp2[k][i][j])
ans = 0
for k in range(4):
    # ans = max(ans, dp[R - 1][C - 1][k])
    ans = max(ans, dp2[k][R - 1][C - 1])
print(ans)

# print(dp[R - 1][C - 1][3])


Measured memory_bytes: 430552
// ================
// Himanshu Lal
// MNIT Jaipur
// ================
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define TEZ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rf(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define INF 1e18
#define vi vector<pair<ll,ll>>
#define ff first
#define ss second
#define mp map<ll,ll>
#define test ll tp; cin>>tp; while(tp--)
#define srt(v) sort(v.begin(),v.end())
double pi=acos(-1);
void OJ(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
}
int main(){
    TEZ;
    ll n;
    cin>>n;
    vector<ll> v(n);
    mp m,m1;
    ll s=0;
    f(i,0,n){
        cin>>v[i];
        m[v[i]]++;
        s+=v[i];
    }
    test{
        ll a,b;
        cin>>a>>b;
        if(m[a]){
            s-=(a*m[a]);
            // if(m[b]){
            m[b]+=m[a];
            // }
            s+=(b*m[a]);
            m[a]=0;
        }
        cout<<s<<endl;
    }
}

Measured memory_bytes: 9700
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int h = stdIn.nextInt(); //縦
		int w = stdIn.nextInt(); //横
		String[] pic = new String[2*h];
		
		for(int i = 0; i < h; i++) {
			pic[i] = stdIn.next();
		}
		
		
		for(int i = 0; i < h; i++) {
			System.out.println(pic[i]);
			System.out.println(pic[i]);
		}
	}

}


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

public class Hello
{
    public static int A, B, C;
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var k = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        A = int.Parse(line[0]);
        B = int.Parse(line[1]);
        C = int.Parse(line[2]);
        var s = Console.ReadLine().Trim();
        var ans = 0;
        for (int i = 0; i < k; i++)
        {
            var ww = getAns(n, k, s, i);
            ans += ww;
        }
        Console.WriteLine(ans);
    }
    static int getAns(int n, int k, string s, int t)
    {
        var ans = 0;
        var w = t;
        var a = new List<char>();
        while (w < n)
        {
            if (s[w] == 'r') a.Add('g');
            else if (s[w] == 's') a.Add('c');
            else a.Add('p');
            w += k;
        }
        var amax = a.Count();
        var p = 0;
        var pre = 'x';
        while (p < amax)
        {
            var my = getWin(a[p]);
            if (my != pre) ans += getPoint(a[p]);
            else
            {
                if (p + 1 < amax)
                {
                    var nextmy = getWin(a[p + 1]);
                    my = getOther(my, nextmy);
                }
                else my = getOther2(my);
            }
            pre = my;
            p++;
        }
        return ans;
    }
    static char getOther2(char a)
    {
        if (a == 'g') return 'c';
        if (a == 'c') return 'p';
        return 'g';
    }
    static char getOther(char a, char b)
    {
        var t = new char[2];
        t[0] = a; t[1] = b;
        Array.Sort(t);
        if (t[0] == 'c' && t[1] == 'g') return 'p';
        if (t[0] == 'c' && t[1] == 'p') return 'g';
        if (t[0] == 'g' && t[1] == 'p') return 'c';
        if (t[0] == 'g' && t[1] == 'g') return 'c';
        if (t[0] == 'c' && t[1] == 'c') return 'p';
        return 'g';
    }
    static int getPoint(char a)
    {
        if (a == 'g') return C;
        if (a == 'c') return A;
        return B;
    }
    static char getWin(char a)
    {
        if (a == 'g') return 'p';
        if (a == 'c') return 'g';
        return 'c';
    }
}

Measured memory_bytes: 17340
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n,t,s,v; cin>>n>>t;
    vector<vector<int>> dpl(n,vector<int>(3001,0)),dpr(n,vector<int>(3001,0));
    vector<pp> g(n);
    rep(i,n){
        int a,b; cin>>a>>b;
        g[i]=mk(a,b);
    }
    for(int i=1;i<=n-1;i++){
        tie(s,v)=g[i-1];
        rep(j,3001){
            dpl[i][j]=dpl[i-1][j];
            if(j>=s){
                if(dpl[i][j]<dpl[i-1][j-s]+v)
                dpl[i][j]=dpl[i-1][j-s]+v;
            }
        }
    }
    for(int i=1;i<=n-1;i++){
        tie(s,v)=g[n-i];
        rep(j,3001){
            dpr[i][j]=dpr[i-1][j];
            if(j>=s){
                if(dpr[i][j]<dpr[i-1][j-s]+v)
                dpr[i][j]=dpr[i-1][j-s]+v;
            }
        }
    }
    int ans=0,cnt;
    rep(i,n){
        rep(j,t){
            cnt=g[i].second+dpl[i][j]+dpr[n-1-i][t-1-j];
            ans=max(ans,cnt);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 70784
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {

	int N;
	cin >> N;

	vector<int> num;
	num.clear();
	int p;
	for (int i = 1; i <= N; i++) {
		cin >> p;
		if (p != i) {
			num.push_back(i);
		}
	}

	if (2 == num.size() || 0 == num.size()) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
;; F - Silver Fox vs Monster

(defun solve (d a xh)
  (loop
    with accum = 0  ; 破壊済みの体力
    with head = xh  ; 尺取法の区間の先頭
    for pair in xh  ; 最左モンスターのX座標と体力
     do (loop while (< (caar head) (- (car pair) d d))
           do (decf accum (* a (ceiling (cdar head) a)))
              (setf head (cdr head)))
        (decf (cdr pair) (min accum (cdr pair)))
        (incf accum (* a (ceiling (cdr pair) a)))
    sum (ceiling (cdr pair) a)))

(let* ((n (read))
       (d (read))
       (a (read))
       (xh (loop repeat n collect (cons (read) (read)))))
  (setf xh (sort xh #'< :key #'car))
  (princ (solve d a xh)))


Measured memory_bytes: 65928
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <list>
#include <cmath>
#include <stack>
#include <queue>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

int main()
{
	int n;
	cin >> n;
	int d[100];
	for (int i = 0; i < n; i++)
	{
		cin >> d[i];
	}
	long long  sum = 0;
	for (int i = 0; i < n - 1; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			sum += (long long)d[i] * d[j];
		}
	}
	cout << sum;
}


Measured memory_bytes: 31488
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;
int N;
int A[200003];

ll solve(int b){
  ll sum = 0;
  REP(i,N){
    sum += abs(A[i] - b);
  }
  return sum;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  REP(i,N){
    cin >> A[i];
    A[i] -= i + 1;
  }
  sort(A, A + N);
  cout << solve(A[N/2]) << endl;
  return 0;
}


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

int main(){
	int a,b;
	char op;
	while(1){
		cin>>a>>op>>b;
		if(op=='?') break;
		switch (op){
			case '+':cout<<a+b<<endl; break;
			case '-':cout<<a-b<<endl; break;
			case '*':cout<<a*b<<endl; break;
			case '/':cout<<a/b<<endl; break;
		}
	}
	return 0;
}	

Measured memory_bytes: 1160
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2019-12-29 23:28:41
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;
template<class T> ostream& operator<<(ostream& os, vector<T>& _) { os << '{'; for (T& x : _) { os << x; if (&x != &_.back()) os << ','; } os << '}'; return os; }
template<class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

#ifdef LOCAL
#define debug(_) cerr << #_ << ": " << (_) << '\n'
#else
#define debug(_) 1728
#endif

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

  string s, t; cin >> s >> t;
  cout << t << s << endl;

  return 0;
}

Measured memory_bytes: 384
package main

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

var sc *bufio.Scanner

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

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

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 0), 1000000001*3)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	lArray := make([]int, n)
	for i := range lArray {
		lArray[i] = nextInt()
	}
	sort.Sort(sort.IntSlice(lArray))

	ans := 0
	for i := 0; i < n-2; i++ {
		for j := i + 1; j < n-1; j++ {
			kLeft := sort.SearchInts(lArray[j+1:], lArray[j]-lArray[i])
			kRight := sort.SearchInts(lArray[j+1:], lArray[j]+lArray[i])
			ans += kRight - kLeft
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640