akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <functional>

using namespace std;

int INF = 10000000;

int n;



int cast(int n)
{
	int sum = 0;
	for(int i = 1;i < n;i++)
	{
		int temp = 0;
		for(int j = i;j < n;j++)
		{
			temp += j;
			if(temp == n)
				sum++;
		}
	}
	return sum;
}


int main()
{
	int n;
	while(cin >> n && n)
	{
		cout << cast(n) << endl;
	}

  return 0;
}

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

static const int NMAX = 100;
static const int AMAX = 100;


void selectSort(const int N, int* A)
{
    int nswaps = 0;

    for (int i=0; i < N-1; i++) {
        int minj = i;
        for (int j = i+1; j < N; j++) {
            if ( A[j] < A[minj] ) {
                minj = j;
            }
        }
        if (minj != i) {
            int tmp = A[minj];
            A[minj] = A[i];
            A[i] = tmp;
            nswaps++;
        }
    }

    for (int k=0; k < N-1; k++) cout << A[k] << " ";
    cout << A[N-1] << endl;
    cout << nswaps << endl;
}

int main (void) {

    int N;
    int A[NMAX];

    cin >> N;
    for (int i=0; i < N; i++) cin >> A[i];
    
    selectSort(N, A);
}



Measured memory_bytes: 3120
n = int(input())
p = list(map(int, input().split()))

a=[1]
for num in range(1,n):
    a.append(num * 22000)
c=[0]*n

p=list(reversed(p))
new_p=[0]*n

for i in range(n):
    new_p[p[i]-1]=i

for i in range(n):
    c[i]=10**9 - new_p[i]

b=[0]*n
for i in range(n):
    b[i] = c[i]-a[i]

print(*a)
print(*b)

Measured memory_bytes: 46468
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  long long int n,a,b,c,d,e;
  cin>>n>>a>>b>>c>>d>>e;
  long long int tmp=min({a,b,c,d,e});
  cout<<(n%tmp==0 ? ((n/tmp)+4):((n/tmp)+5));
}


Measured memory_bytes: 256
let n, m, c = Scanf.scanf " %d %d %d" @@ fun a b c -> a, b, c
let bs = Array.init m @@ fun _ -> Scanf.scanf " %d" (+) 0
let a_ss = Array.init n @@ fun _ -> Array.init m @@ fun _ -> Scanf.scanf " %d" (+) 0
let f ans a_s = ans + if Array.mapi (fun i a -> a * bs.(i)) a_s |> Array.fold_left (+) c > 0 then 1 else 0
let _ = Array.fold_left f 0 a_ss |> Printf.printf "%d\n"

Measured memory_bytes: 512
N=int(input())
s=[]
t=[]
for i in range(N):
    a=str(input())
    s.append(a)
M=int(input())
for i in range(M):
    b=str(input())
    t.append(b)
u=0
for i in list(set(s)):
    u=max(u,s.count(i)-t.count(i))
print(u)

Measured memory_bytes: 3060
K, T = map(int, input().split())
A = [int(i) for i in input().split()]

A = sorted(A, reverse=True)
while len(A) > 1:
    A[0] -= 1
    A[-1] -=1
    if A[0] == 0:
        del A[0]
    if A[-1] == 0:
        del A[-1]

if A:
    print(A[0]-1)
else:
    print(0)


Measured memory_bytes: 3060
use io::*;

use std::collections::BTreeMap;

fn main() {
    let con = read_string();
    let mut sc = Scanner::new(&con);

    let n: usize = sc.next();
    let aa: Vec<i64> = (0..n).map(|_| sc.next()).collect();

    let mut sums: Vec<i64> = vec![0; n + 1];
    let mut mm: BTreeMap<i64, i64> = BTreeMap::new();
    let mut ans = 0;
    mm.insert(0, 1);

    for i in 0..n {
        sums[i + 1] = sums[i] + aa[i];
        ans += *mm.get(&sums[i + 1]).unwrap_or(&0);
        *mm.entry(sums[i + 1]).or_insert(0) += 1;
    }

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

//-----

pub mod io {
    use std;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T>(&mut self) -> T
        where
            T: std::str::FromStr,
            <T as std::str::FromStr>::Err: std::fmt::Debug,
        {
            let s = self.iter.next().unwrap();
            s.parse::<T>().unwrap()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 14588
solve(i,j){
  m[i][j]='0';
  if(m[i][j-1]-'0')solve(i,j-1);
  if(m[i][j-2]-'0')solve(i,j-2);
  if(m[i][j-3]-'0')solve(i,j-3);
  if(m[i-1][j]-'0')solve(i-1,j);
  if(m[i-2][j]-'0')solve(i-2,j);
  if(m[i-3][j]-'0')solve(i-3,j);
  if(m[i+1][j]-'0')solve(i+1,j);
  if(m[i+2][j]-'0')solve(i+2,j);
  if(m[i+3][j]-'0')solve(i+3,j);
  if(m[i][j+1]-'0')solve(i,j+1);
  if(m[i][j+2]-'0')solve(i,j+2);
  if(m[i][j+3]-'0')solve(i,j+3);
}

main(c){
  int n,h=10,i,j;
  for(scanf("%d",&n);c<=n;c++){
    printf("Data %d:\n",c);
    memset(m,'0',sizeof(m));
    for(i=3;i<=h;m[i][11]='0',i++)
      scanf("%s",m[i]+3);
    scanf("%d%d",&i,&j);
    solve(j+2,i+2);
    for(i=3;i<=h;printf("%s\n",m[i]+3),i++)
      m[i][11]=0;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>


using namespace std;
int a[10000+10];
int main()
{
	int n;
	cin>>n;
	int s = 0;
	for(int i = 0; i < n; ++i){
		cin>>a[i];
		s+=(a[i]-1);
	}
	cout<<s<<endl;
	return 0;
}

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

#define ll long long

int cmp(const void * a, const void * b)
{
  return ( *(int*)a - *(int*)b );
}

int main(void)
{
    int i,arr[3];
    for(i=0;i<3;i++)
        scanf("%d",arr+i);
    qsort(arr,3,sizeof(int),cmp);
    for(i=0;i<3;i++)
        printf("%d%c",arr[i],(i!=2)?' ':'\n');
    return 0;
}




Measured memory_bytes: 2044
#include <iostream>
#include <vector>
#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 a, b, c;
    cin >> a >> b >> c;
    if(a == b && a != c) cout << "Yes" << endl;
    else if(a == c && a != b) cout << "Yes" << endl;
    else if(b == c && b != a) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rp(i,n) for (int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define all_acc(x) (x).begin(), (x).end(), 0LL
#define int long long
#define absSort(v) sort(a.begin(), a.end(), [](int i, int j) -> bool { return abs(i) < abs(j); });
using namespace std;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
using ll = long long;
double pi=3.14159265359;


signed main(){
    int n,k; cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];

    for(int i=k;i<n;i++){
        if(a[i]>a[i-k]) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

Measured memory_bytes: 5196
#create date: 2020-08-22 21:00

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n, x, t = na()
    print(((n-1)//x+1)* t)

if __name__ == "__main__":
    main()

Measured memory_bytes: 61628
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n;
long long a[88],dp[88],bt;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	dp[0]=1000;
	for(int i=1;i<=n;i++){
		dp[i]=dp[i-1];
		for(int buy=1;buy<i;buy++){
			bt=dp[buy-1]/a[buy];
			dp[i]=max(dp[i],bt*a[i]+dp[buy-1]%a[buy]);
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 3604
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<ctime>
#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
#include<fstream>
#include<complex>
#include<algorithm>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ll long long
using namespace std;
const int INF = 0x3f3f3f3f;

int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int a,b,c;
	cin>>a>>b>>c;
	set<int> st;
	st.insert(a);
	st.insert(b);
	st.insert(c);
	if(st.size()==2) cout<<"Yes"<<endl;
	else cout<<"No"<<endl; 
    return 0;
}


Measured memory_bytes: 256
n,a,b,c,d = gets.split.map(&:to_i) # a<b , a<c , b<d
s = gets.chomp
i = a-1
while i < c-1
  if i < n-2 && s[i+2] == "."
    i += 2
  elsif i < n-1 && s[i+1] == "."
    i += 1
  else
    puts "No"
    exit
  end
  #p i
end
i = b-1
while i < d-1
  if i < n-2 && s[i+2] == "."
    i += 2
  elsif i < n-1 && s[i+1] == "."
    i += 1
  else
    puts "No"
    exit
  end
  #p i
end

if c < d
  puts "Yes"
else
  i = b-2
  m = 0
  while i < d+1 && i < n
    if s[i] == "."
      m += 1
    else
      m = 0
    end
    if m >= 3
      puts "Yes"
      exit
    end
    #p [i,m]
    i += 1
  end
  puts "No"
end


Measured memory_bytes: 2300
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int k = s.nextInt();
		int l = s.nextInt();
		int i = 0;
		int j = 0;
		int m = 15;
		int count = 0;

		int ans = 0;
		int q = 0;

		for (i = 0; i <= k; i++) {
			for (j = 0; j <= k; j++) {

				q = i + j;
				m = l-q;
				if(m>=0&&0<=i&&i<=k&&j<=k&&m<=k) {

					count++;
				}else {

				}
			}
			j=0;
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 21332
import java.lang.*;
import java.io.*;
import java.util.*;

class Main{
	public static void main(String args[]) throws Exception{
		FScanner sc=new FScanner();
		//Scanner sc=new Scanner(System.in);
		String[] s=sc.readStringL("");
		
		for(int i=0; i<s.length; i++){
			if(s[i].equals("1")){
				s[i]="9";
			}else if(s[i].equals("9")){
				s[i]="1";
			}
		}
		for(String c: s){
			System.out.print(c);
		}
		System.out.println();
		
	}
	
	static void solve(int cur, int nx, int en, int hld){}

	static void disp(int[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%d ",data[i]);
		}
			System.out.println();
	}
	
	static void disp(String[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%s ",data[i]);
		}
			System.out.println();
	}
	
	static void disp(long[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%d ",data[i]);
		}
			System.out.println();
	}
	
	static class FScanner{
		BufferedReader read=null;
		StringTokenizer tok=null;
		Scanner sc;
		FScanner() throws FileNotFoundException{
			sc=new Scanner(System.in);
		}
		boolean hasNextLine(){
			boolean has=true;
			if(!sc.hasNextLine()){
				has=false;
			}
			return has;
		}
		int readInt(){
			String buf=sc.nextLine();
			return Integer.parseInt(buf);
		}
		long readLong(){
			long i=Long.parseLong(sc.nextLine());
			return i;
		}
		int[] readIntL(){
			String[] buf=sc.nextLine().split(" ");
			int[] num=new int[buf.length];
			for(int i=0; i<buf.length; i++){
				num[i]=Integer.parseInt(buf[i]);
			}
			return num;
		}
		
		String readString(){
			return sc.nextLine();
		}
		String[] readStringL(String dlm){
			String[] s=sc.nextLine().split(dlm);
			return s;
		}
	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstring>

using namespace std;

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

	int P[200005];
	int result = 1;
	cin >> P[0];
	int mn = P[0];
	for (int i = 1; i < N; i++) {
		cin >> P[i];
		if (P[i] < mn) {
			result++;
			mn = P[i];
		}
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 1024
from collections import Counter
from collections import deque
from functools import reduce
from operator import mul
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
def COMBINATION(n, r):
    if n < 0 or r < 0 or n < r:
        return 0
    r = min(n-r, r)
    if r == 0:
        return 1
    o = reduce(mul, range(n, n - r, -1))
    u = reduce(mul, range(1, r + 1))
    return o // u
class UnionFind():

    def __init__(self, n):
        self.n = n
        self.node = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def same(self, x, y):
        return bool(self.root(x) == self.root(y))

    def root(self, x):
        if self.node[x] == x:
            return x
        else:
            self.node[x] = self.root(self.node[x])  # 経路圧縮
            return self.node[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return  # 結合不要
        if self.size[x] < self.size[y]:
            x, y = y, x
        self.node[y] = x
        self.size[x] += self.size[y]

    def return_size(self, x):
        return self.size[self.root(x)]


a, b, c = MI()
ans = c - (a - b)
print(max(ans, 0))



Measured memory_bytes: 68076
from sys import exit, setrecursionlimit
setrecursionlimit(10**6)

def array2D(row, col ,val=0):
    return [[val]*col for i in range(row)]


def comb2(x):
    if x>=2:
        return x*(x-1)//2
    else:
        return 0

n = int(input())
A = list(map(int, input().split()))
d = {}
for a in A:
    if a not in d:
        d[a] = 1
    else:
        d[a] += 1

ans_t = 0
for i in d:
    ans_t += comb2(d[i])

for a in A:
    print(ans_t - comb2(d[a]) + comb2(d[a]-1))


Measured memory_bytes: 26140
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		String[] line = reader.readLine().split(" ");
		int n = Integer.parseInt(line[0]);
		int q = Integer.parseInt(line[1]);
		LinkedList<String[]> queue = new LinkedList<String[]>();
		for (int i = 0; i < n; i++) {
			queue.addFirst(reader.readLine().split(" "));
		}
		String[] work = new String[2];
		int elapse = 0;
		while ((work = queue.pollLast())!=null) {
			int time = Integer.parseInt(work[1]);
			if (time <= q) {
				elapse += time;
				builder.append(work[0]).append(" ").append(elapse).append("\n");
			} else {
				time -= q;
				elapse += q;
				work[1] = String.valueOf(time);
				queue.addFirst(work);
			}
		/*	queue.forEach(a->System.out.println(Arrays.toString(a)));
			System.out.println(Arrays.toString(work) + "  ->  work    " + elapse);
			System.out.println();*/

		}
		System.out.print(builder);
	}
}

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

int main() {
  int n,m,q,last;
  cin>>n>>m>>q;
  bool tf;
  int p[200000][n];
  for(int i=0;i<n;i++)p[0][i]=1;
  for(int i=1;i<200000;i++){
    tf=false;
    for(int j=n-1;j>=0;j--){
      if(p[i-1][j]!=m){
        p[i][j]=p[i-1][j]+1;
        for(int k=0;k<j;k++)p[i][k]=p[i-1][k];
        for(int k=n-1;k>j;k--)p[i][k]=p[i][j];
        tf=true;
      }
      if(tf)break;
    }
    if(!tf){
      last=i;
      break;
    }
  }
  int a[q][4];
  for(int i=0;i<q;i++){
    int b,c,d,e;
    cin>>b>>c>>d>>e;
    a[i][0]=b;
    a[i][1]=c;
    a[i][2]=d;
    a[i][3]=e;
  }
  long long ans=0,sum;
  for(int i=0;i<last;i++){
    sum=0;
    for(int j=0;j<q;j++){
      if(p[i][a[j][1]-1]-p[i][a[j][0]-1]==a[j][2])sum+=a[j][3];
    }
    ans=max(ans,sum);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 7152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
ll qpow(ll a, ll n) {
	ll res = 1;
	while(n) {
		if (n & 1) res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	if (n == 1) 
		cout << 0;
	else 
		cout << (qpow(10,n) - qpow(9,n) * 2 + qpow(8, n) + MOD * 2) % MOD;
	return 0;
}

Measured memory_bytes: 3656
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 262144
#define REP(i,n) for(long long i = 0;i < n;++i)
int geko[300000] = {};
int main() {
	int n;
	cin >> n;
	for (int q = 0; q < 20; ++q) {
		if (1 << q == n) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	if (n % 2 == 1) {
		cout << "1 2" << endl;
		cout << "2 3" << endl;
		cout << "3 " << n + 1 << endl;
		cout << n + 1 << " " << n + 2 << endl;
		cout << n + 2 << " " << n + 3 << endl;
		for (int q = 4; q < n; q += 2) {
			cout << q << " " << n + 1 << endl;
			cout << q + 1 << " " << q << endl;
			cout << n + q + 1 << " " << n + 1 << endl;
			cout << n + q << " " << n + q + 1 << endl;
		}
	}
	else {
		cout << "1 2" << endl;
		cout << "2 3" << endl;
		cout << "3 " << n + 1 << endl;
		cout << n + 1 << " " << n + 2 << endl;
		cout << n + 2 << " " << n + 3 << endl;
		geko[2] = n + 2;
		geko[3] = 3;
		for (int q = 4; q < n-1; q += 2) {
			cout << q << " " << n + 1 << endl;
			geko[q] = q;
			cout << q + 1 << " " << q << endl;
			cout << n + q + 1 << " " << n + 1 << endl;
			geko[q + 1] = n + q + 1;
			cout << n + q << " " << n + q + 1 << endl;
		}
		for (long long q = 2; q <= n - 1; ++q) {
			long long tea = (n ^ q);
			tea ^= 1;
			if (tea < n&&tea >= 2 && tea != q) {
				cout << n << " " << geko[q] << endl;
				cout << 2 * n << " " << geko[tea] << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,t;
    int a[200001];
    scanf("%d",&n);
    memset(a,0,sizeof(a));
    for(int i=0;i<n-1;i++){
    	scanf("%d",&t);
    	a[t]++;
	}
	for(int i=1;i<=n;i++){
		printf("%d\n",a[i]);
	}
	return 0; 
}

Measured memory_bytes: 4604
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
using namespace std;
using boost::irange;
constexpr char nl = '\n';

template<class T> ostream& operator<<(ostream& out, const vector<T>& vs) { for (size_t i = 0; i < vs.size(); ++i) { if(i) { out << ' '; } out << vs[i]; } return out; }

int main() {
    string s;
    cin >> s;
    auto N = s.size();
    vector<int> a(N);
    for (auto i : irange(0ul, N - 1)) {
        if (s[i] == 'R' && s[i+1] == 'L') {
            for (auto j = i;  j >= 0 && s[j] == 'R'; j--) a[i + (j-i) % 2]++;
            for (auto j = i+1; j < N && s[j] == 'L'; j++) a[i + (i-j) % 2]++;
        }
    }
    cout << a << nl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main() {
  int N;
  cin>>N;
  vector<int>d(N);
  for(int i=0;i<N;i++){
    cin>>d[i];
  }
  int ans=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
     ans+=d[i]*d[j];
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

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

	int n;
	cin >> n;
	auto color = [&](int a, int b) {
		for (int i = 20; i >= 0; i--) {
			if (((a >> i) & 1) != ((b >> i) & 1)) {
				return i + 1;
			}
		}
		return -1;
	};
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			cout << color(i, j) << ' ';
		}
		cout << endl;
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A=0;
  string S,T;
  cin>>S>>T;
  int s=S.size();
  int t=T.size();
   if(s+1==t){
    for(int i;i<s;i++){
     if(S[i]!=T[i]){
       A++;
       break;
     }    
    }
    if(A==1){
     cout<<"No"<<endl; 
    }else{
     cout<<"Yes"<<endl; 
    }
  }else{
    cout<<"No"<<endl;
  }
}

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

int main(){
  long n;
  cin >> n;
  vector<long long int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  
  rep(i, n/2){
    if(a[2*i] + a[2*i+1] < 0){
      a[2*i] *= -1;
      a[2*i+1] *= -1;
    }
    else break;
  }
  
  long long int ans = 0;
  rep(i, n) ans += a[i];
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <functional>
#include <sstream>
#include <complex>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define EPS 1e-8

int main(){
	int n;
	int data[128];
	while(scanf("%d",&n),n){
		rep(i,n)scanf("%d",data+i);
		sort(data,data+n);
		int sum = 0;
		REP(i,1,n-1)sum+=data[i];
		printf("%d\n",sum/(n-2));
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ps push_back
#define LL long long
using namespace std;
string s, t;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>s>>t;
    int ans=0;
    for(int i=0; i<s.size(); i++)
    {
        ans+=s[i]!=t[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3792
import numpy as np

n = int(input())
s = np.array(list(input()))

l = s.size

dp = np.zeros(l, dtype=np.int16)
ans = 0
for i, e in enumerate(s, 1):
    dp_prev = dp[:]
    mx = np.arange(1, l + 1) - i
    idx = np.hstack([np.full(i, False), s[i:] == e]).astype(np.bool)
    idx_prev = np.hstack([np.full(i-1, False), s[i:] == e, False]).astype(np.bool)
    dp = np.zeros(l, dtype=np.int16)
    dp[idx] = np.minimum(dp_prev[idx_prev] + 1, mx[idx])
    ans = max(ans, dp.max())

print(ans)


Measured memory_bytes: 14664
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)
 
#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(20)
 
const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;
 
// typedef long long ll;
#define int long long
#define double long double
 
template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
 
typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  string S; cin >> S;
  int ans = 0;
  REP(i, S.size()){
    if(S[i] != S[S.size()-1-i]) ans++;
  }
  cout << ans/2 << endl;
}

Measured memory_bytes: 256
function main(input) {
    const args = input.split(' ');
    var n = parseInt(args[0], 10);
    const r = parseInt(args[1], 10);

  	if (n >= 10) n = 10;
    console.log(r + 100 * (10 - n));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
n,m = map(int,input().split())
s = [tuple(map(int,input().split())) for i in range(n)]
c = [tuple(map(int,input().split())) for i in range(m)]
a = [0] * n
for i,sp in enumerate(s):
  m = 10**9
  for j,cp in enumerate(c):
    d = abs(sp[0]-cp[0]) + abs(sp[1]-cp[1])
    if d < m:
      m = d
      a[i] = j+1
print('\n'.join(map(str,a)))

Measured memory_bytes: 3064
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}

ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int main(){
  int r, g, b; cin >> r >> g >> b;
  ll sum = 100 * r + 10 * g + b;
  if(sum % 4){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) cin >> vec.at(i);

  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());

  int A = 0;
  int B = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) A += vec.at(i);
    else B += vec.at(i); 
  }

  cout << A - B << endl;
}

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

#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define per(i,n) for (int i=(int)(n)-1;i>=0;i--)
#define For(i,n) for (int i=1;i<=(int)(n);i++)
#define Rep(i,n) for (int i=0;i<=(int)(n);i++)
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define all(x) (x).begin(),(x).end()
#define Max(a,b,c) max(a,max(b,c))
#define Min(a,b,c) min(a,min(b,c))
#define cmax(x,y) x=max(x,y)
#define cmin(x,y) x=min(x,y)
#define pii pair<int,int>
#define vi vector <int>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define pb push_back
#define re return
#define se second
#define fi first
const int INF=0x7fffffff;
const int MAXN=100+3;
const int MOD=1e9+7;

int f[MAXN][100003],n,k,a[MAXN],t;

int main(){
	cin>>n>>k;
	For(i,n){
		cin>>a[i];
	}
	f[0][0]=1;
	For(i,n){
		t=0;
		Rep(j,k){
			t+=f[i-1][j];
			if (t>=MOD) t-=MOD;
			if (j-a[i]-1>=0){
				t-=f[i-1][j-a[i]-1];
				if (t<0) t+=MOD;
			}
			f[i][j]=t;
		}
	}
	cout<<f[n][k]<<endl;
	re 0;
}

Measured memory_bytes: 39296
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
	int nn,kk;
	cin >> nn >> kk;
	
	vector<int> pp(nn);
	rep(i,nn) cin >> pp[i];
	
	sort(pp.begin(),pp.end());
	
	int sum=0;
	
	rep(i,kk) sum+=pp[i];
	
	cout << sum << endl;
	return 0;
}

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

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

    bool cards[4][13] = {};
    for (int i = 0; i < n; i++) {
        char mark;
        int num, imark;
        cin >> mark >> num;

        if (mark == 'S') {
            imark = 0;
        } else if (mark == 'H') {
            imark = 1;
        } else if (mark == 'C') {
            imark = 2;
        } else if (mark == 'D') {
            imark = 3;
        } else {
            return 1;
        }

        cards[imark][num - 1] = true;
    }

    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 13; j++) {
            if (!cards[i][j]) {
                char mark;
                if (i == 0) {
                    mark = 'S';
                } else if (i == 1) {
                    mark = 'H';
                } else if (i == 2) {
                    mark = 'C';
                } else if (i == 3) {
                    mark = 'D';
                } else {
                    return 1;
                }

                printf("%c %d\n", mark, j + 1);
            }
        }
    }

    return 0;
}


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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define REPC(var, start, end) for(int var = start; var <= (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cout << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;

int a, b, c;
bool isPossible()
{
    VI A{a, b, c};
    sort(ALL(A), greater<int>());
    return A[0] == A[1] + A[2];
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
    cin >> a >> b >> c;

    if(isPossible())
        cout << "Yes";
    else
        cout << "No";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

    template<class T> inline bool chmin(T& a, T b) {
        if (a > b) {
            a = b;
            return true;
        }
        return false;
    }
    template<class T> inline bool chmax(T& a, T b) {
        if (a < b) {
            a = b;
            return true;
        }
        return false;
    }

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint,dijkstra

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll vec[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        ll k;
        cin>>k;
        cout<<vec[k-1]<<endl;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL (1LL<<62) // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll x;
    cin >> x;
    cout << (x^1) << endl;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <algorithm>

typedef long long LL;
const int Mod = 1000000007;
const int MN = 1005, MM = 2005;

inline int qPow(int b, int e) {
	int a = 1;
	for (; e; e >>= 1, b = (LL)b * b % Mod)
		if (e & 1) a = (LL)a * b % Mod;
	return a;
}

int N, M, eu[MM], ev[MM], ew[MM], ep[MM], cho[MM], val[MM];
int fa[MN * 2];
int ff(int x) { return fa[x] ? fa[x] = ff(fa[x]) : x; }
LL Sum, X;
int Ans;

int lc[MN * 2], rc[MN * 2], wgh[MN * 2], dep[MN * 2], faz[MN * 2][10], cnt;
void DFS(int u, int fz) {
	dep[u] = dep[fz] + 1;
	for (int j = 0; 2 << j < dep[u]; ++j)
		faz[u][j + 1] = faz[faz[u][j]][j];
	if (u > N) DFS(lc[u], u), DFS(rc[u], u);
}
inline int LCA(int x, int y) {
	if (dep[x] < dep[y]) std::swap(x, y);
	for (int d = dep[x] - dep[y], j = 0; d; d >>= 1, ++j)
		if (d & 1) x = faz[x][j];
	if (x == y) return x;
	for (int j = 9; j >= 0; --j)
		if (faz[x][j] != faz[y][j])
			x = faz[x][j],
			y = faz[y][j];
	return faz[x][0];
}

int main() {
	scanf("%d%d%lld", &N, &M, &X), cnt = N;
	for (int i = 1; i <= M; ++i) {
		scanf("%d%d%d", &eu[i], &ev[i], &ew[i]);
		ep[i] = i;
	}
	std::sort(ep + 1, ep + M + 1, [](int i, int j) { return ew[i] < ew[j]; });
	for (int id = 1; id <= M; ++id) {
		int i = ep[id], u = ff(eu[i]), v = ff(ev[i]);
		if (u == v) continue;
		cho[i] = 1;
		Sum += ew[i];
		wgh[++cnt] = ew[i];
		faz[u][0] = faz[v][0] = cnt;
		lc[cnt] = u, rc[cnt] = v;
		fa[u] = fa[v] = cnt;
	}
	X -= Sum;
	if (X < 0) return puts("0"), 0;
	DFS(cnt, 0);
	int t1 = 0, t2 = 0, t3 = 0;
	for (int i = 1; i <= M; ++i) if (!cho[i])
		val[i] = ew[i] - wgh[LCA(eu[i], ev[i])],
		++(val[i] == X ? t2 : val[i] < X ? t1 : t3);
	Ans = (qPow(2, t2 + t3 + 1) - qPow(2, t3 + 1)) % Mod;
	if (X == 0) Ans = (Ans + qPow(2, M) - qPow(2, M - N + 2)) % Mod;
	printf("%d\n", (Ans + Mod) % Mod);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long K;
    cin >> K;
    long long temp = 7;
    set<long long> s;
    s.insert(temp);
    long long cnt = 1;
    while(1){
        if(temp % K == 0) break;
        temp = temp * 10 + 7;
        cnt++;
        temp %= K;
        if(s.count(temp)) {
            cout << -1 << endl;
            return 0;
        }
        else s.insert(temp);
    }
    cout << cnt << endl;
}

Measured memory_bytes: 50420
#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<int,int>
#define vint vector<int>
#define pb push_back
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
int read(){
	int g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const int N=505;
const int maxn=500;
int k;
namespace solve1{
	void Main(){
		cout<<k<<'\n';
		for(int i=1;i<=k;i++,cout<<'\n')for(int j=1;j<=k;j++,cout<<' ')cout<<i;
	}
}
namespace solve2{
	int a[N][N];
	void Main(){
		cout<<maxn<<'\n';
		for(int i=1;i<=maxn;i++)for(int j=1;j<=maxn;j++)a[i][j]=(i+j-2)%maxn+1;
		for(int i=maxn+1;i<=k;i++)for(int j=1;j<=maxn;j+=2){int x=(i-maxn-2+j)%maxn+1,y=(i-x)%maxn+1;a[x][y]=i;}
		for(int i=1;i<=maxn;i++,cout<<'\n')for(int j=1;j<=maxn;j++,cout<<' ')cout<<a[i][j];
	}
}
signed main(){
	k=read();
	if(k<=500)solve1::Main();
	else solve2::Main();
	return signed();
}

Measured memory_bytes: 4616
#include <bits/stdc++.h>
using namespace std;
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>

const int N = 2e5+10;

int n,c;
int h[N];
int dp[N];

struct line
{
    int m,c;
    
    line() {}
    line(int m,int c) : m(m),c(c) {}
    
    int gety(int x) 
    {
        return (m*x) + c;
    }
    
    long double isect(line & o)
    {
        return ((long double)o.c - c)/((long double)m - o.m);
    }
};

//maintain upper hull
deque<line> chull;

//values of x are increasing
int query(int x)
{
   while(chull.size() >= 2 && chull[0].gety(x) >= chull[1].gety(x)) 
       chull.pop_front();
    
   return chull[0].gety(x);
}

//values of m are decreasing 
void insert(int c,int m)
{
    line go(m,c);
    
    while(chull.size() >= 2 && go.isect(chull[(int)chull.size()-2]) >= go.isect(chull.back()) ) 
        chull.pop_back();   
    
    chull.push_back(go);
}

signed main()
{
    fast;
    
    cin >> n >> c;
    f(i,n) cin >> h[i];
  
    insert(h[0]*h[0],-2*h[0]);
    
    for(int i=1;i<n;i++)
    {
    dp[i] = query(h[i]) + (h[i]*h[i]) + c;     
    insert(dp[i]+(h[i]*h[i]),-2*h[i]);
    }
    
    cout << dp[n-1];
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL a[100005], b[100005];

int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        if (i % 2) b[1] += a[i];
        else b[1] -= a[i];
    }
    for(int i = 2; i <= n; i++) b[i] = 2 * a[i-1] - b[i-1];
    for(int i = 1; i <= n; i++){
        if (i - n) cout << b[i] << " ";
        else cout << b[i] << endl;
    }
	return 0;
}

Measured memory_bytes: 2816
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long

int main(){
    int n; cin >> n;
    lint M = 0, m = 1e9 + 1;
    rep(i, n){
        lint a; cin >> a;
        M = max(M, a);
        m = min(m, a);
    }
    cout << M - m << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    std::cin >> a >>b;
    if(b==1){
        std::cout << 0 << std::endl;
        return 0;
    }
    int c=1;
    int ans=0;
    while(c<b){
        c-=1;
        c+=a;
        ans++;
    }
    std::cout << ans << std::endl;
}


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

using namespace std;

int main()
{
    int n;
    int ans = 0;

    cin >> n;

    for (int i = 1; i <= n; i++) {
        if (to_string(i).size() % 2) {
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
class UnionFind
  def initialize(n)
    @size = Array.new(n, 1)
    @parent = Array.new(n, &:itself)
  end
 
  def get_root(x)
    @parent[x] == x ? x : get_root(@parent[x])
  end
 
  def unite(x, y)
    x = get_root(x)
    y = get_root(y)
    return if x == y
    x, y = y, x if @size[x] < @size[y]
    @size[x] += @size[y]
    @parent[y] = x 
  end
 
  def same_root?(x, y)
    return get_root(x) == get_root(y)
  end
 
  def size(x)
    return @size[get_root(x)]
  end
end

n, m, k = gets.chomp.split.map(&:to_i)
uf = UnionFind.new(n + 1)
fr_cnt = Array.new(n + 1, 0)
bl_cnt = Array.new(n + 1, 0)

m.times do
  a, b = gets.chomp.split.map(&:to_i)
  uf.unite(a, b)
  fr_cnt[a] += 1
  fr_cnt[b] += 1
end

k.times do
  c, d = gets.chomp.split.map(&:to_i)
  if uf.same_root?(c, d)
    bl_cnt[c] += 1
    bl_cnt[d] += 1
  end
end

res = Array.new(n)
1.step(n) do |i|
  res[i - 1] = uf.size(i) - fr_cnt[i] - bl_cnt[i] - 1
end

puts res.join(" ")


Measured memory_bytes: 6908
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <map>
#include <tuple>
#include <cmath>
#include <cstdio>
#include <cassert>
#include <functional>
#define _LIBCPP_DEBUG 0
using namespace std;

int main(void)
{
    long long n, d;
    cin >> n >> d;
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        long long a, b;
        cin >> a >> b;
        if (a*a + b*b <= d*d)
        {
            count++;
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 3604
#include<iostream>
using namespace std;
int gcd(int a, int b) {
	if (a < b) return gcd(b, a);
	if (b == 0) return a;
	return gcd(b, a%b);
}
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (c%gcd(a, b)==0) cout << "YES";
	else cout << "NO";
}

Measured memory_bytes: 256
N = int(input())
As = list(map(int, input().split(" ")))

rule = 1000000007
s = 0
list_sum = sum(As[1:])
if list_sum >= rule:
    list_sum = list_sum % rule

for i in range(len(As) - 1):
    s += As[i] * list_sum
    if s >= rule:
        s = s % rule
    list_sum -= As[i+1]
    if list_sum < 0:
        list_sum += rule
print(s)

Measured memory_bytes: 94516
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

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

    int n;
    cin >> n;
    map<int,int> mp;
    rep(i,n){
        int a;
        cin >> a;
        if (mp.find(a) == mp.end()){
            mp[a] = 1;
        }else if(mp[a] == 1){
            mp[a] = 0;
        }else{
            mp[a] = 1;
        }
    }
    int ans = 0;
    for(auto itr=mp.begin();itr != mp.end();itr++){
        if (itr->second == 1){
            ans += 1;
        }
    }
    cout << ans << endl;
    
    
}

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

using namespace std;

int main(void){
	int n,k,q;
	cin >> n >> k >> q;
	vector<int> a(n,0);
	for(int i=0;i<q;i++){
		int aa;
		cin >> aa;
		a[aa-1]++;
	}
	for(int i=0;i<n;i++){
		if(q-a[i] < k){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc172/abc172_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  ll N;
  cin >> N;

  cout << N + N * N + N * N * N << endl;
}

Measured memory_bytes: 3528
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 





int main() {
  string s,t;
  cin >> s >> t;
  int s_len = s.length();
  int cnt =0;
  for (int i=0;i <s_len; i++) {
    if (s[i]!=t[i]) cnt++;
  }
  cout << cnt << endl;
  return 0;

}


Measured memory_bytes: 3916
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
from functools import lru_cache

N = I()
A = LI()

@lru_cache(maxsize=None)
def ncr(n, r):
    return int(n*(n-1)/2)

tmp = 0
AA = collections.Counter(A)
As = AA.items()
for n, t in As:
    tmp += ncr(t, 2)

for a in A:
    an = AA[a]
    print(tmp - ncr(an, 2) + ncr(an - 1, 2))


Measured memory_bytes: 83680
#include <stdio.h>

int main(void){
   
int i,a,b,c,d,e;
    while(scanf("%d",&a)!=EOF){
        b=600/a;
        int sum=0;
            for(i=1;i<b;i++){
                e=i*a;
                d=e*e;
                c=a*d;
                sum+=c;
            }
        printf("%d\n",sum);
        if(a == 0){
            break;
        }
    }
    
    return 0;
}



Measured memory_bytes: 1980
/*
         ██╗ ██████╗ ██╗███╗   ██╗    ██╗   ██╗███████╗
         ██║██╔═══██╗██║████╗  ██║    ██║   ██║██╔════╝
         ██║██║   ██║██║██╔██╗ ██║    ██║   ██║███████╗
    ██   ██║██║   ██║██║██║╚██╗██║    ██║   ██║╚════██║
    ╚█████╔╝╚██████╔╝██║██║ ╚████║    ╚██████╔╝███████║
     ╚════╝  ╚═════╝ ╚═╝╚═╝  ╚═══╝     ╚═════╝ ╚══════╝
*/
//password:+BdCHpO8dQvpo5fnV3/u
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 5e5 + 5;
const int inf = 0x3f3f3f3f;



int main() {
    int k;
    scanf("%d",&k);
    ll ans=0;
    for(int a=1;a<=k;a++){
        for(int b=1;b<=k;b++){
            for(int c=1;c<=k;c++){
                ans+=__gcd(a,__gcd(b,c));
            }
        }
    }
    printf("%lld",ans);    
    return 0;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int a, b, c; cin >> a >> b >> c;
  cout << (b - a == c - b ? "YES" : "NO") << '\n';
}


Measured memory_bytes: 256