akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			double answer = 0;
			for(int i = 0; i < N; i++) {
				final double x = sc.nextDouble();
				String type = sc.next();
				
				if("JPY".equals(type)) {
					answer += x;
				}else {
					answer += x * 380000;
				}
			}
			
			System.out.printf("%.8f\n", answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;

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

  vector<vector<char>> G(H + 1, vector<char>(W + 1, '#'));
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      cin >> G.at(i).at(j);
    }
  }

  vector<vector<int>> dp(H + 1, vector<int>(W + 1, 0));
  dp.at(1).at(1) = 1;

  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if (G.at(i).at(j) == '#') continue;
      dp.at(i).at(j) += (dp.at(i - 1).at(j) + dp.at(i).at(j - 1)) % mod;
    }
  }

  cout << dp.at(H).at(W) << endl;
  return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <iomanip>

using namespace std;

int main() {

    int a, b, d, r;
    double f;

    cin >> a >> b;

    d = a / b;
    r = a % b;
    f = (double)a / b;

    cout << fixed;
    cout << setprecision(5) << d << " " << r << " " << f << "\n";
    return 0;
}



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

int main(){
  ll s[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 n;
  in(n);
  out(s[n - 1]);
  memi;
}

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

int main(){

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll a,b,n,x;
    cin >> a >> b >> n;
    if( n< b-1){
    	x = n;
    }
    else{
    	x = b-1;
    }

    ll ans = (a*x)/b - a*(x/b);
    cout << ans << "\n";

    

	return 0;
}

Measured memory_bytes: 3652
import sys
from collections import Counter


def main():
    input = sys.stdin.buffer.readline
    h, w, m = map(int, input().split())
    h = [0] * m
    w = [0] * m
    object_set = set()
    for i in range(m):
        h[i], w[i] = map(int, input().split())
        object_set.add((h[i], w[i]))
    h_counter = Counter(h)
    w_counter = Counter(w)
    max_h_num = h_counter.most_common()[0][1]
    max_w_num = w_counter.most_common()[0][1]
    ans = max_h_num + max_w_num

    h_cand = set()
    w_cand = set()
    for e, n in h_counter.most_common():
        if n == max_h_num:
            h_cand.add(e)
    for e, n in w_counter.most_common():
        if n == max_w_num:
            w_cand.add(e)

    cnt = 0
    for h_e, w_e in object_set:
        if h_e in h_cand and w_e in w_cand:
            cnt += 1

    print(ans if cnt < len(h_cand) * len(w_cand) else ans - 1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 214304
#include<bits/stdc++.h>
using namespace std; 
using lint  =                           long long int;
using pint  =                           pair<int, int>;
using plint =                           pair<lint, lint>;
#define vli                             vector<lint>
#define pb                              push_back
#define ALL(x)                          begin(x),end(x)
#define inf                             (1LL<63)-1
#define MOD                             1000000007
#define SZ(x)                           ((lint)(x).size())
#define                                 FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define                                 IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define                                 REP(i, n) FOR(i,0,n)
#define                                 IREP(i, n) IFOR(i,0,n)
#define                                 f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define                                 debug(x) cerr << #x << " " << (x) << endl
struct fast_ios                         { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T>                    istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T>                    bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T>                    bool mmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }


/* -------
         |
    **   |
   -------      
   |
   ---------------------------------------------------------------------------------------------------------------------------------*/

void solve(){  
  int N;
  cin >> N;
  int K;
  cin >> K;
  vector<int> A(N);
  cin >> A;
  int count = 0;
  for(int i = 0;i < A.size(); ++i){
      if(A[i] >= K){
          ++count;
      }
  }
  cout << count << endl;
}

int main(){   
  
 solve();

 return 0;
}


Measured memory_bytes: 640
package main

import (
	"fmt"
)

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	cnt := 0
	for i := 0; i < len(s); i++ {
		if s[i] != t[i] {
			cnt++
		}
	}
	fmt.Println(cnt)


}


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

typedef long long int ll;

ll ans = 0;


int main()
{
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    
    for(ll i = 1;i <= n;i++){
        if(i - 1 >= k){
            ans += n / i * max((i - k), 0LL);
        }
        if(n % i != 0){
            ll t = 0;
            if(k != 0){
                t++;
            }
            ans += max(n % i - k + t, 0LL);
        }
    }

    cout << ans;

    return 0;
}

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

typedef long long ll;


int main(){
    ll N;
    cin >> N;
    vector<ll> A(N), B(N), C(N);
    for(int i=0; i<N; i++) cin >> A[i] >> B[i];
    
    if(A[N-1]==0 || B[N-1]==1 || A[N-1]%B[N-1]==0)
        C[N-1] = 0;
    else
        C[N-1] = B[N-1] - (A[N-1]%B[N-1]);
    
    for(ll i=N-2; i>=0; i--){
        A[i] += C[i+1];
        if(B[i]==1 || A[i]%B[i]==0)
            C[i] = C[i+1];
        else
            C[i] = C[i+1] + (B[i] - (A[i]%B[i]));
    }
    
    cout << C[0] << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(1){
		c-=b;
		if(c<=0){
			cout<<"Yes"<<endl;
			return 0;
		}
		a-=d;
		if(a<=0){
			cout<<"No"<<endl;
			return 0;	
		}
	}
	return 0;
}


Measured memory_bytes: 3632
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define INF (1<<29)
#define test cout << "test" << endl;
#define NNN_MAX 100010
typedef pair<int,int> P;
 
long long min(long long a, long long b){
	return (a>b)? b:a;
}
 
long long max(long long a,long long b){
	return (a>b)? a:b;
}
 
int main (){
	long long  X,Y;
	cin >>X>>Y;
	int shiftcount =0;
	while(Y >= X){
		shiftcount ++;
		X=2*X;
	}
	cout << shiftcount <<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
int main(){
    int N,M;
    cin >> N>>M;

    char a[N][N],b[M][M];

    REP(i,N){
        REP(j,N){
            cin >> a[i][j];
        }
    }

    REP(i,M){
        REP(j,M){
            cin >> b[i][j];
        }
    }
    bool exist = false;
    REP(i,N-M+1){
        REP(j,N-M+1){
            bool fl=true;
            for(int k=0;k<M;k++){
                for(int h=0;h<M;h++){
                    if(a[i+k][j+h]!=b[k][h]) fl=false;
                }
            }
            if(fl){
                exist = true;
            }
        }
    }
    if(exist){
        cout << "Yes"  <<endl;
    }else{
        cout << "No" <<endl;
    }
}

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

    def makeBIT(numEle):
        numPow2 = 2 ** (numEle-1).bit_length()
        data = [0] * (numPow2+1)
        return data, numPow2
    def setValue(iA, A):
        iB = iA + 1
        while iB <= numPow2:
            if A > data[iB]:
                data[iB] = A
            iB += iB & -iB
    def getMax(iA):
        iB = iA + 1
        ans = 0
        while iB > 0:
            if data[iB] > ans:
                ans = data[iB]
            iB -= iB & -iB
        return ans


    iHs = list(range(N))
    iHs.sort(key=lambda iH: Hs[iH])
    odrHs = [0]*(N)
    for odrH, iH in enumerate(iHs):
        odrHs[iH] = odrH

    data, numPow2 = makeBIT(N)

    ans = 0
    for iH in range(N):
        odrH = odrHs[iH]
        v = As[iH] + getMax(odrH)
        if v > ans:
            ans = v
        setValue(odrH, v)

    print(ans)


solve()


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

int main() {
  int N;
  cin >> N;
  
  int x,y;
  x = 800 * N;
  if(N >=90) y = 1200;
  else if(N >=75) y = 1000;
  else if(N >=60) y = 800;
  else if(N >=45) y = 600;
  else if(N >=30) y = 400;
  else if(N >=15) y = 200;
  else y = 0;
  
  cout << x - y << endl;
}

Measured memory_bytes: 3536
n,m=map(int,input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
h=make_divisors(m)
h.sort()
for u in h:
    if u>=n:
        print(m//u)
        break

Measured memory_bytes: 3188
import java.util.*;
import java.io.*;
class Main
{
	public static void main(String args[]) throws java.lang.Exception
	{
		BufferedReader inp = new BufferedReader (new InputStreamReader(System.in));
			// String h[]=inp.readLine().split(" ");
			String h[]=inp.readLine().split(" ");
			int n=Integer.parseInt(h[0]);
			int w=Integer.parseInt(h[1]);
			long dp[]=new long[w+1];
			HashSet<Long>hash=new HashSet<>();
			// hash.put((long)0,(long)0);
			hash.add((long)0);
			for(int i=0;i<n;i++)
			{
					
				String hh[]=inp.readLine().split(" ");
				long w1=Long.parseLong(hh[0]);
				long v1=Long.parseLong(hh[1]);
				long dp1[]=new long[w+1];
				HashSet<Long>hash1=new HashSet<>();
				Iterator value = hash.iterator(); 
  
		        while (value.hasNext()) { 
		          	long f=(Long)value.next();
		          	hash1.add(f);
		          	dp1[(int)f]=Math.max(dp1[(int)f],dp[(int)f]);
		          	if(f+w1<=w)
		          	{
		          		hash1.add(f+w1);
		          		dp1[(int)(f+w1)]=Math.max(dp1[(int)(f+w1)],dp[(int)f]+v1);
		          	}
		        }
		        hash=hash1;
		        dp=dp1; 		
					


					
				
			}
			long max=0;
			for(int i=0;i<=w;i++)
			{
				max=Math.max(dp[i],max);
			}
			System.out.println(max);
					
		
	}
	
}
class Pair
{
	int a;
	long b;
	
	Pair(int e, long f)
	{
		a=e;
		b=f;
		
	}
}

Measured memory_bytes: 319116
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  sm=sum(l)
  ans=inf

  _sm=0
  for x in l:
    _sm+=x
    other=sm-_sm

    ans=min(ans,abs(_sm-other))

  return ans

# main()
print(main())


Measured memory_bytes: 28312
/*i-=-1*/
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define in(n) for(int i=0;i<n;i++)
#define inj(n) for(int j=0;j<n;j++)
#define itn int
#define int ll int 
#define ll long long
#define ull unsigned ll
#define int ll int
#define S second 
#define F first 
#define mod 1000000007
#define globalbool 2000000
#define pii pair<int,int>
#define vi vector<int>
#define test int tc;for(cin>>tc;tc>0;tc--)
#define all(x) x.begin(),x.end()
#define pb push_back
using namespace std;
using namespace std::chrono;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	auto start = high_resolution_clock::now();
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	itn ans=0;
	ans+=min(a,k);
	k-=ans;
	if(k>0)
	{
		k-=min(b,k);
	}
	if(k>0)
	{
		ans-=(min(k,c));
	}
	cout<<ans<<endl;
	auto stop = high_resolution_clock::now();
    //auto duration = duration_cast<microseconds>(stop - start); 
  
    //cout << "Time taken by function: "
    //<< duration.count() << " microseconds" << endl;
}
//g++ -DLOCAL -std=c++17 -Wshadow -Wall -o "h" "h.cpp" -fsanitize=address
// -fsanitize=undefined -D_GLIBCXX_DEBUG -g

Measured memory_bytes: 3648
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 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 I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    A = sorted(LI())
    B = sorted(LI())
    C = sorted(LI())
    cnt = 0
    B_lt_A = [0] * N
    C_lt_B = [0] * N

    b_ix = 0
    for a_ix, a in enumerate(A):
        while b_ix < N and a >= B[b_ix]:
            b_ix += 1
        B_lt_A[a_ix] = N - b_ix

    c_ix = 0
    for b_ix, b in enumerate(B):
        while c_ix < N and b >= C[c_ix]:
            c_ix += 1
        C_lt_B[b_ix] = N - c_ix
    cumsum = [0] * (N+1)
    for i in range(N):
        cumsum[i+1] = cumsum[i] + C_lt_B[i]

    for i in range(N):
        B_lt_A[i] = N - B_lt_A[i]
    for c_ix in B_lt_A:
        cnt += (cumsum[-1] - cumsum[c_ix])

    print(cnt)
main()



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

int main(){
	int n;
  	cin >> n;
  
  	ll ans = (ll)n * (n-1) / 2;
  
  	cout << ans << endl;
}

Measured memory_bytes: 3612
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

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

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

func min(x []int) int {
	minv := x[0]
	for _, v := range x {
		if v < minv {
			minv = v
		}
	}
	return minv
}

var inf = int(math.Pow(10, 9))

func dfs(cur, mpA, mpB, mpC, n, a, b, c int, lenghs []int) int {
	if cur == n {
		if min([]int{mpA, mpB, mpC}) > 0 {
			return abs(mpA-a) + abs(mpB-b) + abs(mpC-c) - 30
		}
		return inf
	}
	ret0 := dfs(cur+1, mpA, mpB, mpC, n, a, b, c, lenghs)
	ret1 := dfs(cur+1, mpA+lenghs[cur], mpB, mpC, n, a, b, c, lenghs) + 10
	ret2 := dfs(cur+1, mpA, mpB+lenghs[cur], mpC, n, a, b, c, lenghs) + 10
	ret3 := dfs(cur+1, mpA, mpB, mpC+lenghs[cur], n, a, b, c, lenghs) + 10
	return min([]int{ret0, ret1, ret2, ret3})
}

func main() {
	n, _ := strconv.Atoi(input())
	a, _ := strconv.Atoi(input())
	b, _ := strconv.Atoi(input())
	c, _ := strconv.Atoi(input())
	lenghs := make([]int, n)
	for i := 0; i < n; i++ {
		lenghs[i], _ = strconv.Atoi(input())
	}
	fmt.Println(dfs(0, 0, 0, 0, n, a, b, c, lenghs))
}


Measured memory_bytes: 640
#include <iostream>
#include <math.h>
using namespace std;


int main(void){
    while (1) {
        int n, r;
        cin >> n >> r;
        if (n == 0 && r == 0) return 0;
        
        int m[55];
        for (int i = 0; i < n; i++) m[n - 1 - i] = i;
        
        for (int i = 0; i < r; i++) {
            int p, c;
            cin >> p >> c;
            
            int tmp[55];
            for (int j = 0; j < p - 1; j++) tmp[j] = m[j];
            
            for (int j = 0; j < c; j++) m[j] = m[p - 1 + j];
            
            for (int j = 0; j < p - 1; j++) m[c + j] = tmp[j];
            
        }
        
        cout << m[0] + 1 << endl;
    }
}



Measured memory_bytes: 3072
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <unordered_map>
#include <map>
#include <cmath>
#include <iomanip>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define sort_key(struct_name,key_name) [](const struct_name &x, const struct_name &y){return x.key_name < y.key_name;}
#define pb(x) push_back(x)
typedef long long ll;
using namespace std;

//main
int main(){
  int N; cin >> N;
  vector<int> D(N);
  rep(i,N) cin >> D[i];
  sort(ALL(D));
  cout << D[N/2]-D[N/2-1] << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>

using namespace std;

int gcd(int m, int n) {
    if (m < n) {
        int w = m;
        m = n;
        n = w;
    }

    while (n != 0) {
        int w = m % n;
        m = n;
        n = w;
    }

    return m;
}

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

    vector<int> a(n + 2, 0);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    vector<int> gcd_l(n + 2, 0);
    gcd_l[1] = a[1];
    for (int i = 2; i <= n; i++) {
        gcd_l[i] = gcd(gcd_l[i - 1], a[i]);
    }
    gcd_l[n + 1] = gcd_l[n];

    vector<int> gcd_r(n + 2, 0);
    gcd_r[n] = a[n];
    for (int i = n - 1; i >= 1; i--) {
        gcd_r[i] = gcd(gcd_r[i + 1], a[i]);
    }
    gcd_r[0] = gcd_r[1];

    int gcd_max = 0;
    for (int i = 1; i <= n; i++) {
        int r = gcd(gcd_l[i - 1], gcd_r[i + 1]);
        if (gcd_max < r) {
            gcd_max = r;
        }
    }

    cout << gcd_max << endl;
}


Measured memory_bytes: 1408
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
x = list(map(int,input().split()))
A = a[0]
B = b[0]
C = c[0]
X = x[0]
Count = 0
for i in range(A+1):
    for k in range(B+1):
        for t in range(C+1):
            if 500*i + 100*k + 50*t == X:
                Count += 1
print(Count)

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

int main(){
  int N, Aamount = 0, Bamount = 0, answer;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  for(int i = 0; i < N; i+=2){
    Aamount += a.at(i);
  }
  for(int i = 1; i < N; i+=2){
    Bamount += a.at(i);
  }
  answer = Aamount - Bamount;
  cout << answer << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
# define    all(a)              a.begin(), a.end()
#define forn(i, a, b) for (int i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define MOD int(1e9+7)
using namespace std;

typedef long long int ll;

bool cmp(int a, int b) {
    return a < b;
}

void printV(vector<int> nums) {
    for (int i: nums) {
        printf("%d ", i);// << " ";
    }
    printf("\n");
}

// void printV(vector<ll> nums) {
//     for (ll i: nums) {
//         printf("%lld ", i);// << " ";
//     }
//     printf("\n");
// }



int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

bool valid(int i, int j, int n, int m) {
    if (i >= 0 && i < n && j >=0 && j < m)
        return true;
    else 
        return false;
}


int main() {
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    // ios_base::sync_with_stdio(false);
    // cin.tie(0);cout.tie(0);
    // time_t start, end;
    // time(&start);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a*b, c*d) << endl;
    // time(&end); 
    // double time_taken = double(end - start);
    // cout << "Time Taken: " << fixed << time_taken << setprecision(5);
    // cout << " sec" << endl;
    return 0;
}      

Measured memory_bytes: 3576
n=int(input())
x,y,h=[],[],[]
for _ in [0]*n:
    xi,yi,hi=[int(x) for x in input().split()]
    x.append(xi)
    y.append(yi)
    h.append(hi)
diff = 0
if min(h)>=10:
    diff=min(h)-5
h=[i-diff for i in h]
# print(h)
def pattern(cx,cy,H):
    for i in range(n):
        # print(cx,x[i],cy,y[i],H,h[i],max(H-abs(x[i]-cx)-abs(y[i]-cy),0))
        if max(H-abs(x[i]-cx)-abs(y[i]-cy),0)!=h[i]:
            return False
    return True
from itertools import product
for H in range(1,1000):
    for cx,cy, in product(range(101),range(101)):
        if pattern(cx,cy,H):
            print(cx,cy,H+diff)
            import sys
            sys.exit()

Measured memory_bytes: 52060
# ABC147C - HonestOrUnkind2
from itertools import combinations


def main():
    N = int(input())
    testimonies = {i: {} for i in range(1, N + 1)}
    for i in range(1, N + 1):
        A = int(input())
        for _ in range(A):
            x, y = map(int, input().split())
            testimonies[i][x] = y

    for cnt_honest in range(N, 0, -1):
        for honest_people in combinations(range(1, N + 1), cnt_honest):
            honest_people = set(honest_people)
            is_consistent = True
            for i in honest_people:
                for x, y in testimonies[i].items():
                    if (x in honest_people and not y) or (x not in honest_people and y):
                        is_consistent = False
                        break
                if not is_consistent:
                    break
            if is_consistent:
                print(cnt_honest)
                return
    print(0)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
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; }






int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,t;cin >> n >> t;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	vector<int> ma(n);
	ma.at(n - 1) = a.at(n - 1);
	for(int i = n - 2; i >= 0; i--){
		ma.at(i) = max(ma.at(i + 1), a.at(i));
	}
	int k = 0;
	rep(i,n - 1){
		k = max(k, ma.at(i + 1) - a.at(i));
	}
	int ans = 0;
	rep(i,n - 1){
		if(ma.at(i + 1) - a.at(i) == k) ans++;
	}
	cout << ans << endl;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  
  int sum = 0;
  for (int i=0; i<N; i++){
    int x;
    cin >> x;
    int A = x * 2;
    int B = (x - K) * 2;
    
    if(B < 0)
      B *= -1;
    sum += A < B ? A : B;
  }
  cout << sum << endl;
}

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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int r; 
    cin >> r;
    cout << 3 * r * r << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a[100][100] ={};
  int b[100] ={};
  int n, m;
  cin >> n >> m;
  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++) cin >>  b[i];
  int c[100] = {};
  for(int i = 0;i<n;i++)
    for(int j = 0;j<m;j++)  c[i] += a[i][j] * b[j];
  for (int i = 0; i<n ; i++) cout << c[i] << endl ;
}


Measured memory_bytes: 3140
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
	map<int, int>ans;
	int now = 2;
	while (now * now <= x) {
		if (x % now == 0) {
			x /= now;
			ans[now]++;
		}
		else now++;
	}
	if (x != 1) ans[x]++;
	return ans;
}

signed main() {
	int n, k;
	int ma = 0;
	int t[100005], d[100005];
	priority_queue<int>que[100005];
	vector<int>big;
	priority_queue<int>oth;

	cin >> n >> k;
	rep(i, n) {
		cin >> t[i] >> d[i];
		t[i]--;
		que[t[i]].push(d[i]);
	}
	rep(i, n) {
		if (!que[i].empty()) {
			big.push_back(que[i].top());
			que[i].pop();
			while (!que[i].empty()) {
				oth.push(que[i].top());
				que[i].pop();
			}
		}
	}

	sort(big.begin(), big.end());
	reverse(big.begin(), big.end());
	int cnt = 0;
	rep(i, min(k, (int)big.size())) {
		cnt += big[i];
	}
	rep(i, k - min(k, (int)big.size())) {
		cnt += oth.top();
		oth.pop();
	}
	for (int i = min(k, (int)big.size()); i >= 1; i--) {
		ma = max(ma, cnt + (i * i));
		cnt -= big[i - 1];
		if (!oth.empty()) {
			cnt += oth.top();
			oth.pop();
		}
	}
	cout << ma << endl;

	return 0;
}


Measured memory_bytes: 9208
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
using namespace std;
using ll=int64_t;
using vi=vector<int>;
using VI=vector<ll>;
using vis=vector<string>;
using vvi=vector<vi>;
int gcd(int a,int b){
    if(a%b==0)
    return b;
    return gcd(b,a%b);
}
int main(){
    int n;
     cin>>n;
     vector<int> b(n-1);
     for(int i=0;n-1>i;++i)
     cin>>b.at(i);

     vector<int> a(n);
     int ans=0;

     for(int i=0;n>i;++i){
         if(i==0)
         a.at(i)=b.at(i);
         else if(i==n-1)
         a.at(i)=b.at(i-1);
         else
         a.at(i)=min(b.at(i-1),b.at(i));
         ans+=a.at(i);
     }

     cout<<ans<<endl;
}

Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using pii = pair<int, int>;
const int MOD = (int)1e9 + 7, INF = (1 << 27); const ll INFLL = (1LL << 55);
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
template<typename T, typename U> inline void chmax(T &x, U y) { if (x < y) x = y; }
template<typename T, typename U> inline void chmin(T &x, U y) { if (x > y) x = y; }


int main() {
    string s; int k;
    cin >> s >> k;

    //for (auto c : s) if (c != '1') {
    //    cout << c << "\n";
    //    return 0;
    //}

    k--;
    rep(i, s.size()) {
        if (s[i] != '1') {
            cout << s[i] << "\n";
            return 0;
        }
        if (i == k) {
            cout << s[i] << "\n";
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,t[200000]={0},x[200000]={0},y[200000]={0},z=1;
  cin>>n;
  rep(i,n) cin>>t[i+1]>>x[i+1]>>y[i+1];
  rep(i,n){
    int T=t[i+1]-t[i],X=abs(x[i+1]-x[i]),Y=abs(y[i+1]-y[i]);
    if(T<X+Y){z=0;break;}
    if(T%2!=(X+Y)%2){z=0;break;}
  }
  if(z) cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
  for(;;) {
    int n, m;
    cin >> n >> m;
    if(n == 0 && m == 0) break;
    vector<vector<bool>> bs;
    for(int i = 0; i < n; i++) {
      string str;
      cin >> str;
      vector<bool> v;
      for(int j = 0; j < m; j++) {
        v.push_back(str[j] == '1');
      }
      bs.push_back(move(v));
    }
    if(n <= 20) { // recipie < stuff  -> all possible combinations of recipes!
      const int nn = 1 << n;
      int mxc = 0;
      for(int i = 0; i < nn; i++) {
        vector<bool> ss(m, false);
        int c = 0;
        for(int j = 1, ii = 0; j < nn; j<<=1, ii++) {
          if(i & j) {
            c++;
            for(int k = 0; k < m; k++) {
              ss[k] = ss[k] ^ bs[ii][k];
            }
          }
        }
        bool ng = false;
        for(int k = 0; k < m; k++) {
          if(ss[k]) {
            ng = true;
            break;
          }
        }
        if(!ng) {
          if(mxc < c) mxc = c;
        }
      }
      cout << mxc << endl;
    } else { // recipie >= stuff  -> all possible states of odd stuff
      const int mm = 1 << m;
      vector<int> ms;
      for(int i = 0; i < n; i++) {
        int msk = 0;
        for(int j = 1, ii = 0; j < mm; j<<=1, ii++) {
          if(bs[i][ii]) msk |= j;
        }
        ms.push_back(msk);
      }
      vector<int> ss(mm, -1);
      ss[0] = 0;
      for(int i = 0; i < n; i++) { // using recipe i.
        vector<int> tt(mm, -1);
        for(int j = 0; j < mm; j++) {
          if(ss[j] < 0) continue;
          if(tt[j] < ss[j]) tt[j] = ss[j];
          int k = j ^ ms[i];
          if(tt[k] < ss[j] + 1) {
            tt[k] = ss[j] + 1;
          }
        }
        ss = move(tt);
      }
      cout << ss[0] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 84836
program grand_garden
  implicit none
  integer :: n, h(100) = 0, i
  read(*,*) n
  read(*,*) h(1:n)
  write(*,'(i0)') watering(h(1:n))
contains
  recursive function watering(h) result(res)
    integer, intent(in) :: h(:)
    integer :: n, m, l, r, i, res
    res = 0
    if (maxval(h) == 0) return
    n = size(h)
    m = minval(h)
    res = m
    l = 0
    do r = 1, n
      if (r == n .or. h(r) == m) then
        i = merge(r-1,n,h(r) == m)
        if (l+1 <= i) res = res+watering(h(l+1:i)-m)
        l = r
      end if
    end do
  end
end program grand_garden

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdtr1c++.h>
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
bool oppositeSigns(int x, int y) { return ((x ^ y) < 0); }
using namespace std;
typedef long long ll;
const int N = 100001;
const int MOD = 1000000007;
vector<int> adj[100001];
bool visited[100001];
vector<string> res;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a,b, t;
    cin >> a >> b >>t;
    cout << (t/a)*b;
    return 0;
}

Measured memory_bytes: 6008
package main

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

func main() {
	N := ReadInt()
	p := ReadInts(N)
	ans := 0
	i := 0
	for i < N {
		if p[i] == i+1 {
			ans++
			if i+1 < N && p[i+1] == i+2 {
				i += 2
			} else {
				i++
			}
			continue
		}
		i++
	}
	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 3244
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    ll X; cin >> X;

    ll ans = 0; ll v = 100;
    while (1) {
        if (v >= X) {
            cout << ans << endl;
            return 0;
        }
        v = v + v / 100;
        ans++;
        // cout << v << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;

void Compute(ll k,string s)
{
    KAKA
    ll len = s.length();
    if(len <= k) cout<<s<<"\n";
    else
    {
        string t = s.substr(0,k);
        t += "...";
        cout<<t<<"\n";
    }
    
}
int main()
{
    KAKA
    ll k;
    string s;
    cin>>k>>s;
    Compute(k,s);
}

Measured memory_bytes: 3636
while True:
    e = int(input())
    if e == 0:
        break
    ans = e
    z = 0
    while z**3<=e:
        y = int((e-z**3)**0.5)
        x = e-z**3-y**2  #zとyを先に定める
        ans = min(x+y+z,ans)
        z +=1
    print(ans)
        


Measured memory_bytes: 5712
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
vector<int> x = {1,-1,0,0};
vector<int> y = {0,0,-1,1};
int main(){
    int r,g,b,n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    rep(i,0,n+1){
        rep(j,0,n+1){
            int left = n-i*r-j*g;
            if(left>=0&&left%b==0){
                //cout<<i<<j<<endl;
                ans ++;
            }
        }
    }
    cout<<ans<<endl;

    

  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int n;
    string s;
    cin >> n >>  s;
    rep(i,s.size()){
        s[i]+=n;
        if(s[i]>'Z')s[i]-=26;
        cout << s[i];
    }
	return 0;
}

Measured memory_bytes: 3616
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean[] arr = new boolean[n + 3];
		arr[0] = true;
		arr[1] = true;
		int count = 0;
		for (int i = 2; i < arr.length; i++) {
		    if (!arr[i]) {
		        for (int j = 2; j * i < arr.length; j++) {
		            arr[i * j]  = true;
		        }
		        if (!arr[i] && !arr[i - 2]) {
		            count++;
		        }
		    }
		}
		System.out.println(count * 2);
	}
}



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

int main() {

        int n;

        std::cin >> n;
        std::vector<float> a(n);

        int sum = 0;
        for (auto& ai : a) {
                std::cin >> ai;
                sum += ai;
        }

        float average = sum / (float)n;

        for (auto& ai : a) {
                ai = std::abs(ai - average);
        }

        auto min = a[0];
        int min_idx = 0;
        for (auto ai = 0; ai < n; ++ai) {
                if (a[ai] < min) {
                        min = a[ai];
                        min_idx = ai;
                }
        }

        std::cout << min_idx << std::endl;

        return 0;
}

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

int main() {
	clog << "Ready\n";
	
	int n;
	cin >> n;
	vector <int> a(n + 1), b(n);
	
	for (int i = 0; i <= n; ++ i)
		cin >> a[i];
	for (int i = 0; i < n; ++ i)
		cin >> b[i];
	
	#define ll long long 
	ll sum = 0;
	
	for (int i = 0; i < n; ++ i) {
		int cnt = min(a[i], b[i]);
		sum += cnt;
		int t = b[i] - cnt;
		cnt = min(a[i + 1], t);
		sum += cnt;
		a[i + 1] -= cnt;
	}
	cout << sum;
	
	return 0;
}


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


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

    ll n;
    cin>>n;
    ll t[n],a[n];
    for(ll i=0;i<n;i++){
        cin>>t[i];
    }
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    vector<ll> h(n),h2(n);
    h[0]=t[0];
    for(ll i=1;i<n;i++){
        if(t[i]>t[i-1]){
            h[i]=t[i];
        }
    }
    
    h2[n-1]=a[n-1];
    for(int i=n-2;i>=0;i--){
        if(a[i]>a[i+1]){
            h2[i]=a[i];
        }
    }
    ll mn=0;
    for(int i=0;i<n;i++){
        
        mn=max(mn,h2[i]);
        if(t[i]<mn){
            cout<<0<<endl;
            return 0;
        }
    }
    mn=0;
    ll mod=1e9+7;
    for(int i=n-1;i>=0;i--){
        mn=max(mn,h[i]);
        if(a[i]<mn){
            //cerr<<mod<<endl;
            cout<<0<<endl;
            return 0;
        }
    }
    for(int i=0;i<n;i++){
        if(h[i]&&h2[i]&&h[i]!=h2[i]){
            //cout<<mod<<mod<<endl;
            cout<<0<<endl;
            return 0;
        }
        if(h2[i]) h[i]=h2[i];
    }


    ll ans=1;

    for(ll i=0;i<n;i++){
        if(h[i]==0){
            ans*=min(a[i],t[i]);
            ans%=mod;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3456
#!/usr/bin/env python

import sys

def DBsearch(L,x,narrow):
    n= len(L)
    if n==0: return 0
    if narrow and x in L: return L.index(x)
    last = L[-1]
    if x<last: return n
    if not narrow and x==last: return n
    #
    idx= -1
    i= 0
    j= n-1
    while j>=i:
        if i==j:
            if x>L[i]: idx= i
            break
        #
        mid= i + (j-i)//2
        if x<L[mid]:
            i= mid+1
        elif x==L[mid]:
            if narrow:
                idx= mid
                j  = mid - 1
            else:
                i = mid + 1
        else:
            idx= mid
            j= mid-1
    #
    return idx
#
def lds(L,narrow):
    seq= []
    for x in L:
        if len(seq)==0 or x<seq[-1]:
            seq.append(x)
        elif x==seq[-1]:
            if narrow:
                seq[DBsearch(seq,x,narrow)]= x
            else:
                seq.append(x)
        else:
            seq[DBsearch(seq,x,narrow)]= x
    #
    return len(seq)
#
n= int(sys.stdin.readline())
ai= [ int(sys.stdin.readline()) for _ in range(n) ]
print( lds( ai,False ) )


Measured memory_bytes: 7848
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
// please, read the question correctly (do you need set or multiset)???
const int N=200010; //check the limits, dummy
int a[N];
int n, m;
int main(){
	scanf("%d",&n);
	for(int i=0; i<n; ++i){
		scanf("%d",a+i);
	}
	sort(a, a+n);
	int ans=0;
	for(int i=0; i<n; ++i){
		for(int j=i; j<n; ++j){
			if(a[j]==a[i])continue;
			for(int k=j+1; k<n; ++k){
				if(a[k]==a[j])continue;
				if(a[k]<a[i]+a[j]){
					++ans;
				}
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3764
H, W, K = map(int, input().split(' '))
ls, rst = [], 0
for i in range(H):
    ls.append(list(input()))

for i in range(1 << H):
    for j in range(1 << W):
        cnt = 0
        for s in range(H):
            if i >> s & 1:
                continue
            for t in range(W):
                if j >> t & 1:
                    continue
                if ls[s][t] == '#':
                    cnt += 1
        if cnt == K:
            rst += 1
print(rst)

Measured memory_bytes: 9144
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
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; }
int main()
{
    int64_t N;
    cin >> N;
    pair<int64_t, int64_t> p = make_pair(0, 0);
    int64_t now_sec = 0;
    bool can_move = true;
    for (int64_t i=0; i<N; i++) {
        int64_t sec, x, y;
        cin >> sec >> x >> y;
        int64_t use_sec = sec - now_sec;
        int64_t idoukyori = abs(x - p.first) + abs(y - p.second);
        if (idoukyori > use_sec) {
            can_move = false;
            break;
        }

        if (use_sec % 2 == 0) {
            if (idoukyori % 2 != 0) {
                can_move = false;
                break;
            }
        } else {
            if (idoukyori % 2 == 0) {
                can_move = false;
                break;
            }
        }

        p = make_pair(x, y);
        now_sec = sec;
    }

    if (can_move) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3644
S = list(input())

AAA = 0
BBB = 0
CCC = 0

for i in range(3):
    if S[i] == "a":
        AAA = 1
    if S[i] == "b":
        BBB = 1
    if S[i] == "c":
        CCC = 1
else:
    if AAA == 1 and BBB == 1 and CCC == 1:
        print("Yes")
    else:
        print("No")


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

typedef long long ll; // -9,223,372,036,854,775,808 から 9,223,372,036,854,775,807

template <class T> using vec = std::vector<T>;
template <class T> using vec2 = vec<vec<T>>;
template <class T> using vec3 = vec<vec<vec<T>>>;

#define DEBUG

ll sub(ll n, vec<ll>& a, int sign){
    ll currentSum = 0;
    ll numOps = 0;
    for(int i=0; i < n; i++){
        ll nextSum = currentSum + a.at(i);
        if(nextSum*sign > 0){
            // そのまま
            // currentSum = nextSum;
        }else{
            // cout << "violated" << nextSum << endl;
            numOps += abs(sign - (currentSum + a.at(i)));
            nextSum = sign;
        }
        currentSum = nextSum;
        sign *= -1;
        // cout << currentSum << " " << numOps  << endl;
    }
    return numOps;

}

void solve(long long n, std::vector<long long> a){
    ll pos = sub(n, a, 1);
    ll neg = sub(n, a, -1);
    // cout << pos << " " << neg << endl;
    cout << min(pos, neg) << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long n;
    scanf("%lld",&n);
    std::vector<long long> a(n);
    for(int i = 0 ; i < n ; i++){
        scanf("%lld",&a[i]);
    }
    solve(n, std::move(a));
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,A,B,S=0;cin>>N>>A>>B;
  for(int i=1;i<=N;i++){
    int s=0,a=i;
    while(a>0){s+=a%10;a/=10;}
    if(A<=s&&s<=B)S+=i;
  }
  cout<<S<<endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'

typedef long long int ll;
typedef pair<int, int> P;

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

  int a, b, c;
  cin >> a >> b >> c;

  rep(i, b) {
    if (a * i % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int N, M;
    while (cin >> N >> M, N) {
        vector<int> mx(M, 0);
        REP (i, N) {
            int d, v;
            cin >> d >> v;
            d--;
            mx[d] = max(mx[d], v);
        }
        int ans = 0;
        REP (i, M) ans += mx[i];
        cout << ans << endl;
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}


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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  string s;
  cin >> s;

  bool flag = false;
  if ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])) flag = true;

  // 解答
  cout << (flag ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int t,i,m;
    scanf("%d",&m);
    char s[m],n[m];
    scanf("%s%s",s,n);
    for(i=0; i<m; i++)
    {
        printf("%c",s[i]);
        printf("%c",n[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
import heapq

n, m=map(int, input().split())
A=list(map(lambda x:int(x)*(-1), input().split()))
heapq.heapify(A)

for _ in range(m):
  temp=(-1)*heapq.heappop(A)>>1
  heapq.heappush(A, temp*(-1))
print(-sum(A))

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

using namespace std;

typedef long long int ll;
typedef pair<int,int> ii;

const int N = 1e5 + 5;

int n,a[N];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> n;
  for (int i = 1 ;  i <= n ; i++)
    cin >> a[i];
  for (int i = 1 ; i <= n ; i++)
    if (a[i] != 1 && a[i] != a[i - 1])
      a[i]--;
  for (int i = 2 ; i <= n ; i++)
      if (a[i] < a[i - 1]) {
        cout << "No\n";
        return 0;
      }
  cout << "Yes\n";
}

Measured memory_bytes: 640