akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int c[3][3];
    REP(i,0,3) REP(j,0,3) cin >> c[i][j];
    REP(i,0,2) REP(j,0,2) {
        if (c[0+i][0+j] + c[1+i][1+j] != c[1+i][0+j] + c[0+i][1+j]) {
            //cerr << i << " " << j << endl;
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

int main() {
    solve();
    
    return 0;
}


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

void solve() {

   ll x, k, d;
   cin >> x >> k >> d;
   x = abs(x);

   if (k >= x / d) {
      ll r = x % d, p = (k - x / d) & 1;
      if (p == 1) {
         cout << d - r << '\n';
      } else {
         cout << r << '\n';
      }
   } else {
      cout << x - k * d << '\n';
   }

}

int main() {
#ifndef ONLINE_JUDGE
   freopen("inp.txt", "r", stdin);      freopen("outp.txt", "w", stdout);
#endif
   ios::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);

   solve();

   return 0;
}


Measured memory_bytes: 3684
#include<bits/stdc++.h>
#include<vector>
#include<set>
#include<algorithm>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define T int t, q=0; scanf("%d", &t); while(q++<t)
#define ll long long
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll x,y,z,a=0,b=0,c=0,d=0,sum,ans,total,cnt,n,m,k,p,kase,i;
string s1,s2;
#define N 100001
#define MX 1000000001
vector <ll> v;
map<ll,ll> mp;
set<ll> s;
map<ll,ll> :: iterator itr1, ptr1;
set<ll> :: iterator itr, ptr;


int main()
{

    cin>>x;
   n=x/500;
   sum=n*1000;

   n=x-(n*500);
   n=n/5;
   n*=5;
   sum+=n;
   cout<<sum;




    return 0;
}
// Happy Coding  (:


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

using namespace std;

int Dx[4] = {0, 1, 0, -1};
int Dy[4] = {1, 0, -1, 0};

int dhx[4][4] = {
	{0, 1, 1, 1},
	{1, 1, 0, -1},
	{0, -1, -1, -1},
	{-1, -1, 0, 1},
};
int dhy[4][4] = {
	{1, 1, 0, -1},
	{0, -1, -1, -1},
	{-1, -1, 0, 1},
	{0, 1, 1, 1},
};

struct Node {
	int x, y, hx, hy, dir;
};

int H, W;
int wall[60][60] = {0};
bool used[60][60] = {0};
bool reach[60][60][60][60][4] = {0};
bool inRange(int x, int y) {
	return 0 <= x && x < W && 0 <= y && y < H;
}
bool inRange2(int x, int y) {
	return -1 <= x && x <= W && -1 <= y && y <= H;
}
bool Wall(int x, int y) {
	if (inRange(x, y)) return wall[y][x];
	return true;
}
bool isInvalidHand(int px, int py, int hx, int hy, int dir) {
//	cout << ":" << px << " " << py << " " << hx << " " << hy << endl;
	if (!Wall(hx, hy)) return true;
	for (int i = 0; i < 4; ++i) {
		int x = px + dhx[dir][i];
		int y = py + dhy[dir][i];
		if (inRange2(x, y) && hx == x && hy == y) {
			return false;
		}
	}
	return true;
}

int main() {
	cin >> H >> W;

	for (int i = 0; i < 4; ++i) {
		Dy[i] = -Dy[i];
		for (int j = 0; j < 4; ++j) {
			dhy[i][j] = -dhy[i][j];
		}
	}

	int sx = -1, sy = -1, sd = -1;
	int gx = -1, gy = -1;
	for (int y = 0; y < H; ++y) {
		string str; cin >> str;
		for (int x = 0; x < W; ++x) {
			switch (str[x]) {
			case '#': wall[y][x] = true; break;
			case 'G': gx = x, gy = y; break;
			case '^': sx = x, sy = y; sd = 0; break;
			case '>': sx = x, sy = y; sd = 1; break;
			case 'v': sx = x, sy = y; sd = 2; break;
			case '<': sx = x, sy = y; sd = 3; break;
			}
		}
	}
	int ans = -1;
	queue<Node> Q;
//	fill(used[0], used[50], false);
//	fill(reach[0][0][0][0], reach[49][49][50][51], false);
	Q.push((Node){sx, sy, sx + Dx[(sd+1)%4], sy + Dy[(sd+1)%4], sd});
	while ( !Q.empty() ) {
		Node node = Q.front(); Q.pop();
		int px = node.x, py = node.y, hx = node.hx, hy = node.hy, dir = node.dir;
		if ( !inRange(px, py) ) continue;
		if ( wall[py][px] ) continue;
		if ( !inRange2(hx, hy) ) continue;
		if ( reach[py][px][hy+1][hx+1][dir] ) continue;
		if ( isInvalidHand(px, py, hx, hy, dir) ) continue;
		reach[py][px][hy+1][hx+1][dir] = true;
		used[py][px] = true;
		if (px == gx && py == gy) {
			break;
		}
//			cout << px << " " << py << " " << hx << " " << hy << " " << dir << endl;

		// move player
		{
			int npx = px + Dx[dir];
			int npy = py + Dy[dir];
			Q.push((Node){npx, npy, hx, hy, dir});
		}

		// move hand
		for (int dx = -1; dx <= 1; ++dx) for (int dy = -1; dy <= 1; ++dy) {
			int nhx = hx + dx;
			int nhy = hy + dy;
			if ( inRange2(nhx, nhy) && Wall(hx, hy) ) {
				Q.push((Node){px, py, nhx, nhy, dir});
			}
		}

		// change dir / turn
		Q.push((Node){px, py, hx, hy, (dir+1)%4});
		Q.push((Node){px, py, hx, hy, (dir-1+4)%4});
	}
	int s = 0;
	for (int y = 0; y < H; ++y) {
		for (int x = 0; x < W; ++x) {
			s += used[y][x];
		}
	}
	if (used[gy][gx] && (ans < 0 || s < ans)) {
		ans = s;
	}
	cout << ans << endl;
}

Measured memory_bytes: 42560
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            double x = sc.nextDouble();
            double y = sc.nextDouble();
            if (Math.sqrt(x * x + y * y) <= d) {
                cnt++;
            }
        }
        System.out.println(cnt);
    }

}


Measured memory_bytes: 65056
import sys
readline = sys.stdin.readline

L = list(map(int, readline().strip()))
LN = len(L)
K = int(readline())

dpp = [0]*(K+1)
dpp[1] = 1
dpn = [0]*(K+1)
dpn[0] = 1
dpn[1] = L[0]-1
for l in L[1:]:
    dpp2 = [0]*(K+1)
    dpn2 = dpn[:]
    for i in range(1, K+1):
        dpn2[i] += 9*dpn[i-1]
        if l:
            dpn2[i] += (l-1)*dpp[i-1] + dpp[i]
    if not l:
        dpp2 = dpp[:]
    else:
        for i in range(1, K+1):
            dpp2[i] = dpp[i-1]
    dpp = dpp2[:]
    dpn = dpn2[:]

print(dpp[K] + dpn[K])

Measured memory_bytes: 38384
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = Array(N, {i -> readLine()!!.toInt()})

    tailrec fun next(n: Int, count: Int): Int =
        if (n==2) count
        else if (count >= 1e5+10) -1
        else next(A[n-1], count+1)

    println(next(1, 0))
}

Measured memory_bytes: 37608
package main

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcdInt64(m, n int64) int64 {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcmInt64(m, n int64) int64 {
	return m / gcdInt64(m, n) * n
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

const mod int = 1e9 + 7

func main() {
	s := readString()
	n := len(s)

	dp := make([][]int, n+1)
	for i := range dp {
		dp[i] = make([]int, 13)
	}
	dp[0][0] = 1

	for i := 1; i < n+1; i++ {
		c := s[i-1 : i]
		cnum, _ := strconv.Atoi(c)
		for j := 0; j < 10; j++ {
			if c != "?" && j != cnum {
				continue
			}
			for k := 0; k < 13; k++ {
				dp[i][(k*10+j)%13] = (dp[i][(k*10+j)%13] + dp[i-1][k]) % mod
			}
		}
	}

	fmt.Println(dp[n][5])
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	string s;
	t = 1;
	while(t--) {
	 cin >> s;
	 if(s[0] == '1')
	  s[0] = '9';
     else
      s[0] = '1';
     if(s[1] == '1')
	  s[1] = '9';
     else
      s[1] = '1';
     if(s[2] == '1')
	  s[2] = '9';
     else
      s[2] = '1';
	 cout << s << endl;
	}
	return 0;
}



Measured memory_bytes: 256
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));   
   let color = xs.sort((a, b) => b - a);
   //console.log(color);
   let count = 0;
   for(let i =0; i < xs.length; i++){
      if(color[i]!=color[i+1]){
        count++;
      }
   }
   console.log(count);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
#!/usr/bin/env ruby

require 'prime'
require 'prime'

N = gets.chomp.to_i
A = gets.chomp.split.map(&:to_i).sort

dp = Hash.new(true)

A.each do |a|
  m = 2
  next unless dp[a]

  loop do
    b = a * m
    break if b > A[-1]
    dp[b] = false
    m += 1
  end
end

hash = A.tally.reject {|_, c| c > 1 }

puts hash.count { |a, _| dp[a] }


Measured memory_bytes: 74428
#include <cstdio>
#include <cstring>

const int MaxN = 100;

int N;
char S[MaxN + 5];

inline bool p(int l, int r) {
  for (int i = 0; i <= r - l; ++i)
    if (S[l + i] != S[r - i]) return false;
  return true;
}

int main() {
  scanf("%s", S + 1);
  N = strlen(S + 1);
  if (p(1, N) == true && p(1, (N - 1) / 2) == true) puts("Yes");
  else puts("No");
  return 0;
}

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

int main() {
    int n, q;
    ll k;
    cin >> n >> k >> q;
    ll p[n] = {};
    rep(i, q){
        int a;
        cin >> a;
        ++p[a - 1];
    }
    rep(i, n){
        if(p[i] + k > q) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

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

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

  int n; cin >> n;
  vector<int> s(n);
  int sum = 0;
  rep(i, n) {
    cin >> s[i];
    sum += s[i];
  }
  sort(s.begin(), s.end());

  int ans;
  if(sum%10 != 0) ans = sum;
  else {
    bool flag = false;
    rep(i, n) {
      if(s[i]%10 != 0) {
        ans = sum-s[i];
        flag = true;
        break;
      }
    }
    if(!flag) ans = 0;
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args) throws IOException {
        FastReader scan = new FastReader();
        //PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("taming.out")));
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        Task solver = new Task();
        //int t = scan.nextInt();
        int t = 1;
        for(int i = 1; i <= t; i++) solver.solve(i, scan, out);
        out.close();
    }
    static class Task {
        public void solve(int testNumber, FastReader sc, PrintWriter pw) {
        	long a = sc.nextLong();
        	long b = sc.nextLong();
        	long sum = (a/2)*2*(b/2);
        	if(a==1||b==1){
        		pw.println(1);return;
        	}
        	if(a%2==1){
        		sum+=(b+1)/2;
        	}
        	if(b%2==1){
        		sum+=(a+1)/2;
        	}
        	if(b%2==1&&a%2==1)sum--;
        	pw.println(sum);
        }

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

        @Override
        public int compareTo( tup o2) {
            return o2.b!=b?Integer.compare(o2.b,b):Integer.compare(o2.a,a);
        }
    }
    static void shuffle(long[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            long temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }
    static void shuffle(int[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(new File(s)));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

Measured memory_bytes: 21332
#include <stdlib.h>
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){
    int H, W;

    cin >> H >> W;
    string S[H];

    for(int i=0;i<H;i++){
        cin >> S[i];
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            int count = 0;
            for(int ii=max(0, i-1);ii<min(i+2, H);ii++){
                for(int jj=max(0, j-1);jj<min(j+2, W);jj++){
                    if(S[ii][jj]=='#'){
                        if(!(i==ii and j==jj)){
                            count++;
                        }
                    }
                }
            }
            if(S[i][j]=='.'){
                S[i][j] = count + '0';
            }
        }
    }
    for(int i=0;i<H;i++){
        cout << S[i] << endl;
    }
    return 0;
}

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

using namespace std;


int main()
{
    std::ios_base::sync_with_stdio(false);

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

   int a;
   cin>>a;

   cout<<(a+a*a+a*a*a);

    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
const int INF = 1e9;
#define MAX 100
int main(void) {
	string s, t = "";
	cin >> s;
	for (int i = 0; i < s.length(); ++i) {
		if (s[i] == '0') t += "0";
		else if (s[i] == '1') t += "1";
		else t = t.substr(0, t.length() - 1);
	}
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
void call2(int n)
{
	int i = 1;
	while(i <= n)
	{
		int x = i;
		if (x % 3 == 0)
		{
			cout << " " << i;
			i++;
			continue;
		}
		while (x)
		{


			
			if (x % 10 == 3)
			{
				cout << " " << i;
				break;
			}
			x /= 10;

		}
		i++;
	}
	cout << endl;
}
int main()
{
	int n;
	cin >> n;
	call2(n);
	return 0;
}


Measured memory_bytes: 3112
#include <iostream>

using namespace std;
int table[246920];
int main(){
  int n,ans;
  table[0]=table[1]=1;
  int i,j;
  for(i=2;i*i<246920;i++){
    for(j=i*i;j<246920;j+=i)table[j]=1;
  }

  while(1){
    ans=0;
    cin >> n;
    if(n==0)break;
    for(i=n+1;i<=2*n;i++)if(table[i]==0)ans++;
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 4032
#include <iostream>
#include <cstdlib>
#include <algorithm>

const long M = 1000000007;

int pow_mod(int x, long expo) {
	long c = 1;
	for (int i = 0; i < expo; i++) {
		c = (c * x) % M;
	}

	return c;
}


int main() {
	long n;
	long long all, exclude, ans;

	std::cin >> n;
	all = pow_mod(10, n) % M;
	exclude = (((2 * (pow_mod(9, n) % M)) % M) - (pow_mod(8, n) % M)) % M;
	ans = (all - exclude) % M;
	ans = (ans + M) % M;

	std::cout << ans << "\n";

	return 0;
}

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

int size;

vector<vector<int> > edge;
vector<int> dim;

void dfs(int depth, int* parent){
	/*
	printf("depth %d\n", depth);
	for(int i = 0; i < depth; i++){
		printf("(%d, %d, %d)", parent[i], dim[parent[i]], edge[parent[i]].size());
	}
	cout << endl;
	*/
	int val;
	cin >> val;
	if(val == 0){
		return;
	}else if(val > 0){
		int idx = dim.size();
		dim.push_back(val);
		edge.push_back(vector<int>());
		if(depth){
			edge[idx].push_back(parent[depth- 1]);
			edge[parent[depth - 1]].push_back(idx);
		}
		parent[depth] = idx;
		while(edge[idx].size() < val){
			dfs(depth + 1, parent);
		}
		
	}else{
		int ci = parent[depth - 1];
		int ti = parent[depth - 1 + val];
		edge[ci].push_back(ti);
		edge[ti].push_back(ci);
	}
}

int main(){
	int N;
	cin >> N;
	while(N--){
		dim.clear();
		edge.clear();
		int parent[200];
		dfs(0, parent);
		int val;
		cin >> val;
		for(int i = 0; i < dim.size(); i++){
			cout << (i + 1) ;
			sort(edge[i].begin(), edge[i].end());
			for(auto v : edge[i]) cout << " " << (v + 1);
			cout << endl;
		}
	}
}

Measured memory_bytes: 3120
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(true){
			int n=sc.nextInt();
			if(n==0){
				break;
			}
			int[] a=new int[n];
			for(int i=0;i<n;i++){
				a[i]=sc.nextInt();
			}
			Arrays.sort(a);
			long sum=0;
			long add=0;
			for(int i=1;i<n;i++){
				add+=a[i-1];
				sum+=add;
			}
			System.out.println(sum);
		}
	}
}

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

int N, K;
std::vector<int> l;

int main(void){
    std::cin >> N >> K;
    l.resize(N);
    for(int i=0; i<N; ++i){
        std::cin >> l[i];
    }

    std::sort(l.begin(), l.end());
    int ans = 0;
    for(int i=0; i<K; ++i){
        ans += l[N-1-i];
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using v  = vector<int>;
using vv = vector<v>;
const int MOD = 1000000007;

ll power[20000001];
ll fac[20000001];
ll inv[20000001];
ll fnv[20000001];

void pow_init(){
    power[0] = 1;
    rep(i,2000000){
        power[i+1] = power[i]*25;
        power[i+1] %= MOD;
    }
    return;
}

void com_init(){
    
    fac[0]=1LL;
    fac[1]=1LL;
    inv[0]=0LL;
    inv[1]=1LL;
    fnv[0]=1LL;
    fnv[1]=1LL;
    
    for(int i=2; i<2000001; i++){
        fac[i] = fac[i-1]*i % MOD;
        inv[i] = MOD - (MOD/i) * inv[MOD%i] % MOD;
        fnv[i] = fnv[i-1] * inv[i] % MOD;
    }
    return;
}

ll combi(int n, int k){
    if(n<k)return 0LL;
    if(k<0 || n<0 )return 0LL;
    
    return fac[n] * (fnv[k]*fnv[n-k] % MOD) % MOD;
}

ll modpow(ll a, ll n, ll mod = MOD) {
    ll rtn = 1;
    while (n > 0) {
        if (n & 1) rtn = rtn * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return rtn;
}


int main(){
    pow_init();
    com_init();
    
    int k;string s;
    cin>>k>>s;
    
    int len = k+s.size();
    
    ll ans = modpow(26,len, MOD);
    
    for(int i=0; i<s.size(); i++){
        ll buff = combi(len, i)*power[len-i]%MOD;
        ans = (ans + MOD - buff)%MOD;
    }
    
    cout<< ans <<endl;
    
    return 0;
}

Measured memory_bytes: 67852
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define loop(i,a,B) for (int i = a; i B; i++)
#define loopR(i,a,B) for (int i = a; i B; i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define cauto const auto
#ifdef LOCAL
#define dump(...) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", my_dmp(#__VA_ARGS__, __VA_ARGS__)
void my_dmp(const char*) { cerr << endl; }
template <class T, class... U>
void my_dmp(const char *s, T const& x, U const& ...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o,o+3,*s)) i++; if (count(e,e+3,*s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; my_dmp(s, y...); }
#else
#define dump(...)
#endif
using ll = long long;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, vector<T>, greater<T> >;
#define OUTPUT(...) ostream& operator<<(ostream& os, __VA_ARGS__ const& v) { os << "{"; for (auto const& x : v) os << " " << x; return os << " }"; }
template <class T> OUTPUT(vector<T>)
template <class T> OUTPUT(deque<T>)
template <class T> OUTPUT(set<T>)
template <class T> OUTPUT(multiset<T>)
template <class T, class U> OUTPUT(map<T,U>)
#undef OUTPUT
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S>& p) { return is >> p.first >> p.second; }
struct my_Init { my_Init() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } my_init;

template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
template <class It> auto sumof(It b, It e) { return accumulate(b,e,typename iterator_traits<It>::value_type{}); }
////////////////////////////////

int32_t main() {
    int a,b; cin >> a >> b;
    cout << max(0LL,a-2*b) << "\n";
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll A, B, C;
	cin >> A >> B >> C;

	if(A==B) cout << C << endl;
	if(A==C) cout << B << endl;
	if(C==B) cout << A << endl;
	return 0;
}

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

int main() {
    int A, B, K;
    cin >> A >> B >> K;

    int leftMax = A + K - 1;
    int rightMin = B - K + 1;
    vector<int> tmp;
    for (int i = A; i <= B; i++) {
        if(i <= leftMax || rightMin<= i) tmp.push_back(i);
    }

    for(int ans : tmp) {
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3556
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll n,r; cin >> n >> r;
	ll ans = r + max(0LL,(10-n)*100);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
long long gcd(long long a,long long b){
  if(b==0) return a;
  gcd(b,(a%b));
}

int main() {
  long long i,j,res;
  while(std::cin>>i>>j) {
    res=gcd(i,j);
    std::cout<<res<<" "<<(i*j)/res<<"\n";
  }
}

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

int main() {
  int N, devider = 0;
  cin >> N;
  for (int n = N; n != 0; n /= 10) {
    devider += n % 10;
  }

  if (N % devider == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,m,l;
    long long A[100][100],B[100][100],C[100][100];
    cin>>n>>m>>l;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>A[i][j];
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            cin>>B[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            C[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            for(int k=0;k<m;k++){
                C[i][j]+=A[i][k]*B[k][j];
            }
        }
        
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            if(j>0) cout<<" "<<C[i][j];
            else{
                cout<<C[i][j];
            }
        }cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3344
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int A, B, C, D;
	std::cin >> A >> B >> C >> D;
	int first = std::max(A, C);
	int last = std::min(B, D);
	if (first > last)
		std::cout << "0\n";
	else
		std::cout << (last - first) << "\n";
}


Measured memory_bytes: 256
num = int(input())
tmp = input().split()
tmp = [int(i) for i in tmp]
flg = 0

ans = abs(tmp[0] - sum(tmp[1:]))
for i in range(1,num):
  if abs(sum(tmp[:i]) - sum(tmp[i:])) > ans:
    print(ans)
    flg = 1
    break
  else:
    ans = abs(sum(tmp[:i]) - sum(tmp[i:]))

if flg == 0: print(ans)

Measured memory_bytes: 3064
h, w = map(int, input().split())
d = []
for i in range(10):
    d.append(list(map(int, input().split())))
for k in range(10):
    for i in range(10):
        for j in range(10):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])
rslt = 0
for i in range(h):
    for j in map(int, input().split()):
        if j != -1:
            rslt += d[j][1]
print(rslt)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
int n;

int main(){
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  sort(a,a+n);
  for(int i=1;i<n;i++){
    if(a[i-1]==a[i]) {
      cout << "NO" <<endl;
      break;
    }
    if(n==i+1) cout << "YES" <<endl;
  } 
  return 0;
}

Measured memory_bytes: 1024
n, k=map(int, input().split())
a=list(map(int, input().split()))

right=max(a)
left=0
def logs(a, n, x):
    sm=0
    for i in range(n):
        sm+=(a[i]-1)//x
    if sm<=k:
        return True
    else:
        return False

def binary_search(left, right):
    while right - left > 1:
        center=(left+right)//2
        if logs(a, n, center):
            right=center
        else:
            left=center
    
    return right
        
print(binary_search(left, right))

Measured memory_bytes: 30708
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();

		int[] hj = {-1,-1,-1,0,0,1,1,1};
		int[] wi = {-1,0,1,-1,1,-1,0,1};


		int[][] map= new int[H][W];

		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				map[i][j] = 0;
			}
		}


		for(int i = 0; i < H; i++) {
			String input = sc.next();
			for(int j = 0; j < W; j++) {
				char s = input.charAt(j);
				if(s == '#') {
					map[i][j] = -1;
					for(int k = 0; k < hj.length; k++) {
						map = setmap(i + wi[k], j + hj[k], map);
					}
				}
			}
		}

		for (int[] is : map) {
			for (int i : is) {
				if(i == -1) {
					System.out.print("#");
				} else {
					System.out.print(i);
				}

			}
			System.out.println();
		}
	}

	static int[][] setmap(int i, int j, int[][] map){

		try {
			if(map[i][j] != -1) {
				map[i][j] += 1;
			}

		} catch (Exception e) {

		}
		return map;

	}
}

Measured memory_bytes: 24276
#include <sstream>
#include <fstream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <string>
#include <queue>
#include <bitset>
using namespace std;

#define int long long
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; --i)
#define REP(i, a) for (int i = 0, _a = (a); i < _a; ++i)
#define REPD(i,n) for(int i = (n)-1; i >= 0; --i)

#define DEBUG(X) { cerr << #X << " = " << (X) << endl; }
#define PR(A, n) { cerr << #A << " = "; FOR(_, 1, n) cerr << A[_] << ' '; cerr << endl; }
#define PR0(A, n) { cerr << #A << " = "; REP(_, n) cerr << A[_] << ' '; cerr << endl; }

#define sqr(x) ((x) * (x))
#define ll long long
#define double long double
typedef pair<int, int> II;
#define PI (2 * acos((double)0))
#define __builtin_popcount __builtin_popcountll
#define SZ(x) ((int)(x).size())
#define ALL(a) (a).begin(), (a).end()
#define MS(a,x) memset(a, x, sizeof(a))
#define next ackjalscjaowjico
#define prev ajcsoua0wucckjsl
#define y1 alkscj9u20cjeijc
#define left lajcljascjljl
#define right aucouasocjolkjl
#define y0 u9cqu3jioajc

#define TWO(X) (1LL<<(X))
#define CONTAIN(S,X) ((S) & TWO(X))

double safe_sqrt(double x) { return sqrt(max((double)0.0, x)); }
int GI(int& x) { return scanf("%lld", &x); }

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout << (fixed) << setprecision(9);
    int x;
    while (cin >> x) {
        int n = 0, sum = 0;
        while (sum < x) {
            ++n;
            sum += n;
        }
        cout << n << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int m, n, s;
    int i;
    
    while (scanf("%d", &m) && m){
        
        s = 0;
        for(i = 0; i < m * (m - 1) / 2; i++){
            scanf("%d", &n);
            s += n;
        }
        printf("%d\n", s / (m - 1));
    }
    
    return (0);
}

Measured memory_bytes: 0
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
d = [0]*n
e = 0
t = 0
for i in range(n):
    d[i] = a[i] - b[i]
    if d[i] < 0:
        e += 1
        t -= d[i]
d = sorted(d,reverse=True)
if sum(d) < 0:
    ans = -1
else:
    s = 0
    for i in range(n):
        if s >= t:
            break
        else:
            s += d[i]
    ans = i + e
print(ans)

Measured memory_bytes: 24144
#define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

int main() {
	for (int n; cin >> n;) {
		int M, m, R;
		cin >> R; m = R;
		cin >> R; M = R - m; m = min(R, m);
		for (int j = 2; j < n; j++) {
			scanf("%d", &R);
			M = max(R - m, M);
			m = min(R, m);
		}
		cout << M << endl;
	}
	return 0;
}

Measured memory_bytes: 1244
#include <stdio.h>
int main (){
int i,a,b,k[101]={0},max=0,sum=0;
scanf ("%d",&a);
for (i=0;i<a;i++){
	scanf ("%d",&k[i]);
	if (max<k[i]){
	max=k[i];
	b=i;
		}
	}
	for (i=0;i<a;i++){
	if (i==b){
	sum=sum+(k[i]/2);
		}
		else
		{	
		sum=sum+k[i];
		}
		}
		printf ("%d",sum);
	return 0;
	}

Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn solve(n: i32) -> String {
    for i in 1..10 {
        for j in 1..10 {
            if i * j == n {
                return String::from("Yes");
            }
        }
    }
    String::from("No")
}

fn main() {
    input! {
        n: i32,
    }
    println!("{}", solve(n));
}


Measured memory_bytes: 2132
#![allow(unused_imports)]

use std::{i32, i64, u32, u64, usize, f64};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};
use maplit::*;
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

#[proconio::fastout]
fn main() {
    proconio::input!(
        n: usize,
        ab: [(i64, i64); n],
    );
    let mut ans = 0;
    for (a, b) in ab.iter().copied().rev() { ans += b * ((a + ans + b - 1) / b) - a - ans; }
    println!("{}", ans);
}


Measured memory_bytes: 5620
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX

#include <bits/stdc++.h>
#define db(x) cout << (x) << '\n';
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pii;
typedef pair<double,ll> pdi;
typedef pair<ld,ld> pdd;
typedef pair<double,ll> pdi;
typedef pair<double,pii> pdp;
typedef pair<string,ll> psi;
typedef pair<ll,string> pls;
typedef pair<string,string> pss;
typedef pair<ll,pii> pip;
typedef pair<pii,pii> ppp;
typedef complex<ld> point;
typedef pair<point,int> ppi;
#define mod (ll)(1e9+7)
#define eps (1e-9)
#define oo (ll)(0x3f3f3f3f)
#define pi acos(-1)
#define MAXN (ll)(1e3+5)

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

    int n,k;
    cin >> n >> k;
    vector<ll> pos;
    vector<ll> neg;
    for(int i=0;i<n;i++)
    {
        int a;
        cin >> a;
        if(a>0)
            pos.push_back(a);
        else
            neg.push_back(a);
    }

    sort(all(neg));
    sort(all(pos));

    if(k==n)
    {
        ll res=1;
        for(auto y : neg)
            res=(res*(y+mod))%mod;
        for(auto y : pos)
            res=(res*y)%mod;
        db(res)
    }
    else if(pos.empty())
    {
        if(k&1)
        {
            reverse(all(neg));
            ll res=1;
            for(int i=0;i<k;i++)
                res=(res*(neg[i]+mod))%mod;
            db(res)
        }
        else
        {
            ll res=1;
            for(int i=0;i<k;i++)
                res=(res*(neg[i]+mod))%mod;
            db(res)
        }
    }
    else
    {
        ll res=1;
        if(k&1)
        {
            res=pos[pos.size()-1];
            pos.pop_back();
            k--;
        }

        reverse(all(pos));

        vector<ll> poss;
        for(int i=0;i+1<neg.size();i+=2)
            poss.push_back(neg[i]*neg[i+1]);
        for(int i=0;i+1<pos.size();i+=2)
            poss.push_back(pos[i]*pos[i+1]);
        sort(allr(poss));
        k/=2;
        for(int i=0;i<k;i++)
        {
            poss[i]%=mod;
            res=(res*poss[i])%mod;
        }
        db(res)
    }

    return 0;
}
/**
4 2
1 2 -3 -4
**/


Measured memory_bytes: 6500
length = 2010

n = int(input())
L = list(map(int, input().split()))
ans = 0
L.sort()
sum_1 = [0]*length
for i in range(n):
    sum_1[L[i]]+=1
#棒の長さで累積和
for i in range(length-1):
    sum_1[i+1] +=sum_1[i]
for i in range(n-1):
    for j in range(i+1, n):
        a = abs(L[i]-L[j])
        b = L[i]+L[j]
        ans = ans + sum_1[b-1] - sum_1[a]

        if a<L[i] and L[i]<b:
            ans -=1
        
        if a<L[j] and L[j]<b:
            ans -=1
print(ans//3)

Measured memory_bytes: 41948
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const int INF = 1e9;
const ll MAXN = 1e9;

struct dinic{
 
    struct edge{
        int to,cap,rev;
        edge(){}
        edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
    };
 
    int n;
    vector<vector<edge> > G;
    vector<int> level;
    vector<int> iter;
 
    dinic(){};
    dinic(int V):n(V),G(n),level(n),iter(n){}
 
    void add_edge(int from,int to,int cap){
        G[from].push_back(edge(to,cap,(int)G[to].size()));
        G[to].push_back(edge(from,0,(int)G[from].size()-1));
    }
 
    //sからの層グラフつくり
    void bfs(int s){
        level.assign(level.size(),-1);
        queue<int> que;
        level[s] = 0;
        que.push(s);
        while(!que.empty()){
            int v = que.front();
            que.pop();
            for(int i = 0; i < (int)G[v].size(); i++){
                edge e = G[v][i];
                if (e.cap > 0 && level[e.to] < 0){
                    level[e.to] = level[v]+1;
                    que.push(e.to);
                }
            }
        }
    }

    int dfs(int v,int t,int f){
        if(v == t) return f;
        for(int &i = iter[v]; i < (int)G[v].size(); i++){
            edge &e = G[v][i];
            if(e.cap > 0 && level[v] < level[e.to]){
                int d = dfs(e.to,t,min(f,e.cap));
                if(d > 0){
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    int max_flow(int s,int t,int lim){
        int flow = 0;
        for(; ;){
            bfs(s);
            if(level[t] < 0 || lim == 0){
                return flow;
            }
            iter.assign(iter.size(),0);
            int f;
            while((f = dfs(s,t,INF)) > 0){
                flow += f;
                lim -= f;
            }
        }
    }
};

int main()
{
	int h,w;
	cin >> h >> w;
	vector<string> a(h);
	int s,t;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			char c;
			cin >> c;
			a[i].push_back(c);
		}
	}

	dinic din(h+w+2);

	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(a[i][j] != '.')
			{

				if(a[i][j] == 'S'){
					din.add_edge(0,i+1,INF);
					din.add_edge(0,j+1+h,INF);
				}else if(a[i][j] == 'T'){
					din.add_edge(i+1,h+w+1,INF);
					din.add_edge(j+1+h,h+w+1,INF);
				}else{
					din.add_edge(i+1,j+1+h,1);
					din.add_edge(j+1+h,i+1,1);
				}
			}
		}
	}

	int ans = din.max_flow(0,h+w+1,INF);

	cout << (ans<INF?ans:-1) << endl;

	return 0;
}

Measured memory_bytes: 896
package main

import "fmt"

func main() {
	var n, k, x, y, total int
	fmt.Scan(&n, &k, &x, &y)
	for i := 0; i < n; i++ {
		if i < k {
			total += x
			continue
		}
		total += y
	}
	fmt.Println(total)
}


Measured memory_bytes: 512
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#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 <cmath>
#include <numeric>
#include <float.h>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
typedef unsigned long long ll;

 //最大公約数求める関数
auto my_gcd(auto n , auto m){
  if(n < m){
    auto tmp = n;
    n = m;
    m = tmp;
  }
  auto l  = n % m;
  while(l != 0){
    n = m;
    m = l;
    l = n % m;
}
return m;
}

//char⇒int関数
 int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}



int main(){
int N ; cin >> N;
vector<int> A(N);
A[0] = 0;
vector<int> cnt(N,0);
for(int i = 1; i < N; i++){
	cin >> A[i];
	cnt[A[i]-1]++;
}
rep(i,N){
	cout << cnt[i] << endl;
}

}

Measured memory_bytes: 4808
def m():
    n = int(input())
    nowt = 0
    nowx = 0
    nowy = 0
    for i in range(n):
        t, x, y = map(int, input().split())
        divt = abs(nowt - t)
        divx = abs(nowx - x)
        divy = abs(nowy - y)
        if divt < divx + divy:
            return "No"
        if divt == divx + divy:
            continue
        if (divt - divx + divy) % 2 == 0:
            continue
        return "No"
    return "Yes"

print(m())


Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    VI a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(all(a));
    if (a[0] + a[1] == a[2] || a[0] == a[1] + a[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cctype>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <vector>
#include <map>
#include <set>
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

int main() {
	long n, a, b;
	cin >> n >> a >> b;
	long ab = a + b;
	long ans = a * (n / ab) + min(a, n % ab);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256